/* ==========================================================================
   SQL TABLE LAB - ESTILOS DEDICADOS
   Diseño estilo Microsoft Access & Modern Dark UI
   ========================================================================== */

/* ── Transiciones y Animaciones ── */
.field-row {
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    animation: slideIn 0.25s ease-out;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.field-row:hover {
    background-color: rgba(51, 65, 85, 0.45);
}

.field-row.has-error {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.35);
}

/* ── Inputs y Controles de Formulario ── */
.field-input {
    background: #0f172a;
    border: 1px solid #334155;
    color: #e2e8f0;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    width: 100%;
}

.field-input:focus {
    outline: none;
    border-color: #14b8a6;
    box-shadow: 0 0 0 2px rgba(20, 184, 166, 0.25);
}

.field-input.input-error {
    border-color: #ef4444;
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
}

.field-select {
    background: #0f172a;
    border: 1px solid #334155;
    color: #e2e8f0;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    transition: border-color 0.2s;
    cursor: pointer;
    width: 100%;
}

.field-select:focus {
    outline: none;
    border-color: #14b8a6;
    box-shadow: 0 0 0 2px rgba(20, 184, 166, 0.25);
}

.field-checkbox {
    appearance: none;
    -webkit-appearance: none;
    width: 17px;
    height: 17px;
    border: 2px solid #475569;
    border-radius: 4px;
    background: #0f172a;
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
    flex-shrink: 0;
}

.field-checkbox:checked {
    background: #14b8a6;
    border-color: #14b8a6;
}

.field-checkbox:checked::after {
    content: '✓';
    position: absolute;
    color: white;
    font-size: 11px;
    font-weight: 900;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.field-checkbox:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* ── Pestañas de Tablas (Access Style Multi-Table Bar) ── */
.table-tab-item {
    transition: all 0.2s ease;
    border-top: 2px solid transparent;
    user-select: none;
}

.table-tab-item.active {
    background: #1e293b;
    border-top-color: #14b8a6;
    color: #f1f5f9;
}

.table-tab-item:not(.active) {
    background: rgba(15, 23, 42, 0.6);
    color: #94a3b8;
}

.table-tab-item:not(.active):hover {
    background: rgba(30, 41, 59, 0.7);
    color: #e2e8f0;
}

/* ── Pestañas de Modo (Diseño vs Hoja de Datos) ── */
.view-tab-btn {
    transition: all 0.2s ease;
    border-bottom: 2px solid transparent;
}

.view-tab-btn.active {
    color: #2dd4bf;
    border-bottom-color: #14b8a6;
    background-color: rgba(20, 184, 166, 0.08);
}

.view-tab-btn:not(.active):hover {
    color: #e2e8f0;
    background-color: rgba(51, 65, 85, 0.3);
}

/* ── Pestañas de SQL Output ── */
.sql-tab-btn {
    transition: all 0.2s ease;
}

.sql-tab-btn.active {
    background-color: #14b8a6;
    color: #ffffff;
}

.sql-tab-btn:not(.active) {
    background-color: #1e293b;
    color: #94a3b8;
}

.sql-tab-btn:not(.active):hover {
    background-color: #334155;
    color: #f1f5f9;
}

/* ── SQL Output Styling ── */
.sql-output {
    background: #0d1117;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    line-height: 1.65;
    overflow-x: auto;
    white-space: pre;
    color: #e2e8f0;
    padding: 1.25rem;
    min-height: 120px;
}

.sql-keyword { color: #ff79c6; font-weight: 600; }
.sql-type { color: #8be9fd; }
.sql-constraint { color: #50fa7b; font-weight: 500; }
.sql-name { color: #f1fa8c; }
.sql-paren { color: #bd93f9; }
.sql-comma { color: #6272a4; }
.sql-number { color: #ffb86c; }
.sql-string { color: #f1fa8c; }
.sql-comment { color: #6272a4; font-style: italic; }
.sql-null { color: #ff5555; font-weight: 600; }

/* ── Cuadrícula Estilo Microsoft Access (Datasheet) ── */
.access-grid-container {
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 0.75rem;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.access-table {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
    min-width: 600px;
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
}

.access-table th {
    background: #1e293b;
    color: #cbd5e1;
    font-weight: 600;
    font-size: 0.78rem;
    letter-spacing: 0.03em;
    padding: 8px 12px;
    border-bottom: 2px solid #334155;
    border-right: 1px solid #334155;
    text-align: left;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 10;
    user-select: none;
}

.access-table th:first-child {
    width: 48px;
    text-align: center;
    background: #1e293b;
}

.access-table td {
    padding: 0;
    border-bottom: 1px solid #1e293b;
    border-right: 1px solid #1e293b;
    background: #0f172a;
    transition: background 0.15s;
    vertical-align: middle;
}

.access-table tr:hover td {
    background: rgba(30, 41, 59, 0.4);
}

.access-table tr.active-row td {
    background: rgba(20, 184, 166, 0.05);
}

.access-row-selector {
    width: 44px;
    min-width: 44px;
    max-width: 44px;
    background: #1e293b !important;
    text-align: center;
    color: #64748b;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    font-weight: 600;
    user-select: none;
    border-right: 1px solid #334155 !important;
}

.access-row-selector .row-cursor {
    color: #14b8a6;
    font-size: 0.7rem;
    display: inline-block;
    margin-right: 2px;
}

.access-cell-input {
    width: 100%;
    height: 100%;
    min-height: 36px;
    padding: 6px 10px;
    background: transparent;
    border: 1px solid transparent;
    color: #f1f5f9;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.82rem;
    outline: none;
    transition: border-color 0.15s, background-color 0.15s;
}

.access-cell-input:focus {
    background: #090d16;
    border: 1px solid #14b8a6;
    box-shadow: inset 0 0 0 1px #14b8a6;
}

.access-cell-input::placeholder {
    color: #475569;
    font-style: italic;
    font-size: 0.75rem;
}

.access-cell-input.auto-val {
    color: #a78bfa;
    font-style: italic;
    cursor: not-allowed;
    background: rgba(167, 139, 250, 0.05);
}

.access-cell-select {
    width: 100%;
    min-height: 36px;
    padding: 6px 8px;
    background: transparent;
    border: 1px solid transparent;
    color: #f1f5f9;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.82rem;
    outline: none;
    cursor: pointer;
}

.access-cell-select:focus {
    background: #090d16;
    border: 1px solid #14b8a6;
}

.access-cell-select option {
    background: #1e293b;
    color: #f1f5f9;
}

/* Access new row star row */
.access-new-row td {
    background: rgba(15, 23, 42, 0.75);
}

.access-new-row .access-row-selector {
    color: #14b8a6;
    font-weight: bold;
}

/* ── Acciones de fila ── */
.access-row-actions {
    width: 44px;
    text-align: center;
}

.access-del-btn {
    opacity: 0.3;
    transition: opacity 0.2s, color 0.2s, transform 0.2s;
}

tr:hover .access-del-btn {
    opacity: 1;
}

.access-del-btn:hover {
    color: #ef4444;
    transform: scale(1.15);
}

/* ── Barra de Estado estilo Access (Footer) ── */
.access-status-bar {
    background: #1e293b;
    border-top: 1px solid #334155;
    padding: 6px 14px;
    font-size: 0.75rem;
    color: #94a3b8;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
}

/* ── Modal / Overlay Asistente ── */
.modal-backdrop {
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease-out;
}

.modal-content {
    animation: zoomIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes zoomIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

/* ── Scrollbars personalizadas ── */
.panel-scroll {
    -webkit-overflow-scrolling: touch;
}

.panel-scroll::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.panel-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.panel-scroll::-webkit-scrollbar-thumb {
    background: #475569;
    border-radius: 3px;
}

.panel-scroll::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

/* ── Alertas ── */
.alert-msg {
    animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.copy-btn.copied {
    background-color: #059669 !important;
}

/* ── Responsividad ── */
@media (max-width: 768px) {
    .field-config-grid {
        grid-template-columns: 1fr 1fr !important;
    }
    .field-checks {
        grid-column: span 2;
    }
}

/* ── Editor de Consultas SQL (CodeMirror) ── */
#queryEditorContainer .CodeMirror {
    height: 100% !important;
    font-family: 'JetBrains Mono', monospace !important;
    font-size: 13px !important;
    line-height: 1.55;
    background: #0e1420 !important;
}

#queryEditorContainer .CodeMirror-gutters {
    background: #0a0e17 !important;
    border-right: 1px solid #1e293b !important;
}

#queryEditorContainer .CodeMirror-linenumber {
    color: #475569 !important;
    font-size: 11px;
}

/* ── Tabla de Resultados de Consulta SQL ── */
.query-result-table {
    width: 100%;
    min-width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-family: 'Inter', sans-serif;
    font-size: 0.8rem;
}

.query-result-table th {
    background: #1e293b;
    color: #2dd4bf;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 7px 12px;
    border-bottom: 2px solid #334155;
    border-right: 1px solid #334155;
    text-align: left;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.query-result-table td {
    padding: 6px 12px;
    border-bottom: 1px solid #1a2333;
    border-right: 1px solid #1a2333;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    color: #cbd5e1;
    white-space: nowrap;
    background: #090d16;
    transition: background-color 0.15s;
}

.query-result-table tr:hover td {
    background: rgba(30, 41, 59, 0.6);
}

.query-result-table .query-row-idx {
    width: 36px;
    min-width: 36px;
    max-width: 36px;
    text-align: center;
    color: #64748b;
    background: #111827 !important;
    font-size: 0.72rem;
    user-select: none;
    border-right: 1px solid #334155 !important;
}

.query-val-null {
    color: #f87171;
    font-style: italic;
    font-weight: 500;
}

.query-val-number {
    color: #fb923c;
}

.query-val-bool {
    color: #c084fc;
    font-weight: 600;
}

.query-card-suggestion {
    background: rgba(30, 41, 59, 0.5);
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 10px 14px;
    transition: all 0.2s ease;
    cursor: pointer;
}

.query-card-suggestion:hover {
    background: rgba(20, 184, 166, 0.12);
    border-color: #14b8a6;
    transform: translateY(-1px);
}
