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

body { 
    font-family: monospace; 
    background: #1e1e1e; 
    color: #d4d4d4; 
    display: flex; 
    flex-direction: column; 
    height: 100vh; 
    height: 100dvh; 
    overflow: hidden; 
    -webkit-tap-highlight-color: transparent;
}

header { 
    background: #252526; 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    padding: 8px 12px; 
    border-bottom: 1px solid #333; 
    height: 45px; 
    flex-shrink: 0;
    z-index: 20;
}

.nav-left, .nav-right { display: flex; gap: 8px; align-items: center; }

button { 
    background: #333; 
    color: #fff; 
    border: none; 
    padding: 6px 10px; 
    border-radius: 4px; 
    cursor: pointer; 
    font-size: 13px; 
    user-select: none;
}
button:active { background: #0e639c; }

/* Dropdowns */
.dropdown-container {
    position: relative;
    display: inline-block;
}

.dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    background: #252526;
    border: 1px solid #454545;
    z-index: 1000;
    min-width: 220px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    border-radius: 6px;
    overflow: hidden;
}

.dropdown-item {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 13px;
    color: #d4d4d4;
    border-bottom: 1px solid #333;
    transition: background 0.2s;
}

.dropdown-item:last-child { border-bottom: none; }
.dropdown-item:hover { background: #094771; color: #fff; }

.main-container { 
    display: flex; 
    flex: 1; 
    overflow: hidden; 
    position: relative; 
}

/* Panel del Explorador de Archivos */
aside { 
    width: 280px; 
    background: #252526; 
    border-right: 1px solid #333; 
    display: flex; 
    flex-direction: column; 
    transition: transform 0.3s ease; 
    position: absolute; 
    height: 100%; 
    z-index: 10; 
    left: 0; 
    transform: translateX(-100%); 
}
aside.open { transform: translateX(0); }
@media(min-width: 768px) { aside { position: relative; transform: translateX(0); } }

.sidebar-header { 
    padding: 10px; 
    font-weight: bold; 
    border-bottom: 1px solid #333; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    font-size: 12px; 
    color: #9cdcfe; 
}

.file-tree { overflow-y: auto; flex: 1; padding: 8px; font-size: 13px; }
.tree-item { padding: 6px; cursor: pointer; border-radius: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tree-item:hover { background: #2a2d2e; }
.tree-folder { color: #dcdcaa; font-weight: bold; margin-top: 4px; }
.tree-file { color: #9cdcfe; padding-left: 15px; }

/* Menú Desplegable Flotante (Drawer) */
.drawer-overlay { 
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100vw; 
    height: 100vh; 
    background: rgba(0, 0, 0, 0.6); 
    backdrop-filter: blur(2px);
    z-index: 999; 
    display: none; 
    opacity: 0;
    transition: opacity 0.3s ease;
}
.drawer-overlay.open { display: block; opacity: 1; }

.hamburger-drawer { 
    position: fixed; 
    bottom: 60px; 
    left: 10px; 
    right: 10px; 
    max-width: 400px;
    margin: 0 auto;
    max-height: 55vh; 
    background: #252526; 
    border: 1px solid #3c3c3c;
    border-radius: 12px; 
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    z-index: 1000; 
    transform: translateY(20px) scale(0.95); 
    opacity: 0;
    pointer-events: none;
    transition: transform 0.25s ease, opacity 0.25s ease; 
    display: flex; 
    flex-direction: column; 
}
.hamburger-drawer.open { transform: translateY(0) scale(1); opacity: 1; pointer-events: auto; }

.drawer-header { padding: 14px 16px; border-bottom: 1px solid #333; font-size: 12px; font-weight: bold; color: #4ec9b0; display: flex; justify-content: space-between; align-items: center; }
.drawer-content { overflow-y: auto; padding: 10px; }

.workspace-item { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    padding: 12px; 
    margin-bottom: 6px;
    background: #2d2d2d;
    border: 1px solid transparent;
    cursor: pointer; 
    border-radius: 6px; 
}
.workspace-item:hover { background: #383838; }
.workspace-item.active { background: #1e1e1e; border-color: #4ec9b0; }

/* Menú Contextual */
.context-menu {
    position: fixed;
    background: #252526;
    border: 1px solid #454545;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    z-index: 2000;
    border-radius: 6px;
    padding: 4px 0;
    min-width: 160px;
}
.context-menu div {
    padding: 10px 14px;
    font-size: 12px;
    color: #cccccc;
    cursor: pointer;
}
.context-menu div:hover {
    background: #094771;
    color: #ffffff;
}

/* Área del Editor */
.editor-area { flex: 1; display: flex; flex-direction: column; background: #1e1e1e; overflow: hidden; min-width: 0; }
.tabs-bar { display: flex; background: #2d2d2d; overflow-x: auto; border-bottom: 1px solid #333; height: 35px; align-items: center; flex-shrink: 0; }
.tab { padding: 0 12px; height: 100%; display: flex; align-items: center; gap: 8px; font-size: 12px; border-right: 1px solid #333; cursor: pointer; background: #2d2d2d; color: #858585; white-space: nowrap; }
.tab.active { background: #1e1e1e; color: #ffffff; border-top: 2px solid #0e639c; }
.tab .close-tab { font-size: 10px; padding: 2px; border-radius: 50%; }
.tab .close-tab:hover { background: #444; }

.editor-container {
    display: flex;
    flex: 1;
    overflow: hidden;
    background: #1e1e1e;
    position: relative;
}

.line-numbers {
    width: 45px;
    background: #1e1e1e;
    color: #858585;
    padding-top: 12px;
    padding-right: 6px;
    font-family: monospace;
    font-size: 14px;
    line-height: 1.5;
    text-align: right;
    user-select: none;
    overflow: hidden;
    white-space: pre;
    border-right: 1px solid #333;
}

#codeEditor { 
    flex: 1;
    background: #1e1e1e; 
    color: #d4d4d4; 
    border: none; 
    padding: 12px; 
    font-family: monospace; 
    font-size: 14px; 
    resize: none; 
    outline: none; 
    line-height: 1.5;
    white-space: pre;
    overflow-wrap: normal;
    overflow-x: auto;
}

/* Barra Fija Inferior - Respetando el área segura de Android */
footer { 
    background: #252526; 
    display: flex; 
    justify-content: space-around; 
    align-items: center; 
    padding: 4px 8px; 
    border-top: 1px solid #333; 
    height: 55px; 
    flex-shrink: 0;
    position: relative; 
    z-index: 100; 
    padding-bottom: env(safe-area-inset-bottom, 5px);
}
footer button { 
    background: transparent; 
    padding: 4px 6px; 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    gap: 2px; 
    font-size: 10px; 
    color: #bbb; 
    min-width: 45px;
}
footer button span.icon { font-size: 16px; }
footer button:hover { background: #333; color: #fff; }

#btnMenu {
    background: rgba(78, 201, 176, 0.1);
    border-radius: 6px;
    border: 1px solid rgba(78, 201, 176, 0.2);
    color: #4ec9b0;
}