/* ============================================================
   style.css — NEXTROUTER v2.0
   Untuk halaman: Auth, Admin, Top Up, Toko, History, dll.

   CATATAN: Halaman Chat (index.html) pakai INLINE CSS sendiri.
   Jangan tambahkan style .chat-box, .msg, .input-area di sini.
   ============================================================ */

/* ============================================================
   1. DESIGN TOKENS (CSS Custom Properties)
   ============================================================ */
:root {
    /* — Warna Primer — */
    --c-primary: #075e54;
    --c-primary-dark: #064e46;
    --c-primary-light: #059669;
    --c-primary-lighter: #86efac;
    --c-primary-bg: #f0fdf4;
    --c-primary-border: #bbf7d0;

    /* — Warna Netral — */
    --c-bg: #f0f2f5;
    --c-surface: #ffffff;
    --c-surface-hover: #f9fafb;
    --c-border: #e5e7eb;
    --c-border-light: #f3f4f6;
    --c-text: #111827;
    --c-text-secondary: #555555;
    --c-text-muted: #888888;
    --c-text-faint: #aaaaaa;

    /* — Warna Status — */
    --c-success: #059669;
    --c-success-bg: #f0fdf4;
    --c-success-border: #bbf7d0;
    --c-danger: #dc2626;
    --c-danger-bg: #fef2f2;
    --c-danger-border: #fecaca;
    --c-warning: #92400e;
    --c-warning-bg: #fffbeb;
    --c-warning-border: #fde68a;
    --c-info: #2563eb;
    --c-info-bg: #eff6ff;
    --c-info-border: #bfdbfe;

    /* — Sidebar — */
    --c-sidebar-bg: #111827;
    --c-sidebar-hover: #1f2937;
    --c-sidebar-border: #374151;
    --c-sidebar-text: #d1d5db;
    --c-sidebar-text-muted: #9ca3af;

    /* — Spacing Scale (4px base) — */
    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-5: 20px;
    --sp-6: 24px;
    --sp-8: 32px;
    --sp-10: 40px;

    /* — Border Radius — */
    --r-sm: 6px;
    --r-md: 8px;
    --r-lg: 12px;
    --r-xl: 14px;
    --r-pill: 9999px;

    /* — Font Size — */
    --fs-xs: 11px;
    --fs-sm: 12px;
    --fs-base: 14px;
    --fs-md: 15px;
    --fs-lg: 16px;
    --fs-xl: 17px;
    --fs-2xl: 22px;
    --fs-3xl: 24px;

    /* — Shadow — */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 2px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-xl: 0 20px 60px rgba(0,0,0,0.2);

    /* — Transition — */
    --transition-fast: 0.15s ease;
    --transition-base: 0.2s ease;
    --transition-slow: 0.3s ease;

    /* — Z-Index Scale — */
    --z-sidebar: 1000;
    --z-overlay: 999;
    --z-header: 100;
    --z-modal: 2000;
    --z-toast: 9999;
}

/* ============================================================
   2. RESET & GLOBAL
   ============================================================ */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--c-bg);
    color: var(--c-text);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--c-primary-light);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    text-decoration: underline;
}

img {
    max-width: 100%;
    height: auto;
}

/* ============================================================
   3. ACCESSIBILITY — Focus Visible
   ============================================================ */
:focus-visible {
    outline: 2px solid var(--c-primary-light);
    outline-offset: 2px;
}

:focus:not(:focus-visible) {
    outline: none;
}

/* ============================================================
   4. HEADER (dipakai di semua halaman NON-chat)
   ============================================================ */
.chat-header {
    background: var(--c-primary);
    color: white;
    padding: 0 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 56px;
    z-index: var(--z-header);
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
    /* Safe area untuk notch devices */
    padding-left: max(15px, env(safe-area-inset-left));
    padding-right: max(15px, env(safe-area-inset-right));
}

.chat-header h3 {
    flex: 1;
    text-align: center;
    margin: 0;
    font-size: var(--fs-xl);
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-header .menu-btn {
    background: none;
    border: none;
    color: white;
    font-size: 22px;
    cursor: pointer;
    padding: 6px;
    border-radius: var(--r-sm);
    transition: background var(--transition-base);
    -webkit-tap-highlight-color: transparent;
}

.chat-header .menu-btn:hover {
    background: rgba(255,255,255,0.15);
}

.chat-header .saldo-header {
    font-size: var(--fs-sm);
    font-weight: 600;
    background: rgba(255,255,255,0.2);
    padding: 4px 10px;
    border-radius: var(--r-pill);
    white-space: nowrap;
}

/* ============================================================
   5. SIDEBAR
   ============================================================ */
.sidebar {
    height: 100%;
    width: 0;
    position: fixed;
    z-index: var(--z-sidebar);
    top: 0;
    left: 0;
    background-color: var(--c-sidebar-bg);
    overflow-x: hidden;
    transition: width var(--transition-slow);
    padding-top: 60px;
    display: flex;
    flex-direction: column;
}

.sidebar.open {
    width: 280px;
}

.sidebar a {
    padding: 14px 24px;
    text-decoration: none;
    font-size: var(--fs-md);
    color: var(--c-sidebar-text);
    display: block;
    transition: background var(--transition-base), color var(--transition-base);
}

.sidebar a:hover {
    color: white;
    background: var(--c-sidebar-hover);
    text-decoration: none;
}

.sidebar .closebtn {
    position: absolute;
    top: 12px;
    right: 18px;
    font-size: 28px;
    color: var(--c-sidebar-text-muted);
    text-decoration: none;
    cursor: pointer;
    background: none;
    border: none;
    padding: 4px;
    line-height: 1;
    border-radius: var(--r-sm);
    transition: color var(--transition-base);
}

.sidebar .closebtn:hover {
    color: white;
}

.sidebar-footer {
    margin-top: auto;
    border-top: 1px solid var(--c-sidebar-border);
    padding-bottom: 15px;
}

.sidebar-footer a {
    padding: 12px 24px;
    color: var(--c-sidebar-text-muted);
}

.sidebar-footer a:hover {
    color: white;
    background: var(--c-sidebar-hover);
}

/* Overlay saat sidebar terbuka */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: var(--z-overlay);
    cursor: pointer;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.sidebar-overlay.active {
    display: block;
}

/* ============================================================
   6. BACK BUTTON
   ============================================================ */
.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--r-md);
    color: var(--c-text);
    font-size: var(--fs-base);
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition-base);
    margin-bottom: var(--sp-4);
    -webkit-tap-highlight-color: transparent;
}

.btn-back:hover {
    background: var(--c-surface-hover);
    border-color: #bbb;
    text-decoration: none;
}

.btn-back:active {
    transform: scale(0.97);
}

/* ============================================================
   7. AUTH PAGES (Login & Register)
   ============================================================ */
.auth-container {
    max-width: 420px;
    margin: 0 auto;
    padding: 80px 20px 40px;
    min-height: 100vh;
}

.auth-card {
    background: var(--c-surface);
    border-radius: var(--r-lg);
    padding: 30px 24px;
    box-shadow: var(--shadow-md);
}

.auth-card h2 {
    text-align: center;
    margin-bottom: 8px;
    color: var(--c-primary);
    font-size: var(--fs-3xl);
}

.auth-card .subtitle {
    text-align: center;
    color: var(--c-text-muted);
    font-size: var(--fs-base);
    margin-bottom: var(--sp-6);
}

.form-toggle {
    display: flex;
    margin-bottom: var(--sp-6);
    background: #f3f4f6;
    border-radius: var(--r-md);
    padding: 3px;
}

.form-toggle button {
    flex: 1;
    padding: 10px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: var(--r-sm);
    font-size: var(--fs-base);
    font-weight: 500;
    color: #666;
    transition: all var(--transition-base);
    -webkit-tap-highlight-color: transparent;
}

.form-toggle button.active {
    background: var(--c-primary);
    color: white;
    font-weight: 600;
}

.auth-card form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.auth-card form label {
    font-size: 13px;
    font-weight: 600;
    color: var(--c-text-secondary);
    margin-bottom: -8px;
}

.auth-card form input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--c-border);
    border-radius: var(--r-md);
    font-size: var(--fs-base);
    outline: none;
    transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

.auth-card form input:focus {
    border-color: var(--c-primary-light);
    box-shadow: 0 0 0 3px rgba(5,150,105,0.1);
}

.btn-primary {
    width: 100%;
    padding: 12px;
    background: var(--c-primary);
    color: white;
    border: none;
    border-radius: var(--r-md);
    cursor: pointer;
    font-size: var(--fs-md);
    font-weight: 600;
    transition: background var(--transition-base), transform var(--transition-fast);
    margin-top: 4px;
    -webkit-tap-highlight-color: transparent;
}

.btn-primary:hover {
    background: var(--c-primary-dark);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-primary:disabled {
    background: #aaa;
    cursor: not-allowed;
    transform: none;
}

.msg-text {
    text-align: center;
    margin-top: 12px;
    font-size: var(--fs-base);
    padding: 8px;
    border-radius: var(--r-sm);
}

.msg-text.error {
    color: var(--c-danger);
    background: var(--c-danger-bg);
    border: 1px solid var(--c-danger-border);
}

.msg-text.success {
    color: var(--c-success);
    background: var(--c-success-bg);
    border: 1px solid var(--c-success-border);
}

.auth-card .auth-footer {
    text-align: center;
    margin-top: 16px;
    font-size: 13px;
    color: var(--c-text-muted);
}

.auth-card .auth-footer a {
    color: var(--c-primary);
    font-weight: 600;
}

/* ============================================================
   8. PAGE CONTAINER (generic wrapper)
   ============================================================ */
.page-container {
    padding: 70px 16px 30px;
    padding-top: max(70px, calc(56px + env(safe-area-inset-top)));
    max-width: 900px;
    margin: 0 auto;
    min-height: 100vh;
}

.page-title {
    font-size: var(--fs-2xl);
    font-weight: 700;
    color: var(--c-text);
    margin-bottom: var(--sp-5);
    display: flex;
    align-items: center;
    gap: 8px;
}

.page-subtitle {
    font-size: var(--fs-base);
    color: var(--c-text-muted);
    margin-top: -12px;
    margin-bottom: var(--sp-5);
}

/* ============================================================
   9. USER DASHBOARD
   ============================================================ */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: var(--sp-6);
}

.stat-card {
    background: var(--c-surface);
    padding: 16px;
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
    text-align: center;
    transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.stat-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.stat-card .stat-icon {
    font-size: 28px;
    margin-bottom: 6px;
}

.stat-card .stat-value {
    font-size: var(--fs-2xl);
    font-weight: 700;
    color: var(--c-text);
}

.stat-card .stat-label {
    font-size: var(--fs-sm);
    color: var(--c-text-muted);
    margin-top: 2px;
}

/* Quick Actions */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin-bottom: var(--sp-6);
}

.quick-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 16px 10px;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: 10px;
    cursor: pointer;
    text-decoration: none;
    color: var(--c-text);
    font-size: 13px;
    font-weight: 500;
    transition: all var(--transition-base);
    -webkit-tap-highlight-color: transparent;
}

.quick-action-btn:hover {
    background: var(--c-primary-bg);
    border-color: var(--c-primary-lighter);
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

.quick-action-btn .action-icon {
    font-size: 24px;
}

/* ============================================================
   10. PLAN / TOKO PAGE
   ============================================================ */
.plan-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.plan-card {
    background: var(--c-surface);
    padding: 20px;
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
    border: 2px solid transparent;
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

.plan-card:hover {
    border-color: var(--c-primary-lighter);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.plan-card .plan-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: var(--c-primary-light);
    color: white;
    padding: 3px 10px;
    border-radius: var(--r-pill);
    font-size: var(--fs-xs);
    font-weight: 600;
}

.plan-card h4 {
    color: var(--c-primary);
    font-size: 18px;
    margin-bottom: 8px;
}

.plan-card .plan-model {
    font-size: 13px;
    color: var(--c-text-muted);
    margin-bottom: 12px;
}

.plan-card .plan-features {
    list-style: none;
    padding: 0;
    margin-bottom: 16px;
}

.plan-card .plan-features li {
    padding: 4px 0;
    font-size: 13px;
    color: var(--c-text-secondary);
}

.plan-card .plan-features li::before {
    content: '✅ ';
    margin-right: 4px;
}

.plan-card .price {
    font-size: var(--fs-2xl);
    font-weight: 700;
    color: #e91e63;
    margin: 12px 0;
}

.plan-card .price small {
    font-size: 13px;
    color: var(--c-text-muted);
    font-weight: 400;
}

.plan-card .btn-buy {
    width: 100%;
    padding: 10px;
    background: var(--c-primary);
    color: white;
    border: none;
    border-radius: var(--r-md);
    cursor: pointer;
    font-size: var(--fs-base);
    font-weight: 600;
    transition: background var(--transition-base);
    -webkit-tap-highlight-color: transparent;
}

.plan-card .btn-buy:hover {
    background: var(--c-primary-dark);
}

.plan-card .btn-buy:disabled {
    background: #aaa;
    cursor: not-allowed;
}

/* ============================================================
   11. TOP UP PAGE
   ============================================================ */
.topup-container {
    max-width: 500px;
    margin: 0 auto;
}

.topup-info {
    background: var(--c-warning-bg);
    border: 1px solid var(--c-warning-border);
    border-radius: 10px;
    padding: 14px 18px;
    margin-bottom: var(--sp-5);
    font-size: var(--fs-base);
    color: var(--c-warning);
    line-height: 1.5;
}

.topup-info strong {
    display: block;
    margin-bottom: 4px;
    color: #78350f;
}

.topup-amounts {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}

.topup-amount-btn {
    padding: 14px 10px;
    background: var(--c-surface);
    border: 2px solid var(--c-border);
    border-radius: 10px;
    cursor: pointer;
    text-align: center;
    font-size: var(--fs-md);
    font-weight: 600;
    color: var(--c-text);
    transition: all var(--transition-base);
    -webkit-tap-highlight-color: transparent;
}

.topup-amount-btn:hover {
    border-color: var(--c-primary-lighter);
    background: var(--c-primary-bg);
}

.topup-amount-btn.selected {
    border-color: var(--c-primary-light);
    background: var(--c-primary-bg);
    color: var(--c-primary-light);
}

.topup-amount-btn .amount-label {
    font-size: var(--fs-xs);
    color: var(--c-text-muted);
    font-weight: 400;
    margin-top: 2px;
}

.topup-form {
    background: var(--c-surface);
    border-radius: var(--r-lg);
    padding: var(--sp-5);
    box-shadow: var(--shadow-sm);
}

.topup-form label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--c-text-secondary);
    margin-bottom: 6px;
}

.topup-form input,
.topup-form select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--c-border);
    border-radius: var(--r-md);
    font-size: var(--fs-base);
    outline: none;
    margin-bottom: 14px;
    transition: border-color var(--transition-base);
}

.topup-form input:focus,
.topup-form select:focus {
    border-color: var(--c-primary-light);
}

.topup-summary {
    background: var(--c-primary-bg);
    border: 1px solid var(--c-primary-border);
    border-radius: var(--r-md);
    padding: 12px 16px;
    margin-bottom: 16px;
    font-size: var(--fs-base);
}

.topup-summary .summary-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
}

.topup-summary .summary-total {
    border-top: 1px solid var(--c-primary-border);
    margin-top: 6px;
    padding-top: 8px;
    font-weight: 700;
    font-size: var(--fs-lg);
}

/* ============================================================
   12. HISTORY PAGE
   ============================================================ */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.history-card {
    background: var(--c-surface);
    padding: 14px 18px;
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background var(--transition-base);
}

.history-card:hover {
    background: var(--c-surface-hover);
}

.history-card .history-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.history-card .history-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.history-card .history-info h4 {
    color: var(--c-text);
    font-size: var(--fs-base);
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-card .history-info .history-detail {
    font-size: var(--fs-sm);
    color: var(--c-text-muted);
}

.history-card .history-right {
    text-align: right;
    flex-shrink: 0;
    margin-left: 12px;
}

.history-card .history-amount {
    font-size: var(--fs-md);
    font-weight: 700;
}

.history-card .history-amount.in {
    color: var(--c-success);
}

.history-card .history-amount.out {
    color: var(--c-danger);
}

.history-card .history-date {
    font-size: var(--fs-xs);
    color: var(--c-text-faint);
    margin-top: 2px;
}

.history-empty {
    text-align: center;
    padding: var(--sp-10) var(--sp-5);
    color: var(--c-text-faint);
    font-style: italic;
}

.history-empty .empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
    display: block;
}

/* ============================================================
   13. ADMIN PAGES
   ============================================================ */
.admin-container {
    max-width: 1000px;
    margin: 0 auto;
}

.admin-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: var(--sp-6);
}

.admin-stat-card {
    background: var(--c-surface);
    padding: 18px;
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
    text-align: center;
}

.admin-stat-card .stat-number {
    font-size: 28px;
    font-weight: 700;
    color: var(--c-primary);
}

.admin-stat-card .stat-desc {
    font-size: 13px;
    color: var(--c-text-muted);
    margin-top: 4px;
}

/* Admin Table */
.admin-table-wrapper {
    background: var(--c-surface);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    margin-bottom: var(--sp-5);
}

.admin-table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--c-border);
}

.admin-table-header h3 {
    font-size: var(--fs-lg);
    color: var(--c-text);
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th {
    background: #f9fafb;
    padding: 10px 14px;
    text-align: left;
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--c-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--c-border);
}

.admin-table td {
    padding: 12px 14px;
    font-size: var(--fs-base);
    border-bottom: 1px solid var(--c-border-light);
    vertical-align: middle;
}

.admin-table tr {
    transition: background var(--transition-fast);
}

.admin-table tbody tr:hover {
    background: var(--c-surface-hover);
}

.admin-table .user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.admin-table .user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--c-primary-light);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: var(--fs-base);
    flex-shrink: 0;
}

.admin-table .user-name {
    font-weight: 600;
    color: var(--c-text);
}

.admin-table .user-email {
    font-size: var(--fs-sm);
    color: var(--c-text-muted);
}

/* Status Badge */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: var(--r-pill);
    font-size: var(--fs-xs);
    font-weight: 600;
}

.badge-active {
    background: var(--c-success-bg);
    color: var(--c-success);
    border: 1px solid var(--c-success-border);
}

.badge-inactive {
    background: var(--c-danger-bg);
    color: var(--c-danger);
    border: 1px solid var(--c-danger-border);
}

.badge-admin {
    background: var(--c-info-bg);
    color: var(--c-info);
    border: 1px solid var(--c-info-border);
}

.badge-user {
    background: #f3f4f6;
    color: #6b7280;
    border: 1px solid var(--c-border);
}

/* Admin Action Buttons */
.btn-action {
    padding: 6px 12px;
    border: none;
    border-radius: var(--r-sm);
    font-size: var(--fs-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    margin: 2px;
    -webkit-tap-highlight-color: transparent;
}

.btn-action:active {
    transform: scale(0.95);
}

.btn-toggle {
    background: #fef3c7;
    color: var(--c-warning);
    border: 1px solid var(--c-warning-border);
}

.btn-toggle:hover {
    background: var(--c-warning-border);
}

.btn-toggle.active {
    background: var(--c-success-bg);
    color: var(--c-success);
    border: 1px solid var(--c-success-border);
}

.btn-danger {
    background: var(--c-danger-bg);
    color: var(--c-danger);
    border: 1px solid var(--c-danger-border);
}

.btn-danger:hover {
    background: var(--c-danger-border);
}

.btn-edit {
    background: var(--c-info-bg);
    color: var(--c-info);
    border: 1px solid var(--c-info-border);
}

.btn-edit:hover {
    background: var(--c-info-border);
}

.btn-success {
    background: var(--c-success-bg);
    color: var(--c-success);
    border: 1px solid var(--c-success-border);
}

.btn-success:hover {
    background: var(--c-success-border);
}

/* ============================================================
   14. ADMIN SETTINGS PAGE
   ============================================================ */
.settings-section {
    background: var(--c-surface);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: var(--sp-5);
    overflow: hidden;
}

.settings-section-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--c-border);
    display: flex;
    align-items: center;
    gap: 8px;
}

.settings-section-header h3 {
    font-size: var(--fs-lg);
    color: var(--c-text);
}

.settings-section-header .section-icon {
    font-size: 20px;
}

.settings-section-body {
    padding: 18px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--c-text-secondary);
    margin-bottom: 6px;
}

.form-group .form-help {
    font-size: var(--fs-sm);
    color: var(--c-text-faint);
    margin-top: 4px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--c-border);
    border-radius: var(--r-md);
    font-size: var(--fs-base);
    outline: none;
    transition: border-color var(--transition-base), box-shadow var(--transition-base);
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--c-primary-light);
    box-shadow: 0 0 0 3px rgba(5,150,105,0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* Toggle Switch */
.toggle-switch {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.toggle-switch input[type="checkbox"] {
    display: none;
}

.toggle-track {
    width: 44px;
    height: 24px;
    background: #ddd;
    border-radius: 12px;
    position: relative;
    transition: background var(--transition-base);
    flex-shrink: 0;
}

.toggle-track::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: transform var(--transition-base);
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-track {
    background: var(--c-primary-light);
}

.toggle-switch input:checked + .toggle-track::after {
    transform: translateX(20px);
}

.toggle-label {
    font-size: var(--fs-base);
    color: var(--c-text);
}

/* Endpoint Cards */
.endpoint-card {
    border: 1px solid var(--c-border);
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 10px;
    transition: all var(--transition-base);
    position: relative;
}

.endpoint-card.active {
    border-color: var(--c-primary-light);
    background: var(--c-primary-bg);
}

.endpoint-card .endpoint-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.endpoint-card .endpoint-name {
    font-weight: 600;
    font-size: var(--fs-base);
    color: var(--c-text);
}

.endpoint-card .endpoint-url {
    font-size: var(--fs-sm);
    color: var(--c-text-muted);
    word-break: break-all;
    margin-bottom: 4px;
    font-family: 'SF Mono', SFMono-Regular, Consolas, monospace;
    background: #f8f9fa;
    padding: 4px 8px;
    border-radius: var(--r-sm);
}

.endpoint-card .endpoint-model {
    font-size: var(--fs-sm);
    color: var(--c-primary-light);
    font-weight: 600;
}

.endpoint-card .endpoint-actions {
    display: flex;
    gap: 6px;
}

/* ============================================================
   15. ADMIN ENDPOINTS PAGE
   ============================================================ */
.btn-add-endpoint {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    background: var(--c-primary-light);
    color: white;
    border: none;
    border-radius: var(--r-md);
    font-size: var(--fs-base);
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition-base);
    margin-bottom: var(--sp-4);
    -webkit-tap-highlight-color: transparent;
}

.btn-add-endpoint:hover {
    background: #047857;
}

/* ============================================================
   16. MODAL
   ============================================================ */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: var(--z-modal);
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    padding: 16px;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: var(--c-surface);
    border-radius: var(--r-xl);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    animation: modalSlideIn 0.25s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--c-border);
}

.modal-header h3 {
    font-size: var(--fs-xl);
    color: var(--c-text);
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--c-text-muted);
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    border-radius: var(--r-sm);
    transition: color var(--transition-fast), background var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
}

.modal-close:hover {
    color: var(--c-text);
    background: var(--c-surface-hover);
}

.modal-body {
    padding: var(--sp-5);
}

.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--c-border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.btn-modal-cancel {
    padding: 10px 20px;
    background: #f3f4f6;
    border: 1px solid var(--c-border);
    border-radius: var(--r-md);
    font-size: var(--fs-base);
    cursor: pointer;
    color: var(--c-text-secondary);
    transition: background var(--transition-fast);
}

.btn-modal-cancel:hover {
    background: var(--c-border);
}

.btn-modal-save {
    padding: 10px 20px;
    background: var(--c-primary-light);
    color: white;
    border: none;
    border-radius: var(--r-md);
    font-size: var(--fs-base);
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition-base);
}

.btn-modal-save:hover {
    background: #047857;
}

/* Body scroll lock saat modal aktif */
body.modal-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

/* ============================================================
   17. LOADING & EMPTY STATES
   ============================================================ */
.loading-spinner {
    text-align: center;
    padding: var(--sp-10);
    color: var(--c-text-muted);
}

.loading-spinner::after {
    content: '';
    display: inline-block;
    width: 28px;
    height: 28px;
    border: 3px solid var(--c-border);
    border-top-color: var(--c-primary-light);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.empty-state {
    text-align: center;
    padding: var(--sp-10) var(--sp-5);
    color: var(--c-text-faint);
}

.empty-state .empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
    display: block;
}

.empty-state p {
    font-size: var(--fs-base);
}

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite;
    border-radius: var(--r-sm);
}

@keyframes skeleton-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-text {
    height: 14px;
    margin-bottom: 8px;
    width: 100%;
}

.skeleton-text.short {
    width: 60%;
}

.skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.skeleton-card {
    height: 120px;
    border-radius: var(--r-lg);
}

/* ============================================================
   18. TOAST NOTIFICATION
   ============================================================ */
.toast {
    position: fixed;
    bottom: 20px;
    bottom: max(20px, env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #1f2937;
    color: white;
    padding: 12px 24px;
    border-radius: 10px;
    font-size: var(--fs-base);
    z-index: var(--z-toast);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    transition: transform 0.3s ease;
    white-space: nowrap;
    max-width: 90vw;
    text-align: center;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

.toast.success {
    background: var(--c-primary-light);
}

.toast.error {
    background: var(--c-danger);
}

.toast.warning {
    background: var(--c-warning);
}

.toast.info {
    background: var(--c-info);
}

/* ============================================================
   19. PAGINATION
   ============================================================ */
.pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: var(--sp-5);
}

.pagination button {
    padding: 8px 14px;
    border: 1px solid var(--c-border);
    background: var(--c-surface);
    border-radius: var(--r-sm);
    cursor: pointer;
    font-size: 13px;
    transition: all var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
}

.pagination button:hover {
    background: #f3f4f6;
}

.pagination button.active {
    background: var(--c-primary);
    color: white;
    border-color: var(--c-primary);
}

.pagination button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ============================================================
   20. ALERT BOX
   ============================================================ */
.alert {
    padding: 12px 16px;
    border-radius: var(--r-md);
    font-size: var(--fs-base);
    margin-bottom: 16px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    line-height: 1.5;
}

.alert-info {
    background: var(--c-info-bg);
    border: 1px solid var(--c-info-border);
    color: #1e40af;
}

.alert-success {
    background: var(--c-success-bg);
    border: 1px solid var(--c-success-border);
    color: #065f46;
}

.alert-warning {
    background: var(--c-warning-bg);
    border: 1px solid var(--c-warning-border);
    color: var(--c-warning);
}

.alert-danger {
    background: var(--c-danger-bg);
    border: 1px solid var(--c-danger-border);
    color: #991b1b;
}

.alert .alert-icon {
    font-size: 18px;
    flex-shrink: 0;
    line-height: 1.4;
}

/* ============================================================
   21. UTILITY CLASSES
   ============================================================ */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

.text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.no-select {
    -webkit-user-select: none;
    user-select: none;
}

/* ============================================================
   22. MOBILE RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    .admin-table {
        font-size: 13px;
    }
    .admin-table th,
    .admin-table td {
        padding: 8px 10px;
    }
    .form-row {
        grid-template-columns: 1fr;
    }
    .plan-list {
        grid-template-columns: 1fr;
    }
    .topup-amounts {
        grid-template-columns: repeat(2, 1fr);
    }
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .admin-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    .page-container {
        padding: 66px 12px 20px;
        padding-top: max(66px, calc(56px + env(safe-area-inset-top)));
    }
}

@media (max-width: 480px) {
    .auth-container {
        padding: 60px 12px 20px;
    }
    .auth-card {
        padding: 20px 16px;
        border-radius: 10px;
    }
    .admin-table .user-email {
        display: none;
    }
    .dashboard-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    .stat-card {
        padding: 12px;
    }
    .stat-card .stat-value {
        font-size: 18px;
    }
    .modal-content {
        max-width: 100%;
        border-radius: var(--r-lg);
        margin: 0 8px;
    }
    .btn-action {
        padding: 5px 8px;
        font-size: 11px;
    }
}

/* ============================================================
   23. REDUCED MOTION — Accessibility
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    html {
        scroll-behavior: auto;
    }
}

/* ============================================================
   24. PRINT STYLES
   ============================================================ */
@media print {
    .chat-header,
    .sidebar,
    .sidebar-overlay,
    .btn-back,
    .btn-action,
    .pagination,
    .toast,
    .modal-overlay,
    .quick-actions,
    .btn-add-endpoint {
        display: none !important;
    }
    body {
        background: white;
        color: black;
    }
    .page-container {
        padding: 0;
        max-width: 100%;
    }
    .admin-table-wrapper,
    .settings-section,
    .plan-card,
    .stat-card {
        box-shadow: none;
        border: 1px solid #ddd;
        break-inside: avoid;
    }
    a {
        color: black;
        text-decoration: underline;
    }
    a[href]::after {
        content: ' (' attr(href) ')';
        font-size: 12px;
        color: #666;
    }
}

/* ============================================================
   25. DARK MODE (opsional — aktif via data-theme="dark" di <html>)
   ============================================================ */
html[data-theme="dark"] {
    --c-bg: #0f172a;
    --c-surface: #1e293b;
    --c-surface-hover: #334155;
    --c-border: #334155;
    --c-border-light: #1e293b;
    --c-text: #f1f5f9;
    --c-text-secondary: #cbd5e1;
    --c-text-muted: #94a3b8;
    --c-text-faint: #64748b;

    --c-primary-bg: rgba(5,150,105,0.1);
    --c-primary-border: rgba(5,150,105,0.3);

    --c-success-bg: rgba(5,150,105,0.15);
    --c-success-border: rgba(5,150,105,0.3);
    --c-danger-bg: rgba(220,38,38,0.15);
    --c-danger-border: rgba(220,38,38,0.3);
    --c-warning-bg: rgba(146,64,14,0.15);
    --c-warning-border: rgba(146,64,14,0.3);
    --c-info-bg: rgba(37,99,235,0.15);
    --c-info-border: rgba(37,99,235,0.3);

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 2px 12px rgba(0,0,0,0.3);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.4);

    color-scheme: dark;
}

html[data-theme="dark"] body {
    background: var(--c-bg);
}

/* Admin table dark mode */
html[data-theme="dark"] .admin-table th {
    background: #0f172a;
}
html[data-theme="dark"] .admin-table td {
    border-bottom-color: var(--c-border);
}
html[data-theme="dark"] .admin-table tbody tr:hover {
    background: var(--c-surface-hover);
}

/* Form elements dark mode */
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
    background: var(--c-surface);
    color: var(--c-text);
    border-color: var(--c-border);
}

/* Skeleton dark mode */
html[data-theme="dark"] .skeleton {
    background: linear-gradient(90deg, #1e293b 25%, #334155 50%, #1e293b 75%);
    background-size: 200% 100%;
}

/* Toggle track dark mode */
html[data-theme="dark"] .toggle-track {
    background: #475569;
}

/* Topup amount btn dark mode */
html[data-theme="dark"] .topup-amount-btn {
    background: var(--c-surface);
    border-color: var(--c-border);
}

/* Auth card dark mode */
html[data-theme="dark"] .form-toggle {
    background: var(--c-border);
}
