:root {
    --bg-dark: #09090e;
    --bg-darker: #020617;
    --cloud-color: #1a1a2e;
    --cloud-glow: rgba(56, 189, 248, 0.1);
    
    --glass-bg: rgba(30, 41, 59, 0.4);
    --glass-border: rgba(255, 255, 255, 0.05);
    
    --color-text: #f8fafc;
    --color-text-dim: #94a3b8;
    
    --status-online: #22c55e;
    --status-offline: #ef4444;
    --status-deploying: #38bdf8;
    
    --glow-online: 0 0 15px rgba(34, 197, 94, 0.4);
    --glow-offline: 0 0 15px rgba(239, 68, 68, 0.4);
    --glow-deploying: 0 0 15px rgba(56, 189, 248, 0.6);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', sans-serif;
    background: linear-gradient(180deg, var(--bg-dark) 0%, #16222A 100%);
    color: var(--color-text);
    min-height: 100vh;
    height: 100vh; /* Mengunci tinggi browser agar tak scroll luar */
    overflow: hidden; /* Hilangkan scroll body! Panning via JS */
    display: flex;
    flex-direction: column;
}

/* Ambient Cloud Backdrops */
.ambient-cloud {
    position: fixed;
    width: 400px;
    height: 150px;
    background: var(--cloud-color);
    border-radius: 200px;
    filter: blur(50px);
    z-index: 0;
    opacity: 0.6;
    box-shadow: 0 0 150px 80px var(--cloud-glow);
    pointer-events: none;
}
.ambient-cloud:nth-child(1) { top: -5%; left: -10%; animation: floatSlow 20s infinite alternate; }
.ambient-cloud:nth-child(2) { top: 50%; right: -15%; animation: floatSlow 25s infinite alternate-reverse; }

@keyframes floatSlow {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(40px, -20px) scale(1.1); }
}

/* Header & Tabs */
.dashboard-header {
    text-align: center;
    padding: 2rem 1rem 1rem 1rem;
    z-index: 100;
    position: relative;
    background: linear-gradient(180deg, rgba(9, 9, 14, 0.9) 0%, rgba(9, 9, 14, 0) 100%);
    pointer-events: none; /* Biarkan cursor tembus header jika kanvas digeser */
}
.dashboard-header * { pointer-events: auto; } /* Kembalikan pointer untuk tombol */

.title-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 1.5rem;
    position: relative;
}

.cloud-icon { font-size: 2.5rem; filter: drop-shadow(0 0 10px rgba(56, 189, 248, 0.5)); }

.dashboard-header h1 {
    font-size: 2.5rem;
    font-weight: 800;
    background: linear-gradient(90deg, #38bdf8, #818cf8);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logout-btn {
    position: absolute;
    right: 2rem;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ef4444;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}
.logout-btn:hover { background: rgba(239, 68, 68, 0.2); }

/* Navigation Tabs */
.tabs-nav {
    display: inline-flex;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(10px);
    padding: 0.5rem;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    gap: 0.5rem;
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--color-text-dim);
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tab-btn:hover { color: white; }
.tab-btn.active {
    background: linear-gradient(90deg, rgba(56, 189, 248, 0.2), rgba(129, 140, 248, 0.2));
    color: #38bdf8;
    box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.3);
}

/* Contents Wrapper (Full Screen Flex) */
.contents-wrapper {
    flex: 1;
    position: relative;
    z-index: 10;
    width: 100%;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.tab-content { display: none; width: 100%; height: 100%; animation: fadeIn 0.4s ease; }
.tab-content.active { display: block; height: 100%; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Boundary for Tables agar tidak melebar sepull layar */
.table-boundary {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
    height: 100%;
    overflow-y: auto; /* Bisa scroll tabel ke bawah */
}

/* ==================================
   TABLE STYLES FOR LIST VIEWS 
   ================================== */
.table-container {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    overflow: hidden;
    margin-top: 2rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.data-table { width: 100%; border-collapse: collapse; text-align: left; }
.data-table th { background: rgba(15, 23, 42, 0.8); color: var(--color-text-dim); padding: 1.2rem 1.5rem; }
.data-table td { padding: 1.2rem 1.5rem; border-bottom: 1px solid rgba(255, 255, 255, 0.02); }
.data-table tr:hover td { background: rgba(56, 189, 248, 0.05); }

.badge { padding: 0.3rem 0.8rem; border-radius: 20px; font-size: 0.8rem; font-weight: 600; text-transform: uppercase; }
.badge.online { background: rgba(34, 197, 94, 0.1); color: var(--status-online); border: 1px solid rgba(34, 197, 94, 0.3); }
.badge.offline { background: rgba(239, 68, 68, 0.1); color: var(--status-offline); border: 1px solid rgba(239, 68, 68, 0.3); }
.badge.deploying { background: rgba(56, 189, 248, 0.1); color: var(--status-deploying); border: 1px solid rgba(56, 189, 248, 0.3); }


/* ==================================
   CANVAS WHITEBOARD STYLES (Draggable) 
   ================================== */
/* 
    1. topology-wrapper berfungsi seperti lubang kunci (kaca pembesar)
    2. zoom-container adalah kanvas super besarnya yang bergerak di balik lubang tersebut
*/
.topology-wrapper {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0; 
    overflow: hidden; /* Sembunyikan scrollbar standar */
    cursor: grab;
    z-index: 1; /* Di bawah header yg z-index 100 */
}

.topology-wrapper:active {
    cursor: grabbing;
}

.zoom-container {
    position: absolute;
    top: 0; left: 0;
    transform-origin: 0 0;
    will-change: transform;
    pointer-events: none; /* Pointer jatuh langsung ke wrapper atau node */
}

#cables-layer { position: absolute; top: 0; left: 0; pointer-events: none; }
#nodes-container { position: absolute; top: 0; left: 0; }

.cable-path { fill: none; stroke-width: 3; opacity: 0.4; transition: stroke 0.5s ease; }
.cable-flow { fill: none; stroke-width: 4; stroke-linecap: round; stroke-dasharray: 10 20; animation: flowData 2s linear infinite; }
@keyframes flowData { from { stroke-dashoffset: 60; } to { stroke-dashoffset: 0; } }

/* Cloud Node Stylings */
.node {
    position: absolute; transform: translate(-50%, -50%);
    background: var(--glass-bg); backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border); border-radius: 20px;
    padding: 1.25rem; width: 230px; text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    transition: box-shadow 0.3s, border-color 0.3s;
    pointer-events: auto; /* Bisa diklik/hover */
}

/* Matikan efek hover naik turun karena mengganggu sistem grid/kanvas */
.node:hover { background: rgba(30, 41, 59, 0.7); box-shadow: 0 15px 40px rgba(0,0,0,0.7); z-index: 100;}

.node.status-online { border-color: rgba(34, 197, 94, 0.4); box-shadow: var(--glow-online), 0 10px 30px rgba(0,0,0,0.5); }
.node.status-offline { border-color: rgba(239, 68, 68, 0.4); border-style: dashed; opacity: 0.7;}
.node.status-deploying { border-color: rgba(56, 189, 248, 0.4); box-shadow: var(--glow-deploying), 0 10px 30px rgba(0,0,0,0.5); animation: pulseGlow 1.5s infinite alternate; }

.node-icon { font-size: 2.2rem; margin-bottom: 0.5rem; }
.node h3 { font-size: 1.05rem; margin-bottom: 0.5rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;}
.node-ip { font-size: 0.8rem; color: #94a3b8; font-family: monospace; background: rgba(0,0,0,0.3); padding: 3px 6px; border-radius: 5px; margin-bottom: 0.5rem; display: inline-block;}
.node-status-text { font-size: 0.85rem; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 5px;}
.node-uptime { font-size: 0.75rem; color: #cbd5e1; }

.status-online .node-status-text { color: var(--status-online); }
.status-offline .node-status-text { color: var(--status-offline); }
.status-deploying .node-status-text { color: var(--status-deploying); }

/* Root Node Specifics */
.node.root-node { width: 280px; padding: 1.8rem; background: rgba(15, 23, 42, 0.9); border-color: rgba(139, 92, 246, 0.6); box-shadow: 0 0 30px rgba(139, 92, 246, 0.3); }
.node.root-node .node-icon { font-size: 3.5rem; color: #a78bfa; filter: drop-shadow(0 0 10px rgba(167, 139, 250, 0.6)); }

@keyframes pulseGlow {
    from { box-shadow: 0 0 5px rgba(56, 189, 248, 0.4), 0 10px 30px rgba(0,0,0,0.5); border-color: rgba(56, 189, 248, 0.2); }
    to { box-shadow: 0 0 25px rgba(56, 189, 248, 0.9), 0 10px 30px rgba(0,0,0,0.5); border-color: rgba(56, 189, 248, 0.8); }
}

/* ==================================
   ZOOM CONTROLS UI
   ================================== */
.zoom-controls {
    position: absolute;
    bottom: 30px;
    right: 30px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 200;
}

.zoom-controls button {
    width: 45px; height: 45px;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
    backdrop-filter: blur(10px);
}

.zoom-controls button:hover {
    background: rgba(56, 189, 248, 0.8);
    border-color: rgba(56, 189, 248, 1);
    transform: scale(1.1);
}

/* ==================================
   CRUD ADDITIONS & MODALS
   ================================== */
.fab-add-btn {
    position: fixed;
    bottom: 40px;
    right: 100px; /* Di sebelah zoom box */
    width: 65px; height: 65px;
    border-radius: 50%;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: white;
    font-size: 2.5rem;
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 5px 20px rgba(34, 197, 94, 0.6);
    cursor: pointer;
    z-index: 500;
    transition: all 0.3s;
    font-weight: 800;
}

.fab-add-btn:hover {
    transform: scale(1.1) rotate(90deg);
    box-shadow: 0 10px 30px rgba(34, 197, 94, 0.8);
}

.action-buttons {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.btn-edit, .btn-delete {
    padding: 6px 10px;
    border: none; border-radius: 6px;
    cursor: pointer; font-size: 0.85rem; font-weight: bold;
    color: white; transition: 0.2s transform;
}
.btn-edit { background: rgba(56, 189, 248, 0.8); }
.btn-delete { background: rgba(239, 68, 68, 0.8); }
.btn-edit:hover, .btn-delete:hover { transform: translateY(-2px); }

/* Lencana Kematian / Down Badge */
.node-down-badge {
    position: absolute;
    top: -10px;
    right: -10px;
    background: #ef4444;
    color: white;
    font-size: 0.75rem;
    font-weight: 800;
    padding: 4px 8px;
    border-radius: 20px;
    border: 2px solid var(--bg-dark);
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.8);
    animation: flashBadge 2s infinite;
}

@keyframes flashBadge {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Modal Form Styles */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    z-index: 9999; /* Tertinggi */
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0; /* Hidden by default CSS logic */
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.modal-box {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(20px);
    width: 450px;
    max-width: 90%;
    padding: 2rem;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.8);
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.modal-overlay.show .modal-box {
    transform: translateY(0);
}

.modal-box h2 {
    font-size: 1.5rem;
    color: white;
    margin-bottom: 1.5rem;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 10px;
}

.form-group {
    margin-bottom: 1.2rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--color-text-dim);
    margin-bottom: 5px;
    font-weight: 600;
}

.form-group input, .form-group select {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    padding: 10px 15px;
    border-radius: 8px;
    color: white;
    font-family: inherit;
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: #38bdf8;
    background: rgba(0, 0, 0, 0.5);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 2rem;
}

.btn-cancel, .btn-save {
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    font-weight: bold;
    cursor: pointer;
    font-size: 0.95rem;
    transition: background 0.2s;
}

.btn-cancel {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}
.btn-cancel:hover { background: rgba(255, 255, 255, 0.2); }

.btn-save {
    background: #38bdf8;
    color: #020617;
}
.btn-save:hover { background: #0ea5e9; }
