/**
 * Gold Bar Authenticity System - Luxury Glassmorphism Design System
 * Typography: IRANYekanX Variable Font (FaNum)
 * Supports Dark (Midnight Obsidian) & Light (Pearl & Gold) Themes
 */

@font-face {
    font-family: 'IRANYekanX';
    src: url('../fonts/Pardis-gold-regular.woff2') format('woff2');
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

:root {
    /* Base Dark Theme (Midnight Obsidian & Gold) */
    --bg-dark: #07090e;
    --bg-surface: #0e121d;
    --bg-surface-elevated: #141b2b;

    /* Luxury Gold Gradients */
    --gold-light: #ffdf73;
    --gold-primary: #d4af37;
    --gold-dark: #996515;
    --gold-gradient: linear-gradient(135deg, #ffdf73 0%, #d4af37 50%, #996515 100%);
    --gold-gradient-subtle: linear-gradient(135deg, rgba(255, 223, 115, 0.15) 0%, rgba(212, 175, 55, 0.05) 100%);
    --gold-glow: 0 0 25px rgba(212, 175, 55, 0.35);

    /* Glass Tokens */
    --glass-bg: rgba(18, 24, 38, 0.65);
    --glass-bg-hover: rgba(24, 32, 50, 0.75);
    --glass-border: 1px solid rgba(212, 175, 55, 0.22);
    --glass-border-light: 1px solid rgba(255, 255, 255, 0.08);
    --glass-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.7), inset 0 1px 1px rgba(255, 255, 255, 0.12);
    --glass-blur: blur(24px);

    /* Status Colors */
    --status-valid-bg: rgba(16, 185, 129, 0.12);
    --status-valid-border: rgba(16, 185, 129, 0.4);
    --status-valid-text: #34d399;
    --status-valid-glow: 0 0 30px rgba(16, 185, 129, 0.25);

    --status-warning-bg: rgba(245, 158, 11, 0.12);
    --status-warning-border: rgba(245, 158, 11, 0.4);
    --status-warning-text: #fbbf24;

    --status-danger-bg: rgba(239, 68, 68, 0.12);
    --status-danger-border: rgba(239, 68, 68, 0.4);
    --status-danger-text: #f87171;

    /* Text Colors */
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
    --text-gold: #fde68a;

    /* Input Background */
    --input-bg: rgba(10, 14, 23, 0.75);
    --input-text: #ffdf73;

    /* Ambient Opacity */
    --ambient-opacity: 0.4;

    /* Radius */
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 22px;
    --radius-xl: 30px;
}

/* Light Theme (Pearl & Royal Gold) */
[data-theme="light"] {
    --bg-dark: #f0f2f7;
    --bg-surface: #ffffff;
    --bg-surface-elevated: #f8fafc;

    /* Glass tokens on white */
    --glass-bg: rgba(255, 255, 255, 0.88);
    --glass-bg-hover: rgba(255, 255, 255, 0.98);
    --glass-border: 1px solid rgba(180, 140, 30, 0.30);
    --glass-border-light: 1px solid rgba(0, 0, 0, 0.10);
    --glass-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.10), inset 0 1px 1px rgba(255, 255, 255, 0.9);

    /* Gold tones: much darker so they're visible on white */
    --gold-light: #7c5a00;       /* Deep amber – for headings */
    --gold-primary: #a07800;     /* Rich gold – for buttons & accents */
    --gold-dark: #5c3d00;        /* Dark bronze – for hover states */
    --gold-gradient: linear-gradient(135deg, #d4a017 0%, #a07800 50%, #7c5a00 100%);
    --gold-gradient-subtle: linear-gradient(135deg, rgba(160, 120, 0, 0.12) 0%, rgba(160, 120, 0, 0.04) 100%);
    --gold-glow: 0 0 20px rgba(160, 120, 0, 0.20);

    /* Status – higher saturation for light bg */
    --status-valid-bg: rgba(16, 185, 129, 0.08);
    --status-valid-border: rgba(16, 185, 129, 0.45);
    --status-valid-text: #047857;     /* Deeper green on white */
    --status-valid-glow: 0 0 20px rgba(16, 185, 129, 0.10);

    --status-warning-bg: rgba(217, 119, 6, 0.08);
    --status-warning-border: rgba(217, 119, 6, 0.40);
    --status-warning-text: #b45309;   /* Amber-brown on white */

    --status-danger-bg: rgba(220, 38, 38, 0.07);
    --status-danger-border: rgba(220, 38, 38, 0.40);
    --status-danger-text: #b91c1c;    /* Deeper red on white */

    /* Text: high contrast on white */
    --text-main: #0f172a;
    --text-muted: #374151;
    --text-dim: #6b7280;
    --text-gold: #7c5a00;            /* Same as gold-light – dark amber */

    /* Input on light */
    --input-bg: rgba(255, 255, 255, 0.96);
    --input-text: #7c5a00;           /* Dark amber input text */

    --ambient-opacity: 0.18;
}

/* Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'IRANYekanX', system-ui, -apple-system, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    position: relative;
    direction: rtl;
    text-align: right;
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Top Navigation Bar */
.top-navbar {
    width: 100%;
    max-width: 600px;
    margin: 12px auto 0;
    padding: 0 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    z-index: 10;
}

.top-brand-small {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--text-main);
    font-size: 0.88rem;
    font-weight: 700;
}

/* Theme Toggle Button */
.theme-toggle-btn {
    background: var(--glass-bg);
    border: var(--glass-border-light);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--gold-primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: all 0.25s ease;
}

.theme-toggle-btn:hover {
    transform: scale(1.08);
    border-color: var(--gold-primary);
    box-shadow: var(--gold-glow);
}

.theme-toggle-btn svg {
    width: 20px;
    height: 20px;
    transition: transform 0.3s ease;
}

/* Ambient Light Orbs (Background Glow) */
.ambient-glow {
    position: fixed;
    border-radius: 50%;
    filter: blur(120px);
    pointer-events: none;
    z-index: 0;
    opacity: var(--ambient-opacity);
    transition: opacity 0.5s ease;
}

.ambient-gold-1 {
    top: -15%;
    right: 10%;
    width: 450px;
    height: 450px;
    background: radial-gradient(circle, rgba(212, 175, 55, 0.45) 0%, rgba(212, 175, 55, 0) 70%);
}

.ambient-gold-2 {
    bottom: -10%;
    left: 5%;
    width: 550px;
    height: 550px;
    background: radial-gradient(circle, rgba(153, 101, 21, 0.35) 0%, rgba(153, 101, 21, 0) 70%);
}

.ambient-emerald {
    top: 40%;
    left: 30%;
    width: 350px;
    height: 350px;
    background: radial-gradient(circle, rgba(16, 185, 129, 0.2) 0%, rgba(16, 185, 129, 0) 70%);
}

/* Main Container Layout */
.app-container {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 600px;
    margin: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Luxury Glass Card */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: var(--glass-border);
    box-shadow: var(--glass-shadow);
    border-radius: var(--radius-lg);
    padding: 28px 24px;
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease, background 0.3s ease;
    position: relative;
    overflow: hidden;
}

.glass-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(255, 223, 115, 0.6), transparent);
}

/* Header & Brand */
.brand-header {
    text-align: center;
    margin-bottom: 24px;
}

.brand-emblem {
    width: 68px;
    height: 68px;
    margin: 0 auto 16px;
    background: var(--gold-gradient-subtle);
    border: 1px solid rgba(212, 175, 55, 0.4);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--gold-glow);
}

.brand-emblem svg {
    width: 36px;
    height: 36px;
    fill: var(--gold-primary);
}

.brand-title {
    font-size: 1.45rem;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: -0.5px;
    margin-bottom: 6px;
}

.brand-title span {
    background: var(--gold-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-subtitle {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 400;
}

/* Code Input Box */
.input-section {
    margin-bottom: 12px;
}

.input-label {
    display: block;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-gold);
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.code-input {
    width: 100%;
    height: 60px;
    background: var(--input-bg);
    border: 1px solid rgba(212, 175, 55, 0.35);
    border-radius: var(--radius-md);
    padding: 0 16px 0 46px;
    font-size: 1.25rem; /* Desktop: large & readable */
    font-weight: 700;
    color: var(--input-text);
    letter-spacing: 2px;
    text-align: center;
    direction: ltr;
    outline: none;
    transition: all 0.25s ease;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
    /* iOS: min 16px prevents auto-zoom */
    -webkit-text-size-adjust: 100%;
}

.code-input:focus {
    border-color: var(--gold-primary);
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.25);
}

.code-input::placeholder {
    color: rgba(148, 163, 184, 0.5);
    font-size: 1rem;
    letter-spacing: 1px;
    font-weight: 400;
}

.clear-btn {
    position: absolute;
    left: 12px;
    width: 30px;
    height: 30px;
    background: rgba(0, 0, 0, 0.08);
    border: none;
    border-radius: 50%;
    color: var(--text-muted);
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.clear-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
}

/* Submit Action Button */
.btn-verify {
    width: 100%;
    height: 54px;
    margin-top: 16px;
    background: var(--gold-gradient);
    border: none;
    border-radius: var(--radius-md);
    color: #07090e;
    font-size: 1.05rem;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: var(--gold-glow);
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
}

.btn-verify:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 0 35px rgba(212, 175, 55, 0.5);
}

.btn-verify:active:not(:disabled) {
    transform: translateY(0);
}

.btn-verify:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    filter: grayscale(0.2);
}

.btn-verify .spinner {
    width: 22px;
    height: 22px;
    border: 3px solid rgba(7, 9, 14, 0.3);
    border-top-color: #07090e;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: none;
}

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

/* Result Box (Directly Underneath Input) */
.result-container {
    margin-top: 20px;
    display: none;
    animation: slideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

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

.result-card {
    border-radius: var(--radius-md);
    padding: 22px;
    border-width: 1px;
    border-style: solid;
    position: relative;
}

/* Valid State (Emerald & Gold) */
.result-card.status-valid {
    background: var(--status-valid-bg);
    border-color: var(--status-valid-border);
    box-shadow: var(--status-valid-glow);
}

/* Warning State (Amber) */
.result-card.status-warning {
    background: var(--status-warning-bg);
    border-color: var(--status-warning-border);
}

/* Danger State (Ruby/Red) */
.result-card.status-danger {
    background: var(--status-danger-bg);
    border-color: var(--status-danger-border);
}

.result-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] .result-header {
    border-bottom-color: rgba(255, 255, 255, 0.08);
}

.result-icon-badge {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.status-valid .result-icon-badge {
    background: rgba(16, 185, 129, 0.2);
    color: var(--status-valid-text);
    border: 1px solid rgba(16, 185, 129, 0.4);
}

.status-warning .result-icon-badge {
    background: rgba(245, 158, 11, 0.2);
    color: var(--status-warning-text);
    border: 1px solid rgba(245, 158, 11, 0.4);
}

.status-danger .result-icon-badge {
    background: rgba(239, 68, 68, 0.2);
    color: var(--status-danger-text);
    border: 1px solid rgba(239, 68, 68, 0.4);
}

.result-title {
    font-size: 1.15rem;
    font-weight: 800;
}

.status-valid .result-title {
    color: var(--status-valid-text);
}

.status-warning .result-title {
    color: var(--status-warning-text);
}

.status-danger .result-title {
    color: var(--status-danger-text);
}

.result-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Spec Rows in Valid Card */
.spec-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-top: 14px;
}

.spec-item {
    background: rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
}

[data-theme="dark"] .spec-item {
    background: rgba(0, 0, 0, 0.25);
    border-color: rgba(255, 255, 255, 0.05);
}

.spec-label {
    font-size: 0.78rem;
    color: var(--text-dim);
    margin-bottom: 3px;
}

.spec-val {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
}

.spec-val.highlight {
    color: var(--gold-primary);
}

.history-banner {
    margin-top: 14px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    line-height: 1.5;
}

.history-first {
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: var(--status-valid-text);
}

.history-repeated {
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: var(--status-warning-text);
}

/* Visual Physical Guide */
.card-guide-section {
    background: var(--glass-bg);
    border: var(--glass-border-light);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 10px;
}

.guide-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: rgba(212, 175, 55, 0.15);
    color: var(--gold-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.guide-text {
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.5;
}

/* Footer */
.app-footer {
    text-align: center;
    font-size: 0.78rem;
    color: var(--text-dim);
    margin-top: 15px;
}

/* ==========================================================
 * Admin Panel CSS
 * ========================================================== */
.admin-body {
    background-color: var(--bg-dark);
}

.admin-layout {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    width: 260px;
    background: var(--glass-bg);
    border-left: 1px solid rgba(212, 175, 55, 0.15);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.admin-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    margin-bottom: 10px;
}

[data-theme="dark"] .admin-brand {
    border-bottom-color: rgba(255, 255, 255, 0.08);
}

.admin-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.92rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.admin-nav-item:hover,
.admin-nav-item.active {
    background: var(--gold-gradient-subtle);
    color: var(--gold-primary);
    border: 1px solid rgba(212, 175, 55, 0.25);
}

.admin-main {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
}

.admin-header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

/* Stats Cards Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--glass-bg);
    border: var(--glass-border-light);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: rgba(212, 175, 55, 0.15);
    color: var(--gold-primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-info .stat-val {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-main);
}

.stat-info .stat-lbl {
    font-size: 0.82rem;
    color: var(--text-muted);
}

/* Table Styling */
.table-wrapper {
    overflow-x: auto;
    background: var(--glass-bg);
    border: var(--glass-border-light);
    border-radius: var(--radius-md);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.data-table th {
    background: rgba(0, 0, 0, 0.05);
    padding: 14px 16px;
    color: var(--text-gold);
    font-weight: 700;
    text-align: right;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] .data-table th {
    background: rgba(0, 0, 0, 0.35);
    border-bottom-color: rgba(255, 255, 255, 0.08);
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    color: var(--text-main);
}

[data-theme="dark"] .data-table td {
    border-bottom-color: rgba(255, 255, 255, 0.04);
}

.data-table tr:hover td {
    background: rgba(0, 0, 0, 0.02);
}

[data-theme="dark"] .data-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* Badges */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
}

.badge-active {
    background: rgba(16, 185, 129, 0.15);
    color: #059669;
}

[data-theme="dark"] .badge-active {
    color: #34d399;
}

.badge-sold {
    background: rgba(59, 130, 246, 0.15);
    color: #2563eb;
}

[data-theme="dark"] .badge-sold {
    color: #60a5fa;
}

.badge-revoked {
    background: rgba(239, 68, 68, 0.15);
    color: #dc2626;
}

[data-theme="dark"] .badge-revoked {
    color: #f87171;
}

.badge-warning {
    background: rgba(245, 158, 11, 0.15);
    color: #d97706;
}

[data-theme="dark"] .badge-warning {
    color: #fbbf24;
}

/* Form Controls */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    color: var(--text-main);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

[data-theme="dark"] .form-control {
    border-color: rgba(255, 255, 255, 0.12);
}

.form-control:focus {
    border-color: var(--gold-primary);
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--gold-gradient);
    color: #07090e;
}

.btn-primary:hover {
    box-shadow: var(--gold-glow);
}

.btn-secondary {
    background: rgba(0, 0, 0, 0.06);
    color: var(--text-main);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.1);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    color: #dc2626;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

[data-theme="dark"] .btn-danger {
    color: #f87171;
}

/* ========================================================
 * Light Theme – Targeted Component Overrides
 * (Ensure dark-amber gold is used everywhere on white)
 * ======================================================== */

/* Table header gold text */
[data-theme="light"] .data-table th {
    color: var(--gold-primary);
    background: rgba(160, 120, 0, 0.06);
    border-bottom-color: rgba(0, 0, 0, 0.08);
}

/* Table rows on light */
[data-theme="light"] .data-table td {
    border-bottom-color: rgba(0, 0, 0, 0.06);
}
[data-theme="light"] .data-table tr:hover td {
    background: rgba(160, 120, 0, 0.04);
}

/* Stat card icon on light */
[data-theme="light"] .stat-icon {
    background: rgba(160, 120, 0, 0.12);
    color: var(--gold-primary);
}

/* Brand emblem on light */
[data-theme="light"] .brand-emblem {
    background: rgba(160, 120, 0, 0.10);
    border-color: rgba(160, 120, 0, 0.30);
}
[data-theme="light"] .brand-emblem svg {
    fill: var(--gold-primary);
}

/* Guide icon on light */
[data-theme="light"] .guide-icon {
    background: rgba(160, 120, 0, 0.10);
    color: var(--gold-primary);
}

/* Spec item on light */
[data-theme="light"] .spec-item {
    background: rgba(0, 0, 0, 0.025);
    border-color: rgba(0, 0, 0, 0.07);
}
[data-theme="light"] .spec-val.highlight {
    color: var(--gold-primary);
}

/* Input text legibility on light */
[data-theme="light"] .code-input {
    border-color: rgba(160, 120, 0, 0.35);
}
[data-theme="light"] .code-input:focus {
    border-color: var(--gold-primary);
    box-shadow: 0 0 16px rgba(160, 120, 0, 0.20);
}
[data-theme="light"] .code-input::placeholder {
    color: rgba(107, 114, 128, 0.6);
}

/* Verify button stays visible on light */
[data-theme="light"] .btn-verify {
    color: #fff;
}

/* Badge adjustments on light */
[data-theme="light"] .badge-active {
    color: #065f46;
    background: rgba(16, 185, 129, 0.12);
}
[data-theme="light"] .badge-sold {
    color: #1e40af;
    background: rgba(59, 130, 246, 0.12);
}
[data-theme="light"] .badge-revoked {
    color: #991b1b;
    background: rgba(239, 68, 68, 0.12);
}
[data-theme="light"] .badge-warning {
    color: #92400e;
    background: rgba(245, 158, 11, 0.12);
}

/* Admin nav on light */
[data-theme="light"] .admin-nav-item:hover,
[data-theme="light"] .admin-nav-item.active {
    background: rgba(160, 120, 0, 0.10);
    color: var(--gold-primary);
    border-color: rgba(160, 120, 0, 0.25);
}

/* Admin sidebar border on light */
[data-theme="light"] .admin-sidebar {
    border-left-color: rgba(160, 120, 0, 0.15);
    background: rgba(255, 255, 255, 0.92);
}

/* Top brand small on light */
[data-theme="light"] .top-brand-small {
    color: var(--text-main);
}

/* History banners on light */
[data-theme="light"] .history-first {
    background: rgba(16, 185, 129, 0.10);
    color: #065f46;
}
[data-theme="light"] .history-repeated {
    background: rgba(217, 119, 6, 0.10);
    color: #92400e;
}



/* Public portal: tiny screens */
@media (max-width: 400px) {
    .app-container {
        padding: 10px;
        gap: 14px;
    }
    .glass-card {
        padding: 20px 14px;
        border-radius: var(--radius-md);
    }
    .brand-emblem {
        width: 56px;
        height: 56px;
    }
    .brand-emblem svg {
        width: 28px;
        height: 28px;
    }
    .brand-title {
        font-size: 1.15rem;
    }
    .code-input {
        height: 56px;
        font-size: 1.1rem;
        letter-spacing: 1.5px;
    }
    .btn-verify {
        height: 50px;
        font-size: 0.95rem;
    }
    .result-card {
        padding: 16px;
    }
    .spec-grid {
        grid-template-columns: 1fr;
    }
}

/* Public portal: small/medium phones */
@media (max-width: 600px) {
    .top-navbar {
        padding: 0 12px;
    }
    .app-container {
        padding: 12px;
    }
    .spec-grid {
        grid-template-columns: 1fr;
    }
    .code-input {
        font-size: 1.15rem;
        letter-spacing: 2px;
    }
    .guide-text {
        font-size: 0.78rem;
    }
    .result-header {
        gap: 10px;
    }
    .result-icon-badge {
        width: 38px;
        height: 38px;
    }
    .result-title {
        font-size: 1rem;
    }
}

/* Admin Panel: tablet and mobile */
@media (max-width: 900px) {
    .admin-layout {
        flex-direction: column;
    }

    .admin-sidebar {
        width: 100%;
        flex-direction: column;
        border-left: none;
        border-bottom: 1px solid rgba(212, 175, 55, 0.15);
        padding: 14px 12px;
    }

    /* Horizontal scrollable nav on mobile admin */
    .admin-sidebar nav {
        flex-direction: row !important;
        flex-wrap: wrap;
        gap: 6px !important;
    }

    .admin-nav-item {
        font-size: 0.82rem;
        padding: 8px 12px;
    }

    /* Codes generation grid: 3 col -> 1 col */
    .admin-main {
        padding: 16px;
    }

    .admin-header-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 640px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    /* Result spec grid: 1 column on phones */
    .spec-grid {
        grid-template-columns: 1fr;
    }

    /* Make tables horizontally scrollable */
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .data-table {
        min-width: 560px;
    }

    /* Form buttons full width on mobile */
    .btn {
        padding: 10px 14px;
    }

    /* Codes management 3-col grid -> 1 col */
    .codes-action-grid {
        grid-template-columns: 1fr !important;
    }
}

/* Touch devices: larger tap targets */
@media (hover: none) and (pointer: coarse) {
    .btn-verify {
        height: 58px;
        font-size: 1.05rem;
    }
    .btn {
        min-height: 42px;
    }
    .code-input {
        height: 62px;
    }
    .admin-nav-item {
        min-height: 44px;
    }
    .clear-btn {
        width: 36px;
        height: 36px;
    }
    .tab-btn {
        min-height: 44px;
        padding: 10px 14px;
    }
}