/* ==========================================
   AbzarDownload — Layout CSS
   Header + Footer (loaded sitewide)
   ========================================== */

/* ── CSS Variables (mirror main.css) ───── */
:root {
  --header-height: 64px;
  --bg-primary:    #0d1117;
  --bg-secondary:  #161b22;
  --bg-tertiary:   #21262d;
  --bg-hover:      #2d333b;
  --accent-green:       #2ea043;
  --accent-green-hover: #3fb950;
  --accent-green-glow:  rgba(46,160,67,0.25);
  --accent-blue:        #1f6feb;
  --accent-blue-hover:  #388bfd;
  --text-primary:   #e6edf3;
  --text-secondary: #8b949e;
  --text-muted:     #6e7681;
  --border-color:   #30363d;
  --border-hover:   #484f58;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.5);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.6);
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --font-persian: 'Vazirmatn', -apple-system, sans-serif;
  --transition: all 0.2s ease;
}

/* ==========================================
   HEADER
   ========================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  height: var(--header-height);
  background: rgba(13,17,23,0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  transition: box-shadow 0.3s ease;
}

.site-header.scrolled { box-shadow: var(--shadow-md); }

.header-inner {
  display: flex;
  align-items: center;
  gap: 20px;
  height: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ── Zone 1: Logo ───────────────────────── */
.site-branding { flex-shrink: 0; }

.site-logo-text {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.3px;
  text-decoration: none;
}

.site-logo-text:hover { color: var(--accent-green); }
.site-logo-text .logo-icon { flex-shrink: 0; }

/* ── Zone 2: Navigation ─────────────────── */
.primary-nav { flex: 1; }

.nav-menu {
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-menu li { position: relative; }

.nav-menu li a {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  white-space: nowrap;
  text-decoration: none;
}

.nav-menu li a:hover,
.nav-menu li.current-menu-item > a,
.nav-menu li.current_page_item > a {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.chevron-icon { transition: transform 0.2s; flex-shrink: 0; }

/* Nav dropdown */
.sub-menu.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 200px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: all 0.2s ease;
  z-index: 100;
  list-style: none;
}

.nav-menu li:hover > .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.nav-menu li:hover > a .chevron-icon { transform: rotate(180deg); }

.dropdown-menu li a {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
}

/* ── Zone 3: Search ─────────────────────── */
.header-search-wrap { flex-shrink: 0; }

.header-search { position: relative; }

.search-form { margin: 0; }

.search-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 6px 14px;
  transition: var(--transition);
}

.search-input-wrap:focus-within {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(31,111,235,0.25);
}

.search-icon { color: var(--text-muted); flex-shrink: 0; }

.search-input {
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font-persian);
  font-size: 0.875rem;
  width: 200px;
}

.search-input::placeholder { color: var(--text-muted); }

.search-clear {
  color: var(--text-muted);
  padding: 0;
  line-height: 1;
  transition: var(--transition);
}

.search-clear:hover { color: var(--text-primary); }

.live-search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  z-index: 200;
  display: none;
}

.live-search-dropdown.visible { display: block; }

.search-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  transition: var(--transition);
  border-bottom: 1px solid var(--border-color);
}

.search-result-item:last-child { border-bottom: none; }

.search-result-item:hover,
.search-result-item.focused { background: var(--bg-tertiary); }

.search-result-thumb {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-tertiary);
}

.search-result-info { flex: 1; min-width: 0; }

.search-result-title {
  display: block;
  color: var(--text-primary);
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-meta { display: flex; gap: 8px; margin-top: 2px; }
.search-result-meta span { font-size: 0.75rem; color: var(--text-muted); }
.search-result-version { color: var(--accent-green) !important; }

.search-loading,
.search-no-results {
  padding: 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* ── Zone 3: Auth ───────────────────────── */
.header-auth {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.header-auth-links {
  display: flex;
  gap: 8px;
  align-items: center;
}

.btn-header-login {
  padding: 7px 16px;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  text-decoration: none;
  font-size: 0.875rem;
  transition: border-color 0.2s, color 0.2s;
}

.btn-header-login:hover {
  border-color: var(--accent-green);
  color: var(--accent-green);
}

.btn-header-register {
  padding: 7px 16px;
  background: var(--accent-green);
  color: #fff;
  border-radius: var(--radius-md);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 600;
  transition: background 0.2s;
}

.btn-header-register:hover { background: var(--accent-green-hover); }

/* User dropdown */
.header-user-menu { position: relative; }

.header-user-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 6px 12px;
  color: var(--text-primary);
  cursor: pointer;
  font-family: var(--font-persian);
  font-size: 0.875rem;
  transition: border-color 0.2s;
  direction: rtl;
}

.header-user-btn:hover { border-color: var(--accent-green); }

.header-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-green);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
  position: relative;
}

.header-username {
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-user-btn[aria-expanded="true"] .chevron-icon { transform: rotate(180deg); }

.header-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  min-width: 185px;
  z-index: 1001;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity 0.15s, transform 0.15s, visibility 0.15s;
  direction: rtl;
  padding: 4px;
}

.header-dropdown.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  color: var(--text-primary);
  text-decoration: none;
  font-size: 0.875rem;
  border-radius: 7px;
  transition: background 0.15s;
}

.dropdown-item:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.dropdown-divider {
  height: 1px;
  background: var(--border-color);
  margin: 4px 0;
}

.dropdown-item-danger { color: #f85149; }

.dropdown-item-danger:hover {
  background: rgba(248,81,73,0.1);
  color: #f85149;
}

/* Unread ticket badge on support link */
.dropdown-unread-badge {
  margin-right: auto;
  margin-left: 0;
  background: #f85149;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 20px;
  line-height: 1.4;
  min-width: 16px;
  text-align: center;
}

/* ── Hamburger ──────────────────────────── */
.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  padding: 8px;
  margin-right: 0;
  margin-left: auto;
  order: 99;
}

.hamburger-line {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text-secondary);
  border-radius: 2px;
  transition: var(--transition);
}

.hamburger.active .hamburger-line:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
.hamburger.active .hamburger-line:nth-child(2) { opacity: 0; }
.hamburger.active .hamburger-line:nth-child(3) { transform: rotate(-45deg) translate(5px, -5px); }

/* ==========================================
   FOOTER (4-column grid)
   ========================================== */
.site-footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  margin-top: 80px;
}

/* 4 columns: about (2fr) | quick-links (1fr) | categories (1fr) | os+contact (1fr) */
.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 40px;
  padding: 48px 0;
  max-width: 1280px;
  margin: 0 auto;
  padding-left: 20px;
  padding-right: 20px;
}

/* Column 1: About */
.footer-about {}

.footer-logo-text {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-primary);
  margin-bottom: 12px;
  text-decoration: none;
}

.footer-logo-text:hover { color: var(--accent-green); }

.footer-desc {
  color: var(--text-muted);
  font-size: 0.875rem;
  line-height: 1.8;
  margin-bottom: 20px;
}

.footer-stats {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}

.footer-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.footer-stat-num {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent-green);
  line-height: 1;
}

.footer-stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Column headers */
.footer-col-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

/* Columns 2 & 3: nav links */
.footer-nav-list,
.footer-categories {
  display: flex;
  flex-direction: column;
  gap: 2px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.footer-nav-list li a,
.footer-categories li a,
.footer-nav-menu li a {
  display: block;
  font-size: 0.875rem;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 5px 0;
  transition: color 0.2s, padding-right 0.2s;
}

.footer-nav-list li a:hover,
.footer-categories li a:hover,
.footer-nav-menu li a:hover {
  color: var(--accent-green);
  padding-right: 4px;
}

/* Keep old .footer-nav-menu working */
.footer-nav-menu {
  display: flex;
  flex-direction: column;
  gap: 2px;
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Column 4: OS + Contact */
.footer-os-section { margin-bottom: 20px; }

.footer-os-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.footer-os-icons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.footer-os-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.footer-os-chip svg { flex-shrink: 0; }

.footer-contact-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.footer-contact-link {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.2s;
}

.footer-contact-link:hover { color: var(--accent-green); }

/* Footer bottom bar */
.footer-bottom {
  border-top: 1px solid var(--border-color);
  padding: 18px 0;
}

.footer-bottom-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 20px;
}

.copyright, .powered-by {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.copyright a, .powered-by a { color: var(--text-secondary); }
.copyright a:hover, .powered-by a:hover { color: var(--accent-green); }

/* ==========================================
   RESPONSIVE
   ========================================== */
@media (max-width: 1100px) {
  .footer-grid {
    grid-template-columns: 2fr 1fr 1fr;
  }
  .footer-col-os { grid-column: span 3; }

  .search-input { width: 160px; }
}

@media (max-width: 900px) {
  .footer-grid {
    grid-template-columns: 1fr 1fr;
  }
  .footer-about { grid-column: span 2; }
  .footer-col-os { grid-column: auto; }
}

@media (max-width: 768px) {
  :root { --header-height: 56px; }

  .hamburger { display: flex; }

  .primary-nav { display: none; }
  .header-search-wrap { display: none; }

  .primary-nav.open {
    display: block;
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-secondary);
    z-index: 999;
    overflow-y: auto;
    padding: 20px;
  }

  .primary-nav.open .nav-menu {
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
  }

  .primary-nav.open .nav-menu li a {
    padding: 12px 16px;
    font-size: 1rem;
  }

  .sub-menu.dropdown-menu {
    position: static;
    display: none;
    opacity: 1;
    visibility: visible;
    transform: none;
    box-shadow: none;
    border: none;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    padding: 0 0 0 16px;
  }

  .nav-menu li.open > .dropdown-menu { display: block; }

  .header-username { display: none; }
}

@media (max-width: 640px) {
  .footer-grid {
    grid-template-columns: 1fr;
    gap: 28px;
    padding-top: 32px;
    padding-bottom: 32px;
  }
  .footer-about { grid-column: auto; }
  .footer-col-os { grid-column: auto; }

  .footer-stats { gap: 16px; }

  .footer-bottom-inner { flex-direction: column; text-align: center; }
}

@media (max-width: 380px) {
  .header-inner { gap: 12px; padding: 0 12px; }
  .btn-header-login { padding: 6px 10px; font-size: 0.8rem; }
  .btn-header-register { padding: 6px 10px; font-size: 0.8rem; }
}
