/* --- Variabel Global & Tema --- */
:root {
    --bg-main: #0B0F19;
    --bg-panel: rgba(20, 26, 40, 0.7);
    --border-color: rgba(255, 255, 255, 0.1);
    --primary-color: #2496ED;
    --primary-hover: #1b75bc;
    --success-color: #2EA043;
    --error-color: #F85149;
    --text-main: #E6EDF3;
    --text-muted: #8B949E;
    --font-ui: 'Inter', sans-serif;
    --font-code: 'JetBrains Mono', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: var(--font-ui);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* --- Kustomisasi Scrollbar (UI Enterprise) --- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.2); border-radius: 4px; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.2); }

/* --- Efek Glow Background --- */
.bg-glow {
    position: fixed;
    width: 400px;
    height: 400px;
    border-radius: 50%;
    filter: blur(120px);
    z-index: -1;
    opacity: 0.25;
    pointer-events: none;
}
.blob-1 { top: -100px; left: -100px; background: var(--primary-color); }
.blob-2 { bottom: -100px; right: -100px; background: var(--success-color); }

/* --- Tata Letak Utama --- */
.app-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 25px;
    display: flex;
    flex-direction: column;
    gap: 25px;
    min-height: 100vh; 
}

.glass-panel {
    background: var(--bg-panel);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* --- Header --- */
.app-header { display: flex; justify-content: space-between; align-items: center; padding: 15px 25px; }
.brand { display: flex; align-items: center; gap: 15px; }
.brand i { font-size: 2.5rem; color: var(--primary-color); }
.brand-text h1 { font-size: 1.3rem; font-weight: 700; letter-spacing: 0.5px; margin-bottom: 2px; }
.brand-text span { font-size: 0.85rem; color: var(--text-muted); }

.status-badge {
    display: flex; align-items: center; gap: 8px;
    background: rgba(46, 160, 67, 0.1); color: var(--success-color);
    padding: 6px 14px; border-radius: 20px; font-size: 0.85rem;
    font-weight: 600; border: 1px solid rgba(46, 160, 67, 0.3);
}
.pulse-dot { width: 8px; height: 8px; background-color: var(--success-color); border-radius: 50%; animation: pulse 1.5s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(46, 160, 67, 0.7); } 70% { box-shadow: 0 0 0 10px rgba(46, 160, 67, 0); } 100% { box-shadow: 0 0 0 0 rgba(46, 160, 67, 0); } }

/* --- Grid Kompleks Enterprise --- */
.main-grid {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    grid-template-rows: auto auto auto;
    gap: 25px;
    flex-grow: 1;
}

/* Panel Baris 1: Editor & Metrik */
.editor-panel { grid-column: 1 / 2; grid-row: 1 / 2; display: flex; flex-direction: column; height: 450px; }
.result-panel { grid-column: 2 / 3; grid-row: 1 / 2; display: flex; flex-direction: column; height: 450px; }

/* Panel Baris 2 & 3 (Full Width): Diagram & Logs */
.diagram-panel { grid-column: 1 / 3; grid-row: 2 / 3; display: flex; flex-direction: column; }
.logs-panel { grid-column: 1 / 3; grid-row: 3 / 4; height: 450px; display: flex; flex-direction: column; }

.panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; border-bottom: 1px solid var(--border-color); padding-bottom: 12px; }
.panel-header h2 { font-size: 1.05rem; display: flex; align-items: center; gap: 10px; color: var(--text-muted); font-weight: 600; }

/* --- Area Editor YAML (Scrollable) --- */
.editor-wrapper { display: flex; flex-grow: 1; background: #0d1117; border: 1px solid var(--border-color); border-radius: 8px; overflow: hidden; height: 100%; }
.line-numbers { padding: 18px 12px; background: #010409; color: #484f58; text-align: right; font-family: var(--font-code); font-size: 0.95rem; border-right: 1px solid var(--border-color); user-select: none; overflow: hidden; }
.code-editor { flex-grow: 1; background: transparent; color: #e6edf3; font-family: var(--font-code); font-size: 0.95rem; padding: 18px; border: none; resize: none; outline: none; line-height: 1.6; white-space: pre; overflow: auto; }

.btn-primary { background: var(--primary-color); color: white; border: none; padding: 10px 20px; border-radius: 6px; font-weight: 600; cursor: pointer; transition: all 0.3s ease; display: flex; align-items: center; gap: 8px; font-size: 0.95rem; }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-2px); box-shadow: 0 4px 15px rgba(36, 150, 237, 0.4); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; box-shadow: none; }

/* --- Metrik & Stack Visualizer --- */
.metrics-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-bottom: 25px; }
.metric-card { background: rgba(255,255,255,0.02); border: 1px solid rgba(255,255,255,0.05); padding: 15px; border-radius: 8px; text-align: center; }
.metric-label { display: block; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.5px; }
.metric-value { font-size: 1.3rem; font-weight: 700; font-family: var(--font-code); }
.valid-text { color: var(--success-color); }
.invalid-text { color: var(--error-color); }

.stack-visualizer { flex-grow: 1; display: flex; flex-direction: column; overflow: hidden; }
.stack-visualizer h3 { font-size: 0.95rem; color: var(--text-muted); margin-bottom: 12px; font-weight: 500; }
.stack-container { display: flex; flex-direction: column-reverse; align-items: center; gap: 6px; background: #010409; border: 1px solid var(--border-color); border-radius: 8px; padding: 20px; flex-grow: 1; max-height: 100%; overflow-y: auto; }

.stack-item { background: rgba(36, 150, 237, 0.1); border: 1px solid var(--primary-color); color: var(--primary-color); padding: 8px 25px; border-radius: 6px; font-family: var(--font-code); font-size: 0.95rem; width: 85%; text-align: center; animation: slideIn 0.3s ease-out forwards; }
.stack-item.z0 { background: rgba(139, 148, 158, 0.1); border-color: var(--text-muted); color: var(--text-muted); }
@keyframes slideIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

/* --- Perbaikan Container Mermaid Diagram --- */
.mermaid-container {
    background: #010409;
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 8px;
    padding: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 350px; 
    overflow-x: auto;  
}
.mermaid { width: 100%; display: flex; justify-content: center; }

/* --- Tabel Trace Logs --- */
.table-responsive { overflow-y: auto; flex-grow: 1; border: 1px solid rgba(255,255,255,0.05); border-radius: 8px; background: #010409; }
.logs-table { width: 100%; border-collapse: separate; border-spacing: 0; font-family: var(--font-code); font-size: 0.9rem; }
.logs-table th { position: sticky; top: 0; background: #0d1117; color: var(--text-muted); text-align: left; padding: 16px; border-bottom: 1px solid var(--border-color); font-family: var(--font-ui); font-weight: 600; z-index: 10; }
.logs-table td { padding: 14px 16px; border-bottom: 1px solid rgba(255,255,255,0.03); color: #c9d1d9; }
.logs-table tr:hover td { background: rgba(255,255,255,0.03); }
.empty-state { text-align: center; color: var(--text-muted) !important; font-style: italic; padding: 40px !important; }

/* Tag Indikator Log */
.tag-push { color: #a371f7; background: rgba(163,113,247,0.15); padding: 4px 10px; border-radius: 4px; font-weight: 600; font-size: 0.85rem;}
.tag-pop { color: #f69d50; background: rgba(246,157,80,0.15); padding: 4px 10px; border-radius: 4px; font-weight: 600; font-size: 0.85rem;}
.tag-error { color: var(--error-color); background: rgba(248, 81, 73, 0.15); padding: 4px 10px; border-radius: 4px; font-weight: 600; font-size: 0.85rem;}

/* --- Modifikasi Fitur Lanjutan: Tombol Ekspor & Error Highlight --- */

.btn-secondary {
    background: transparent;
    color: var(--text-main);
    border: 1px solid var(--border-color);
    padding: 6px 14px;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 8px;
}
.btn-secondary:hover:not(:disabled) {
    background: rgba(255,255,255,0.05);
    border-color: var(--text-muted);
}
.btn-secondary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Modifikasi area line-numbers untuk menampung class error */
.line-numbers div {
    padding: 0 4px;
    border-radius: 3px;
    transition: background-color 0.3s ease;
}

/* Efek nyala merah jika baris mengalami kegagalan/ditolak */
.line-error {
    background-color: rgba(248, 81, 73, 0.5);
    color: #ffffff;
    font-weight: bold;
    border-left: 2px solid var(--error-color);
}