/* ============================================================
   LSHIDMTAMSFO — Design System
   Dark mode only. Red accent #C62828. Lucide icons.
   Forked from Kona design system.
   ============================================================ */

/* --- Tokens (dark only) --- */
:root {
    color-scheme: dark;

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    --bg: #0f0f0f;
    --bg-primary: #0f0f0f;
    --bg-secondary: #161616;
    --bg-tertiary: #1e1e1e;
    --bg-hover: #252525;

    --surface: #1a1a1a;
    --surface-hover: #222222;
    --surface-active: #2a2a2a;
    --border: #2e2e2e;
    --border-primary: #2e2e2e;
    --border-light: #252525;

    --text: #e1e1e1;
    --text-primary: #e1e1e1;
    --text-secondary: #9a9a9a;
    --text-muted: #6b6b6b;
    --text-inverse: #0f0f0f;

    --accent: #C62828;
    --accent-hover: #B71C1C;
    --accent-light: #2a1010;
    --accent-border: #5e2020;
    --accent-text: #ef9a9a;

    --primary: #C62828;
    --primary-hover: #B71C1C;
    --primary-light: #2a1010;
    --primary-border: #5e2020;
    --primary-text: #ef9a9a;

    --success: #34c89a;
    --success-light: #132e24;
    --success-border: #1e5e42;
    --warning: #e5a32e;
    --warning-light: #2e2410;
    --warning-border: #5e4a1e;
    --danger: #e85050;
    --danger-light: #2e1414;
    --danger-border: #5e2020;
    --info: #38b5d0;
    --info-light: #102e34;
    --info-border: #1e5060;
    --muted: #6b6b6b;
    --muted-light: #1e1e1e;

    --sidebar-bg: #0a0a0a;
    --sidebar-text: #6b6b6b;
    --sidebar-text-hover: #9a9a9a;
    --sidebar-text-active: #e1e1e1;
    --sidebar-hover: #141414;
    --sidebar-active-bg: rgba(198, 40, 40, 0.14);
    --sidebar-active-border: #C62828;
    --sidebar-section: #6b6b6b;

    --radius: 8px;
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --radius-xl: 12px;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 1px 3px rgba(0,0,0,0.4);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.35);

    --sidebar-width: 240px;
    --topbar-height: 56px;
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Typography --- */
h1 { font-size: 1.714rem; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; }
h2 { font-size: 1.286rem; font-weight: 600; letter-spacing: -0.01em; line-height: 1.3; }
h3 { font-size: 1.071rem; font-weight: 600; line-height: 1.4; }
h4 { font-size: 1rem; font-weight: 600; }
.text-sm { font-size: 0.857rem; }
.text-xs { font-size: 0.786rem; }
.text-mono { font-family: var(--font-mono); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }

/* --- Layout --- */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    transition: transform 0.2s var(--ease);
}

.sidebar-header {
    height: var(--topbar-height);
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-brand-text {
    font-size: 15px;
    font-weight: 700;
    color: var(--sidebar-text-active);
    letter-spacing: -0.02em;
}

.sidebar-brand-icon {
    flex-shrink: 0;
}

.sidebar-brand-gif {
    height: 40px;
    max-width: 160px;
    border-radius: 4px;
    object-fit: contain;
    cursor: pointer;
}

.meme-lightbox {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0,0,0,0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.meme-lightbox img {
    max-width: 80vw;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 8px;
}

.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }

.sidebar-divider {
    height: 1px;
    background: rgba(255,255,255,0.06);
    margin: 8px 16px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 16px;
    margin: 2px 10px;
    border-radius: var(--radius-md);
    color: var(--sidebar-text);
    font-size: 0.929rem;
    font-weight: 400;
    cursor: pointer;
    transition: all 0.15s var(--ease);
    text-decoration: none;
    border-left: 2px solid transparent;
}

.nav-item:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text-hover);
    text-decoration: none;
}

.nav-item.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-text-active);
    border-left-color: var(--sidebar-active-border);
    font-weight: 500;
}

.nav-item.disabled {
    opacity: 0.4;
    pointer-events: none;
}

.nav-item .lucide, .nav-item i { width: 18px; height: 18px; opacity: 0.65; flex-shrink: 0; }
.nav-item:hover .lucide, .nav-item:hover i { opacity: 0.85; }
.nav-item.active .lucide, .nav-item.active i { opacity: 1; }

/* --- Topbar --- */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

.topbar {
    height: var(--topbar-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.sidebar-menu-toggle { display: none; }
.sidebar-backdrop { display: none; }

.page-title { font-size: 1.071rem; font-weight: 600; }

.content-area {
    padding: 24px;
    max-width: 1400px;
}

/* --- Notification Bell --- */
.notif-bell {
    position: relative;
    color: var(--text-secondary);
    cursor: pointer;
}
.notif-bell:hover { color: var(--text); }
.notif-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--accent);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* Notification panel items */
.notif-list { max-height: 400px; overflow-y: auto; }
.notif-empty { padding: 24px; text-align: center; color: var(--text-muted); }
.notif-item {
    padding: 12px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.notif-item:last-child { border-bottom: none; }
.notif-item.notif-unread { border-left: 3px solid var(--accent); padding-left: 12px; }
.notif-header { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.notif-title { font-weight: 500; font-size: 14px; }
.notif-time { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.notif-body { font-size: 13px; color: var(--text-secondary); margin: 4px 0 8px; }
.notif-actions { display: flex; gap: 6px; }
.notif-actions .btn { padding: 2px 8px; font-size: 12px; }

/* --- Topbar user menu --- */
.topbar-user-menu { position: relative; }
.topbar-user-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-md);
    transition: background 0.15s;
}
.topbar-user-btn:hover { background: var(--surface-hover); }
.topbar-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.857rem;
    font-weight: 600;
    flex-shrink: 0;
}
.topbar-user-chevron {
    width: 14px;
    height: 14px;
    color: var(--text-secondary);
    transition: transform 0.2s;
}
.topbar-user-menu.open .topbar-user-chevron { transform: rotate(180deg); }
.topbar-user-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 200px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    padding: 4px 0;
}
.topbar-user-menu.open .topbar-user-dropdown { display: block; }
.topbar-user-header { padding: 10px 14px 6px; }
.topbar-user-name {
    font-size: 0.857rem;
    font-weight: 600;
    color: var(--text-primary);
}
.topbar-user-role {
    font-size: 0.714rem;
    color: var(--text-secondary);
    text-transform: capitalize;
}
.topbar-user-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}
.topbar-user-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    font-size: 0.857rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}
.topbar-user-item:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
    text-decoration: none;
}
.topbar-user-item svg, .topbar-user-item i {
    width: 16px;
    height: 16px;
}

/* --- Cards --- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    font-size: 0.929rem;
    font-weight: 600;
}

.card-body { padding: 20px; }
.card-body.compact { padding: 12px 20px; }

/* --- Dashboard Grid --- */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.dashboard-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    text-decoration: none;
    color: var(--text);
    transition: all 0.15s var(--ease);
}

.dashboard-card:hover {
    border-color: var(--primary);
    background: var(--surface-hover);
    text-decoration: none;
}

.dashboard-card-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-lg);
    background: var(--accent-light);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.dashboard-card-icon i, .dashboard-card-icon svg { width: 24px; height: 24px; }

.dashboard-card-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 2px;
}

.dashboard-card-desc {
    font-size: 0.857rem;
    color: var(--text-secondary);
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    font-family: var(--font-sans);
    font-size: 0.857rem;
    font-weight: 500;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text);
    cursor: pointer;
    transition: all 0.15s var(--ease);
    white-space: nowrap;
    line-height: 1.4;
}
.btn:hover {
    border-color: var(--text-secondary);
    background: var(--surface-hover);
    text-decoration: none;
}
.btn .lucide, .btn i { width: 15px; height: 15px; }
.btn-primary {
    border-color: var(--primary);
    color: var(--primary);
}
.btn-primary:hover {
    background: var(--primary);
    color: white;
}
.btn-success { border-color: var(--success); color: var(--success); }
.btn-success:hover { background: var(--success); color: var(--text-inverse); }
.btn-warning { border-color: var(--warning); color: var(--warning); }
.btn-warning:hover { background: var(--warning); color: var(--text-inverse); }
.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: var(--text-inverse); }
.btn-sm { padding: 4px 10px; font-size: 0.786rem; }
.btn-lg { padding: 10px 20px; font-size: 1rem; }
.btn-icon {
    padding: 6px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    cursor: pointer;
}
.btn-icon:hover { background: var(--surface-hover); color: var(--text); }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled, .btn[disabled] { opacity: 0.45; cursor: not-allowed; pointer-events: none; }
.btn-ghost { border-color: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--surface-hover); color: var(--text); }

/* --- Forms --- */
.form-group { margin-bottom: 16px; }
.form-label {
    display: block;
    font-size: 0.857rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 4px;
}
.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 8px 12px;
    font-family: var(--font-sans);
    font-size: 0.929rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text);
    transition: border-color 0.15s;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(198, 40, 40, 0.15);
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-help { font-size: 0.786rem; color: var(--text-muted); margin-top: 2px; }
.form-error { font-size: 0.786rem; color: var(--danger); margin-top: 2px; }
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

/* --- Tables --- */
.table-container { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
    padding: 8px 12px;
    font-size: 0.786rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    text-align: left;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}
tbody td {
    padding: 10px 12px;
    font-size: 0.929rem;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}
tbody tr:hover { background: var(--surface-hover); }
tbody tr:last-child td { border-bottom: none; }

/* --- Badges --- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    font-size: 0.786rem;
    font-weight: 500;
    border-radius: 10px;
    white-space: nowrap;
}
.badge-primary { background: var(--primary-light); color: var(--primary-text); }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-info { background: var(--info-light); color: var(--info); }
.badge-muted { background: var(--muted-light); color: var(--muted); }

/* --- Stat Cards --- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
}
.stat-label {
    font-size: 0.786rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 4px;
}
.stat-value {
    font-size: 1.714rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.1;
}
.stat-detail {
    font-size: 0.786rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* --- Modal --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s var(--ease);
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal {
    background: var(--surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 560px;
    max-height: 85vh;
    overflow-y: auto;
    transform: translateY(8px) scale(0.98);
    transition: transform 0.2s var(--ease);
}
.modal-overlay.open .modal { transform: translateY(0) scale(1); }
.modal-header {
    padding: 20px 24px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.modal-title { font-size: 1.071rem; font-weight: 600; }
.modal-close {
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    border: none; background: transparent;
    color: var(--text-muted); border-radius: var(--radius-md); cursor: pointer;
}
.modal-close:hover { background: var(--surface-hover); color: var(--text); }
.modal-body { padding: 16px 24px; }
.modal-footer {
    padding: 16px 24px 20px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* --- Toast Notifications --- */
.toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}
.toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    min-width: min(320px, calc(100vw - 32px));
    max-width: min(420px, calc(100vw - 32px));
    pointer-events: auto;
    animation: toast-in 0.25s var(--ease);
    cursor: pointer;
}
.toast.removing { animation: toast-out 0.2s var(--ease) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(20px); } }
.toast-icon { flex-shrink: 0; margin-top: 1px; }
.toast-icon .lucide, .toast-icon i { width: 18px; height: 18px; }
.toast-success .toast-icon { color: var(--success); }
.toast-danger .toast-icon { color: var(--danger); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-info .toast-icon { color: var(--info); }
.toast-content { flex: 1; }
.toast-title { font-size: 0.857rem; font-weight: 600; }
.toast-message { font-size: 0.786rem; color: var(--text-secondary); margin-top: 2px; }

/* --- Alert --- */
.alert {
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: 0.857rem;
}
.alert-info { background: var(--info-light); color: var(--info); border: 1px solid var(--info-border); }
.alert-success { background: var(--success-light); color: var(--success); border: 1px solid var(--success-border); }
.alert-warning { background: var(--warning-light); color: var(--warning); border: 1px solid var(--warning-border); }
.alert-danger { background: var(--danger-light); color: var(--danger); border: 1px solid var(--danger-border); }

/* --- Progress Bar --- */
.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s var(--ease);
}
.progress-fill.green { background: var(--success); }
.progress-fill.yellow { background: var(--warning); }
.progress-fill.red { background: var(--danger); }
.progress-fill.blue { background: var(--info); }
.progress-fill.accent { background: var(--accent); }

/* --- Utility --- */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-full { width: 100%; }
.responsive-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

/* --- Mobile Responsive --- */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-backdrop.open { display: block; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 99; }
    .sidebar-menu-toggle { display: flex !important; }
    .main-content { margin-left: 0; }
    .content-area { padding: 16px; }
    .topbar { padding: 0 16px; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .responsive-grid-2 { grid-template-columns: 1fr; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .modal { max-width: calc(100vw - 32px); }
}

@media (max-width: 480px) {
    .content-area { padding: 12px; }
    .stat-grid { grid-template-columns: 1fr; gap: 12px; }
    .page-title { font-size: 1rem; }
    .topbar-right { gap: 4px; }
}
