/* Modern IPSW CMS - Main Stylesheet */

:root {
    --primary: #007AFF;
    --primary-dark: #0051D5;
    --secondary: #5856D6;
    --success: #34C759;
    --danger: #FF3B30;
    --warning: #FF9500;
    --dark: #1C1C1E;
    --gray: #8E8E93;
    --light-gray: #F2F2F7;
    --bg: #FFFFFF;
    --text: #000000;
    --text-secondary: #6E6E73;
    --border: #D1D1D6;
    --shadow: rgba(0, 0, 0, 0.1);
    --radius: 12px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    overflow-x: hidden;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Focus visible for accessibility - keyboard users */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid #007AFF;
    outline-offset: 2px;
}

/* Screen reader only - visually hidden but accessible to assistive technology */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Visitor bar – fixed at top on every page, never moves */
.visitor-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 0.25rem 0;
    font-size: 0.82rem;
    color: var(--text-secondary);
    text-align: center;
}
/* When visitor bar is present, push content down and stick header below bar */
body.visitor-bar-fixed {
    padding-top: 2.2rem;
}
body.visitor-bar-fixed .header {
    top: 2.2rem;
}
.visitor-bar .container {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.15rem 0.25rem;
    padding-left: 12px;
    padding-right: 12px;
}
.visitor-bar-label {
    color: inherit;
}
.visitor-bar-ip,
.visitor-bar-country,
.visitor-bar-time,
.visitor-bar-count {
    color: #dc2626;
}
.visitor-bar-date,
.visitor-bar-weather {
    color: #2563eb;
}
.visitor-bar-sep {
    margin: 0 0.25rem;
    color: var(--border);
}

/* Hide offer popup, IP address, and Time on small screens (mobile) only */
@media (max-width: 767px) {
    .offer-overlay {
        display: none !important;
    }
    /* Hide visitor bar on mobile completely */
    .visitor-bar {
        display: none !important;
    }
    body.visitor-bar-fixed {
        padding-top: 0 !important;
    }
    body.visitor-bar-fixed .header {
        top: 0 !important;
    }
    /* Hide IP address section: label "Your IP:", IP value, and separator after IP */
    .visitor-bar .container > .visitor-bar-label:first-child,
    .visitor-bar .container > .visitor-bar-ip,
    .visitor-bar .container > .visitor-bar-sep:first-of-type {
        display: none !important;
    }
    /* Hide Date section: label "Date:", date value (#visitor-date), and separator after it */
    .visitor-bar-date,
    #visitor-date,
    .visitor-bar-date + .visitor-bar-sep {
        display: none !important;
    }
    /* Hide the "Date:" label - target label before date element */
    .visitor-bar-label:has(+ .visitor-bar-date),
    .visitor-bar-label:has(+ #visitor-date) {
        display: none !important;
    }
    /* Fallback for browsers without :has() support - hide 3rd label (Date) and its separator */
    @supports not selector(:has(*)) {
        .visitor-bar .container > .visitor-bar-label:nth-of-type(3),
        .visitor-bar .container > .visitor-bar-sep:nth-of-type(3) {
            display: none !important;
        }
    }
    /* Hide Time section: label "Time:", time value (#visitor-time), and separator after it */
    .visitor-bar-time,
    #visitor-time,
    .visitor-bar-time + .visitor-bar-sep {
        display: none !important;
    }
    /* Hide the "Time:" label - find it by checking if next sibling is #visitor-time */
    .visitor-bar-label:has(+ .visitor-bar-time),
    .visitor-bar-label:has(+ #visitor-time) {
        display: none !important;
    }
    /* Disable all animations and transitions on visitor bar for mobile */
    .visitor-bar,
    .visitor-bar *,
    .visitor-bar .container,
    .visitor-bar .container * {
        animation: none !important;
        transition: none !important;
        transform: none !important;
    }
}

/* Header */
.header {
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1000;
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.95);
    overflow: visible;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.5rem;
    padding: 0.5rem 0;
    overflow: visible;
}

/* Logo first, then menu – logo area always visible */
.header-content .logo {
    flex-shrink: 0;
    min-height: 2.5rem;
    display: flex;
    align-items: center;
}

.header-content .logo .site-logo-text {
    align-items: center;
    white-space: nowrap;
}
.header-content .main-nav {
    flex: 0 1 auto;
    min-width: 0;
    margin-right: 0;
    overflow: visible;
}

.logo a {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition);
}

.logo a:hover {
    transform: scale(1.05);
}

.logo i {
    font-size: 1.8rem;
}

.main-nav ul {
    display: flex;
    flex-wrap: wrap;
    list-style: none;
    gap: 0.5rem;
    justify-content: flex-start;
    align-items: center;
}

.main-nav ul > li {
    flex-shrink: 0;
}

/* Site-wide main nav: same size, style & animation as Home/Pannel/IPSW – applies to all pages and new menu items */
.header .main-nav > ul > li > a {
    color: var(--text);
    text-decoration: none;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0.5rem 1rem;
    min-height: 2.5rem;
    min-width: 2.5rem;
    border-radius: var(--radius);
    background: rgba(0, 0, 0, 0.04);
    box-sizing: border-box;
    transition: background-color 0.25s ease, color 0.25s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.header .main-nav > ul > li > a:hover {
    color: var(--primary);
    background: var(--light-gray);
    transform: translateY(-1px);
}

.header .main-nav > ul > li > a.active {
    color: var(--primary);
    background: var(--light-gray);
}

/* Dropdown: main menu item with sub-menus */
.main-nav li.has-dropdown {
    position: relative;
}
.main-nav li.has-dropdown .nav-arrow {
    font-size: 0.6em;
    margin-left: 4px;
    opacity: 0.8;
    transition: transform 0.2s ease;
}
.main-nav li.has-dropdown.dropdown-open .nav-arrow {
    transform: rotate(180deg);
}
.main-nav .submenu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 200px;
    margin: 0;
    padding: 0.5rem 0;
    list-style: none;
    background: var(--bg, #fff);
    border: 1px solid var(--border, #e5e7eb);
    border-radius: var(--radius, 8px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    display: none;
    z-index: 1100;
    flex-direction: column;
    gap: 0;
}
.main-nav li.has-dropdown.dropdown-open .submenu {
    display: flex !important;
}
.main-nav .submenu li {
    display: block;
}
.main-nav .submenu a {
    display: block;
    padding: 0.5rem 1rem;
    white-space: nowrap;
    border-radius: 0;
}
.main-nav .submenu a:hover {
    background: var(--light-gray, #f3f4f6);
}

/* Dim placeholder links (# or empty) – header and footer */
.main-nav a.menu-item-no-link,
.footer-menu a.menu-item-no-link {
    opacity: 0.4;
    pointer-events: none;
}

.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text);
    padding: 0.4rem;
    border-radius: 8px;
    line-height: 1;
    flex-shrink: 0;
    margin-left: auto;
    transition: background 0.2s;
}
.mobile-menu-toggle:hover { background: var(--light-gray); }

/* Hero Section */
.hero {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2rem 0;
    text-align: center;
}

.hero-content h1 {
    font-size: 3rem;
    font-weight: 800;
    margin-bottom: 1rem;
    animation: fadeInUp 0.6s ease;
}

.hero-tagline {
    font-size: 1.3rem;
    opacity: 0.9;
    margin-bottom: 2rem;
    animation: fadeInUp 0.6s ease 0.1s both;
}

/* Search Box */
.search-box {
    max-width: 600px;
    margin: 2rem auto;
    animation: fadeInUp 0.6s ease 0.2s both;
}

.search-box form {
    display: flex;
    gap: 1rem;
}

.search-input-group {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    background: white;
    border-radius: var(--radius);
    padding: 0 1rem;
}

.search-input-group i {
    color: var(--gray);
    margin-right: 0.5rem;
}

.search-input-group input {
    flex: 1;
    border: none;
    outline: none;
    padding: 1rem 0;
    font-size: 1rem;
    color: var(--text);
}

.search-clear {
    color: var(--gray);
    cursor: pointer;
    transition: var(--transition);
}

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

/* Buttons - min 44x44px tap targets for accessibility */
.btn {
    padding: 0.75rem 1.5rem;
    min-height: 44px;
    min-width: 44px;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3);
}

.btn-secondary {
    background: var(--secondary);
    color: white;
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-download {
    background: var(--success);
    color: white;
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
}

.btn-download:hover {
    background: #28a745;
    transform: translateY(-1px);
}

/* Hero Stats */
.hero-stats {
    display: flex;
    justify-content: center;
    gap: 3rem;
    margin-top: 2rem;
    animation: fadeInUp 0.6s ease 0.3s both;
}

.stat {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat i {
    font-size: 2rem;
    opacity: 0.8;
}

.stat strong {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
}

.stat span {
    display: block;
    opacity: 0.8;
    font-size: 0.9rem;
}

/* Device Categories */
.device-categories {
    padding: 4rem 0;
}

.device-category {
    margin-bottom: 3rem;
}

.category-title {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 1.8rem;
    margin-bottom: 1.5rem;
    color: var(--dark);
}

.category-title i {
    color: var(--primary);
}

.device-count {
    font-size: 1rem;
    color: var(--gray);
    font-weight: 400;
}

/* Device Grid */
.device-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.device-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    text-decoration: none;
    color: var(--text);
    transition: var(--transition);
    cursor: pointer;
}

.device-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px var(--shadow);
    border-color: var(--primary);
}

.device-icon {
    width: 60px;
    height: 60px;
    background: var(--light-gray);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: var(--primary);
}

.device-info {
    flex: 1;
}

.device-info h3 {
    font-size: 1.1rem;
    margin-bottom: 0.3rem;
    color: var(--text);
}

.device-identifier {
    color: var(--gray);
    font-size: 0.9rem;
}

.device-arrow {
    color: var(--gray);
    font-size: 1.2rem;
}

/* Search Results */
.search-results-header {
    margin-bottom: 2rem;
}

.search-results-header h2 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.search-results-header p {
    color: var(--gray);
}

.no-results {
    text-align: center;
    padding: 4rem 2rem;
}

.no-results i {
    font-size: 4rem;
    color: var(--gray);
    margin-bottom: 1rem;
}

.no-results h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.no-results p {
    color: var(--gray);
}

/* Breadcrumbs */
.breadcrumbs {
    padding: 1rem 0;
    margin-bottom: 1rem;
}

.breadcrumbs ol {
    display: flex;
    flex-wrap: wrap;
    list-style: none;
    gap: 0.5rem;
    align-items: center;
}

.breadcrumbs li {
    display: flex;
    align-items: center;
}

.breadcrumbs li:not(:last-child)::after {
    content: '/';
    margin-left: 0.5rem;
    color: var(--gray);
}

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

.breadcrumbs a:hover {
    text-decoration: underline;
}

/* Device Header */
.device-header {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    margin: 1.25rem 0;
    display: flex;
    flex-wrap: nowrap;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.device-header-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
    flex: 1 1 auto;
}

.device-header-icon {
    width: 48px;
    height: 48px;
    background: var(--light-gray);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    color: var(--primary);
    flex-shrink: 0;
}

.device-header-info {
    min-width: 0;
}

.device-header-info h1,
.device-name-line {
    font-size: 1.15rem;
    margin: 0;
    font-weight: 600;
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 0.5rem;
}

.device-name-link {
    color: var(--primary);
    text-decoration: none;
}
.device-name-link:hover {
    text-decoration: underline;
}

.device-identifier {
    color: var(--gray);
    font-size: 0.85rem;
    font-weight: 400;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.device-stats-wrapper {
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 0.4rem 0.6rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    flex-shrink: 0;
}

.device-stats {
    display: flex;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 0.3rem;
}

.stat-item {
    text-align: center;
}

.stat-item:not(.stat-card) strong {
    display: block;
    font-size: 2rem;
    color: var(--primary);
}

.stat-item:not(.stat-card) span {
    color: var(--gray);
    font-size: 0.9rem;
}

.stat-item.stat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    min-width: 2.6rem;
    padding: 0.3rem 0.4rem;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.stat-item.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
    border-color: transparent;
}

.stat-item .stat-icon-wrap,
.stat-item .stat-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.35rem;
    height: 1.35rem;
    margin-bottom: 0.2rem;
    border-radius: 6px;
    font-size: 0.65rem;
    color: #fff;
}

.stat-item .stat-icon-wrap {
    flex-shrink: 0;
}

.stat-item.stat-official .stat-icon-wrap { background: linear-gradient(135deg, #10b981 0%, #059669 100%); }
.stat-item.stat-official strong { color: #059669; }
.stat-item.stat-official:hover .stat-icon-wrap { box-shadow: 0 4px 12px rgba(5, 150, 105, 0.35); }

.stat-item.stat-beta .stat-icon-wrap { background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%); }
.stat-item.stat-beta strong { color: #7c3aed; }
.stat-item.stat-beta:hover .stat-icon-wrap { box-shadow: 0 4px 12px rgba(124, 58, 237, 0.35); }

.stat-item.stat-total .stat-icon-wrap { background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%); }
.stat-item.stat-total strong { color: #2563eb; }
.stat-item.stat-total:hover .stat-icon-wrap { box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35); }

.stat-item.stat-visits .stat-icon-wrap { background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%); }
.stat-item.stat-visits strong { color: #0891b2; }
.stat-item.stat-visits:hover .stat-icon-wrap { box-shadow: 0 4px 12px rgba(8, 145, 178, 0.35); }

.stat-item.stat-downloads .stat-icon-wrap { background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%); }
.stat-item.stat-downloads strong { color: #d97706; }
.stat-item.stat-downloads:hover .stat-icon-wrap { box-shadow: 0 4px 12px rgba(217, 119, 6, 0.35); }

.stat-item.stat-divider {
    flex: 0 0 0;
    min-width: 0;
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
    border-left: 1px solid #e2e8f0;
    border-radius: 0;
    margin: 0.1rem 0.15rem 0.1rem 0.2rem;
}
.stat-item.stat-divider:hover {
    transform: none;
    box-shadow: none;
}

.stat-item.stat-card strong {
    display: block;
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.03em;
}

.stat-item .stat-label {
    display: block;
    margin-top: 0.05rem;
    font-size: 0.5rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Firmware Filters */
.firmware-filters {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 2rem;
    display: flex;
    gap: 2rem;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.filter-group label {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filter-group select {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    cursor: pointer;
    background: white;
}

/* Firmware Table */
.table-responsive {
    overflow-x: auto;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.firmware-table {
    width: 100%;
    border-collapse: collapse;
}

.firmware-table th {
    background: var(--light-gray);
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid var(--border);
}

.firmware-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.firmware-row:hover {
    background: var(--light-gray);
}

.version-cell strong {
    color: var(--primary);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.status-badge.signed {
    background: #d4edda;
    color: var(--success);
}

.status-badge.unsigned {
    background: #f8d7da;
    color: var(--danger);
}

/* Firmware Info Cards */
.firmware-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.info-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.info-card h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    color: var(--primary);
}

.info-card p {
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.info-card.warning {
    background: #fff3cd;
    border-color: var(--warning);
}

.info-card.warning h3 {
    color: var(--warning);
}

/* Footer */
.footer {
    background: var(--dark);
    color: white;
    padding: 3rem 0 1rem;
    margin-top: 4rem;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.footer-section h3 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.footer-section h4 {
    margin-bottom: 1rem;
}

.footer-section ul {
    list-style: none;
}

.footer-section ul li {
    margin-bottom: 0.5rem;
}

.footer-section a {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: var(--transition);
}

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

.social-links {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.social-links a {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.social-links a:hover {
    background: var(--primary);
}

.newsletter-form {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.newsletter-form input {
    flex: 1;
    padding: 0.75rem;
    border: none;
    border-radius: var(--radius);
}

.footer-bottom {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 1rem;
    text-align: center;
    color: rgba(255, 255, 255, 0.6);
}

.footer-bottom a {
    color: var(--primary);
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive - mobile first improvements */
@media (max-width: 768px) {
    .container {
        padding-left: 16px;
        padding-right: 16px;
    }
    
    body {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
    
    .header-content {
        padding: 0.75rem 0;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .logo a {
        font-size: 1.25rem;
    }
    
    .logo i {
        font-size: 1.5rem;
    }

    /* Show hamburger toggle on mobile */
    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Nav hidden by default on mobile, toggled by JS */
    .main-nav {
        display: none;
        width: 100%;
        order: 3;
        margin-top: 0.25rem;
        padding-top: 0.5rem;
        border-top: 1px solid var(--border);
    }
    .main-nav.mobile-open {
        display: flex;
    }
    
    .main-nav ul {
        flex-wrap: wrap;
        gap: 0.5rem;
        justify-content: flex-start;
    }
    
    .header .main-nav > ul > li > a {
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
        min-height: 44px;
        min-width: 44px;
        justify-content: center;
        border-radius: 8px;
    }
    /* Dropdown on tablet/mobile: show submenu in flow below parent when open */
    .main-nav li.has-dropdown {
        flex-direction: column;
        align-items: stretch;
    }
    .main-nav li.has-dropdown .submenu {
        position: static;
        display: none;
        box-shadow: none;
        border: none;
        border-left: 2px solid var(--border, #e5e7eb);
        margin-left: 0.5rem;
        margin-top: 0.25rem;
        padding-left: 0.5rem;
    }
    .main-nav li.has-dropdown.dropdown-open .submenu {
        display: flex;
    }
    .main-nav .submenu a {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    
    .hero {
        padding: 1.25rem 0;
    }
    
    .hero-content h1 {
        font-size: 1.75rem;
        line-height: 1.2;
    }
    
    .hero-tagline {
        font-size: 1rem;
    }
    
    .hero-stats {
        flex-direction: column;
        gap: 1rem;
    }
    
    .device-grid {
        grid-template-columns: 1fr;
    }
    
    .device-header {
        flex-direction: column;
        align-items: flex-start;
        padding: 0.6rem 0.75rem;
    }

    .device-header-icon {
        width: 40px;
        height: 40px;
        font-size: 1.5rem;
    }

    .device-header-info h1,
    .device-name-line {
        font-size: 1rem;
    }

    .device-identifier {
        font-size: 0.75rem;
    }
    
    .device-stats {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: nowrap;
    }

    .device-stats-wrapper {
        padding: 0.35rem 0.5rem;
    }

    .stat-item.stat-card {
        min-width: 2.35rem;
        padding: 0.25rem 0.35rem;
    }

    .stat-item.stat-card strong {
        font-size: 0.85rem;
    }

    .stat-item .stat-icon-wrap,
    .stat-item .stat-icon {
        width: 1.2rem;
        height: 1.2rem;
        font-size: 0.6rem;
        margin-bottom: 0.15rem;
    }

    .stat-item .stat-label {
        font-size: 0.45rem;
    }

    .stat-item.stat-divider {
        margin: 0.08rem 0.12rem 0.08rem 0.15rem;
    }
    
    .firmware-filters {
        flex-direction: column;
    }
    
    .firmware-table {
        font-size: 0.85rem;
    }
    
    .firmware-table td,
    .firmware-table th {
        padding: 0.5rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding-left: 12px;
        padding-right: 12px;
    }
    
    .main-nav ul {
        gap: 0.35rem;
    }
    
    .header .main-nav > ul > li > a {
        padding: 0.45rem 0.6rem;
        font-size: 0.85rem;
    }
    
    .hero-content h1 {
        font-size: 1.5rem;
    }
}

/* ═══════════════════════════════════════════════
   ADMIN PANEL — DESIGN 3-F ROSE GOLD THEME
═══════════════════════════════════════════════ */

/* CSS variables for the theme */
:root {
    --rg-primary:   #f43f5e;
    --rg-dark:      #4c0519;
    --rg-mid:       #881337;
    --rg-light:     #fff1f2;
    --rg-pill-bg:   rgba(255,255,255,0.18);
    --rg-pill-hover:rgba(255,255,255,0.28);
    --rg-text:      rgba(255,255,255,0.92);
    --rg-text-dim:  rgba(255,255,255,0.55);
    --rg-border:    rgba(255,255,255,0.14);
}

.admin-container { max-width: 1400px; }

/* ── Header ── */
.admin-header {
    background: #fff;
    color: #1e293b;
    border-bottom: 1px solid #fecdd3;
    box-shadow: 0 1px 8px rgba(244,63,94,0.08);
    height: 62px;
}
.admin-header__brand { color: var(--rg-primary) !important; font-weight: 800 !important; }
.admin-header__brand i { color: var(--rg-primary); }
.admin-top-nav__link { color: #475569 !important; }
.admin-top-nav__link:hover, .admin-top-nav__link.active { color: var(--rg-primary) !important; }
.admin-dropdown { border-top: 2px solid var(--rg-primary); }
.admin-dropdown__link:hover, .admin-dropdown__link.active { color: var(--rg-primary) !important; background: #fff1f2 !important; }

/* ── Sidebar wrapper ── */
.admin-sidebar {
    width: 260px !important;
    background: linear-gradient(175deg, #f43f5e 0%, #be123c 38%, #881337 65%, #4c0519 100%) !important;
    border-right: none !important;
    box-shadow: 4px 0 20px rgba(244,63,94,0.25) !important;
    height: 100vh !important;
    position: fixed !important;
    left: 0 !important;
    top: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 0 !important;
    z-index: 200 !important;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.2) transparent;
}
.admin-sidebar::-webkit-scrollbar { width: 4px; }
.admin-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 4px; }

/* Sidebar brand (logo area) */
.admin-sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 22px 20px 18px;
    border-bottom: 1px solid var(--rg-border);
    margin-bottom: 10px;
    text-decoration: none;
}
.admin-sidebar-brand-icon {
    width: 38px; height: 38px;
    background: rgba(255,255,255,0.2);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem; color: #fff;
    flex-shrink: 0;
}
.admin-sidebar-brand-text { font-size: 1.1rem; font-weight: 800; color: #fff; letter-spacing: -0.02em; }
.admin-sidebar-brand-sub  { font-size: 0.68rem; color: var(--rg-text-dim); font-weight: 500; }

/* Sidebar section labels */
.admin-sidebar-section-label {
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--rg-text-dim);
    padding: 12px 20px 4px;
    display: block;
}

/* Sidebar list items */
.admin-sidebar ul { list-style: none; }

.admin-sidebar a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px 9px 20px;
    color: var(--rg-text);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: 10px;
    margin: 1px 10px;
    transition: background 0.15s, color 0.15s;
}
.admin-sidebar a:hover {
    background: var(--rg-pill-hover);
    color: #fff;
}
.admin-sidebar a.active {
    background: #fff;
    color: var(--rg-primary) !important;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}
.admin-sidebar a.active .admin-sidebar__subdot { background: var(--rg-primary); }
.admin-sidebar a .fas:first-child { width: 18px; text-align: center; font-size: 0.88rem; }

.admin-sidebar__list { padding: 0; margin: 0; list-style: none; }
.admin-sidebar__item { list-style: none; }

.admin-sidebar__parent {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 16px 9px 20px;
    border: none;
    background: transparent;
    color: var(--rg-text);
    font-size: 0.9rem;
    font-weight: 500;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s;
    border-radius: 10px;
    margin: 1px 10px;
    width: calc(100% - 20px);
}
.admin-sidebar__parent:hover { background: var(--rg-pill-hover); color: #fff; }
.admin-sidebar__parent.is-open { background: var(--rg-pill-bg); color: #fff; font-weight: 600; }
.admin-sidebar__parent .fas:first-child { width: 18px; text-align: center; font-size: 0.88rem; }

.admin-sidebar__chevron { margin-left: auto; font-size: 0.65rem; color: var(--rg-text-dim); transition: transform 0.2s; }
.admin-sidebar__parent.is-open .admin-sidebar__chevron { color: rgba(255,255,255,0.8); }

.admin-sidebar__submenu {
    list-style: none;
    padding: 2px 0 6px 0;
    margin: 0;
    border-left: 2px solid rgba(255,255,255,0.2);
    margin-left: 30px;
}
.admin-sidebar__submenu li { list-style: none; }
.admin-sidebar__submenu a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px 7px 14px;
    color: var(--rg-text-dim);
    font-size: 0.84rem;
    border-radius: 8px;
    margin: 1px 8px 1px 0;
    font-weight: 400;
}
.admin-sidebar__submenu a:hover { background: rgba(255,255,255,0.12); color: #fff; }
.admin-sidebar__submenu a.active { background: rgba(255,255,255,0.18); color: #fff; font-weight: 600; }
.admin-sidebar__submenu a .fas { font-size: 0.78rem; width: 14px; text-align: center; opacity: 0.8; }

.admin-sidebar__subdot { width: 5px; height: 5px; border-radius: 50%; background: rgba(255,255,255,0.4); flex-shrink: 0; }
.admin-sidebar__submenu a.active .admin-sidebar__subdot { background: #fff; opacity: 1; }

.admin-sidebar__sep { border-top: 1px solid var(--rg-border); margin: 8px 16px !important; padding: 0 !important; }

.admin-sidebar__logout { color: rgba(255,200,200,0.85) !important; }
.admin-sidebar__logout:hover { background: rgba(255,0,0,0.15) !important; color: #fca5a5 !important; }

/* ── Main content ── */
.admin-main {
    margin-left: 260px;
    min-height: 100vh;
    background: #fff1f2;
    padding: 0;
}
.admin-content {
    padding: 24px 28px;
}

/* ── Admin top-bar inside content ── */
.rg-topbar {
    background: #fff;
    border-bottom: 1px solid #fecdd3;
    padding: 14px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    position: sticky; top: 0; z-index: 100;
    box-shadow: 0 1px 6px rgba(244,63,94,0.06);
}
.rg-topbar-left h1 { font-size: 1.3rem; font-weight: 800; color: #1e293b; margin: 0; }
.rg-topbar-left p  { font-size: 0.78rem; color: var(--rg-primary); margin: 2px 0 0; font-weight: 600; }
.rg-topbar-right   { display: flex; align-items: center; gap: 10px; }
.rg-search {
    display: flex; align-items: center; gap: 7px;
    background: #fff1f2; border: 1.5px solid #fecdd3; border-radius: 30px;
    padding: 7px 14px; font-size: 0.85rem; color: #475569;
}
.rg-search i { color: var(--rg-primary); font-size: 0.82rem; }
.rg-search input { border: none; background: transparent; outline: none; font-size: 0.85rem; width: 150px; font-family: inherit; color: #1e293b; }
.rg-bell {
    width: 36px; height: 36px; border-radius: 50%;
    background: #fff1f2; border: 1.5px solid #fecdd3;
    display: flex; align-items: center; justify-content: center;
    color: var(--rg-primary); font-size: 0.88rem; cursor: pointer; position: relative;
    text-decoration: none;
}
.rg-bell-dot {
    position: absolute; top: 4px; right: 4px;
    width: 8px; height: 8px; background: var(--rg-primary);
    border-radius: 50%; border: 2px solid #fff;
}
.rg-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: linear-gradient(135deg, var(--rg-primary), var(--rg-mid));
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 0.88rem; font-weight: 800;
    border: 2px solid #fecdd3;
}
.rg-viewsite {
    display: inline-flex; align-items: center; gap: 5px;
    background: var(--rg-primary); color: #fff;
    border-radius: 20px; padding: 6px 14px;
    font-size: 0.78rem; font-weight: 700; text-decoration: none;
    transition: opacity 0.15s;
}
.rg-viewsite:hover { opacity: 0.88; }

/* ── Dashboard stat cards ── */
.rg-stats { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; margin-bottom: 20px; }
.rg-stat {
    background: #fff; border-radius: 16px;
    padding: 20px 18px; border: 1px solid #fecdd3;
    box-shadow: 0 2px 12px rgba(244,63,94,0.07);
    display: flex; align-items: flex-start; gap: 14px;
    transition: transform 0.15s, box-shadow 0.15s;
}
.rg-stat:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(244,63,94,0.13); }
.rg-stat-icon {
    width: 46px; height: 46px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem; flex-shrink: 0;
}
.rg-stat-body { flex: 1; }
.rg-stat-val  { font-size: 1.8rem; font-weight: 900; color: #0f172a; line-height: 1; }
.rg-stat-label{ font-size: 0.75rem; color: #64748b; font-weight: 600; margin-top: 4px; }
.rg-stat-badge { display: inline-flex; align-items: center; gap: 3px; font-size: 0.72rem; font-weight: 700; padding: 2px 8px; border-radius: 20px; margin-top: 8px; }
.rg-stat-badge.up   { background: #d1fae5; color: #065f46; }
.rg-stat-badge.info { background: #e0f2fe; color: #0369a1; }
.rg-stat-badge.ok   { background: #f0fdf4; color: #15803d; }

/* ── Two-column panels ── */
.rg-panels { display: grid; grid-template-columns: 1fr 340px; gap: 16px; margin-bottom: 20px; }
.rg-card { background: #fff; border-radius: 16px; border: 1px solid #fecdd3; box-shadow: 0 2px 12px rgba(244,63,94,0.06); overflow: hidden; }
.rg-card-head { padding: 18px 20px 14px; border-bottom: 1px solid #fff1f2; display: flex; align-items: center; justify-content: space-between; }
.rg-card-title { font-size: 0.95rem; font-weight: 800; color: #1e293b; }
.rg-card-link  { font-size: 0.78rem; color: var(--rg-primary); text-decoration: none; font-weight: 600; }
.rg-card-link:hover { text-decoration: underline; }

/* ── Posts table ── */
.rg-posts-table { width: 100%; border-collapse: collapse; }
.rg-posts-table th { background: #fff8f8; padding: 10px 16px; text-align: left; font-size: 0.72rem; font-weight: 800; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 1px solid #fecdd3; }
.rg-posts-table td { padding: 12px 16px; border-bottom: 1px solid #fff1f2; vertical-align: middle; }
.rg-posts-table tr:last-child td { border-bottom: none; }
.rg-posts-table tr:hover td { background: #fff8f8; }
.rg-post-thumb { width: 44px; height: 36px; border-radius: 8px; object-fit: cover; background: #fecdd3; display: block; }
.rg-post-thumb-placeholder { width: 44px; height: 36px; border-radius: 8px; background: #fecdd3; display: flex; align-items: center; justify-content: center; color: var(--rg-primary); font-size: 0.9rem; }
.rg-post-title { font-size: 0.84rem; font-weight: 700; color: #1e293b; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.rg-post-date  { font-size: 0.75rem; color: #94a3b8; margin-top: 2px; }
.rg-cat-pill   { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 0.68rem; font-weight: 700; background: #fecdd3; color: var(--rg-mid); }
.rg-status-pill { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 0.68rem; font-weight: 700; }
.rg-status-pill.pub   { background: #d1fae5; color: #065f46; }
.rg-status-pill.draft { background: #fef3c7; color: #92400e; }
.rg-act-link { font-size: 0.75rem; font-weight: 600; text-decoration: none; padding: 3px 8px; border-radius: 6px; }
.rg-act-edit  { color: #3b82f6; } .rg-act-edit:hover  { background: #dbeafe; }
.rg-act-del   { color: #ef4444; } .rg-act-del:hover   { background: #fee2e2; }

/* ── Quick actions ── */
.rg-actions { padding: 16px; display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.rg-action-btn {
    display: flex; flex-direction: column; align-items: center; gap: 7px;
    background: #fff8f8; border: 1.5px solid #fecdd3;
    border-radius: 14px; padding: 14px 8px;
    text-decoration: none; color: #1e293b;
    font-size: 0.72rem; font-weight: 700;
    text-align: center; transition: transform 0.15s, box-shadow 0.15s;
    cursor: pointer;
}
.rg-action-btn:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(244,63,94,0.15); }
.rg-action-icon {
    width: 40px; height: 40px; border-radius: 11px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1rem; color: #fff;
}

/* ── Analytics area chart ── */
.rg-chart-wrap { padding: 16px 20px; }
.rg-chart-tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.rg-chart-tab { padding: 4px 14px; border-radius: 20px; font-size: 0.72rem; font-weight: 700; background: #fff1f2; color: #94a3b8; border: none; cursor: pointer; }
.rg-chart-tab.active { background: var(--rg-primary); color: #fff; }
.rg-chart-nums { display: flex; gap: 16px; margin-top: 12px; }
.rg-chart-num-box { text-align: center; }
.rg-chart-num-val { font-size: 1.1rem; font-weight: 800; color: #1e293b; }
.rg-chart-num-lbl { font-size: 0.68rem; color: #94a3b8; font-weight: 600; text-transform: uppercase; }

/* ── Visitor log ── */
.rg-log { width: 100%; border-collapse: collapse; }
.rg-log th { background: #fff8f8; padding: 10px 14px; text-align: left; font-size: 0.7rem; font-weight: 800; color: #94a3b8; text-transform: uppercase; border-bottom: 1px solid #fecdd3; }
.rg-log td { padding: 10px 14px; border-bottom: 1px solid #fff1f2; font-size: 0.82rem; color: #475569; }
.rg-log tr:last-child td { border-bottom: none; }
.rg-log tr:hover td { background: #fff8f8; }

/* ── Quick action pills row ── */
.rg-pill-row { display: flex; flex-wrap: wrap; gap: 10px; padding: 18px 20px; border-top: 1px solid #fff1f2; }
.rg-pill { display: inline-flex; align-items: center; gap: 6px; padding: 8px 18px; border-radius: 30px; border: 1.5px solid #fecdd3; background: #fff; color: #1e293b; font-size: 0.82rem; font-weight: 700; text-decoration: none; cursor: pointer; transition: all 0.15s; }
.rg-pill:hover { background: var(--rg-primary); color: #fff; border-color: var(--rg-primary); }
.rg-pill i { font-size: 0.8rem; }

/* ── Admin main cards (forms etc.) ── */
.admin-card { background: #fff; border: 1px solid #fecdd3; border-radius: 16px; padding: 24px; margin-bottom: 20px; box-shadow: 0 2px 10px rgba(244,63,94,0.05); }
.admin-card h2 { margin-bottom: 1.5rem; color: #1e293b; }

/* ── Forms ── */
.form-group { margin-bottom: 1.25rem; }
.form-group label { display: block; font-weight: 700; margin-bottom: 5px; font-size: 0.85rem; color: #374151; }
.form-group input, .form-group textarea, .form-group select {
    width: 100%; padding: 10px 13px;
    border: 1.5px solid #fecdd3; border-radius: 10px;
    font-size: 0.9rem; font-family: inherit; outline: none;
    transition: border-color 0.15s;
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus { border-color: var(--rg-primary); box-shadow: 0 0 0 3px rgba(244,63,94,0.1); }
.form-group textarea { min-height: 140px; resize: vertical; }

/* ── Flash alerts ── */
.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; font-size: 0.88rem; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-danger  { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-info    { background: #dbeafe; color: #1d4ed8; border: 1px solid #bfdbfe; }

/* ── Mobile ── */
@media (max-width: 768px) {
    .admin-sidebar { left: -280px; transition: left 0.28s cubic-bezier(0.4,0,0.2,1); z-index: 1100; top: 0; height: 100vh; box-shadow: 4px 0 24px rgba(244,63,94,0.3); }
    .admin-sidebar.mobile-open { left: 0; }
    .admin-main { margin-left: 0; }
    .admin-content { padding: 16px; }
    .rg-stats { grid-template-columns: 1fr 1fr; gap: 10px; }
    .rg-panels { grid-template-columns: 1fr; }
    .rg-topbar { padding: 12px 16px; }
    .rg-search { display: none; }
    .admin-card { padding: 16px; }
}
@media (max-width: 480px) {
    .rg-stats { grid-template-columns: 1fr 1fr; gap: 8px; }
    .rg-stat-val { font-size: 1.4rem; }
    .rg-actions { grid-template-columns: repeat(3,1fr); }
    .admin-content { padding: 10px; }
}

/* ── Performance: content-visibility for below-fold sections ── */
.footer,
.simple-link-only-section,
.check-modal {
    content-visibility: auto;
    contain-intrinsic-size: auto 300px;
}

/* ── Performance: reduce paint complexity ── */
.device-card:hover,
.btn-primary:hover,
.btn-download:hover {
    will-change: transform;
}

/* ── Performance: reduce animation cost on mobile ── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Mobile responsive (admin + user) */
@import url('mobile-responsive.css');
