/* ============================================
   Expiry Admin — iPlusView
   Design System: Editorial / Dashboard
   Font: IBM Plex Sans Thai + JetBrains Mono
   ============================================ */

/* --- CSS Variables --- */
:root {
    --font-main: 'IBM Plex Sans Thai', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    --bg: #0f1117;
    --bg-card: #181a23;
    --bg-card-hover: #1e2130;
    --bg-surface: #212430;
    --bg-input: #181a23;
    --border: #2a2d3a;
    --border-focus: #6c5ce7;

    --text-primary: #eaedf3;
    --text-secondary: #8b90a0;
    --text-muted: #565b6e;
    --text-inverse: #0f1117;

    --accent: #6c5ce7;
    --accent-hover: #7d6ff0;
    --accent-subtle: rgba(108, 92, 231, 0.12);
    --accent-glow: rgba(108, 92, 231, 0.25);

    --red: #ff4757;
    --red-subtle: rgba(255, 71, 87, 0.12);
    --red-text: #ff6b7a;

    --amber: #ffa502;
    --amber-subtle: rgba(255, 165, 2, 0.12);
    --amber-text: #ffbe45;

    --green: #2ed573;
    --green-subtle: rgba(46, 213, 115, 0.12);
    --green-text: #5fdf96;

    --blue: #1e90ff;
    --blue-subtle: rgba(30, 144, 255, 0.12);

    --sidebar-w: 260px;
    --topbar-h: 72px;
    --radius: 10px;
    --radius-sm: 6px;
    --radius-lg: 14px;
    --shadow: 0 2px 12px rgba(0,0,0,0.25);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.4);
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Light Theme --- */
[data-theme="light"] {
    --bg: #f5f7fa;
    --bg-card: #ffffff;
    --bg-card-hover: #f8fafc;
    --bg-surface: #f1f5f9;
    --bg-input: #f8fafc;
    --border: #e2e8f0;
    --border-focus: #6c5ce7;

    --text-primary: #1a202c;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --text-inverse: #ffffff;

    --accent: #6c5ce7;
    --accent-hover: #5b4cdb;
    --accent-subtle: rgba(108, 92, 231, 0.08);
    --accent-glow: rgba(108, 92, 231, 0.15);

    --red: #ef4444;
    --red-subtle: rgba(239, 68, 68, 0.08);
    --red-text: #dc2626;

    --amber: #f59e0b;
    --amber-subtle: rgba(245, 158, 11, 0.08);
    --amber-text: #d97706;

    --green: #22c55e;
    --green-subtle: rgba(34, 197, 94, 0.08);
    --green-text: #16a34a;

    --blue: #2563eb;
    --blue-subtle: rgba(37, 99, 235, 0.08);

    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.1);
}

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

html {
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-main);
    background: var(--bg);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
    position: fixed;
    left: 0; top: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px 20px;
    border-bottom: 1px solid var(--border);
}

.brand-icon {
    width: 42px;
    height: 42px;
    background: var(--accent);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.brand-text {
    display: flex;
    flex-direction: column;
}

.brand-name {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.brand-sub {
    font-size: 0.73rem;
    color: var(--text-muted);
    font-weight: 500;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

/* Sidebar Nav */
.sidebar-nav {
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.93rem;
    transition: all var(--transition);
}

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

.nav-item.active {
    background: var(--accent-subtle);
    color: var(--accent);
}

.nav-item.active svg {
    stroke: var(--accent);
}

/* Nav Divider */
.nav-divider {
    height: 1px;
    background: var(--border);
    margin: 8px 14px;
}

/* External Link */
.nav-external {
    position: relative;
}

.nav-external .external-icon {
    margin-left: auto;
    opacity: 0;
    transition: opacity var(--transition);
}

.nav-external:hover .external-icon {
    opacity: 0.5;
}

/* Sidebar Stats */
.sidebar-stats {
    padding: 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: auto;
    border-top: 1px solid var(--border);
}

.stat-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 500;
}

.stat-num {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 1.1rem;
}

.stat-label {
    color: var(--text-secondary);
}

.stat-expired { background: var(--red-subtle); }
.stat-expired .stat-num { color: var(--red-text); }

.stat-warning { background: var(--amber-subtle); }
.stat-warning .stat-num { color: var(--amber-text); }

.stat-active { background: var(--green-subtle); }
.stat-active .stat-num { color: var(--green-text); }

/* Sidebar Footer */
.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border);
}

.btn-notify {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: var(--font-main);
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
}

.btn-notify:hover {
    background: var(--accent-subtle);
    border-color: var(--accent);
    color: var(--accent);
}

.notify-badge {
    margin-left: auto;
    background: var(--red);
    color: white;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 10px;
    min-width: 22px;
    text-align: center;
}

.notify-badge:empty,
.notify-badge[data-count="0"] {
    display: none;
}

/* ============================================
   MOBILE HEADER
   ============================================ */
.mobile-header {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 56px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 90;
}

.btn-hamburger,
.btn-add-mobile {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
}

.btn-hamburger:hover,
.btn-add-mobile:hover {
    background: var(--bg-surface);
}

.mobile-title {
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: -0.02em;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 99;
    backdrop-filter: blur(4px);
}

/* ============================================
   MAIN CONTENT
   ============================================ */
.main-content {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    padding: 0 32px 40px;
}

/* Topbar */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 28px 0 24px;
    position: sticky;
    top: 0;
    background: var(--bg);
    z-index: 50;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-divider {
    width: 1px;
    height: 28px;
    background: var(--border);
}

.page-title {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.03em;
}

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

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 18px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-main);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

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

.btn-accent:hover {
    background: var(--accent-hover);
    box-shadow: 0 0 20px var(--accent-glow);
}

.btn-success {
    background: #22c55e;
    color: white;
}

.btn-success:hover {
    background: #16a34a;
    box-shadow: 0 0 20px rgba(34, 197, 94, .3);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    background: var(--bg-surface);
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.btn-danger {
    background: var(--red-subtle);
    color: var(--red-text);
    border: 1px solid transparent;
}

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

/* View Panels */
.view-panel {
    display: none;
    animation: fadeUp 0.3s ease;
}

.view-panel.active {
    display: block;
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   LIGHT THEME OVERRIDES
   ============================================ */
[data-theme="light"] .sidebar {
    box-shadow: 2px 0 8px rgba(0,0,0,0.04);
}

[data-theme="light"] .topbar {
    background: var(--bg);
}

/* Theme Toggle Button */
.btn-theme {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: var(--font-main);
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-theme:hover {
    background: var(--accent-subtle);
    border-color: var(--accent);
    color: var(--accent);
}

