/* ========================================================
   VIPERCELL V16.2 - ADMIN COMMAND CENTER CSS
   ======================================================== */

/* ========================================================
   1. SISTEM TEMA CERDAS (DARK & LIGHT MODE)
   ======================================================== */
:root[data-theme="dark"] {
    --primary: #2563eb;
    --primary-light: #3b82f6;
    --primary-dark: #1d4ed8;
    --primary-gradient: linear-gradient(135deg, #2563eb, #06b6d4);
    
    --bg: #020617;
    --surface: #0f172a;
    --surface-hover: #1e293b;
    --border: #334155;
    
    --text: #f8fafc;
    --text-muted: #94a3b8;
    
    --success: #10b981;
    --success-gradient: linear-gradient(135deg, #10b981, #34d399);
    --warning: #f59e0b;
    --danger: #ef4444;
}

:root[data-theme="light"] {
    --primary: #2563eb;
    --primary-light: #3b82f6;
    --primary-dark: #1d4ed8;
    --primary-gradient: linear-gradient(135deg, #2563eb, #06b6d4);
    
    --bg: #f8fafc;
    --surface: #ffffff;
    --surface-hover: #f1f5f9;
    --border: #e2e8f0;
    
    --text: #0f172a;
    --text-muted: #64748b;
    
    --success: #10b981;
    --success-gradient: linear-gradient(135deg, #10b981, #34d399);
    --warning: #f59e0b;
    --danger: #ef4444;
}

/* ========================================================
   2. RESET & DASAR
   ======================================================== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-tap-highlight-color: transparent;
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

body.no-scroll { overflow: hidden; }
a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; font-family: inherit; outline: none; background: transparent; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: 2px solid var(--primary-light); outline-offset: 2px;
}

/* Scrollbar Custom Minimalis */
::-webkit-scrollbar { width: 6px; height: 6px; background: transparent; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(59, 130, 246, 0.4); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(59, 130, 246, 0.8); }

/* ========================================================
   3. KOMPONEN GLOBAL (TOMBOL, BADGE, TOAST)
   ======================================================== */
.btn {
    padding: 0.7rem 1.2rem; border-radius: 8px; font-weight: 600; font-size: 0.85rem;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s, background-color 0.2s, color 0.2s;
    display: inline-flex; align-items: center; gap: 6px; justify-content: center; min-height: 44px;
}
.btn-primary { background: var(--primary-gradient); color: white; box-shadow: 0 4px 15px rgba(37, 99, 235, 0.2); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(37, 99, 235, 0.4); }
.btn-success { background: var(--success-gradient); color: white; box-shadow: 0 4px 15px rgba(16, 185, 129, 0.2); }
.btn-success:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4); }
.btn-warning { background: rgba(245, 158, 11, 0.15); color: var(--warning); border: 1px solid rgba(245, 158, 11, 0.3); }
.btn-warning:hover { background: var(--warning); color: white; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--surface-hover); }
.btn-danger { background: rgba(239, 68, 68, 0.1); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.2); }
.btn-danger:hover { background: var(--danger); color: white; }
.btn-icon-only {
    padding: 0; width: 40px; height: 40px; border-radius: 50%; font-size: 1.1rem;
    background: var(--surface-hover); color: var(--text); border: 1px solid var(--border);
}
.btn-icon-only:hover { background: var(--border); }

.notif-dot {
    position: absolute; width: 10px; height: 10px; background-color: var(--danger);
    border-radius: 50%; display: none; box-shadow: 0 0 5px rgba(239, 68, 68, 0.8);
}

.status-badge { padding: 0.3rem 0.6rem; border-radius: 6px; font-size: 0.7rem; font-weight: 700; display: inline-block;}
.status-unpaid { background: rgba(148, 163, 184, 0.1); color: var(--text-muted); border: 1px solid rgba(148, 163, 184, 0.3);}
.status-pending { background: rgba(245, 158, 11, 0.1); color: var(--warning); border: 1px solid rgba(245, 158, 11, 0.2);}
.status-success { background: rgba(16, 185, 129, 0.1); color: var(--success); border: 1px solid rgba(16, 185, 129, 0.2);}
.status-failed { background: rgba(239, 68, 68, 0.1); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.2);}

.toast-container {
    position: fixed; top: 15px; left: 50%; transform: translateX(-50%);
    z-index: 999999; display: flex; flex-direction: column; gap: 10px;
    pointer-events: none; width: 90%; max-width: 400px;
}
.toast-item {
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
    padding: 12px 16px; display: flex; align-items: center; gap: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15); pointer-events: auto;
    transform: translateY(-20px); opacity: 0; 
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s;
}
.toast-item.show { transform: translateY(0); opacity: 1; }
.toast-icon { font-size: 1.5rem; flex-shrink: 0; }
.toast-success .toast-icon { color: var(--success); }
.toast-info .toast-icon { color: var(--primary-light); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-error .toast-icon { color: var(--danger); }
.toast-content h4 { margin:0; font-size: 0.95rem; color: var(--text); }
.toast-content p { margin:0; font-size: 0.8rem; color: var(--text-muted); line-height: 1.3; }

/* ========================================================
   4. MODALS & FORMS (OPTIMIZED FOR ADMIN)
   ======================================================== */
.modal-overlay, .msg-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 99999; display: flex; justify-content: center; align-items: center;
    opacity: 0; visibility: hidden; pointer-events: none; transition: opacity 0.2s ease, visibility 0.2s ease; padding: 1rem;
}
.modal-overlay.active, .msg-overlay.active { opacity: 1; visibility: visible; pointer-events: all; }

.modal-content {
    background: var(--bg); border: 1px solid var(--border); border-radius: 16px;
    width: 100%; max-width: 450px; max-height: 90dvh; overflow-y: auto; padding: 1.5rem;
    transform: translateY(20px) scale(0.98); transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5);
}
.modal-overlay.active .modal-content { transform: translateY(0) scale(1); }
.modal-content.large { max-width: 800px; }
.modal-content.wide { max-width: 650px; }
.modal-header {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.2rem;
    border-bottom: 1px solid var(--border); padding-bottom: 0.8rem; position: relative; padding-right: 40px;
}
.modal-header h2 { font-size: 1.1rem; font-weight: 700; color: var(--text); }
.close-btn {
    position: absolute; top: 15px; right: 15px; background: var(--surface-hover); border: 1px solid var(--border);
    color: var(--text-muted); border-radius: 50%; width: 34px; height: 34px; display: flex; justify-content: center; align-items: center;
    font-size: 1rem; transition: background-color 0.2s, color 0.2s; z-index: 100; cursor: pointer;
}
.close-btn:hover { color: var(--danger); background: rgba(239, 68, 68, 0.1); border-color: var(--danger); }

.form-group { margin-bottom: 1rem; text-align: left; }
.form-group label { display: block; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.4rem; font-weight: 600; }
.form-control {
    width: 100%; padding: 0.7rem 1rem; border-radius: 8px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text); outline: none; transition: border-color 0.2s; font-size: 0.9rem; min-height: 44px;
}
.form-control:focus { border-color: var(--primary-light); }
textarea.form-control { resize: vertical; min-height: 80px; }

/* ========================================================
   5. LAYOUT UTAMA DASHBOARD ADMIN
   ======================================================== */
.admin-layout {
    display: flex; height: 100vh; width: 100vw; overflow: hidden; background: var(--bg);
}

.admin-sidebar {
    width: 260px; background: var(--surface); border-right: 1px solid var(--border);
    display: flex; flex-direction: column; flex-shrink: 0;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); z-index: 100;
}
.admin-sidebar-header { padding: 1.5rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.admin-logo-box { display: flex; align-items: center; }

.admin-nav { display: flex; flex-direction: column; gap: 8px; padding: 1.5rem 1rem; flex-grow: 1; overflow-y: auto; }
.admin-tab {
    display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 12px;
    font-weight: 600; color: var(--text-muted); transition: all 0.2s; text-align: left; border: 1px solid transparent;
}
.admin-tab i { font-size: 1.1rem; width: 20px; text-align: center; }
.admin-tab:hover { background: var(--surface-hover); color: var(--text); }
.admin-tab.active { background: var(--primary); color: white; box-shadow: 0 4px 15px rgba(37, 99, 235, 0.3); }
.admin-sidebar-footer { padding: 1.5rem 1rem; border-top: 1px solid var(--border); }

.admin-main { flex: 1; display: flex; flex-direction: column; overflow-y: auto; position: relative; background: var(--bg); }
.admin-main-header {
    position: sticky; top: 0; background: rgba(var(--surface-rgb), 0.8);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    padding: 1rem 2rem; border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center; z-index: 50;
}
.admin-body { padding: 2rem; flex-grow: 1; }

/* ========================================================
   6. KARTU & TABEL ADMIN
   ======================================================== */
.admin-glass-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 1.5rem;
    display: flex; align-items: center; gap: 15px; box-shadow: 0 4px 20px rgba(0,0,0,0.03);
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.admin-glass-card:hover { transform: translateY(-3px); border-color: var(--primary-light); box-shadow: 0 8px 25px rgba(37,99,235,0.1); }
.admin-glass-card .icon-wrap {
    width: 55px; height: 55px; border-radius: 12px; display: flex;
    align-items: center; justify-content: center; font-size: 1.5rem; flex-shrink: 0;
}

.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.5rem; }

.table-responsive {
    display: block; width: 100%; overflow-x: auto; background: var(--surface);
    border-radius: 12px; border: 1px solid var(--border); box-shadow: 0 4px 15px rgba(0,0,0,0.02);
}
table { width: 100%; border-collapse: collapse; text-align: left; font-size: 0.85rem; min-width: 800px; }
th, td { padding: 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--text-muted); font-weight: 600; background: var(--surface-hover); white-space: nowrap; text-transform: uppercase; font-size: 0.75rem; letter-spacing: 0.5px;}

/* ========================================================
   7. LIVE CHAT LAYOUT EKSKLUSIF ADMIN
   ======================================================== */
.admin-chat-layout {
    display: flex; flex-direction: column; height: 75vh; min-height: 500px;
    border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--bg);
}
@media (min-width: 769px) {
    .admin-chat-layout { flex-direction: row; }
    .admin-chat-sidebar { width: 300px; border-right: 1px solid var(--border); display: flex; flex-direction: column; }
    .admin-chat-main { flex: 1; display: flex; flex-direction: column; }
}

.admin-chat-card {
    border-bottom: 1px solid var(--border); padding: 1rem; display: flex; justify-content: space-between; align-items: center;
    cursor: pointer; transition: background 0.2s;
}
.admin-chat-card:hover { background: var(--surface-hover); }
.admin-chat-card.active { background: rgba(37,99,235,0.08); border-left: 4px solid var(--primary-light); }

.chat-msg { max-width: 85%; padding: 8px 12px; border-radius: 12px; font-size: 0.85rem; line-height: 1.4; word-wrap: break-word;}
.chat-msg.admin { background: var(--surface-hover); color: var(--text); align-self: flex-start; border-bottom-left-radius: 2px; border: 1px solid var(--border); }
.chat-msg.user { background: var(--primary); color: white; align-self: flex-end; border-bottom-right-radius: 2px; }
.chat-time { font-size: 0.65rem; color: var(--text-muted); text-align: right; margin-top: 4px; display: block; opacity:0.8;}

/* ========================================================
   8. RESPONSIVE MOBILE (SMARTPHONE)
   ======================================================== */
@media (max-width: 768px) {
    #mobile-admin-toggle { display: inline-flex !important; }
    
    .admin-layout { flex-direction: column; }
    
    /* Mengubah Sidebar menjadi Laci (Drawer) di HP */
    .admin-sidebar {
        position: fixed; top: 0; left: 0; bottom: 0; width: 280px;
        transform: translateX(-100%); z-index: 10000; box-shadow: 5px 0 25px rgba(0,0,0,0.1);
    }
    .admin-sidebar.active { transform: translateX(0); }
    
    .admin-main { padding-bottom: 2rem; }
    .admin-main-header { padding: 1rem; }
    .admin-body { padding: 1rem; }
    
    /* Penyesuaian Modal Mobile */
    .modal-content { padding: 1.2rem; }
    .modal-content.wide { padding: 1rem; max-width: 95vw; }
}