/* ============================================================
   TopList - Modern Topsite Ranking Theme
   Blue & White - Dark/Light mode, glassmorphism, responsive
   ============================================================ */

/* ---------- CSS Variables ---------- */
:root {
  --primary: #2563eb;
  --primary-light: #60a5fa;
  --primary-dark: #1d4ed8;
  --accent: #3b82f6;
  --accent-light: #93c5fd;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --gold: #fbbf24;
  --silver: #c0c0c0;
  --bronze: #cd7f32;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.15);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --font: 'Arial', 'Helvetica', sans-serif;
}

/* ---------- Dark Theme (default) ---------- */
[data-theme="dark"] {
  --bg: #0b1120;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.85);
  --bg-glass: rgba(17, 24, 39, 0.6);
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-heading: #f1f5f9;
  --border: rgba(148, 163, 184, 0.1);
  --input-bg: #1e293b;
  --navbar-bg: rgba(11, 17, 32, 0.95);
}

/* ---------- Light Theme ---------- */
[data-theme="light"] {
  --bg: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.92);
  --bg-glass: rgba(255, 255, 255, 0.75);
  --text: #1e293b;
  --text-muted: #64748b;
  --text-heading: #0f172a;
  --border: rgba(0, 0, 0, 0.08);
  --input-bg: #f1f5f9;
  --navbar-bg: rgba(255, 255, 255, 0.95);
}

/* ---------- Base ---------- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  transition: background 0.3s ease, color 0.3s ease;
}

body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(ellipse at 20% 50%, rgba(37, 99, 235, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(59, 130, 246, 0.04) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

a {
  color: var(--primary-light);
  text-decoration: none;
  transition: var(--transition);
}

a:hover {
  color: var(--accent);
}

h1,
h2,
h3,
h4,
h5,
h6 {
  color: var(--text-heading);
  font-weight: 700;
}

/* ---------- Navbar ---------- */
.navbar-custom {
  background: var(--navbar-bg) !important;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 0;
  z-index: 1000;
}

.navbar-brand {
  font-weight: 800;
  font-size: 1.5rem;
  color: var(--primary);
  -webkit-text-fill-color: var(--primary);
}

.nav-link {
  color: var(--text-muted) !important;
  font-weight: 500;
  padding: 0.5rem 1rem !important;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.nav-link:hover,
.nav-link.active {
  color: var(--primary) !important;
  background: var(--bg-glass);
}

/* Theme toggle */
.theme-toggle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-glass);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  font-size: 1.1rem;
}

.theme-toggle:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  transform: rotate(180deg);
}

/* ---------- Cards ---------- */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: var(--transition);
  overflow: hidden;
}

.glass-card:hover {
  border-color: rgba(37, 99, 235, 0.3);
  box-shadow: 0 8px 32px rgba(37, 99, 235, 0.1);
  transform: translateY(-2px);
}

/* ---------- Site Cards ---------- */
.site-card {
  padding: 1.25rem;
  display: flex;
  gap: 1rem;
  align-items: center;
  position: relative;
}

.site-card .site-rank {
  min-width: 50px;
  text-align: center;
}

.site-card .site-banner {
  width: 150px;
  height: 150px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  object-position: top center;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.site-card .site-info {
  flex: 1;
  min-width: 0;
}

.site-card .site-name {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-heading);
  margin-bottom: 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.site-card .site-url {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.site-card .site-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.site-card .site-meta {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

.site-card .site-meta span {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.site-card .site-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* ---------- Vote Button ---------- */
.btn-vote {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.5rem 1.25rem;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
  text-decoration: none;
}

.btn-vote:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.4);
  color: #fff;
}

.btn-vote:active {
  transform: scale(0.98);
}

.btn-vote.voted {
  background: var(--bg-glass);
  color: var(--text-muted);
  cursor: default;
  border: 1px solid var(--border);
}

.vote-count {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--primary-light);
  line-height: 1;
}

/* ---------- Rank Badges ---------- */
.rank-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--text-muted);
}

.rank-gold {
  color: var(--gold) !important;
  text-shadow: 0 0 12px rgba(251, 191, 36, 0.5);
  animation: glow-gold 2s ease-in-out infinite alternate;
}

.rank-silver {
  color: var(--silver) !important;
  text-shadow: 0 0 8px rgba(192, 192, 192, 0.4);
}

.rank-bronze {
  color: var(--bronze) !important;
  text-shadow: 0 0 8px rgba(205, 127, 50, 0.4);
}

.rank-top10 {
  color: var(--accent) !important;
}

@keyframes glow-gold {
  from {
    text-shadow: 0 0 8px rgba(251, 191, 36, 0.3);
  }

  to {
    text-shadow: 0 0 20px rgba(251, 191, 36, 0.6), 0 0 40px rgba(251, 191, 36, 0.2);
  }
}

/* ---------- Premium Badge ---------- */
.premium-badge {
  background: linear-gradient(135deg, var(--gold), #f0c800);
  color: #1a1a2e;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 0.15rem 0.5rem;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ---------- Category Pills ---------- */
.category-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem 0.85rem;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  transition: var(--transition);
  cursor: pointer;
  text-decoration: none;
}

.category-pill:hover,
.category-pill.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ---------- Buttons ---------- */
.btn-primary-custom {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.6rem 1.5rem;
  font-weight: 600;
  transition: var(--transition);
}

.btn-primary-custom:hover {
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.3);
  transform: translateY(-1px);
  color: #fff;
}

.btn-outline-custom {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 0.6rem 1.5rem;
  font-weight: 600;
  transition: var(--transition);
}

.btn-outline-custom:hover {
  background: var(--primary);
  color: #fff;
}

/* ---------- Dropdowns ---------- */
.dropdown-menu {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.dropdown-item {
  color: var(--text);
  transition: var(--transition);
}

.dropdown-item:hover,
.dropdown-item:focus {
  background: var(--primary);
  color: #fff;
}

/* ---------- Forms ---------- */
.form-control,
.form-select {
  background: var(--input-bg) !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
  border-radius: var(--radius-sm);
  padding: 0.6rem 1rem;
  transition: var(--transition);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15) !important;
}

.form-label {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.85rem;
  margin-bottom: 0.35rem;
}

/* ---------- Stats Cards ---------- */
.stat-card {
  padding: 1.5rem;
  text-align: center;
}

.stat-card .stat-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
  -webkit-text-fill-color: var(--primary);
}

.stat-card .stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 0.25rem;
}

/* ---------- Sort Tabs ---------- */
.sort-tabs {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.sort-tab {
  padding: 0.4rem 1rem;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.sort-tab:hover,
.sort-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ---------- Footer ---------- */
.footer-custom {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: 2rem 0;
  margin-top: 4rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ---------- Admin Sidebar ---------- */
.admin-sidebar {
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  min-height: calc(100vh - 60px);
  padding: 1.5rem 0;
}

.admin-sidebar .nav-link {
  padding: 0.6rem 1.25rem !important;
  margin: 0.1rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}

.admin-sidebar .nav-link.active {
  background: var(--primary) !important;
  color: #fff !important;
}

.admin-sidebar .nav-link i {
  width: 20px;
  text-align: center;
  margin-right: 0.5rem;
}

/* ---------- Tables ---------- */
.table {
  color: var(--text);
}

.table thead th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom-color: var(--border);
}

.table td {
  border-bottom-color: var(--border);
  padding: 0.85rem 0.75rem;
  vertical-align: middle;
}

.table-hover tbody tr:hover {
  background: var(--bg-glass);
}

/* ---------- Alerts ---------- */
.alert {
  border-radius: var(--radius-sm);
  border: none;
  font-size: 0.9rem;
}

/* ---------- Search ---------- */
.search-box {
  position: relative;
}

.search-box input {
  padding-left: 2.5rem !important;
}

.search-box .search-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

/* ---------- Modal ---------- */
.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.modal-header {
  border-bottom-color: var(--border);
}

.modal-footer {
  border-top-color: var(--border);
}

/* ---------- Loading Spinner ---------- */
.spinner-glow {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- Empty State ---------- */
.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
}

.empty-state i {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .site-card {
    flex-wrap: wrap;
    padding: 1rem;
  }

  .site-card .site-banner {
    width: 100px;
    height: 100px;
  }

  .site-card .site-info {
    min-width: calc(100% - 160px);
  }

  .site-card .site-actions {
    flex-direction: row;
    width: 100%;
    justify-content: space-between;
    border-top: 1px solid var(--border);
    padding-top: 0.75rem;
    margin-top: 0.5rem;
  }

  .vote-count {
    font-size: 1.1rem;
  }

  .admin-sidebar {
    min-height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
}

@media (max-width: 576px) {
  .site-card .site-banner {
    display: none;
  }

  .site-card .site-info {
    min-width: calc(100% - 70px);
  }

  .sort-tabs {
    gap: 0.3rem;
  }

  .sort-tab {
    padding: 0.3rem 0.75rem;
    font-size: 0.8rem;
  }
}

/* ---------- Animations ---------- */
.fade-in {
  animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.slide-up {
  animation: slideUp 0.5s ease-out;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- Confetti Canvas ---------- */
#confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
}

/* ---------- Install Page ---------- */
.install-container {
  max-width: 600px;
  margin: 2rem auto;
  padding: 0 1rem;
}

.install-step {
  padding: 2rem;
}

.install-step .step-number {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

/* ---------- Code Block ---------- */
.code-block {
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.8rem;
  position: relative;
  overflow-x: auto;
}

.code-block .copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  padding: 0.2rem 0.6rem;
  font-size: 0.75rem;
}

/* ---------- Button Preview ---------- */
.button-preview {
  padding: 2rem;
  background: var(--input-bg);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  text-align: center;
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Logo Dark Mode Adjustment */
[data-theme="dark"] .navbar-brand img,
[data-theme="dark"] footer img[src*="logo.svg"] {
  filter: brightness(1.5) contrast(1.1);
}