/* ================================================
   COMMON STYLES - Shared across all pages
   ================================================ */

:root {
  --primary: #d35400;
  --primary-dark: #b84700;
  --primary-light: #e67e22;
  --bg: #1a1a1a;
  --bg-secondary: #252525;
  --bg-card: #1e1e1e;
  --text: #e0e0e0;
  --text-secondary: #aaaaaa;
  --text-muted: #777777;
  --border: #333333;
  --tag-bg: #2980b9;
  --tag-hover: #3498db;
  --link: #5dade2;
}

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

body {
  font-family:
    "Roboto",
    -apple-system,
    sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

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

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

/* ================================================
   HEADER
   ================================================ */
.header {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  height: 64px;
  display: flex;
  align-items: center;
}

.header-content {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 100%;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.logo-img {
  height: 50px;
  width: 50px;
  object-fit: contain;
  transition:
    transform 0.2s ease,
    filter 0.2s ease;
}

.logo:hover .logo-img {
  transform: scale(1.05);
  filter: brightness(1.1);
}

.logo-text {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.5px;
}

.logo:hover .logo-text {
  color: var(--primary-light);
}

/* Menu Button */
.menu-btn {
  width: 40px;
  height: 40px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 101;
}

.menu-btn:hover {
  background: var(--bg-secondary);
}

/* ================================================
   SIDEBAR MENU (Mobile)
   ================================================ */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 200;
}

.sidebar-overlay.show {
  display: block;
}

.sidebar {
  position: fixed;
  top: 0;
  right: -280px;
  width: 280px;
  height: 100%;
  background: var(--bg);
  z-index: 201;
  transition: right 0.3s;
  overflow-y: auto;
}

.sidebar.open {
  right: 0;
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-close {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  font-size: 24px;
  cursor: pointer;
  color: var(--text);
}

.sidebar-close:hover {
  color: var(--primary);
}

.sidebar-menu {
  list-style: none;
}

.sidebar-menu-item {
  border-bottom: 1px solid var(--border);
}

.sidebar-menu-item a,
.sidebar-menu-item button.sidebar-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  font-size: 14px;
  color: var(--text);
  transition: background 0.2s;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

.sidebar-menu-item a:hover,
.sidebar-menu-item button.sidebar-btn:hover {
  background: var(--bg-secondary);
  color: var(--primary);
}

.sidebar-menu-item .menu-icon {
  font-size: 18px;
  width: 24px;
  text-align: center;
}

/* Sidebar Auth Section */
.sidebar-auth {
  padding: 16px;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.sidebar-login-btn {
  display: block;
  padding: 12px 16px;
  background: var(--primary);
  color: white !important;
  text-align: center;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.2s;
}

.sidebar-login-btn:hover {
  background: var(--primary-dark);
  color: white !important;
}

/* User profile in sidebar (when logged in) */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  margin-bottom: 12px;
}

.sidebar-user:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.sidebar-user-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #e11d48);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: white;
  font-weight: 700;
  position: relative;
  box-shadow: 0 4px 10px rgba(211, 84, 0, 0.3);
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-user-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-email {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-logout-btn {
  display: block;
  width: 100%;
  padding: 12px;
  background: rgba(231, 76, 60, 0.1);
  border: 1px solid rgba(231, 76, 60, 0.2);
  border-radius: 10px;
  color: #ff4d4d;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.sidebar-logout-btn:hover {
  background: rgba(231, 76, 60, 0.2);
  border-color: #e74c3c;
  color: #fff;
}

/* ================================================
   HEADER NAVIGATION (Desktop)
   ================================================ */
.header-nav {
  display: none;
  gap: 8px;
  margin-left: 20px;
}

.nav-link {
  padding: 8px 10px;
  color: var(--text-secondary);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-link:hover {
  color: var(--primary);
}

.nav-link .nav-icon {
  font-size: 16px;
}

/* Header Dropdown */
.nav-dropdown {
  position: relative;
}

.nav-dropdown-toggle {
  cursor: pointer;
  background: none;
  border: none;
  display: flex;
  align-items: center;
}

.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  min-width: 500px;
  max-width: 600px;
  z-index: 9999;
  padding: 16px;
  margin-top: 8px;
}

.nav-dropdown.open .nav-dropdown-menu {
  display: block !important;
}

.nav-dropdown-menu .menu-columns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* 3-column layout for tags dropdown */
.nav-dropdown-menu .menu-columns-3 {
  display: grid;
  grid-template-columns: repeat(3, auto);
  gap: 6px 12px;
}

.nav-dropdown-menu .menu-col {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-dropdown-menu .menu-col a {
  display: block;
  white-space: nowrap;
  padding: 5px 8px !important;
  font-size: 12px !important;
}

.nav-dropdown-menu a {
  display: inline-block;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  white-space: nowrap;
  transition: all 0.2s;
}

.nav-dropdown-menu a:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* Desktop Auth in Header */
.nav-auth {
  opacity: 0;
  transition: opacity 0.15s ease;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: 16px;
  padding-left: 16px;
  border-left: 1px solid var(--border);
}

.nav-login-btn {
  padding: 8px 16px !important;
  background: var(--primary);
  color: white !important;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
}

.nav-login-btn:hover {
  background: var(--primary-dark);
  color: white !important;
}

/* Source Switch Toggle styles removed - replaced by source tabs */
.nav-user {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 6px;
  transition: background 0.2s;
  position: relative;
}

.nav-user:hover {
  background: var(--bg-secondary);
}

.nav-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: white;
  font-weight: 600;
  position: relative;
}

/* Cultivation Level Badge on Avatar */
.culti-badge {
  position: absolute;
  bottom: -3px;
  right: -3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #2ecc71;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg);
  line-height: 1;
}

/* Cultivation Widget in Dropdown */
.culti-widget {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  cursor: pointer;
  transition: background 0.2s;
}

.culti-widget:hover {
  background: var(--border);
}

.culti-widget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.culti-widget-level {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
}

.culti-widget-streak {
  font-size: 11px;
  color: var(--text-muted);
}

.culti-widget-bar {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.culti-widget-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #2ecc71);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.culti-widget-info {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  font-size: 10px;
  color: var(--text-muted);
}

/* Sidebar Cultivation Widget */
.sidebar-culti-widget {
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: 6px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.2s;
}

.sidebar-culti-widget:hover {
  background: var(--bg-secondary);
}

.sidebar-culti-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.sidebar-culti-level {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
}

.sidebar-culti-streak {
  font-size: 11px;
  color: var(--text-muted);
}

.sidebar-culti-bar {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.sidebar-culti-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #2ecc71);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.sidebar-culti-info {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  font-size: 10px;
  color: var(--text-muted);
}

.nav-user-name {
  font-size: 13px;
  color: var(--text);
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-user-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  min-width: 180px;
  z-index: 150;
  overflow: hidden;
}

.nav-user-dropdown.show {
  display: block;
}

.nav-user-dropdown a,
.nav-user-dropdown button {
  display: block;
  width: 100%;
  padding: 12px 16px;
  text-align: left;
  font-size: 13px;
  color: var(--text);
  background: none;
  border: none;
  cursor: pointer;
  transition: background 0.2s;
}

.nav-user-dropdown a:hover,
.nav-user-dropdown button:hover {
  background: var(--bg-secondary);
  color: var(--primary);
}

.nav-user-dropdown .logout-btn {
  color: #e74c3c;
  border-top: 1px solid var(--border);
}

.nav-user-dropdown .logout-btn:hover {
  background: rgba(231, 76, 60, 0.1);
  color: #e74c3c;
}

/* ================================================
   CATEGORIES MODAL (Mobile)
   ================================================ */
.categories-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 300;
  align-items: flex-end;
}

.categories-modal.show {
  display: flex;
}

.categories-modal-content {
  background: var(--bg);
  width: 100%;
  max-height: 70vh;
  border-radius: 16px 16px 0 0;
  overflow: hidden;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

.categories-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.categories-modal-title {
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
}

.categories-modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--bg-secondary);
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
  color: var(--text);
}

.categories-modal-close:hover {
  background: var(--border);
}

.categories-modal-body {
  padding: 16px;
  max-height: calc(70vh - 60px);
  overflow-y: auto;
}

.categories-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.category-item {
  padding: 10px 8px;
  background: var(--bg-secondary);
  border-radius: 6px;
  text-align: center;
  font-size: 12px;
  color: var(--text);
  transition: all 0.2s;
}

.category-item:hover,
.category-item:active {
  background: var(--primary);
  color: white;
}

/* ================================================
   TELEGRAM BUTTON
   ================================================ */
.telegram-btn {
  width: 44px;
  height: 44px;
  background: transparent;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: fixed;
  bottom: 80px;
  right: 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  z-index: 50;
  text-decoration: none;
  overflow: hidden;
  padding: 0;
}

.telegram-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.telegram-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(0, 136, 204, 0.4);
}

/* ================================================
   LOADING
   ================================================ */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}

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

/* ================================================
   RESPONSIVE
   ================================================ */
@media (min-width: 768px) {
  .menu-btn {
    display: none;
  }

  .header-nav {
    display: flex;
  }

  .header-content {
    max-width: 1100px;
  }
}

@media (max-width: 767px) {
  .header-nav,
  .nav-auth {
    display: none !important;
  }
}

/* nav-auth ready state */
.nav-auth.ready {
  opacity: 1;
}

/* Main Container Fix for CLS */
.container {
  max-width: 1200px;
  margin: 20px auto 40px;
  padding: 0 16px;
  width: 100%;
  /* Prevent CLS by reserving space */
  min-height: 600px;
}

/* ================================================
   SEARCH TABS (PHASE 5)
   ================================================ */
.search-tabs {
  background: var(--bg-secondary);
  padding: 4px;
  border-radius: 10px;
  margin: 12px auto 16px;
  display: none; /* Controlled by JS */
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  border: 1px solid var(--border);
  max-width: 400px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.search-tab {
  padding: 10px 12px;
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

.search-tab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.search-tab.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 2px 8px rgba(211, 84, 0, 0.3);
}

@media (min-width: 768px) {
  .search-tabs {
    max-width: 300px;
  }
}
