/* ====== DARK THEME (default) ====== */
[data-theme="dark"] {
    --bg: #0c1b2e;
    --surface: #0f2137;
    --surface-hover: #162d4a;
    --surface-border: rgba(255,255,255,0.06);
    --accent: #2d7ff9;
    --accent-hover: #1a6de0;
    --accent-glow: rgba(45,127,249,0.15);
    --text: #e8edf4;
    --text-muted: #7a8ba3;
    --text-dim: #4a5d73;
    --white: #ffffff;
    --error: #ff4757;
    --error-bg: rgba(255,71,87,0.08);
    --success: #2ed573;
    --success-bg: rgba(46,213,115,0.08);
    --warning: #ffa502;
    --warning-bg: rgba(255,165,2,0.08);
    --code-bg: rgba(45,127,249,0.1);
    --code-color: var(--accent);
    --shadow: rgba(0,0,0,0.3);
    --modal-overlay: rgba(0,0,0,0.6);
}

/* ====== LIGHT THEME ====== */
[data-theme="light"] {
    --bg: #f0f2f5;
    --surface: #ffffff;
    --surface-hover: #f7f8fa;
    --surface-border: rgba(0,0,0,0.08);
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-glow: rgba(37,99,235,0.12);
    --text: #1a1a2e;
    --text-muted: #64748b;
    --text-dim: #94a3b8;
    --white: #ffffff;
    --error: #dc2626;
    --error-bg: rgba(220,38,38,0.06);
    --success: #16a34a;
    --success-bg: rgba(22,163,74,0.06);
    --warning: #d97706;
    --warning-bg: rgba(217,119,6,0.06);
    --code-bg: rgba(37,99,235,0.06);
    --code-color: var(--accent);
    --shadow: rgba(0,0,0,0.08);
    --modal-overlay: rgba(0,0,0,0.4);
}

/* ====== BASE ====== */
:root { --radius: 14px; --radius-sm: 10px; --radius-xs: 6px; }
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Plus Jakarta Sans', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; transition: background 0.3s, color 0.3s; }

/* ====== SIDEBAR ====== */
.sidebar {
    position: fixed; left: 0; top: 0; width: 260px; height: 100vh;
    background: var(--surface); border-right: 1px solid var(--surface-border);
    display: flex; flex-direction: column; padding: 1.5rem 0; z-index: 100;
    transition: background 0.3s;
}
.sidebar-logo { display: flex; align-items: center; gap: 12px; padding: 0 1.5rem; margin-bottom: 2rem; }
.sidebar-logo-icon {
    width: 40px; height: 40px; background: linear-gradient(135deg, var(--accent), #1a5fd0);
    border-radius: 12px; display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 0.9rem; color: white;
}
.sidebar-logo-text { font-weight: 700; font-size: 1rem; color: var(--text); }
.sidebar-logo-text span { color: var(--text-muted); font-weight: 400; font-size: 0.75rem; display: block; }
.sidebar-nav { flex: 1; padding: 0 0.75rem; overflow-y: auto; }
.nav-section { margin-bottom: 1.5rem; }
.nav-section-title { font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-dim); padding: 0 0.75rem; margin-bottom: 0.5rem; }
.nav-item {
    display: flex; align-items: center; gap: 12px; padding: 10px 12px;
    border-radius: 8px; color: var(--text-muted); text-decoration: none;
    font-size: 0.875rem; font-weight: 500; transition: all 0.2s ease;
}
.nav-item:hover { background: var(--surface-hover); color: var(--text); }
.nav-item.active { background: var(--accent-glow); color: var(--accent); }
.nav-item svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sidebar-footer {
    padding: 1rem 1rem 1rem 1.5rem; border-top: 1px solid var(--surface-border);
    display: flex; align-items: center; gap: 8px;
}
.user-avatar {
    width: 34px; height: 34px; border-radius: 10px; background: var(--accent-glow);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.75rem; color: var(--accent); flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 0.78rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 0.68rem; color: var(--text-dim); }
.btn-logout, .btn-theme {
    background: none; border: none; cursor: pointer; padding: 6px; display: flex;
    align-items: center; border-radius: 6px; transition: all 0.2s; flex-shrink: 0;
}
.btn-logout:hover { background: var(--error-bg); }
.btn-logout svg { width: 18px; height: 18px; stroke: var(--text-dim); fill: none; stroke-width: 2; }
.btn-logout:hover svg { stroke: var(--error); }
.btn-theme:hover { background: var(--accent-glow); }
.btn-theme svg { width: 18px; height: 18px; stroke: var(--text-muted); fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn-theme:hover svg { stroke: var(--accent); }

/* ====== MAIN CONTENT ====== */
.main { margin-left: 260px; padding: 2rem; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 2rem; flex-wrap: wrap; gap: 1rem; }
.page-header-left h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.25rem; }
.page-header-left p { color: var(--text-muted); font-size: 0.9rem; }

/* ====== BUTTONS ====== */
.btn {
    display: inline-flex; align-items: center; gap: 8px; padding: 10px 20px;
    border: none; border-radius: var(--radius-sm); font-family: inherit;
    font-size: 0.875rem; font-weight: 600; cursor: pointer; transition: all 0.2s ease; white-space: nowrap;
}
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 4px 20px var(--accent-glow); }
.btn-secondary { background: var(--surface-border); color: var(--text-muted); }
.btn-secondary:hover { background: var(--surface-hover); color: var(--text); }
.btn-danger { background: var(--error-bg); color: var(--error); border: 1px solid rgba(255,71,87,0.15); }
.btn-danger:hover { background: rgba(255,71,87,0.12); }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; }

/* ====== STATS ====== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.stat-card {
    background: var(--surface); border: 1px solid var(--surface-border);
    border-radius: var(--radius); padding: 1.5rem; transition: all 0.3s ease;
}
.stat-card:hover { border-color: var(--accent-glow); transform: translateY(-2px); box-shadow: 0 8px 24px var(--shadow); }
.stat-label { font-size: 0.8rem; color: var(--text-muted); font-weight: 500; margin-bottom: 0.75rem; }
.stat-value { font-size: 2rem; font-weight: 800; letter-spacing: -1px; }
.stat-value.accent { color: var(--accent); }
.stat-value.success { color: var(--success); }

/* ====== TABLE ====== */
.table-container {
    background: var(--surface); border: 1px solid var(--surface-border);
    border-radius: var(--radius); overflow: hidden; transition: background 0.3s;
}
.table-toolbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1rem 1.25rem; border-bottom: 1px solid var(--surface-border); flex-wrap: wrap; gap: 0.75rem;
}
.search-input {
    background: var(--bg); border: 1px solid var(--surface-border);
    border-radius: var(--radius-xs); padding: 8px 12px 8px 36px;
    color: var(--text); font-family: inherit; font-size: 0.85rem;
    outline: none; width: 280px; transition: all 0.2s;
}
.search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-glow); }
.search-input::placeholder { color: var(--text-dim); }
.search-wrapper { position: relative; }
.search-wrapper svg {
    position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
    width: 16px; height: 16px; stroke: var(--text-dim); fill: none; stroke-width: 2; pointer-events: none;
}
table { width: 100%; border-collapse: collapse; }
thead th {
    text-align: left; padding: 12px 16px; font-size: 0.75rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-dim);
    border-bottom: 1px solid var(--surface-border); white-space: nowrap;
}
tbody td { padding: 12px 16px; font-size: 0.875rem; border-bottom: 1px solid var(--surface-border); }
tbody tr { transition: background 0.15s; }
tbody tr:hover { background: var(--surface-hover); }
.badge {
    display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px;
    border-radius: 100px; font-size: 0.75rem; font-weight: 600;
}
.badge-active { background: var(--success-bg); color: var(--success); }
.badge-inactive { background: var(--error-bg); color: var(--error); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-info { background: var(--accent-glow); color: var(--accent); }
.badge::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.actions { display: flex; gap: 4px; }
.actions button {
    background: none; border: none; cursor: pointer; padding: 6px; border-radius: 6px; transition: all 0.2s;
}
.actions button svg { width: 16px; height: 16px; stroke: var(--text-dim); fill: none; stroke-width: 2; }
.actions .btn-edit:hover { background: var(--accent-glow); }
.actions .btn-edit:hover svg { stroke: var(--accent); }
.actions .btn-delete:hover { background: var(--error-bg); }
.actions .btn-delete:hover svg { stroke: var(--error); }
.empty-state { text-align: center; padding: 3rem; color: var(--text-dim); font-size: 0.9rem; }

/* ====== MODAL ====== */
.modal-overlay {
    display: none; position: fixed; inset: 0; background: var(--modal-overlay);
    z-index: 200; align-items: center; justify-content: center; backdrop-filter: blur(4px);
}
.modal-overlay.show { display: flex; }
.modal {
    background: var(--surface); border: 1px solid var(--surface-border);
    border-radius: var(--radius); width: 100%; max-width: 600px; max-height: 90vh;
    overflow-y: auto; box-shadow: 0 20px 60px var(--shadow);
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--surface-border);
}
.modal-header h3 { font-size: 1.1rem; font-weight: 700; }
.modal-close {
    background: none; border: none; cursor: pointer; padding: 4px; display: flex; border-radius: 6px; transition: all 0.2s;
}
.modal-close:hover { background: var(--surface-hover); }
.modal-close svg { width: 20px; height: 20px; stroke: var(--text-dim); fill: none; stroke-width: 2; }
.modal-body { padding: 1.5rem; }
.modal-footer {
    display: flex; justify-content: flex-end; gap: 10px;
    padding: 1rem 1.5rem; border-top: 1px solid var(--surface-border);
}

/* ====== FORMS ====== */
.form-group { margin-bottom: 1.25rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--text-muted); margin-bottom: 0.4rem; }
.form-input, .form-select {
    width: 100%; padding: 10px 14px; background: var(--bg);
    border: 1px solid var(--surface-border); border-radius: var(--radius-xs);
    color: var(--text); font-family: inherit; font-size: 0.875rem; outline: none; transition: all 0.2s;
}
.form-input:focus, .form-select:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-glow); }
.form-input::placeholder { color: var(--text-dim); }
.form-select {
    appearance: none; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237a8ba3' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px;
}
.form-select option { background: var(--surface); color: var(--text); }
.filter-bar { margin-bottom: 1.5rem; display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.filter-bar .form-label { margin: 0; white-space: nowrap; }
.filter-bar .form-select { max-width: 300px; }

/* ====== TOAST ====== */
.toast {
    position: fixed; bottom: 2rem; right: 2rem; padding: 14px 20px;
    border-radius: var(--radius-sm); font-size: 0.875rem; font-weight: 600;
    display: none; align-items: center; gap: 10px; z-index: 300;
    animation: slideUp 0.3s ease; box-shadow: 0 8px 30px var(--shadow);
}
.toast.show { display: flex; }
.toast-success { background: var(--surface); color: var(--success); border: 1px solid var(--success-bg); }
.toast-error { background: var(--surface); color: var(--error); border: 1px solid var(--error-bg); }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ====== CONFIRM DIALOG ====== */
.confirm-overlay { display: none; position: fixed; inset: 0; background: var(--modal-overlay); z-index: 250; align-items: center; justify-content: center; backdrop-filter: blur(4px); }
.confirm-overlay.show { display: flex; }
.confirm-box {
    background: var(--surface); border: 1px solid var(--surface-border);
    border-radius: var(--radius); padding: 2rem; width: 100%; max-width: 400px; text-align: center;
    box-shadow: 0 20px 60px var(--shadow);
}
.confirm-box h3 { font-size: 1.1rem; margin-bottom: 0.5rem; }
.confirm-box p { color: var(--text-muted); font-size: 0.875rem; margin-bottom: 1.5rem; }
.confirm-actions { display: flex; gap: 10px; justify-content: center; }

/* ====== LOADING ====== */
.spinner-sm { width: 16px; height: 16px; border: 2px solid var(--surface-border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-row td { text-align: center; padding: 2rem; color: var(--text-dim); }

/* ====== CONTENT CARD ====== */
.content-card {
    background: var(--surface); border: 1px solid var(--surface-border);
    border-radius: var(--radius); padding: 1.5rem;
}
.content-card h3 { font-size: 1rem; font-weight: 700; margin-bottom: 0.5rem; }
.content-card p { color: var(--text-muted); font-size: 0.875rem; line-height: 1.6; }

/* ====== CODE ====== */
code { background: var(--code-bg); color: var(--code-color); padding: 2px 6px; border-radius: 4px; font-size: 0.8rem; }

/* ====== RESPONSIVE ====== */
@media (max-width: 768px) {
    .sidebar { width: 60px; padding: 1rem 0; }
    .sidebar-logo-text, .nav-section-title, .user-info, .nav-item span { display: none; }
    .sidebar-logo { justify-content: center; padding: 0; }
    .nav-item { justify-content: center; padding: 10px; }
    .sidebar-footer { flex-wrap: wrap; justify-content: center; padding: 0.5rem; gap: 6px; }
    .main { margin-left: 60px; padding: 1rem; }
    .form-row { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .search-input { width: 100%; }
}
