/* ============================================================
   SANTIAGO MARKET - MINIFICADOR PRO V21
   Diseño profesional | Por: DARIEN TATTOO
   ============================================================ */

/* ======================== VARIABLES CSS ======================== */
:root {
    --bg-dark: #0a0b0f;
    --card-dark: #12141c;
    --accent: #00ff87;
    --accent-hover: #00e074;
    --accent-dim: rgba(0,255,135,0.08);
    --text-main: #e8eaf0;
    --text-muted: #6b6f7e;
    --border: #1e2130;
    --border-bright: #2a2d3a;
    --sidebar-bg: #0d0f17;
    --danger: #ff4a6e;
    --warning: #ffb347;
    --success: #00ff87;
    --info: #3b82f6;
    --backup: #8b5cf6;
}

/* ======================== RESET GLOBAL ======================== */
* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    margin: 0;
    padding: 0;
}

/* ======================== BODY ======================== */
body {
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    margin: 0;
    padding: 16px 12px 32px;
    min-height: 100vh;
}

/* Fondo de cuadrícula sutil */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: linear-gradient(rgba(0,255,135,0.02) 1px, transparent 1px),
                      linear-gradient(90deg, rgba(0,255,135,0.02) 1px, transparent 1px);
    background-size: 40px 40px;
    pointer-events: none;
    z-index: 0;
}

/* ======================== CONTAINER ======================== */
.container {
    max-width: 1400px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

/* ======================== HEADER ======================== */
header {
    text-align: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

header h1 {
    color: var(--accent);
    margin: 0 0 4px;
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: 2px;
    text-shadow: 0 0 40px rgba(0,255,135,0.25);
}

header p {
    color: var(--text-muted);
    margin: 0;
    font-size: 0.7rem;
    font-family: monospace;
}

/* ======================== BOTONES DE ACCIÓN ======================== */
.top-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.btn-settings-trigger, .btn-backup-trigger, .btn-export-trigger {
    background: linear-gradient(135deg, #181a25, #1a1c28);
    color: var(--text-main);
    border: 1px solid var(--accent);
    padding: 10px 18px;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 10px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.btn-settings-trigger:hover, .btn-backup-trigger:hover, .btn-export-trigger:hover {
    background: var(--accent-dim);
    border-color: var(--accent);
    color: var(--accent);
    transform: translateY(-2px);
}

.btn-backup-trigger {
    border-color: var(--backup);
}

.btn-backup-trigger:hover {
    background: rgba(139,92,245,0.1);
    border-color: var(--backup);
    color: var(--backup);
}

.btn-export-trigger {
    border-color: var(--info);
}

.btn-export-trigger:hover {
    background: rgba(59,130,246,0.1);
    border-color: var(--info);
    color: var(--info);
}

/* ======================== GRID PRINCIPAL ======================== */
.grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

@media (max-width: 950px) {
    .grid {
        grid-template-columns: 1fr;
    }
}

/* ======================== PANELES ======================== */
.panel {
    background: var(--card-dark);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.panel h2 {
    font-size: 0.85rem;
    font-family: monospace;
    margin: 0 0 14px;
    color: var(--accent);
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ======================== ZONA DE ARCHIVOS ======================== */
.file-selector {
    border: 2px dashed var(--border-bright);
    padding: 20px 12px;
    text-align: center;
    border-radius: 12px;
    cursor: pointer;
    margin-bottom: 14px;
    background: rgba(255,255,255,0.01);
    transition: all 0.2s;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.file-selector:hover, .file-selector.dragover {
    border-color: var(--accent);
    background: var(--accent-dim);
    color: var(--accent);
}

/* ======================== LISTA DE ARCHIVOS ======================== */
.file-list {
    height: 260px;
    overflow-y: auto;
    background: #07080d;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px;
    font-family: monospace;
    font-size: 0.7rem;
    scrollbar-width: thin;
    scrollbar-color: var(--border-bright) transparent;
}

.file-list::-webkit-scrollbar {
    width: 4px;
}

.file-list::-webkit-scrollbar-track {
    background: transparent;
}

.file-list::-webkit-scrollbar-thumb {
    background: var(--border-bright);
    border-radius: 4px;
}

.file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 6px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    gap: 6px;
}

.file-item.indexed {
    color: var(--accent);
}

.file-badge {
    background: #1c1f2e;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.6rem;
}

.file-size {
    color: var(--text-muted);
    font-size: 0.6rem;
    margin-left: auto;
}

.file-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.8rem;
    padding: 0 4px;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.file-remove:hover {
    opacity: 1;
    color: var(--danger);
}

/* ======================== TEXTAREA ======================== */
textarea {
    width: 100%;
    height: 260px;
    background: #05060a;
    color: #00e87a;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    font-family: 'Courier New', monospace;
    font-size: 0.7rem;
    resize: vertical;
    line-height: 1.4;
    transition: border-color 0.2s;
    outline: none;
}

textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0,255,135,0.1);
}

/* ======================== BOTONES GENERALES ======================== */
.btn {
    background: var(--accent);
    color: #05080a;
    border: none;
    padding: 12px 16px;
    font-size: 0.85rem;
    font-weight: 800;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
}

.btn:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,255,135,0.2);
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: transparent;
    color: var(--text-main);
    border: 1px solid var(--border-bright);
}

.btn-secondary:hover {
    background: var(--border-bright);
    color: var(--accent);
    box-shadow: none;
}

.btn-backup {
    background: var(--backup);
    color: white;
}

.btn-backup:hover {
    background: #7c3aed;
}

.btn-clear {
    background: transparent;
    color: var(--danger);
    border: 1px solid rgba(255,74,110,0.3);
    padding: 4px 8px;
    font-size: 0.65rem;
    font-family: monospace;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-clear:hover {
    background: rgba(255,74,110,0.1);
}

.button-group {
    display: flex;
    gap: 10px;
    margin-top: 12px;
    flex-wrap: wrap;
}

/* ======================== STATUS ======================== */
.status {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 8px;
    font-family: monospace;
    min-height: 1.2em;
}

.status.ok {
    color: var(--accent);
}

.status.err {
    color: var(--danger);
}

/* ======================== STATS ROW ======================== */
.stats-row {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.stat-box {
    flex: 1;
    background: #07080d;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 8px;
    text-align: center;
}

.stat-box .stat-val {
    font-family: monospace;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--accent);
}

.stat-box .stat-lbl {
    font-size: 0.55rem;
    color: var(--text-muted);
}

/* ======================== MODAL PARA NOMBRE DE CARPETA ======================== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.9);
    backdrop-filter: blur(8px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--card-dark);
    border: 1px solid var(--accent);
    border-radius: 20px;
    padding: 24px;
    width: 320px;
    max-width: 90vw;
    text-align: center;
}

.modal h3 {
    color: var(--accent);
    margin: 0 0 16px;
}

.modal input {
    width: 100%;
    padding: 12px;
    background: #05060a;
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-main);
    font-family: monospace;
    margin-bottom: 16px;
    outline: none;
}

.modal input:focus {
    border-color: var(--accent);
}

.modal-buttons {
    display: flex;
    gap: 10px;
}

.modal-buttons button {
    flex: 1;
    padding: 10px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-weight: bold;
}

.btn-modal-confirm {
    background: var(--accent);
    color: #05080a;
}

.btn-modal-cancel {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
}
/* ======================== OVERLAY ======================== */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(4px);
    z-index: 997;
}

.sidebar-overlay.active {
    display: block;
}

/* ======================== SIDEBAR PRINCIPAL ======================== */
.sidebar {
    position: fixed;
    top: 0;
    right: -480px;
    width: 460px;
    max-width: 90vw;
    height: 100%;
    background: var(--sidebar-bg);
    border-left: 1px solid var(--border);
    z-index: 998;
    transition: right 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar.open {
    right: 0;
}

.sidebar-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--sidebar-bg);
    position: sticky;
    top: 0;
    z-index: 10;
}

.sidebar-header h3 {
    margin: 0;
    color: var(--accent);
    font-size: 1.1rem;
    font-family: monospace;
}

.btn-close-sidebar {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s;
}

.btn-close-sidebar:hover {
    color: var(--danger);
    background: rgba(255,74,110,0.1);
}

.sidebar-content {
    padding: 20px;
    flex: 1;
}

/* ======================== SECCIONES DE CONFIGURACIÓN ======================== */
.config-section {
    margin-bottom: 28px;
    background: rgba(255,255,255,0.02);
    border-radius: 12px;
    padding: 12px;
    border: 1px solid var(--border);
}

.config-section h4 {
    margin: 0 0 12px;
    font-size: 0.75rem;
    color: var(--accent);
    font-family: monospace;
    display: flex;
    align-items: center;
    gap: 8px;
}

.option-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 4px;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    font-size: 0.75rem;
}

.option-row label:first-child {
    color: var(--text-muted);
    font-family: monospace;
}

.option-desc {
    font-size: 0.6rem;
    color: #4a4f62;
    margin-left: 6px;
}

/* ======================== SWITCH TOGGLE ======================== */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #1c1f2e;
    border: 1px solid var(--border-bright);
    transition: .25s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background: #6b6f7e;
    transition: .25s;
    border-radius: 50%;
}

input:checked + .slider {
    background: var(--accent);
}

input:checked + .slider:before {
    transform: translateX(19px);
    background: #05080a;
}

/* ======================== RADIO GROUP ======================== */
.radio-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 8px;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    background: rgba(255,255,255,0.02);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.radio-option:hover {
    background: rgba(0,255,135,0.05);
}

.radio-option input[type="radio"] {
    accent-color: var(--accent);
    width: 16px;
    height: 16px;
}

.radio-option label {
    flex: 1;
    cursor: pointer;
    font-size: 0.75rem;
}

.radio-desc {
    font-size: 0.6rem;
    color: var(--text-muted);
}

/* ======================== SIDEBAR FOOTER ======================== */
.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    background: var(--sidebar-bg);
    position: sticky;
    bottom: 0;
}

/* ======================== PANEL DE BACKUPS ======================== */
.backup-panel {
    position: fixed;
    top: 0;
    right: -500px;
    width: 480px;
    max-width: 95vw;
    height: 100%;
    background: var(--sidebar-bg);
    border-left: 1px solid var(--border);
    z-index: 1000;
    transition: right 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.backup-panel.open {
    right: 0;
}

.backup-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--sidebar-bg);
    position: sticky;
    top: 0;
}

.backup-header h3 {
    margin: 0;
    color: var(--backup);
    font-size: 1.1rem;
    font-family: monospace;
}

.backup-content {
    padding: 20px;
    flex: 1;
}

.backup-item {
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 12px;
}

.backup-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    flex-wrap: wrap;
    gap: 8px;
}

.backup-name {
    font-family: monospace;
    font-weight: bold;
    color: var(--backup);
    font-size: 0.8rem;
}

.backup-date {
    font-size: 0.65rem;
    color: var(--text-muted);
}

.backup-type {
    font-size: 0.6rem;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--accent-dim);
    color: var(--accent);
}

.backup-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.backup-actions button {
    padding: 4px 10px;
    font-size: 0.7rem;
    border-radius: 6px;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.btn-restore {
    background: var(--info);
    color: white;
}

.btn-restore:hover {
    background: #2563eb;
}

.btn-export {
    background: var(--backup);
    color: white;
}

.btn-export:hover {
    background: #7c3aed;
}

.btn-delete-backup {
    background: var(--danger);
    color: white;
}

.btn-delete-backup:hover {
    background: #e11d48;
}

.empty-backups {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

/* ======================== BADGES ======================== */
.badge-pro {
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    color: #05080a;
    font-size: 0.6rem;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: bold;
    margin-left: 8px;
}

.btn-reset-default {
    background: var(--warning);
    color: #05080a;
    margin-top: 8px;
}

/* ======================== SCROLLBAR GLOBAL ======================== */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-bright);
    border-radius: 4px;
}