/* =========================================================
   NOESOR - BASE DE DATOS
   Explorador de objetos, consola de generación y editor SQL.
   ========================================================= */

.database-page {
    width: min(calc(100% - 40px), 1280px);
    margin: 0 auto;
    padding: 34px 0 110px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.database-empty-state {
    width: min(calc(100% - 40px), 760px);
    margin: 80px auto 110px;
    padding: 52px 46px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    border: 1px solid rgba(96, 165, 250, 0.17);
    border-radius: 26px;
    background: radial-gradient(circle at 0% 0%, rgba(37, 99, 235, 0.13), transparent 42%), linear-gradient(145deg, rgba(15, 29, 50, 0.92), rgba(7, 17, 31, 0.97));
    box-shadow: 0 35px 80px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.035);
}

    .database-empty-state h1 {
        margin: 10px 0 0;
        font-size: clamp(2rem, 5vw, 3.5rem);
        line-height: 1.08;
        letter-spacing: -0.055em;
    }

    .database-empty-state p {
        max-width: 620px;
        margin: 20px 0 0;
        color: var(--text-soft);
        line-height: 1.75;
    }

    .database-empty-state .database-button {
        margin-top: 28px;
    }

.database-eyebrow {
    display: inline-block;
    color: #67e8f9;
    font-size: 0.68rem;
    font-weight: 850;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

/* Progreso */

.database-progress {
    padding: 14px 18px;
    display: grid;
    grid-template-columns: auto minmax(40px, 1fr) auto minmax(40px, 1fr) auto minmax(40px, 1fr) auto;
    align-items: center;
    gap: 12px;
    border: 1px solid rgba(148, 163, 184, 0.12);
    border-radius: 17px;
    background: rgba(7, 17, 31, 0.72);
    box-shadow: 0 18px 42px rgba(0, 0, 0, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.025);
    backdrop-filter: blur(18px);
}

.database-progress-step {
    min-width: 0;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 0;
    color: var(--text-muted);
    background: transparent;
    text-align: left;
}

button.database-progress-step {
    cursor: pointer;
}

.database-progress-number {
    width: 31px;
    height: 31px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.025);
    font-size: 0.72rem;
    font-weight: 800;
}

.database-progress-step strong,
.database-progress-step small {
    display: block;
    white-space: nowrap;
}

.database-progress-step strong {
    font-size: 0.73rem;
    font-weight: 760;
}

.database-progress-step small {
    margin-top: 2px;
    color: rgba(148, 163, 184, 0.68);
    font-size: 0.63rem;
}

.database-progress-step.completed,
.database-progress-step.active {
    color: var(--text);
}

    .database-progress-step.completed .database-progress-number {
        border-color: rgba(34, 211, 238, 0.28);
        color: #a5f3fc;
        background: rgba(34, 211, 238, 0.08);
    }

    .database-progress-step.active .database-progress-number {
        border-color: rgba(96, 165, 250, 0.42);
        color: #fff;
        background: linear-gradient(135deg, #2563eb, #0891b2);
        box-shadow: 0 8px 22px rgba(37, 99, 235, 0.26);
    }

.database-progress-line {
    height: 1px;
    background: rgba(148, 163, 184, 0.13);
}

    .database-progress-line.completed {
        background: linear-gradient(90deg, rgba(34, 211, 238, 0.44), rgba(96, 165, 250, 0.32));
    }

/* Encabezado */

.database-header {
    padding: 30px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 38px;
    border: 1px solid rgba(148, 163, 184, 0.13);
    border-radius: 22px;
    background: radial-gradient(circle at 90% 0%, rgba(37, 99, 235, 0.11), transparent 36%), linear-gradient(145deg, rgba(14, 28, 48, 0.91), rgba(7, 17, 31, 0.96));
    box-shadow: 0 26px 60px rgba(0, 0, 0, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.025);
}

.database-header-content {
    min-width: 0;
    max-width: 790px;
}

.database-header h1 {
    margin: 7px 0 0;
    font-size: clamp(2.7rem, 5vw, 4.6rem);
    line-height: 1;
    letter-spacing: -0.065em;
}

.database-header p {
    margin: 19px 0 0;
    color: var(--text-soft);
    line-height: 1.75;
}

    .database-header p strong {
        color: #e0f2fe;
    }

.database-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(110px, 1fr));
    gap: 10px;
}

    .database-summary article {
        min-width: 110px;
        min-height: 100px;
        padding: 15px;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        border: 1px solid rgba(148, 163, 184, 0.13);
        border-radius: 15px;
        background: rgba(3, 12, 24, 0.48);
    }

    .database-summary span {
        color: var(--text-muted);
        font-size: 0.64rem;
        font-weight: 760;
        text-transform: uppercase;
        letter-spacing: 0.055em;
    }

    .database-summary strong {
        color: #fff;
        font-size: 2rem;
        line-height: 1;
        letter-spacing: -0.05em;
    }

/* Toolbar */

.database-toolbar {
    padding: 12px;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    border: 1px solid rgba(148, 163, 184, 0.12);
    border-radius: 15px;
    background: rgba(7, 17, 31, 0.66);
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.02);
    backdrop-filter: blur(16px);
}

.database-toolbar-navigation,
.database-toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.database-button {
    min-height: 42px;
    padding: 0 15px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    border: 1px solid transparent;
    border-radius: 11px;
    font: inherit;
    font-size: 0.74rem;
    font-weight: 760;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.15s ease, opacity 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}

    .database-button:hover:not(:disabled) {
        transform: translateY(-1px);
    }

    .database-button:disabled {
        cursor: not-allowed;
        opacity: 0.48;
    }

.database-button-primary {
    color: white;
    background: linear-gradient(135deg, #2563eb, #0891b2);
    box-shadow: 0 10px 24px rgba(37, 99, 235, 0.2);
}

.database-button-secondary {
    color: #e2e8f0;
    border-color: rgba(148, 163, 184, 0.18);
    background: rgba(255, 255, 255, 0.025);
}

.database-button-success {
    color: #d1fae5;
    border-color: rgba(52, 211, 153, 0.25);
    background: rgba(6, 78, 59, 0.22);
}

.database-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.28);
    border-top-color: #fff;
    border-radius: 50%;
    animation: database-spin 0.8s linear infinite;
}

@keyframes database-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Mensajes */

.database-status {
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 11px;
    border-radius: 13px;
    font-size: 0.78rem;
    font-weight: 680;
}

.database-status-success {
    color: #bbf7d0;
    border: 1px solid rgba(52, 211, 153, 0.2);
    background: rgba(6, 78, 59, 0.17);
}

.database-status-error {
    color: #fecaca;
    border: 1px solid rgba(248, 113, 113, 0.22);
    background: rgba(127, 29, 29, 0.16);
}

.database-status-icon {
    width: 23px;
    height: 23px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    border: 1px solid currentColor;
    border-radius: 50%;
    font-size: 0.7rem;
    font-weight: 900;
    opacity: 0.82;
}

/* Workspace */

.database-workspace {
    min-height: 650px;
    display: grid;
    grid-template-columns: 330px minmax(0, 1fr);
    gap: 18px;
}

.database-explorer-card,
.database-editor-card,
.database-validation-card {
    min-width: 0;
    border: 1px solid rgba(148, 163, 184, 0.13);
    border-radius: 18px;
    background: linear-gradient(145deg, rgba(14, 28, 48, 0.91), rgba(7, 17, 31, 0.96));
    box-shadow: 0 26px 60px rgba(0, 0, 0, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.025);
}

.database-explorer-card {
    overflow: hidden;
}

.database-panel-header {
    padding: 21px 22px 18px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
    background: rgba(255, 255, 255, 0.012);
}

    .database-panel-header h2 {
        margin: 6px 0 0;
        font-size: 1.15rem;
        letter-spacing: -0.03em;
    }

.database-count {
    min-width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(96, 165, 250, 0.18);
    border-radius: 9px;
    color: #bfdbfe;
    background: rgba(37, 99, 235, 0.07);
    font-size: 0.68rem;
    font-weight: 800;
}

/* Explorador */

.database-tree {
    max-height: 610px;
    padding: 13px;
    overflow-y: auto;
}

.database-tree-project,
.database-tree-group-header {
    min-height: 35px;
    display: grid;
    grid-template-columns: 17px 18px minmax(0, 1fr) auto;
    align-items: center;
    gap: 6px;
    color: var(--text-soft);
    font-size: 0.72rem;
}

.database-tree-project {
    padding: 0 8px;
    color: #fff;
}

.database-tree-group {
    margin-top: 5px;
}

.database-tree-group-header {
    padding: 0 8px;
    border-radius: 7px;
}

    .database-tree-group-header:hover {
        background: rgba(255, 255, 255, 0.025);
    }

    .database-tree-group-header small {
        color: var(--text-muted);
        font-size: 0.62rem;
    }

.database-tree-chevron {
    color: var(--text-muted);
    font-size: 0.67rem;
}

.database-tree-folder-icon {
    color: #60a5fa;
    font-size: 0.7rem;
}

.database-tree-children {
    margin-left: 18px;
    padding-left: 9px;
    border-left: 1px solid rgba(148, 163, 184, 0.1);
}

.database-tree-table {
    margin-top: 6px;
    overflow: hidden;
    border: 1px solid rgba(148, 163, 184, 0.1);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.016);
}

    .database-tree-table header {
        min-height: 37px;
        padding: 0 10px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        border-bottom: 1px solid rgba(148, 163, 184, 0.08);
    }

        .database-tree-table header > div {
            min-width: 0;
            display: flex;
            align-items: center;
            gap: 7px;
        }

        .database-tree-table header strong {
            overflow: hidden;
            color: #f8fafc;
            font-size: 0.7rem;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .database-tree-table header small {
            color: var(--text-muted);
            font-size: 0.6rem;
        }

.database-table-icon {
    color: #67e8f9;
    font-size: 0.7rem;
}

.database-field-list {
    padding: 6px 7px;
}

.database-field-item {
    min-height: 28px;
    padding: 0 4px;
    display: grid;
    grid-template-columns: 26px minmax(0, 1fr) auto;
    align-items: center;
    gap: 5px;
    border-radius: 6px;
    color: var(--text-soft);
    font-size: 0.64rem;
}

    .database-field-item:hover {
        background: rgba(255, 255, 255, 0.021);
    }

.database-field-icon {
    min-width: 22px;
    height: 18px;
    display: grid;
    place-items: center;
    border-radius: 5px;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.025);
    font-size: 0.5rem;
    font-weight: 850;
}

    .database-field-icon.primary-key {
        color: #fde68a;
        background: rgba(120, 53, 15, 0.14);
    }

    .database-field-icon.foreign-key {
        color: #a5f3fc;
        background: rgba(8, 145, 178, 0.12);
    }

.database-field-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.database-field-item small {
    color: rgba(148, 163, 184, 0.63);
    font-size: 0.56rem;
    white-space: nowrap;
}

.database-more-fields {
    padding: 7px 4px 3px;
    color: var(--text-muted);
    font-size: 0.6rem;
    font-style: italic;
}

/* Editor */

.database-editor-card {
    min-height: 650px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.database-editor-topbar {
    min-height: 48px;
    padding: 0 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
    background: rgba(255, 255, 255, 0.018);
}

.database-editor-tab {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 9px;
}

.database-file-icon {
    min-width: 30px;
    height: 22px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(34, 211, 238, 0.18);
    border-radius: 6px;
    color: #67e8f9;
    background: rgba(8, 145, 178, 0.07);
    font-size: 0.49rem;
    font-weight: 900;
}

.database-editor-tab strong {
    overflow: hidden;
    color: #e2e8f0;
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.69rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.database-editor-saved {
    padding: 3px 6px;
    border: 1px solid rgba(52, 211, 153, 0.15);
    border-radius: 999px;
    color: #86efac;
    background: rgba(6, 78, 59, 0.12);
    font-size: 0.55rem;
}

.database-editor-meta {
    display: flex;
    align-items: center;
    gap: 6px;
}

    .database-editor-meta span {
        padding: 4px 7px;
        border: 1px solid rgba(148, 163, 184, 0.09);
        border-radius: 999px;
        color: var(--text-muted);
        background: rgba(255, 255, 255, 0.014);
        font-size: 0.57rem;
    }

.database-generation-placeholder {
    flex: 1;
    padding: 46px 34px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    background: rgba(2, 8, 18, 0.52);
}

.database-console-preview {
    width: min(100%, 660px);
    overflow: hidden;
    border: 1px solid rgba(148, 163, 184, 0.11);
    border-radius: 13px;
    background: #020817;
    box-shadow: 0 24px 54px rgba(0, 0, 0, 0.28);
    text-align: left;
}

.database-console-titlebar {
    min-height: 39px;
    padding: 0 13px;
    display: flex;
    align-items: center;
    gap: 6px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.08);
    background: rgba(255, 255, 255, 0.025);
}

    .database-console-titlebar > span {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: rgba(148, 163, 184, 0.35);
    }

    .database-console-titlebar strong {
        margin-left: 7px;
        color: var(--text-muted);
        font-family: Consolas, monospace;
        font-size: 0.61rem;
    }

.database-console-body {
    padding: 20px;
    display: grid;
    gap: 11px;
    color: #cbd5e1;
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.69rem;
    line-height: 1.5;
}

    .database-console-body > div {
        display: flex;
        align-items: flex-start;
        gap: 9px;
    }

.console-prompt {
    color: #67e8f9;
}

.console-check {
    color: #34d399;
}

.console-muted {
    margin-top: 4px;
    color: #64748b;
}

.database-generation-placeholder h3 {
    margin: 27px 0 0;
    color: #fff;
    font-size: 1.05rem;
}

.database-generation-placeholder p {
    max-width: 560px;
    margin: 10px 0 0;
    color: var(--text-muted);
    font-size: 0.74rem;
    line-height: 1.65;
}

.database-code-wrapper {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr);
    overflow: hidden;
    background: #020617;
}

.database-line-numbers {
    padding: 17px 10px 17px 0;
    overflow: hidden;
    border-right: 1px solid rgba(148, 163, 184, 0.08);
    color: #475569;
    background: #020617;
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.72rem;
    line-height: 1.65;
    text-align: right;
    user-select: none;
}

    .database-line-numbers span {
        display: block;
    }

.database-script-editor {
    width: 100%;
    min-height: 560px;
    padding: 17px 20px;
    border: 0;
    outline: none;
    resize: none;
    color: #d1fae5;
    background: #020617;
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.72rem;
    line-height: 1.65;
    tab-size: 4;
    white-space: pre;
    overflow: auto;
}

.database-editor-statusbar {
    min-height: 30px;
    padding: 0 12px;
    display: flex;
    align-items: center;
    gap: 14px;
    border-top: 1px solid rgba(148, 163, 184, 0.08);
    color: #64748b;
    background: rgba(15, 23, 42, 0.94);
    font-family: Consolas, monospace;
    font-size: 0.56rem;
}

.database-statusbar-spacer {
    flex: 1;
}

/* Validación */

.database-validation-card {
    overflow: hidden;
}

.database-validation-state {
    padding: 5px 9px;
    border: 1px solid rgba(52, 211, 153, 0.18);
    border-radius: 999px;
    color: #86efac;
    background: rgba(6, 78, 59, 0.13);
    font-size: 0.62rem;
    font-weight: 760;
}

.database-validation-grid {
    padding: 20px 22px;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.database-validation-item {
    min-height: 112px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    border: 1px solid rgba(148, 163, 184, 0.11);
    border-radius: 13px;
    background: rgba(255, 255, 255, 0.018);
}

    .database-validation-item span {
        color: var(--text-muted);
        font-size: 0.64rem;
        font-weight: 720;
        text-transform: uppercase;
        letter-spacing: 0.04em;
    }

    .database-validation-item strong {
        color: #fff;
        font-size: 1.25rem;
        letter-spacing: -0.03em;
    }

    .database-validation-item small {
        color: rgba(148, 163, 184, 0.62);
        font-size: 0.59rem;
    }

.database-next-step {
    margin: 0 22px 22px;
    padding: 21px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    border: 1px solid rgba(34, 211, 238, 0.13);
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.07), rgba(8, 145, 178, 0.035));
}

    .database-next-step h3 {
        margin: 6px 0 0;
        font-size: 1rem;
    }

    .database-next-step p {
        max-width: 700px;
        margin: 8px 0 0;
        color: var(--text-muted);
        font-size: 0.72rem;
        line-height: 1.55;
    }

/* Responsive */

@media (max-width: 1120px) {
    .database-header {
        grid-template-columns: 1fr;
        align-items: start;
    }

    .database-summary {
        width: min(100%, 520px);
    }

    .database-progress {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .database-progress-line {
        display: none;
    }

    .database-workspace {
        grid-template-columns: 290px minmax(0, 1fr);
    }
}

@media (max-width: 900px) {
    .database-progress {
        overflow-x: auto;
        grid-template-columns: repeat(4, minmax(145px, 1fr));
    }

    .database-workspace {
        grid-template-columns: 1fr;
    }

    .database-tree {
        max-height: 440px;
    }

    .database-validation-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 680px) {
    .database-page {
        width: min(calc(100% - 24px), 100%);
        padding-top: 22px;
        padding-bottom: 75px;
    }

    .database-header {
        padding: 22px;
    }

        .database-header h1 {
            font-size: clamp(2.3rem, 11vw, 3.4rem);
        }

    .database-summary {
        grid-template-columns: repeat(3, 1fr);
    }

        .database-summary article {
            min-width: 0;
            min-height: 90px;
            padding: 13px;
        }

    .database-toolbar,
    .database-toolbar-navigation,
    .database-toolbar-actions {
        width: 100%;
        flex-direction: column;
    }

    .database-button {
        width: 100%;
    }

    .database-editor-topbar {
        align-items: flex-start;
        flex-direction: column;
        padding: 10px 12px;
    }

    .database-editor-meta {
        flex-wrap: wrap;
    }

    .database-validation-grid {
        grid-template-columns: 1fr;
    }

    .database-next-step {
        align-items: stretch;
        flex-direction: column;
    }

        .database-next-step .database-button {
            width: 100%;
        }
}

@media (max-width: 460px) {
    .database-page {
        width: min(calc(100% - 18px), 100%);
    }

    .database-summary {
        grid-template-columns: 1fr;
    }

        .database-summary article {
            min-height: 82px;
        }

    .database-code-wrapper {
        grid-template-columns: 40px minmax(0, 1fr);
    }

    .database-script-editor,
    .database-line-numbers {
        font-size: 0.65rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .database-button,
    .database-spinner {
        transition: none !important;
        animation: none !important;
    }
}
