:root {
    --bg-dark: #09090b; /* Zinc 950 */
    --panel-bg: rgba(24, 24, 27, 0.7); /* Zinc 900 semi-transparent */
    --panel-header: rgba(39, 39, 42, 0.5); /* Zinc 800 */
    --border-subtle: #27272a; /* Zinc 800 */
    --border-highlight: #3f3f46;
    
    --primary: #3b82f6; /* Blue 500 */
    --primary-hover: #2563eb;
    --primary-glow: rgba(59, 130, 246, 0.15);
    
    --success: #10b981; /* Emerald 500 */
    --success-hover: #059669;
    --danger: #ef4444; /* Red 500 */
    --warning: #f59e0b; /* Amber 500 */
    
    --text-main: #f4f4f5; /* Zinc 50 */
    --text-muted: #a1a1aa; /* Zinc 400 */
}

body {
    margin: 0; padding: 0;
    background-color: var(--bg-dark);
    font-family: 'Inter', sans-serif;
    height: 100vh; display: flex; flex-direction: column;
    color: var(--text-main); overflow: hidden;
    position: relative;
}

/* EFEK CAHAYA LATAR BELAKANG */
.bg-glow {
    position: absolute;
    top: -20%; left: 30%;
    width: 40vw; height: 40vw;
    background: radial-gradient(circle, var(--primary-glow) 0%, transparent 60%);
    z-index: 0; pointer-events: none;
}

.navbar, .grid-container {
    position: relative; z-index: 10;
}

/* WIDGET VENDOR OVERRIDE (MEMPERBAIKI POSISI) */
#call-widget-app {
    position: fixed !important;
    bottom: 35px !important; /* Dinaikkan agar tidak terlalu mepet bawah */
    right: 35px !important;  /* Digeser ke kiri agar tidak terlalu mepet tepi */
    z-index: 99999 !important; /* Paksa agar berada di lapisan terdepan */
}

/* Styling tambahan untuk dropdown select agar senada */
select.input-modern option {
    background-color: var(--bg-dark);
    color: var(--text-main);
}

.navbar {
    background-color: rgba(9, 9, 11, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-subtle);
    padding: 0 2rem; display: flex;
    justify-content: space-between; align-items: center;
    height: 64px; box-sizing: border-box;
}
.nav-brand { display: flex; align-items: center; gap: 10px; color: var(--text-main); }
.brand-logo { 
    background: linear-gradient(135deg, var(--border-subtle), #18181b);
    border: 1px solid var(--border-highlight);
    width: 32px; height: 32px; border-radius: 8px;
    display: flex; justify-content: center; align-items: center;
    color: var(--primary);
}
.navbar h2 { margin: 0; font-size: 1.05rem; font-weight: 600; letter-spacing: 0.02em; }
.nav-actions { display: flex; gap: 12px; align-items: center; }

.ext-badge { background: var(--panel-bg); border: 1px solid var(--border-subtle); padding: 6px 12px; border-radius: 6px; font-size: 0.85rem; color: var(--text-muted); font-family: 'Fira Code', monospace;}
.status-badge { background: rgba(239, 68, 68, 0.1); border: 1px solid rgba(239, 68, 68, 0.3); color: var(--danger); padding: 6px 12px; border-radius: 6px; font-size: 0.85rem; font-weight: 500;}
.btn-logout { background: transparent; border: 1px solid var(--border-subtle); color: var(--text-muted); padding: 6px 16px; border-radius: 6px; cursor: pointer; font-weight: 500; transition: 0.2s; }
.btn-logout:hover { background: rgba(239, 68, 68, 0.1); color: var(--danger); border-color: rgba(239, 68, 68, 0.3); }

/* GRID LAYOUT */
.grid-container {
    display: grid; 
    grid-template-columns: 1fr 1fr; 
    grid-template-rows: auto 1fr;
    gap: 20px; padding: 20px; 
    height: calc(100vh - 64px); box-sizing: border-box;
}

.panel-dashboard { grid-column: 1; grid-row: 1; }
.panel-history { grid-column: 1; grid-row: 2; }
.panel-log { grid-column: 2; grid-row: 1 / span 2; }

/* KOTAK KONTEN (CARD) */
.grid-item {
    background: var(--panel-bg);
    backdrop-filter: blur(16px);
    border-radius: 12px;
    display: flex; flex-direction: column; overflow: hidden;
    border: 1px solid var(--border-subtle);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.panel-header {
    background-color: var(--panel-header);
    border-bottom: 1px solid var(--border-subtle);
    padding: 12px 20px; font-weight: 500; font-size: 0.9rem;
    color: var(--text-muted); display: flex; align-items: center; justify-content: space-between;
}
.header-title { display: flex; align-items: center; gap: 8px; }
.indicator-dot { width: 8px; height: 8px; border-radius: 50%; }
.indicator-dot.blue { background: var(--primary); box-shadow: 0 0 8px var(--primary); }
.indicator-dot.green { background: var(--success); box-shadow: 0 0 8px var(--success); }
.indicator-dot.orange { background: var(--warning); box-shadow: 0 0 8px var(--warning); }

.panel-content { padding: 24px; flex: 1; overflow-y: auto; }

/* FORM & BUTTONS */
.form-group { margin-bottom: 1.2rem; }
.form-group label { display: block; margin-bottom: 0.5rem; font-size: 0.85rem; color: var(--text-muted);}
.input-modern {
    width: 100%; padding: 0.75rem 1rem; border: 1px solid var(--border-subtle);
    background: rgba(0,0,0,0.2); color: var(--text-main);
    border-radius: 8px; box-sizing: border-box; font-size: 0.95rem;
    font-family: 'Inter', sans-serif; transition: all 0.2s;
}
.input-modern:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-glow); }
.input-modern::placeholder { color: #52525b; }

.btn-primary {
    background-color: var(--primary); color: white; 
    border: 1px solid transparent; padding: 0.75rem 1.5rem; 
    border-radius: 8px; font-size: 0.95rem; font-family: 'Inter', sans-serif;
    font-weight: 500; cursor: pointer; transition: all 0.2s ease;
    width: 100%; display: inline-flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 10px var(--primary-glow);
}
.btn-primary:hover { background-color: var(--primary-hover); }
.btn-primary:disabled { background-color: var(--border-subtle); color: var(--text-muted); cursor: not-allowed; box-shadow: none; }
.btn-success { background-color: var(--success); box-shadow: 0 2px 10px rgba(16, 185, 129, 0.2); }
.btn-success:hover { background-color: var(--success-hover); }

/* NETWORK CARD */
.network-card {
    background: rgba(0,0,0,0.2); border: 1px solid var(--border-subtle); border-radius: 8px; margin-bottom: 24px; overflow: hidden;
}
.network-header { background: var(--panel-header); padding: 8px 16px; font-size: 0.8rem; color: var(--text-muted); border-bottom: 1px solid var(--border-subtle);}
.network-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 16px; }
.net-item { display: flex; flex-direction: column; }
.net-label { font-size: 0.7rem; color: var(--text-muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.05em;}
.net-value { font-size: 0.9rem; color: var(--text-main); }
.mono { font-family: 'Fira Code', monospace; }

/* HISTORY TABLE */
.history-container { padding: 0 !important; }
.history-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.history-table th { background: var(--panel-header); padding: 12px 20px; position: sticky; top: 0; border-bottom: 1px solid var(--border-subtle); text-align: left; color: var(--text-muted); font-weight: 500;}
.history-table td { padding: 12px 20px; border-bottom: 1px solid rgba(255,255,255,0.02); color: var(--text-main);}
.history-table tr:hover { background-color: rgba(255,255,255,0.02); }

/* LOGGER */
.panel-log { background-color: #0c0a09; /* Extra dark for terminal */ }
.log-content { font-family: 'Fira Code', monospace; font-size: 0.8rem; line-height: 1.6; padding: 16px;}
.log-entry { margin-bottom: 8px; word-wrap: break-word; }
.log-time { color: #52525b; margin-right: 12px; }
.log-info { color: #38bdf8; }
.log-success { color: #34d399; }
.log-warn { color: #fbbf24; }
.log-error { color: #f87171; }

/* UTILS */
.hidden { display: none !important; }
.btn-text { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 0.8rem; transition: 0.2s;}
.btn-text:hover { color: var(--text-main); }


/* 1. Turunkan z-index grid container utama */
.grid-container {
    position: relative; 
    z-index: 1; /* Diturunkan dari 10 ke 1 agar tidak menutupi overlay fixed */
}

/* 2. Paksa elemen internal vendor widget berada di lapisan terdepan */
#call-widget-app,
.call-widget,
.widget,
div[class*="widget"] {
    z-index: 999999 !important; /* Nilai z-index maksimal */
}

/* --- MODAL STYLES --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px); /* Efek blur pada background */
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
    display: none;
    opacity: 0;
}

.modal-content {
    background-color: #121212; /* Sesuaikan dengan warna background card Anda */
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    width: 90%;
    max-width: 900px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0,0,0,0.7);
    overflow: hidden;
}

.modal-content .history-container {
    overflow-y: auto;
    max-height: calc(80vh - 60px); /* Menyisakan ruang untuk header */
}


/* --- NAVBAR ACTIONS & HEADER STYLES --- */
.nav-actions {
    display: flex;
    align-items: center;
    gap: 10px; /* Jarak konsisten antar elemen */
}

/* Badge Styling (Ext & Status) */
.nav-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap; /* Mencegah teks turun ke baris baru */
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.03);
    color: #e4e4e7;
    height: 34px; /* Tinggi disamakan dengan tombol */
    box-sizing: border-box;
}

.nav-badge.ext-badge {
    font-family: 'Fira Code', monospace;
}

/* Variasi Warna Status */
.status-badge.offline {
    border-color: rgba(239, 68, 68, 0.3);
    background: rgba(239, 68, 68, 0.05);
    color: #ef4444;
}
.status-badge.offline .status-dot { 
    background: #ef4444; 
}

.status-badge.online {
    border-color: rgba(16, 185, 129, 0.4);
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}
.status-badge.online .status-dot {
    background: #10b981;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    animation: pulse-green 2s infinite; /* Menjalankan animasi berdenyut */
}

/* Animasi Titik Berdenyut (Pulsing) */
@keyframes pulse-green {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

/* Garis Pemisah (Divider) */
.nav-divider {
    width: 1px;
    height: 20px;
    background: rgba(255, 255, 255, 0.15);
    margin: 0 4px;
}

/* Styling Tombol Baru */
.btn-action {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    height: 34px;
    white-space: nowrap;
}

.btn-history {
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.3);
    color: #60a5fa; /* Biru terang */
}
.btn-history:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: rgba(59, 130, 246, 0.5);
    transform: translateY(-1px);
}

.btn-danger {
    background: transparent;
    border-color: rgba(239, 68, 68, 0.3);
    color: #ef4444; /* Merah */
}
.btn-danger:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.5);
    transform: translateY(-1px);
}


/* --- NAV BRAND & LOGO STYLES --- */
.nav-brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

/* Kotak Logo Modern dengan efek Float */
.brand-logo-modern {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(37, 99, 235, 0.02));
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 10px; /* Sedikit lebih melengkung */
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.15);
    animation: float-logo 3.5s ease-in-out infinite; /* Animasi naik-turun halus */
}

/* Keyframes untuk animasi logo */
@keyframes float-logo {
    0% { transform: translateY(0px); box-shadow: 0 0 15px rgba(59, 130, 246, 0.15); }
    50% { transform: translateY(-3px); box-shadow: 0 6px 20px rgba(59, 130, 246, 0.3); }
    100% { transform: translateY(0px); box-shadow: 0 0 15px rgba(59, 130, 246, 0.15); }
}

/* Tipografi Teks Header */
.brand-text {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-name {
    font-size: 1.2rem;
    font-weight: 700;
    color: #f4f4f5; /* Putih terang */
    letter-spacing: 0.5px;
    font-family: 'Inter', sans-serif;
}

.brand-name .brand-sub {
    font-weight: 400; /* Tipis untuk memberikan kontras */
    color: #a1a1aa; /* Abu-abu redup */
}

/* Badge Mode Testing */
.brand-badge-testing {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 4px 8px;
    background: linear-gradient(90deg, rgba(245, 158, 11, 0.15), rgba(217, 119, 6, 0.05));
    color: #fbbf24; /* Kuning/Oranye khas peringatan */
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 4px;
    letter-spacing: 1px;
    margin-top: 2px;
}

/* ==========================================
   📱 RESPONSIVE DESIGN (MOBILE & TABLET)
   ========================================== */
@media screen and (max-width: 768px) {
    /* 1. Navbar Lebih Compact & Anti-Overlap */
    .navbar {
        flex-direction: column;
        padding: 15px;
        gap: 15px;
        height: auto; /* SANGAT PENTING: Membatalkan tinggi fixed 64px dari desktop */
    }

    .nav-brand {
        width: 100%;
        justify-content: flex-start;
    }

    /* Grid tombol 2 kolom */
    .nav-actions {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .nav-divider { display: none; }

    .nav-badge, .btn-action {
        width: 100%;
        margin: 0;
        justify-content: center;
        height: 38px; /* Ditinggikan sedikit agar teks tidak sesak & mudah ditap */
        font-size: 0.8rem;
        padding: 0 5px;
    }

    /* 2. Grid Container Menjadi Scrollable Flex */
    .grid-container {
        display: flex;
        flex-direction: column;
        padding: 15px;
        gap: 15px;
        height: auto; /* Batalkan height calc() dari desktop */
        flex: 1; /* Otomatis mengisi sisa ruang di bawah navbar */
        overflow-y: auto; /* Container bisa discroll secara utuh jika isinya panjang */
    }

    .grid-item {
        width: 100%;
        flex-shrink: 0; /* Mencegah panel menjadi gepeng */
    }

    /* 3. Panel Log & Dashboard */
    .panel-log {
        min-height: 250px; /* Pastikan konsol log cukup luas dan langsung terlihat */
        display: flex;
        flex-direction: column;
    }

    .log-content {
        flex: 1;
        overflow-y: auto;
    }

    /* 4. Pemadatan Panel */
    .panel-header { padding: 10px 15px; }
    .panel-content { padding: 15px; }
    
    .network-card { margin-bottom: 15px; }
    .network-grid { gap: 10px; padding: 12px; }
    .net-label { font-size: 0.65rem; }
    .net-value { font-size: 0.75rem; }

    .action-card { padding: 15px; }
    .action-card > div { flex-direction: column; gap: 10px; } /* Tombol call turun ke bawah */
    #btn-trigger-call { width: 100%; }

    /* 5. Modal History */
    .modal-content {
        width: 95%;
        max-height: 90vh;
    }
    .history-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .history-table th, .history-table td {
        white-space: nowrap;
        font-size: 0.8rem;
        padding: 10px;
    }

    /* Posisi Widget khusus di HP */
    #call-widget-app {
        bottom: 20px !important;
        right: 20px !important;
    }

}

/* ==========================================
   📱 RESPONSIVE DESIGN (VERY SMALL MOBILE)
   ========================================== */
@media screen and (max-width: 480px) {
    .brand-name { font-size: 1.05rem; }
    .brand-badge-testing {
        font-size: 0.55rem;
        padding: 2px 6px;
    }
    
    /* Jika layar HP sangat kecil/sempit, jadikan 1 kolom saja agar teks tidak terpotong */
    .nav-actions {
        grid-template-columns: 1fr;
    }



}


/* WIDGET VENDOR OVERRIDE (MEMPERBAIKI POSISI) */
/* Target langsung ke elemen '.widget' di dalam container */
#call-widget-app .widget.position-bottom.position-right {
    bottom: 50px !important; /* Menaikkan tombol ke atas (sesuaikan angka jika kurang) */
    right: 50px !important;  /* Menggeser tombol ke kiri (menuju posisi bulatan merah) */
    z-index: 99999 !important;
}

/* Opsional: Penyesuaian jarak khusus saat di layar HP */
@media screen and (max-width: 768px) {
    #call-widget-app .widget.position-bottom.position-right {
        bottom: 25px !important;
        right: 25px !important;
    }
}

/* Styling khusus Checkbox Ingat Saya */
.checkbox-group {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 1.5rem;
}

.checkbox-group input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--primary); /* Menyesuaikan warna centang dengan tema biru */
}

.checkbox-group label {
    margin-bottom: 0 !important; /* Menimpa margin-bottom bawaan label form-group */
    cursor: pointer;
    user-select: none;
}