/* ══════════════════════════════════════════════════════════════
   JD-Services Dashboard — Premium Dark Theme v3
   ══════════════════════════════════════════════════════════════ */

:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #1e293b;
    --bg-card-hover: #273548;
    --bg-input: #0f172a;
    --border: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #38bdf8;
    --accent-hover: #0ea5e9;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --gradient-1: linear-gradient(135deg, #38bdf8, #818cf8);
    --gradient-success: linear-gradient(135deg, #22c55e, #10b981);
    --gradient-danger: linear-gradient(135deg, #ef4444, #dc2626);
    --shadow: 0 4px 24px rgba(0,0,0,0.3);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
}

.view { 
    display: flex; 
    flex-direction: column; 
    min-height: 100vh;
}
.hidden { display: none !important; }

/* ─── LOGIN ───────────────────────────────────────────── */
#loginView { 
    justify-content: center; 
    align-items: center; 
    flex-direction: column;
    background: radial-gradient(ellipse at top, #1e293b 0%, #0f172a 70%); 
}
.login-container { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 48px 40px; width: 380px; text-align: center; box-shadow: var(--shadow); }
.login-logo { font-size: 56px; margin-bottom: 8px; }
.login-title { font-size: 24px; font-weight: 700; }
.login-subtitle { color: var(--text-muted); font-size: 13px; margin-bottom: 32px; }

.form-group { margin-bottom: 16px; text-align: left; }
.form-group label { display: block; font-size: 12px; color: var(--text-secondary); margin-bottom: 6px; font-weight: 500; text-transform: uppercase; }
.form-group input { width: 100%; padding: 12px 16px; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-primary); outline: none; transition: var(--transition); }
.form-group input:focus { border-color: var(--accent); }

.btn-primary { width: 100%; padding: 12px; background: var(--gradient-1); color: white; border: none; border-radius: var(--radius-sm); font-weight: 600; cursor: pointer; transition: var(--transition); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(56,189,248,0.3); }

/* ─── HEADER ──────────────────────────────────────────── */
.header { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    padding: 16px 32px; 
    background: var(--bg-secondary); 
    /* border-bottom dihapus agar tidak double line dengan tab-bar */
}
.header-left { display: flex; align-items: center; gap: 12px; }
.header-left h1 { font-size: 18px; }
.header-version { color: var(--text-muted); font-size: 12px; }
.header-logo { font-size: 28px; }
.header-right { display: flex; align-items: center; gap: 12px; }
.status-badge { font-size: 11px; padding: 4px 12px; border-radius: 20px; font-weight: 600; }
.status-badge.online { background: rgba(34,197,94,0.1); color: var(--success); }
.status-badge.offline { background: rgba(239,68,68,0.1); color: var(--danger); }
.user-badge { font-size: 11px; padding: 4px 12px; border-radius: 20px; background: rgba(56,189,248,0.1); color: var(--accent); font-weight: 600; }

.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-secondary); padding: 6px 12px; border-radius: var(--radius-sm); cursor: pointer; }
.btn-outline:hover { color: var(--danger); border-color: var(--danger); }

/* ─── TABS ────────────────────────────────────────────── */
.tab-bar { display: flex; background: var(--bg-secondary); border-bottom: 1px solid var(--border); padding: 0 32px; position: sticky; top: 0; z-index: 100; }
.tab-btn { padding: 14px 24px; background: transparent; border: none; border-bottom: 2px solid transparent; color: var(--text-muted); font-size: 13px; font-weight: 600; cursor: pointer; transition: var(--transition); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-content { display: none; padding: 24px 32px; }
.tab-content.active { display: block; }

/* ─── SYSTEM INFRA ────────────────────────────────────── */
.section { margin-bottom: 32px; }
.section-title { font-size: 13px; font-weight: 700; color: var(--text-secondary); margin-bottom: 16px; text-transform: uppercase; letter-spacing: 1px; }
.section-desc { font-size: 12px; color: var(--text-muted); margin-bottom: 32px; }
.card-grid { display: grid; gap: 12px; }
.card-grid.auto-fill { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.card-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; margin-bottom: 4px; }
.card-value { font-size: 14px; font-weight: 600; word-break: break-all; }
.status-value { color: var(--success); }
.card-error .card-value { color: var(--danger); }

/* ─── CDN GATEWAY — Custom Sizing ─────────────────────── */
.card-wide { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.cdn-grid-custom { display: flex; gap: 24px; align-items: flex-start; }
.req-col { flex: 1; min-width: 0; }
.meta-col { width: 180px; flex-shrink: 0; }
.cdn-label { display: block; font-size: 10px; color: var(--text-muted); text-transform: uppercase; margin-bottom: 6px; }
.cdn-value { font-size: 13px; font-weight: 500; word-break: break-all; color: var(--text-primary); }

/* ─── BOT ENGINE — Indicator States ───────────────────── */
.bot-grid { display: grid; gap: 12px; }
.bot-grid.auto-fill { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.bot-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; transition: var(--transition); border-left: 4px solid transparent; }
.bot-card.active { border-left-color: var(--success); background: rgba(34,197,94,0.05); box-shadow: 0 0 15px rgba(34,197,94,0.1); }
.bot-card.active .bot-header { color: var(--success); }

.bot-header { font-size: 13px; font-weight: 700; margin-bottom: 8px; color: var(--text-secondary); }
.bot-status { font-size: 12px; color: var(--text-muted); margin-bottom: 12px; min-height: 18px; }
.progress-bar { height: 6px; background: var(--bg-primary); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: var(--gradient-success); border-radius: 3px; transition: width 0.5s ease; }

/* ─── QUICK ACTIONS ───────────────────────────────────── */
.quick-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.btn-action { padding: 10px 18px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-primary); font-size: 12px; font-weight: 600; cursor: pointer; transition: var(--transition); }
.btn-action:hover { border-color: var(--accent); background: var(--bg-card-hover); }
.btn-success { background: rgba(34,197,94,0.1); color: var(--success); border-color: rgba(34,197,94,0.3); }
.btn-success:hover { background: var(--success); color: white; }
.btn-danger { background: rgba(239,68,68,0.1); color: var(--danger); border-color: rgba(239,68,68,0.3); }
.btn-danger:hover { background: var(--danger); color: white; }
.btn-divider { width: 1px; height: 30px; background: var(--border); margin: 0 10px; }

/* ─── SETTINGS ────────────────────────────────────────── */
.settings-block { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; margin-bottom: 16px; }
.settings-block-title { font-size: 13px; color: var(--accent); margin-bottom: 20px; font-weight: 700; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; }
.setting-item label { display: block; font-size: 11px; color: var(--text-secondary); margin-bottom: 6px; font-weight: 600; }
.setting-item input { width: 100%; padding: 12px; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-primary); font-size: 13px; outline: none; }
.setting-hint { font-size: 10px; color: var(--text-muted); margin-top: 5px; display: block; }
.toggle-grid { display: flex; gap: 32px; margin-top: 10px; }
.toggle-item { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.btn-save { margin-top: 20px; max-width: 240px; }

/* ─── CHARTS ──────────────────────────────────────────── */
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); gap: 16px; }
.chart-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }
.chart-card h3 { font-size: 13px; color: var(--text-secondary); margin-bottom: 16px; }

.toast { position: fixed; bottom: 32px; right: 32px; padding: 14px 28px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; z-index: 999; box-shadow: var(--shadow); }
.toast.success { background: var(--success); color: white; }
.toast.error { background: var(--danger); color: white; }

/* ─── MOBILE OPTIMIZATION ────────────────────────────── */
@media (max-width: 768px) {
    /* Compact Header */
    .header { padding: 12px 16px; flex-direction: column; gap: 12px; align-items: flex-start; }
    .header-right { width: 100%; justify-content: space-between; }

    /* Mobile Tab Bar (Scrollable) */
    .tab-bar { 
        padding: 0 16px; 
        overflow-x: auto; 
        white-space: nowrap; 
        -webkit-overflow-scrolling: touch; 
        scrollbar-width: none; /* Firefox */
        position: sticky;
        top: 0;
        z-index: 100;
    }
    .tab-bar::-webkit-scrollbar { display: none; } /* Chrome/Safari */
    .tab-btn { padding: 12px 16px; font-size: 12px; }

    /* Content Spacing */
    .tab-content { padding: 16px; }
    .section { margin-bottom: 24px; }

    /* Grid Adjustments */
    .card-grid.auto-fill { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .bot-grid.auto-fill { grid-template-columns: 1fr; gap: 10px; }
    
    /* CDN Custom Grid */
    .cdn-grid-custom { flex-direction: column; gap: 16px; }
    .meta-col { width: 100%; }

    /* Quick Actions */
    .quick-actions { gap: 8px; }
    .btn-action { flex: 1 1 45%; justify-content: center; padding: 12px; }
    .btn-divider { display: none; }

    /* Forms & Settings */
    .settings-block { padding: 16px; }
    .settings-grid { grid-template-columns: 1fr; gap: 16px; }
    .toggle-grid { flex-direction: column; gap: 16px; }
    .btn-save { max-width: 100%; }

    /* Charts */
    .chart-grid { grid-template-columns: 1fr; }
    .chart-card { padding: 16px; }

    /* Login View Mobile */
    .login-container { width: 90%; padding: 32px 24px; }

    /* Toast */
    .toast { left: 16px; right: 16px; bottom: 16px; text-align: center; }
}

/* Small Mobile Optimization */
@media (max-width: 480px) {
    .card-grid.auto-fill { grid-template-columns: 1fr; }
    .header-left h1 { font-size: 16px; }
    .login-logo { font-size: 48px; }
}
/* ─── GDRIVE AUTH UI ───────────────────────────────────── */
.gdrive-auth-ui { display: flex; flex-direction: column; gap: 12px; }
.input-group-btn { display: flex; gap: 8px; }
.input-group-btn input { flex: 1; padding: 12px; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-primary); font-size: 13px; outline: none; }
.input-group-btn .btn-primary { width: auto; white-space: nowrap; }

@media (max-width: 768px) {
    .input-group-btn { flex-direction: column; }
    .input-group-btn .btn-primary { width: 100%; }
}

/* ─── PREMIUM MONITORING TABLE ─── */
.premium-table {
    width: 100%;
    margin-top: 10px;
}
.premium-table th {
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
}
.premium-table td {
    color: var(--text-primary);
    border-bottom: 1px solid rgba(51, 65, 85, 0.5);
    font-size: 13px;
    vertical-align: middle;
}
.premium-table tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

/* ─── CUSTOM SCROLLBAR FOR TERMINAL ─── */
#terminalConsole::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
#terminalConsole::-webkit-scrollbar-track {
    background: #090d16;
}
#terminalConsole::-webkit-scrollbar-thumb {
    background: #1e293b;
    border-radius: 4px;
}
#terminalConsole::-webkit-scrollbar-thumb:hover {
    background: #334155;
}
