/* css/style.css */

:root {
    /* --- DARK MODE (DEFAULT) --- */
    --bg-core: #050b14;
    --bg-glass: rgba(16, 23, 42, 0.7);
    --border-glass: rgba(56, 189, 248, 0.2);
    --shadow-glass: 0 8px 32px rgba(0,0,0,0.5);
    
    --text-main: #f1f5f9;
    --text-dim: #94a3b8;
    --text-accent: #0ea5e9;

    --card-inner-bg: rgba(255,255,255,0.03);
    --table-stripe: rgba(255,255,255,0.02);
    --table-hover: rgba(255,255,255,0.05);

    /* Neon Colors */
    --neon-blue: #0ea5e9;
    --neon-red: #f43f5e;
    --neon-amber: #f59e0b;
    --neon-green: #10b981;

    /* Dimensions */
    --header-h: 70px;
    --footer-h: 30px;
    --sidebar-w: 280px;
    --gap: 16px;
}

/* --- LIGHT MODE VARIABLES --- */
[data-theme="light"] {
    --bg-core: #f0f2f5;
    --bg-glass: rgba(255, 255, 255, 0.85);
    --border-glass: rgba(203, 213, 225, 0.6);
    --shadow-glass: 0 4px 20px rgba(0,0,0,0.05);
    
    --text-main: #1e293b;
    --text-dim: #64748b;
    --text-accent: #0284c7;

    --card-inner-bg: rgba(241, 245, 249, 0.8);
    --table-stripe: rgba(0,0,0,0.02);
    --table-hover: rgba(0,0,0,0.04);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-core);
    background-image: radial-gradient(circle at 50% 0%, var(--border-glass), transparent 40%);
    color: var(--text-main);
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    display: flex; flex-direction: column;
    transition: background 0.3s, color 0.3s;
}

[v-cloak] { display: none; }
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-thumb { background: var(--text-dim); border-radius: 2px; }

/* --- 1. HEADER --- */
.hud-header {
    height: var(--header-h);
    display: flex; justify-content: space-between; align-items: center;
    padding: 0 24px;
    border-bottom: 1px solid var(--border-glass);
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    z-index: 50;
    flex-shrink: 0;
}
.header-center { text-align: center; }
.header-title { font-size: 1.1rem; font-weight: 800; letter-spacing: 2px; margin: 0; color: var(--text-main); text-shadow: 0 0 10px var(--border-glass); }
.header-sub { font-size: 0.75rem; color: var(--text-accent); font-weight: 600; letter-spacing: 1px; margin-top: 2px; }
.header-right { display: flex; align-items: center; gap: 16px; }
.clock-box { text-align: right; line-height: 1.2; }
.clock-time { font-family: 'Courier Prime', monospace; font-size: 1.2rem; font-weight: 700; }
.clock-date { font-size: 0.65rem; color: var(--text-dim); text-transform: uppercase; font-weight: 600; }
.theme-btn {
    background: var(--card-inner-bg); border: 1px solid var(--border-glass);
    color: var(--text-main); width: 36px; height: 36px; border-radius: 50%;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
}
.theme-btn:hover { background: var(--border-glass); transform: rotate(15deg); }

/* --- 2. LAYOUT GRID --- */
.hud-grid {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    gap: var(--gap);
    padding: var(--gap);
    height: calc(100vh - var(--header-h) - var(--footer-h));
    max-width: 1920px; margin: 0 auto; width: 100%;
}

.glass-panel {
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    box-shadow: var(--shadow-glass);
    display: flex; flex-direction: column;
    overflow: hidden; backdrop-filter: blur(8px);
}

.panel-head {
    padding: 10px 16px; border-bottom: 1px solid var(--border-glass);
    background: var(--card-inner-bg); display: flex; justify-content: space-between; align-items: center;
    flex-shrink: 0;
}
.panel-title { font-size: 0.8rem; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; }

/* --- 3. SIDEBAR FIX --- */
.sidebar-section { 
    display: flex; 
    flex-direction: column; 
    overflow: hidden; 
    height: 100%; 
    gap: var(--gap); /* Gunakan gap grid */
}

/* Fix Trafo Box: Tidak boleh shrink, auto height */
.trafo-box {
    flex: 0 0 auto; /* Don't grow, don't shrink */
    min-height: 140px;
}
/* Fix Text Overflow di Trafo Box */
.trafo-content {
    word-wrap: break-word;
    white-space: normal;
    overflow-wrap: break-word;
    padding: 1rem;
    text-align: center;
}

/* Fix PMT Box: Ambil sisa ruang */
.pmt-box {
    flex: 1 1 auto; 
    min-height: 0; /* CRITICAL for nested scroll */
    display: flex;
    flex-direction: column;
}

.pmt-list { 
    overflow-y: auto; 
    flex: 1; /* Isi ruang container */
    display: flex; 
    flex-direction: column; 
    gap: 6px; 
    padding: 12px; 
}

.pmt-row {
    display: flex; justify-content: space-between; align-items: center;
    background: var(--card-inner-bg); padding: 6px 10px; border-radius: 6px;
    border: 1px solid var(--border-glass); font-size: 0.75rem;
    flex-shrink: 0;
}
.pmt-label { font-weight: 700; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 80px; }
.pmt-data { display: flex; gap: 2px; }
.p-box { width: 24px; text-align: center; font-family: monospace; font-weight: bold; font-size: 0.7rem; border-radius: 3px; padding: 2px 0; color: #000; }
.p-r { background: var(--neon-red); color: white; }
.p-s { background: var(--neon-amber); color: black; }
.p-t { background: var(--neon-blue); color: white; }
.p-1 { background: var(--card-inner-bg); border: 1px solid var(--neon-amber); color: var(--neon-amber); width: auto; padding: 0 6px; min-width: 40px; }

/* --- 4. MAIN CONTENT --- */
.main-area { display: flex; flex-direction: column; gap: var(--gap); overflow: hidden; height: 100%; }

.tiles-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--gap); flex-shrink: 0; }
.tile-card {
    background: var(--bg-glass); border: 1px solid var(--border-glass); border-radius: 12px; padding: 12px;
    position: relative; overflow: hidden; min-height: 120px; display: flex; flex-direction: column;
}
.tile-head { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; font-weight: 700; margin-bottom: 8px; text-transform: uppercase; }
.tile-body { display: flex; flex-direction: column; gap: 6px; z-index: 2; overflow-y: auto; }
.sub-card { background: var(--card-inner-bg); border-left: 3px solid var(--border-glass); padding: 6px 10px; border-radius: 4px; display: flex; flex-direction: column; }
.sub-label { font-size: 0.65rem; color: var(--text-dim); font-weight: 700; text-transform: uppercase; }
.sub-val { font-size: 0.8rem; color: var(--text-main); font-weight: 600; }

.inspection-panel { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-height: 0; }
.table-wrap { flex: 1; overflow-y: auto; min-height: 0; }
.hud-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.hud-table th { 
    text-align: left; padding: 10px 16px; color: var(--text-dim); font-size: 0.7rem; 
    text-transform: uppercase; border-bottom: 1px solid var(--border-glass);
    position: sticky; top: 0; background: var(--bg-core); z-index: 10;
}
.hud-table td { padding: 8px 16px; border-bottom: 1px solid var(--table-stripe); color: var(--text-main); }
.hud-table tr:hover { background: var(--table-hover); }

.alert-badge {
    font-size: 0.7rem; font-weight: 700; color: var(--neon-red); 
    background: rgba(244, 63, 94, 0.1); border: 1px solid var(--neon-red);
    padding: 4px 10px; border-radius: 20px; display: flex; align-items: center; gap: 6px;
    animation: glow 2s infinite;
}
@keyframes glow { 50% { box-shadow: 0 0 10px rgba(244, 63, 94, 0.3); } }

/* --- 5. FOOTER --- */
.hud-footer {
    height: var(--footer-h); display: flex; justify-content: center; align-items: center;
    font-size: 0.7rem; color: var(--text-dim); border-top: 1px solid var(--border-glass);
    background: var(--bg-glass); gap: 6px; font-weight: 600; flex-shrink: 0;
}

/* RESPONSIVE */
@media (min-width: 768px) and (max-width: 1400px) {
    :root { --header-h: 60px; --sidebar-w: 240px; --gap: 12px; }
    .header-title { font-size: 0.9rem; }
    .pmt-label { max-width: 60px; font-size: 0.7rem; }
    .p-box { width: 20px; font-size: 0.65rem; }
}

@media (max-width: 767px) {
    body { height: auto; overflow-y: auto; }
    .hud-grid { display: flex; flex-direction: column; height: auto; padding-bottom: 60px; }
    .sidebar-section { height: auto; }
    .tiles-grid { grid-template-columns: 1fr; }
    .hud-header { padding: 0 16px; height: 60px; }
    .inspection-panel { min-height: 400px; }
}