/* ==============================================================================
   HERTZYN ADMIN — DESIGN SYSTEM
   ============================================================================== */

/* --- Tokens --- */
:root {
    --bg-base: #0b1120;
    --bg-surface: rgba(22, 33, 62, 0.75);
    --bg-surface-hover: rgba(30, 41, 72, 0.9);
    --bg-sidebar: rgba(12, 18, 36, 0.95);
    --text-primary: #f0f4f8;
    --text-secondary: #8294b4;
    --accent-primary: #3b82f6;
    --accent-hover: #2563eb;
    --accent-gradient: linear-gradient(135deg, #3b82f6, #8b5cf6);
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
    --info: #6366f1;
    --border-color: rgba(255, 255, 255, 0.08);
    --glass-blur: blur(16px);
    --sidebar-width: 260px;
    --topbar-height: 0px; /* desktop: no topbar */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    background-image:
        radial-gradient(ellipse at 10% 40%, rgba(59, 130, 246, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 90% 20%, rgba(139, 92, 246, 0.08) 0%, transparent 50%);
    background-attachment: fixed;
}

/* ==============================================================================
   LAYOUT — Sidebar + Main
   ============================================================================== */

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

/* --- Sidebar --- */
.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    backdrop-filter: var(--glass-blur);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform var(--transition);
}

.sidebar-brand {
    padding: 1.5rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
}
.sidebar-brand h1 {
    font-size: 1.35rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0;
}
.sidebar-brand small {
    display: block;
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 0.15rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0.75rem;
    overflow-y: auto;
}
.sidebar-nav-label {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 0.75rem 0.75rem 0.4rem;
}
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.75rem;
    margin-bottom: 0.2rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all var(--transition);
}
.sidebar-nav a:hover {
    background: rgba(255,255,255,0.05);
    color: var(--text-primary);
}
.sidebar-nav a.active {
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent-primary);
}
.sidebar-nav a .nav-icon {
    font-size: 1.1rem;
    width: 1.5rem;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.sidebar-footer a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.8rem;
}
.sidebar-footer a:hover { color: var(--danger); }

/* --- Main Content Area --- */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    padding: 2rem;
    width: calc(100% - var(--sidebar-width));
}
.main-content-inner {
    max-width: 1200px;
    margin: 0 auto;
}

/* --- Mobile Topbar (hidden on desktop) --- */
.mobile-topbar {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 56px;
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border-color);
    backdrop-filter: var(--glass-blur);
    z-index: 99;
    padding: 0 1rem;
    align-items: center;
    justify-content: space-between;
}
.mobile-topbar h1 {
    font-size: 1.1rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0;
}

/* Hamburger Button */
.hamburger-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.hamburger-btn span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: all var(--transition);
}

/* Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 99;
}

/* ==============================================================================
   RESPONSIVE — Mobile
   ============================================================================== */
@media (max-width: 768px) {
    :root {
        --topbar-height: 56px;
    }
    .mobile-topbar {
        display: flex;
    }
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-overlay.open {
        display: block;
    }
    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 1rem;
        padding-top: calc(var(--topbar-height) + 1rem);
    }
}

/* ==============================================================================
   COMPONENTS
   ============================================================================== */

/* --- Page Header --- */
.page-header {
    margin-bottom: 1.5rem;
}
.page-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}
.page-header p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* --- Glass Panel --- */
.glass-panel {
    background: var(--bg-surface);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
}

/* --- Stat Cards --- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}
.stat-card {
    padding: 1.25rem;
}
.stat-card .stat-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}
.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 0.25rem;
}
.stat-card .stat-sub {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* --- Text Gradient --- */
.text-gradient {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
}
.btn-primary {
    background: var(--accent-gradient);
    color: white;
    box-shadow: 0 4px 14px rgba(59, 130, 246, 0.3);
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.45);
}
.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}
.btn-ghost {
    background: rgba(255,255,255,0.06);
    color: var(--text-secondary);
}
.btn-ghost:hover {
    background: rgba(255,255,255,0.1);
    color: var(--text-primary);
}
.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
}
.btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
}
.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
}

/* --- Forms --- */
.form-group { margin-bottom: 1rem; }
.form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    margin-bottom: 0.3rem;
    color: var(--text-secondary);
}
.form-control {
    width: 100%;
    padding: 0.55rem 0.75rem;
    font-size: 0.875rem;
    color: var(--text-primary);
    background: rgba(10, 15, 30, 0.6);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus {
    outline: 0;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

/* --- Tables --- */
.table-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
.table th, .table td {
    padding: 0.85rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}
.table th {
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    white-space: nowrap;
}
.table tbody tr { transition: background var(--transition); }
.table tbody tr:hover { background: rgba(255,255,255,0.02); }

/* --- Badge --- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2em 0.65em;
    font-size: 0.75em;
    font-weight: 600;
    border-radius: 9999px;
    white-space: nowrap;
}
.badge-blue    { background: rgba(59,130,246,0.15); color: #60a5fa; }
.badge-green   { background: rgba(16,185,129,0.15); color: #34d399; }
.badge-yellow  { background: rgba(245,158,11,0.15); color: #fbbf24; }
.badge-red     { background: rgba(239,68,68,0.15);  color: #f87171; }
.badge-purple  { background: rgba(99,102,241,0.15); color: #818cf8; }
.badge-gray    { background: rgba(148,163,184,0.15); color: #94a3b8; }

/* --- Alerts --- */
.alert {
    padding: 0.85rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}
.alert-danger  { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.25); color: #fca5a5; }
.alert-success { background: rgba(16,185,129,0.1); border: 1px solid rgba(16,185,129,0.25); color: #34d399; }
.alert-info    { background: rgba(99,102,241,0.1); border: 1px solid rgba(99,102,241,0.25); color: #818cf8; }

/* --- Spinner --- */
.spinner {
    display: none;
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Content Preview --- */
.content-preview {
    max-height: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* --- Auth (Login page — full screen, no sidebar) --- */
.auth-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
    background-color: var(--bg-base);
    background-image:
        radial-gradient(ellipse at 10% 40%, rgba(59, 130, 246, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 90% 20%, rgba(139, 92, 246, 0.08) 0%, transparent 50%);
}
.auth-card {
    width: 100%;
    max-width: 400px;
    padding: 2.5rem;
}

/* --- Two-column layout --- */
.content-grid {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 1.5rem;
}
@media (max-width: 900px) {
    .content-grid { grid-template-columns: 1fr; }
}

/* --- Insight Grid (detail page) --- */
.insight-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}
@media (max-width: 600px) {
    .insight-grid { grid-template-columns: 1fr; }
}

/* --- Highlight Box --- */
.highlight-box {
    background: rgba(255,255,255,0.02);
    border-left: 3px solid var(--accent-primary);
    padding: 1rem 1.25rem;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    margin-bottom: 1.5rem;
}

/* --- Tag list --- */
.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

/* --- Section label --- */
.section-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.4rem;
}

/* --- Empty state --- */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}
.empty-state .empty-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    opacity: 0.5;
}

/* --- Article Modal --- */
.article-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    animation: fadeIn 0.2s ease;
}
.article-modal-overlay.open {
    display: flex;
}
.article-modal {
    background: var(--bg-base);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 800px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.25s ease;
}
.article-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    gap: 1rem;
}
.article-modal-header h3 {
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.4;
    flex: 1;
}
.article-modal-header .close-btn {
    background: rgba(255,255,255,0.06);
    border: none;
    color: var(--text-secondary);
    font-size: 1.25rem;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all var(--transition);
}
.article-modal-header .close-btn:hover {
    background: rgba(255,255,255,0.1);
    color: var(--text-primary);
}
.article-modal-meta {
    display: flex;
    gap: 1rem;
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.75rem;
    color: var(--text-secondary);
}
.article-modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    font-size: 0.9rem;
    line-height: 1.8;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-break: break-word;
}

/* --- Article Preview Block --- */
.article-preview-block {
    position: relative;
    max-height: 120px;
    overflow: hidden;
    font-size: 0.85rem;
    line-height: 1.7;
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-break: break-word;
}
.article-preview-block::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: linear-gradient(transparent, var(--bg-surface));
    pointer-events: none;
}

/* --- Toolbar --- */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
}
.toolbar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* --- CSV Upload Button --- */
.csv-upload-label {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0.65rem;
    font-size: 0.8rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    background: rgba(16, 185, 129, 0.12);
    color: #34d399;
    cursor: pointer;
    transition: all var(--transition);
    border: 1px solid rgba(16, 185, 129, 0.2);
}
.csv-upload-label:hover {
    background: rgba(16, 185, 129, 0.2);
    border-color: rgba(16, 185, 129, 0.35);
}
.csv-upload-label input[type="file"] {
    display: none;
}

/* --- Sortable Table Headers --- */
.sort-header {
    cursor: pointer;
    user-select: none;
    position: relative;
    transition: color var(--transition);
}
.sort-header:hover {
    color: var(--accent-primary);
}
.sort-header .sort-icon {
    display: inline-block;
    margin-left: 0.3rem;
    font-size: 0.6rem;
    opacity: 0.4;
    transition: opacity var(--transition);
}
.sort-header.active .sort-icon {
    opacity: 1;
    color: var(--accent-primary);
}

/* --- Animations --- */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes slideUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Select option lists ---
   The open dropdown is drawn by the OS; without explicit colours Windows paints
   it light-on-light against our dark .form-control. */
select.form-control { color-scheme: dark; }
select.form-control option {
    background: var(--bg-base);
    color: var(--text-primary);
}

/* --- In-page confirm/alert (static/js/dialogs.js) --- */
.hz-dialog-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    animation: fadeIn 0.15s ease;
}
.hz-dialog {
    background: var(--bg-base);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    width: 100%;
    max-width: 460px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.2s ease;
}
.hz-dialog-body {
    padding: 1.25rem 1.25rem 1rem;
    font-size: 0.9rem;
    color: var(--text-primary);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    overflow-y: auto;
}
.hz-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem 1rem;
    border-top: 1px solid var(--border-color);
}
