:root {
    --bg: #f4f5f7;
    --surface: #ffffff;
    --text: #1a1a1a;
    --text-dim: #71717a;
    --primary: #000000;
    --primary-hover: #333333;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --border: #e4e4e7;
    --radius: 16px;
    --radius-sm: 8px;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 0;
    display: flex;
    height: 100vh;
    box-sizing: border-box;
    overflow: hidden;
}

.main-container {
    display: flex;
    flex-direction: row;
    width: 100%;
    height: 100%;
    padding: 15px;
    gap: 15px;
    box-sizing: border-box;
}

/* ─── SECCIÓN PRINCIPAL: ARCHIVOS ─── */
.file-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 25px;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.file-header {
    display: flex;
    gap: 15px;
    align-items: center;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}

.config-btn {
    margin-left: auto;
}

.file-workspace {
    display: flex;
    flex: 1;
    gap: 20px;
    overflow: hidden;
}

.file-sidebar {
    width: 260px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#fileList {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-right: 5px;
}

.file-item {
    padding: 12px 16px;
    background: var(--bg);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text);
    font-weight: 500;
}

.file-item:hover {
    background: var(--surface);
    border-color: var(--border);
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    transform: translateY(-1px);
}

#editorPanel {
    display: flex;
    flex-direction: column;
    gap: 15px;
    flex: 1;
}

#editorFilename {
    flex: 0 0 auto;
    font-weight: 600;
    font-size: 18px;
    border: none;
    background: transparent;
    padding: 5px 0;
}

#editorFilename:focus {
    box-shadow: none;
    border-bottom: 2px solid var(--primary);
    border-radius: 0;
}

textarea {
    padding: 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius-sm);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 14px;
    line-height: 1.6;
    resize: none;
    flex: 1;
    outline: none;
    transition: all 0.2s ease;
}

textarea:focus {
    border-color: var(--primary);
    background: var(--surface);
    box-shadow: 0 0 0 3px rgba(0,0,0,0.03);
}

.editor-controls {
    display: flex;
    gap: 12px;
}

.editor-controls button {
    flex: 1;
}

/* ─── SECCIÓN SECUNDARIA: CHAT ─── */
.chat-section {
    width: 400px;
    display: flex;
    flex-direction: column;
    padding: 25px;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.header {
    display: flex;
    gap: 15px;
    align-items: center;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}

input[type="password"], input[type="text"] {
    padding: 12px 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius-sm);
    flex: 1;
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: all 0.2s ease;
}

input[type="password"]:focus, input[type="text"]:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0,0,0,0.03);
    background: var(--surface);
}

button {
    padding: 12px 20px;
    background: var(--primary);
    color: #ffffff;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    font-family: inherit;
    transition: all 0.2s ease;
    letter-spacing: 0.5px;
}

button:hover { 
    background: var(--primary-hover); 
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

button:active {
    transform: translateY(0);
}

button.active { 
    background: var(--surface); 
    color: var(--primary); 
    border: 2px solid var(--primary);
    padding: 10px 18px; /* Ajuste para compensar el borde */
}

button.danger { 
    background: var(--danger); 
    color: #ffffff; 
}

button.danger:hover {
    background: var(--danger-hover);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

button:disabled { 
    opacity: 0.5; 
    cursor: not-allowed; 
    transform: none;
    box-shadow: none;
}

#chat {
    flex: 1;
    background: var(--bg);
    padding: 20px;
    border-radius: var(--radius-sm);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
}

.msg { 
    max-width: 85%; 
    padding: 14px 18px; 
    line-height: 1.5; 
    word-wrap: break-word;
    border-radius: 18px;
    font-size: 14px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.msg.user { 
    align-self: flex-end; 
    background: var(--primary);
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.msg.user strong {
    color: #ffffff;
    opacity: 0.8;
    font-size: 12px;
}

.msg.gemini { 
    align-self: flex-start; 
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.02);
}

.msg.gemini strong {
    color: var(--text-dim);
    font-size: 12px;
}

.msg.system {
    align-self: center;
    background: transparent;
    color: var(--text-dim);
    font-size: 12px;
    padding: 4px 8px;
    border: none;
}

.controls { 
    display: flex; 
    gap: 12px; 
}

.status { 
    font-size: 12px; 
    color: var(--text-dim); 
    margin-left: auto;
    font-weight: 600;
}

.status-minimal {
    font-size: 13px;
    color: var(--text-dim);
    word-break: break-all;
    font-weight: 500;
}

/* ─── MODAL ─── */
.modal {
    display: none; 
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    background: rgba(255, 255, 255, 0.6); 
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000; 
    justify-content: center; 
    align-items: center;
}

.modal-content {
    background: var(--surface);
    padding: 35px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 420px;
    animation: scaleUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes scaleUp {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.modal-content h3 {
    margin: 0;
    font-size: 1.4em;
    font-weight: 700;
    color: var(--text);
}

.modal-desc {
    font-size: 14px; 
    color: var(--text-dim); 
    margin-top: 0;
    line-height: 1.6;
}

.modal-buttons {
    display: flex;
    gap: 12px;
    margin-top: 10px;
}

.modal-buttons button {
    flex: 1;
}

/* Custom Scrollbar Minimalista */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #d4d4d8;
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-dim);
}
/* --- ESTILOS DEL MENÚ CONTEXTUAL PERSONALIZADO (CLIC DERECHO) --- */
.custom-menu {
    background-color: #252526;
    color: #ffffff;
    border: 1px solid #454545;
    border-radius: 4px;
    padding: 5px 0;
    box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.5);
    font-family: sans-serif;
    font-size: 13px;
    min-width: 150px;
}

.custom-menu div {
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.custom-menu div:hover {
    background-color: #37373d;
    color: #007acc;
}

/* --- ADAPTACIÓN PARA EL MODAL DE PREVISUALIZACIÓN --- */
.preview-content {
    background-color: #1e1e1e !important;
    color: #ffffff !important;
    border: 1px solid #3c3c3c !important;
    border-radius: 6px;
}

.close-preview {
    color: #aaaaaa;
    transition: color 0.2s;
}

.close-preview:hover {
    color: #ff3333;
}