@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

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

:root {
    --sidebar-bg: #252830;
    --sidebar-width: 260px;
    --sidebar-text: rgba(255, 255, 255, 0.65);
    --sidebar-text-active: #ffffff;
    --sidebar-hover: rgba(255, 255, 255, 0.06);
    --sidebar-active: rgba(255, 255, 255, 0.1);
    --sidebar-accent: #4361ee;

    --bg: #f0f2f5;
    --bg-card: #ffffff;
    --bg-hover: #f8fafc;
    --bg-input: #ffffff;

    --text: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;

    --border: #e2e8f0;
    --radius: 8px;
    --radius-sm: 6px;
    --radius-lg: 12px;

    --accent: #4361ee;
    --accent-hover: #3651d4;
    --accent-light: rgba(67, 97, 238, 0.08);
    --success: #10b981;
    --success-light: rgba(16, 185, 129, 0.08);
    --warning: #f59e0b;
    --warning-light: rgba(245, 158, 11, 0.08);
    --danger: #ef4444;
    --danger-light: rgba(239, 68, 68, 0.08);

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.06), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.06), 0 4px 6px -4px rgba(0, 0, 0, 0.04);

    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;

    --transition: all 0.2s ease;
    --transition-fast: all 0.15s ease;
}

html { font-size: 14px; }

body {
    font-family: var(--font-family);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ==================== SIDEBAR ==================== */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

.sidebar-logo {
    padding: 22px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-logo .logo-icon {
    width: 34px;
    height: 34px;
    background: var(--accent);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-logo .logo-icon svg { width: 18px; height: 18px; stroke: white; }

.sidebar-logo h1 {
    color: var(--sidebar-text-active);
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.sidebar-logo .version {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.3);
    font-weight: 400;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 2px; }

.nav-label {
    padding: 18px 20px 8px;
    font-size: 10.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.25);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 400;
    transition: var(--transition-fast);
    border-left: 3px solid transparent;
    margin: 1px 0;
    cursor: pointer;
}

.nav-item:hover {
    color: var(--sidebar-text-active);
    background: var(--sidebar-hover);
    text-decoration: none;
}

.nav-item.active {
    color: var(--sidebar-text-active);
    background: var(--sidebar-active);
    border-left-color: var(--accent);
    font-weight: 500;
}

.nav-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    opacity: 0.6;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.nav-item:hover svg,
.nav-item.active svg { opacity: 1; }

.nav-group .nav-children { display: none; }
.nav-group.open .nav-children { display: block; }

.nav-children .nav-item {
    padding-left: 55px;
    font-size: 13px;
}

.nav-group-toggle { position: relative; }

.nav-group-toggle::after {
    content: '';
    position: absolute;
    right: 20px;
    top: 50%;
    width: 5px;
    height: 5px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: translateY(-50%) rotate(-45deg);
    transition: transform 0.2s ease;
    opacity: 0.4;
}

.nav-group.open .nav-group-toggle::after {
    transform: translateY(-60%) rotate(45deg);
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--sidebar-text-active);
    flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }

.user-name {
    color: var(--sidebar-text-active);
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    color: rgba(255, 255, 255, 0.35);
    font-size: 11px;
    text-transform: capitalize;
}

.btn-logout {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.4);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
}

.btn-logout:hover { color: var(--danger); background: rgba(255, 255, 255, 0.06); }
.btn-logout svg { width: 18px; height: 18px; }

/* ==================== MAIN CONTENT ==================== */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ==================== TOPBAR ==================== */
.topbar {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0 28px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-left { display: flex; align-items: center; gap: 16px; }

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
}

.breadcrumb a { color: var(--text-secondary); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb svg { width: 14px; height: 14px; color: var(--text-muted); }

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

.btn-mobile-menu {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: var(--text);
}

.btn-mobile-menu svg { width: 20px; height: 20px; }

/* ==================== PAGE CONTENT ==================== */
.page-content {
    padding: 28px;
    flex: 1;
    animation: fadeIn 0.3s ease;
}

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

.page-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text);
}

/* ==================== CARDS ==================== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h3 { font-size: 14px; font-weight: 600; }
.card-body { padding: 20px; }

.card-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

/* ==================== STAT CARDS ==================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    box-shadow: var(--shadow-xs);
    transition: var(--transition);
}

.stat-card:hover { box-shadow: var(--shadow-sm); }

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon svg { width: 22px; height: 22px; }

.stat-icon.accent { background: var(--accent-light); color: var(--accent); }
.stat-icon.success { background: var(--success-light); color: var(--success); }
.stat-icon.warning { background: var(--warning-light); color: var(--warning); }
.stat-icon.danger { background: var(--danger-light); color: var(--danger); }

.stat-info h4 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}

.stat-info p {
    font-size: 12.5px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ==================== TABLES ==================== */
.table-wrapper { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

table th {
    padding: 10px 16px;
    text-align: left;
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

table td {
    padding: 12px 16px;
    font-size: 13.5px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

table tbody tr { transition: var(--transition-fast); }
table tbody tr:hover { background: var(--bg-hover); }
table tbody tr:last-child td { border-bottom: none; }

/* ==================== FORMS ==================== */
.form-group { margin-bottom: 18px; }

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 6px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 9px 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font-family);
    font-size: 13.5px;
    color: var(--text);
    background: var(--bg-input);
    transition: var(--transition-fast);
    outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.form-input::placeholder { color: var(--text-muted); }
.form-textarea { resize: vertical; min-height: 80px; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: 12px; color: var(--danger); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ==================== BUTTONS ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-family: var(--font-family);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.4;
}

.btn:hover { text-decoration: none; }
.btn svg { width: 16px; height: 16px; }

.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); box-shadow: var(--shadow-sm); }

.btn-secondary { background: var(--bg); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg-hover); border-color: #cbd5e1; }

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

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #059669; }

.btn-ghost { background: transparent; color: var(--text-secondary); padding: 6px 10px; }
.btn-ghost:hover { background: var(--bg); color: var(--text); }

.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-icon { padding: 7px; border-radius: var(--radius-sm); }

/* ==================== BADGES ==================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 100px;
    font-size: 11.5px;
    font-weight: 500;
    line-height: 1.4;
}

.badge-success { background: var(--success-light); color: var(--success); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-accent { background: var(--accent-light); color: var(--accent); }
.badge-secondary { background: var(--bg); color: var(--text-secondary); }
.badge-info { background: rgba(59, 130, 246, 0.08); color: #2563eb; }
.badge-primary { background: var(--accent-light); color: var(--accent); }

/* Nav Badges */
.nav-badge { display:inline-flex; align-items:center; justify-content:center; min-width:18px; height:18px; padding:0 5px; border-radius:9px; font-size:10px; font-weight:600; background:var(--accent); color:#fff; margin-left:auto; }
.nav-badge-warning { background:var(--warning); color:#fff; }

/* ==================== PAGINATION ==================== */
.pagination { display:flex; align-items:center; justify-content:center; gap:4px; padding:16px 0; }

/* ==================== TOGGLE SWITCH ==================== */
.toggle { position: relative; display: inline-block; width: 40px; height: 22px; }
.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: #cbd5e1;
    border-radius: 22px;
    transition: var(--transition);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: var(--transition);
    box-shadow: var(--shadow-xs);
}

.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }

/* ==================== ALERTS ==================== */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.alert svg { width: 18px; height: 18px; flex-shrink: 0; }
.alert-success { background: var(--success-light); color: #065f46; border: 1px solid rgba(16, 185, 129, 0.2); }
.alert-danger { background: var(--danger-light); color: #991b1b; border: 1px solid rgba(239, 68, 68, 0.2); }
.alert-warning { background: var(--warning-light); color: #92400e; border: 1px solid rgba(245, 158, 11, 0.2); }
.alert-info { background: var(--accent-light); color: #1e40af; border: 1px solid rgba(67, 97, 238, 0.2); }

/* ==================== MAINTENANCE BANNER ==================== */
.maintenance-banner {
    background: var(--warning-light);
    border-bottom: 1px solid rgba(245, 158, 11, 0.2);
    color: #92400e;
    padding: 10px 28px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.maintenance-banner svg { width: 16px; height: 16px; flex-shrink: 0; }

/* ==================== MODAL ==================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.active { display: flex; }

.modal {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 480px;
    max-height: 80vh;
    overflow-y: auto;
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: translateY(-10px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 { font-size: 15px; font-weight: 600; }

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: var(--text-muted);
    transition: var(--transition-fast);
}

.modal-close:hover { color: var(--text); }
.modal-close svg { width: 18px; height: 18px; }
.modal-body { padding: 20px; }

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ==================== TOAST ==================== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 14px 18px;
    min-width: 280px;
    max-width: 400px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    animation: toastIn 0.3s ease;
    font-size: 13.5px;
}

.toast.toast-out { animation: toastOut 0.3s ease forwards; }

@keyframes toastIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(30px); } }

.toast-icon { width: 20px; height: 20px; flex-shrink: 0; margin-top: 1px; }
.toast-success .toast-icon { color: var(--success); }
.toast-danger .toast-icon { color: var(--danger); }
.toast-warning .toast-icon { color: var(--warning); }

/* ==================== LOGIN PAGE ==================== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    padding: 20px;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    width: 100%;
    max-width: 400px;
    padding: 36px 32px;
}

.login-logo { text-align: center; margin-bottom: 28px; }

.login-logo .logo-icon {
    width: 48px;
    height: 48px;
    background: var(--sidebar-bg);
    border-radius: var(--radius);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
}

.login-logo .logo-icon svg { width: 24px; height: 24px; stroke: white; }

.login-logo h2 { font-size: 18px; font-weight: 600; color: var(--text); }
.login-logo p { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }

.login-form .form-group { margin-bottom: 16px; }
.login-form .btn-primary { width: 100%; padding: 11px; font-size: 14px; margin-top: 4px; }

/* ==================== SETUP PAGE ==================== */
.setup-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    padding: 20px;
}

.setup-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    width: 100%;
    max-width: 460px;
    padding: 36px 32px;
}

.setup-card .step-indicator {
    font-size: 12px;
    color: var(--accent);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.setup-card h2 { font-size: 20px; font-weight: 600; margin-bottom: 4px; }
.setup-card .subtitle { font-size: 13px; color: var(--text-secondary); margin-bottom: 24px; }

/* ==================== PERMISSION MATRIX ==================== */
.permission-matrix { width: 100%; }
.permission-matrix th { text-align: center; min-width: 100px; }
.permission-matrix th:first-child { text-align: left; }
.permission-matrix td { text-align: center; }
.permission-matrix td:first-child { text-align: left; font-weight: 500; }

.permission-matrix .group-row td {
    background: var(--bg);
    font-weight: 600;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    padding: 8px 16px;
}

.permission-matrix input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--accent);
}

.permission-matrix input[type="checkbox"]:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

/* ==================== EMPTY STATE ==================== */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-secondary);
}

.empty-state svg { width: 48px; height: 48px; color: var(--text-muted); margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ==================== INLINE SETTINGS ==================== */
.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
}

.setting-row:last-child { border-bottom: none; }

.setting-info { flex: 1; }
.setting-info h4 { font-size: 14px; font-weight: 500; color: var(--text); }
.setting-info p { font-size: 12.5px; color: var(--text-secondary); margin-top: 2px; }

/* ==================== UTILITIES ==================== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-mono { font-family: var(--font-mono); font-size: 12.5px; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.flex-1 { flex: 1; }
.actions { display: flex; align-items: center; gap: 4px; }

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .btn-mobile-menu { display: block; }
    .page-content { padding: 16px; }
    .topbar { padding: 0 16px; }
    .stats-grid { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; align-items: flex-start; gap: 12px; }
    .maintenance-banner { padding: 10px 16px; }
}

.mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 99;
}

.sidebar.open ~ .mobile-overlay { display: block; }

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

/* ==================== PRODUCT: MEDIA GRID ==================== */
.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, 120px);
    gap: 10px;
}

.media-grid-sm {
    grid-template-columns: repeat(auto-fill, 72px);
    gap: 8px;
    margin-top: 8px;
}

.media-grid-xs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }

.media-thumb {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
    background: var(--bg);
    cursor: pointer;
    transition: var(--transition-fast);
}

.media-thumb:hover {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-light);
    transform: scale(1.03);
}

.media-thumb img,
.media-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }

.media-thumb-sm { aspect-ratio: 1; }
.media-thumb-xs { width: 48px; height: 48px; flex-shrink: 0; }

.media-delete-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.65);
    color: white;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 2;
}

.media-thumb:hover .media-delete-btn { opacity: 1; }

.media-add-btn {
    aspect-ratio: 1;
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    cursor: pointer;
    color: var(--text-muted);
    transition: var(--transition-fast);
    font-size: 11px;
    min-height: 80px;
}

.media-add-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }

.media-add-btn-sm {
    width: 72px;
    height: 72px;
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
    transition: var(--transition-fast);
}

.media-add-btn-sm:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }

.media-add-btn-inline {
    cursor: pointer;
    padding: 4px 8px;
    color: var(--text-muted);
    font-size: 16px;
    transition: var(--transition-fast);
    flex-shrink: 0;
}

.media-add-btn-inline:hover { color: var(--accent); }

/* ==================== PRODUCT: VARIANT BUILDER ==================== */
.variant-group {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 16px;
    background: var(--bg-card);
    overflow: hidden;
}

.variant-group-header {
    padding: 12px 16px;
    background: linear-gradient(135deg, var(--bg) 0%, rgba(67, 97, 238, 0.04) 100%);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.variant-group-header .form-input {
    border: 1px solid transparent;
    background: transparent;
    font-size: 14px;
}

.variant-group-header .form-input:focus {
    border-color: var(--accent);
    background: white;
}

.variant-items { padding: 16px; }

.variant-item {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-bottom: 10px;
    background: white;
    transition: var(--transition-fast);
}

.variant-item:hover { box-shadow: var(--shadow-sm); border-color: #cbd5e1; }

.variant-item-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.variant-sub-items {
    padding-left: 20px;
    margin-top: 10px;
    border-left: 2px solid var(--accent);
    position: relative;
}

.variant-sub-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    margin-bottom: 6px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    flex-wrap: wrap;
    border: 1px solid transparent;
    transition: var(--transition-fast);
}

.variant-sub-item:hover {
    background: white;
    border-color: var(--border);
    box-shadow: var(--shadow-xs);
}

/* ==================== PRODUCT: GIFTS ==================== */
.gift-item {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    background: white;
    transition: var(--transition-fast);
    border-left: 3px solid var(--warning);
}

.gift-item:hover { box-shadow: var(--shadow-sm); }

.gift-item-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

/* ==================== LIGHTBOX ==================== */
.lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    z-index: 500;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    cursor: zoom-out;
    animation: lightboxFadeIn 0.2s ease;
}

@keyframes lightboxFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.lightbox-overlay img,
.lightbox-overlay video {
    max-width: 90vw;
    max-height: 85vh;
    object-fit: contain;
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    cursor: default;
    animation: lightboxZoomIn 0.25s ease;
}

@keyframes lightboxZoomIn {
    from { opacity: 0; transform: scale(0.92); }
    to { opacity: 1; transform: scale(1); }
}

.lightbox-close {
    position: absolute;
    top: 16px;
    right: 20px;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    font-size: 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    z-index: 501;
}

.lightbox-close:hover { background: rgba(255, 255, 255, 0.3); }

.lightbox-filename {
    color: rgba(255, 255, 255, 0.6);
    font-size: 12px;
    margin-top: 12px;
    font-family: var(--font-mono);
}

/* ==================== CHAT TEST ==================== */
.chat-test-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    height: calc(100vh - 180px);
    min-height: 500px;
}

.chat-panel {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-panel-header {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg);
    flex-shrink: 0;
}

.chat-panel-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.chat-status {
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    color: var(--text-muted);
    gap: 8px;
    text-align: center;
}

.chat-empty p { font-size: 13px; }

.chat-bubble {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 13.5px;
    line-height: 1.5;
    animation: fadeIn 0.2s ease;
}

.chat-bubble-khach {
    align-self: flex-end;
    background: var(--accent);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-bubble-bot {
    align-self: flex-start;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

.chat-bubble-system {
    align-self: center;
    background: var(--warning-light, #fff8e1);
    color: var(--text-secondary);
    font-size: 12px;
    padding: 6px 12px;
    border-radius: 12px;
}

.chat-bubble-nhan_vien {
    align-self: flex-start;
    background: #e8f5e9;
    color: var(--text);
    border-bottom-left-radius: 4px;
}

.chat-bubble-text { white-space: pre-wrap; word-break: break-word; }

.chat-bubble-images {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

.chat-bubble-images img {
    max-width: 120px;
    max-height: 120px;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
}

.chat-input-area {
    padding: 10px 12px;
    border-top: 1px solid var(--border);
    background: var(--bg);
    flex-shrink: 0;
}

.chat-input-row {
    display: flex;
    gap: 6px;
    align-items: center;
}

.chat-input-row .form-input {
    flex: 1;
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 13px;
}

.chat-attach-btn {
    cursor: pointer;
    padding: 6px;
    color: var(--text-muted);
    transition: var(--transition-fast);
    flex-shrink: 0;
}

.chat-attach-btn:hover { color: var(--accent); }

.chat-images-preview {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

.chat-img-preview {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--border);
}

.chat-input-hint {
    font-size: 11px;
    color: var(--accent);
    margin-top: 4px;
    padding-left: 4px;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Tabs */
.chat-tabs {
    display: flex;
    gap: 2px;
}

.chat-tab {
    padding: 5px 12px;
    border: none;
    background: none;
    font-size: 12px;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
    font-weight: 500;
}

.chat-tab:hover { color: var(--text); background: var(--bg); }
.chat-tab.active { color: var(--accent); background: var(--accent-light); }

/* JSON view */
.chat-json-view { padding: 12px; }
.chat-pre {
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-break: break-all;
    margin: 0;
}

/* Bot toggle */
.chat-bot-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.toggle {
    position: relative;
    width: 32px;
    height: 18px;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
    position: absolute;
    inset: 0;
    background: #ccc;
    border-radius: 18px;
    transition: 0.2s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    left: 2px;
    bottom: 2px;
    background: white;
    border-radius: 50%;
    transition: 0.2s;
}

.toggle input:checked + .toggle-slider { background: var(--success); }
.toggle input:checked + .toggle-slider::before { transform: translateX(14px); }

/* Badge */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}
.badge-success { background: #e8f5e9; color: #2e7d32; }
.badge-danger { background: #fce4ec; color: #c62828; }

@media (max-width: 768px) {
    .chat-test-container { grid-template-columns: 1fr; height: auto; }
    .chat-panel { min-height: 350px; }
}


