/* ============================================ */
/* SANTIAGO CODE STUDIO - NEGRO CARBÓN v10.17   */
/* 🔥 CodeMirror original + Sin scroll horizontal */
/* ============================================ */
 
:root {
    --bg: #0a0b0f;
    --bg-panel: #0e1017;
    --bg-hover: #141720;
    --border: #1a1f2e;
    --text: #c9d1d9;
    --text-dim: #4a5568;
    --text-bright: #e6edf3;
    --accent: #58a6ff;
    --green: #3fb950;
    --green-light: #4ade80;
    --orange: #d2991d;
    --red: #f85149;
    --topbar-height: 38px;
    --subbar-height: 32px;
    --bottombar-height: 52px;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Courier New', monospace;
    --font-system: -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    --safe-bottom: env(safe-area-inset-bottom, 8px);
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
    height: 100%; height: 100dvh; overflow: hidden;
    font-family: var(--font-system); background: var(--bg); color: var(--text);
    display: flex; flex-direction: column;
    user-select: none; -webkit-user-select: none; -webkit-font-smoothing: antialiased;
}

/* ============================================ */
/* BARRA SUPERIOR                                */
/* ============================================ */
#topBar {
    display: flex; align-items: center; justify-content: space-between;
    height: var(--topbar-height); padding: 0 8px;
    background: var(--bg-panel); border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.topbar-left { display: flex; align-items: center; gap: 2px; }
.topbar-title {
    font-size: 13px; font-weight: 600; color: var(--text-bright);
    letter-spacing: 1px; text-transform: uppercase; cursor: help;
}
.icon-btn {
    width: 32px; height: 32px; border: none; background: transparent;
    color: #5a6e8a; border-radius: 6px; cursor: pointer;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
    transition: all 0.15s ease;
}
.icon-btn:active { background: var(--bg-hover); color: #7a8ea8; transform: scale(0.95); }
.icon-btn.accent { color: var(--accent); }

/* ============================================ */
/* BARRA SECUNDARIA (TABS)                       */
/* ============================================ */
#subBar {
    display: flex; align-items: center; height: var(--subbar-height);
    padding: 0 4px; background: var(--bg-panel); border-bottom: 1px solid var(--border);
    flex-shrink: 0; overflow-x: auto; overflow-y: hidden;
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
#subBar::-webkit-scrollbar { display: none; }
.subbar-tabs {
    display: flex; align-items: center; gap: 4px; flex: 1;
    overflow-x: auto; scrollbar-width: none; min-width: 0;
}
.subbar-tabs::-webkit-scrollbar { display: none; }
.subbar-file {
    display: flex; align-items: center; gap: 6px; padding: 3px 8px;
    background: rgba(255,255,255,0.03); border: 1px solid var(--border);
    border-radius: 5px; font-size: 11px; color: #bcc8d6; font-weight: 500;
    white-space: nowrap; flex-shrink: 0; cursor: pointer; transition: all 0.15s ease; max-width: 140px;
}
.subbar-file span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.subbar-file.active { background: rgba(88,166,255,0.12); border-color: var(--accent); color: #fff; }
.subbar-file:active { background: var(--bg-hover); }
.tab-close-btn {
    width: 14px; height: 14px; border: none; background: transparent;
    color: #5a6e8a; cursor: pointer; font-size: 11px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 3px; flex-shrink: 0; transition: all 0.1s ease;
}
.tab-close-btn:hover { color: #fff; background: rgba(255,255,255,0.1); }
.subbar-right { display: flex; align-items: center; gap: 2px; flex-shrink: 0; margin-left: auto; }

/* ============================================ */
/* ÁREA PRINCIPAL                                */
/* ============================================ */
#mainArea { flex: 1; display: flex; overflow: hidden; min-height: 0; background: var(--bg); }
#editorArea { position: relative; flex: 1; overflow: hidden; display: flex; width: 100%; }
#codeEditor { display: none; }

/* ============================================ */
/* BARRA INFERIOR - LIMPIA Y LEGIBLE             */
/* ============================================ */
#bottomBar {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    height: var(--bottombar-height); padding: 8px 10px;
    padding-bottom: calc(8px + var(--safe-bottom));
    background: var(--bg-panel); border-top: 1px solid var(--border); flex-shrink: 0;
}
.bottom-btn {
    width: 36px; height: 36px; border: none; background: transparent;
    color: #8a9ab0; border-radius: 8px; cursor: pointer;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
    transition: all 0.15s ease; position: relative; margin-bottom: 16px;
}
.bottom-btn svg { width: 18px; height: 18px; }
.bottom-btn:active { color: #58a6ff; transform: scale(0.93); }
.bottom-btn.accent { color: #58a6ff; }
.bottom-btn.accent-green { color: #4ade80; }
.bottom-btn.accent-green:active { color: #6ee7a0; }
.btn-label {
    position: absolute; bottom: -18px; left: 50%; transform: translateX(-50%);
    font-size: 9px; color: #a0b0c0; white-space: nowrap; pointer-events: none;
    font-weight: 600; letter-spacing: 0.4px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.9);
}

/* ============================================ */
/* SCROLLBAR                                     */
/* ============================================ */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ============================================ */
/* PANEL LATERAL                                 */
/* ============================================ */
.sidebar-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 90;
    opacity: 1; transition: opacity 0.25s ease;
}
.sidebar-overlay.hidden { opacity: 0; pointer-events: none; }
.sidebar {
    position: fixed; left: -90vw; top: 0; width: min(340px, 88vw);
    height: 100%; height: 100dvh; background: var(--bg-panel); z-index: 100;
    display: flex; flex-direction: column; border-right: 2px solid #1a1f2e;
    transition: left 0.25s cubic-bezier(0.4,0,0.2,1); box-shadow: 4px 0 20px rgba(0,0,0,0.5);
}
.sidebar.open { left: 0; }
.sidebar-header {
    display: flex; align-items: center; justify-content: space-around;
    gap: 10px; padding: 16px 14px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.sidebar-header-btn {
    width: 48px; height: 48px; border: none; background: transparent;
    color: #7a8ea8; border-radius: 10px; cursor: pointer;
    display: flex; align-items: center; justify-content: center; transition: all 0.15s ease;
}
.sidebar-header-btn svg { width: 26px; height: 26px; }
.sidebar-header-btn.active { color: var(--accent); background: rgba(88,166,255,0.15); }
.sidebar-header-btn:active { background: var(--bg-hover); transform: scale(0.93); }
.sidebar-actions {
    display: flex; align-items: center; justify-content: space-around;
    gap: 8px; padding: 14px 14px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.sidebar-action-btn {
    width: 44px; height: 44px; border: none; background: transparent;
    color: #7a8ea8; border-radius: 10px; cursor: pointer;
    display: flex; align-items: center; justify-content: center; transition: all 0.15s ease; position: relative;
}
.sidebar-action-btn svg { width: 24px; height: 24px; }
.sidebar-action-btn:active { background: var(--bg-hover); color: var(--accent); transform: scale(0.93); }
.sidebar-tree { flex: 1; overflow-y: auto; padding: 8px 0; }
.tree-item {
    display: flex; align-items: center; gap: 10px; padding: 8px 14px;
    cursor: pointer; transition: background 0.1s ease; font-size: 14px;
    color: #bcc8d6; border-radius: 6px; margin: 1px 6px; min-height: 40px;
}
.tree-item:active { background: var(--bg-hover); }
.tree-item.active { background: rgba(88,166,255,0.1); color: var(--accent); }
.tree-icon { width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.tree-icon svg { width: 22px; height: 22px; }
.file-icon-large { width: 26px; height: 26px; }
.file-icon-large svg { width: 24px; height: 24px; }
.tree-name {
    flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    font-size: 14px; font-weight: 500; color: #e6edf3;
}
.tree-chevron { flex-shrink: 0; color: #5a6e8a; opacity: 0.8; transition: transform 0.2s ease; }
.tree-chevron svg { width: 18px; height: 18px; }
.tree-chevron.expanded { transform: rotate(180deg); }
.folder .tree-name { font-weight: 600; color: var(--orange); font-size: 14px; }
.tree-dots {
    width: 36px; height: 36px; border: none; background: transparent;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    border-radius: 8px; flex-shrink: 0; opacity: 0.7; transition: all 0.15s ease; margin-left: auto;
}
.tree-dots svg { width: 22px; height: 22px; }
.tree-dots:active { opacity: 1; background: rgba(255,255,255,0.08); }
.tree-empty {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 60px 16px; color: var(--text-dim); text-align: center;
}
.tree-empty svg { width: 56px; height: 56px; margin-bottom: 20px; color: #5a6e8a; opacity: 0.5; }
.tree-empty p { font-size: 15px; margin-bottom: 8px; color: #bcc8d6; }
.tree-empty span { font-size: 13px; opacity: 0.6; }
.sidebar-footer { padding: 12px 14px; border-top: 1px solid var(--border); flex-shrink: 0; }
.sidebar-footer-btn {
    width: 100%; height: 48px; border: 1px dashed rgba(255,255,255,0.2);
    background: transparent; color: #bcc8d6; border-radius: 12px; cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 10px;
    font-size: 15px; font-family: inherit; transition: all 0.15s ease;
}
.sidebar-footer-btn svg { width: 22px; height: 22px; color: #bcc8d6; }
.sidebar-footer-btn:active { background: var(--bg-hover); color: var(--accent); border-color: var(--accent); }

/* ============================================ */
/* MODAL CONTEXTUAL                               */
/* ============================================ */
.modal-overlay {
    position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,0.5);
    display: flex; align-items: flex-start; justify-content: flex-start;
    padding: 20px; transition: opacity 0.2s ease;
}
.modal-overlay.hidden { opacity: 0; pointer-events: none; }
.modal-box {
    background: var(--bg-panel); backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px); border: 1px solid var(--border);
    border-radius: 16px; min-width: 240px; max-width: 300px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.6); overflow: hidden;
    animation: modalIn 0.2s ease;
}
@keyframes modalIn {
    from { opacity: 0; transform: translateY(-10px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 15px; font-weight: 600; color: #e6edf3; }
.modal-close {
    width: 32px; height: 32px; border: none; background: transparent;
    color: #5a6e8a; border-radius: 8px; cursor: pointer;
    display: flex; align-items: center; justify-content: center; opacity: 0.7; transition: all 0.15s ease;
}
.modal-close:active { opacity: 1; background: rgba(255,255,255,0.08); }
.modal-list { padding: 6px; }
.modal-item {
    display: flex; align-items: center; gap: 14px; padding: 13px 14px;
    border-radius: 10px; color: #e6edf3; font-size: 14px; cursor: pointer;
    width: 100%; border: none; background: none; text-align: left;
    font-family: inherit; transition: all 0.1s ease;
}
.modal-item svg { flex-shrink: 0; }
.modal-item:active { background: rgba(88,166,255,0.15); }
.modal-item.danger { color: #f85149; }
.modal-item.danger:active { background: rgba(248,81,73,0.15); }

/* ============================================ */
/* CODEMIRROR - TEMA ORIGINAL + SIN SCROLL       */
/* ============================================ */
.CodeMirror {
    height: 100% !important;
    font-family: var(--font-mono) !important;
    font-size: 13px !important;
    line-height: 1.6 !important;
}
.CodeMirror-scroll {
    overflow-x: hidden !important;
}
.CodeMirror pre.CodeMirror-line,
.CodeMirror pre.CodeMirror-line-like {
    white-space: pre-wrap !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
}
.CodeMirror-lines { 
    padding: 10px 16px 10px 8px !important; 
}

/* ============================================ */
/* INDICADOR DE PROFUNDIDAD                      */
/* ============================================ */
#depthIndicator {
    position: absolute; right: 4px; top: 0; width: 12px; height: 100%;
    font-family: var(--font-mono); font-size: 8px; color: var(--border);
    text-align: center; padding-top: 14px; pointer-events: none;
    z-index: 1; white-space: pre; line-height: 1.7; letter-spacing: -1px;
}

/* ============================================ */
/* RESPONSIVE                                    */
/* ============================================ */
@media (max-width: 360px) {
    #bottomBar { gap: 4px; padding: 6px 4px; }
    .bottom-btn { width: 30px; height: 30px; }
    .bottom-btn svg { width: 16px; height: 16px; }
    .btn-label { font-size: 7px; bottom: -15px; }
    .subbar-file { font-size: 10px; padding: 2px 6px; max-width: 100px; }
}