/* =========================================================
   NOESOR - ENTIDADES Y CAMPOS
   Listado lateral, editor de entidad, tabla de campos,
   acciones y estados de validación.
   ========================================================= */

/* =========================================================
   ESTADO VACÍO
   ========================================================= */

.entity-empty-state {
    width: min(calc(100% - 40px), 760px);
    margin: 80px auto 110px;
    padding: 48px;
    text-align: center;
}

    .entity-empty-state h1 {
        margin: 12px 0 0;
        font-size: clamp(2rem, 5vw, 3.4rem);
        line-height: 1.12;
        letter-spacing: -0.045em;
    }

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

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

/* =========================================================
   ENCABEZADO
   ========================================================= */

.entity-page-header {
    width: min(calc(100% - 40px), 1220px);
    margin: 0 auto 24px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 32px;
}

    .entity-page-header > div:first-child {
        min-width: 0;
    }

.entity-page-header h1 {
    margin: 8px 0 0;
    line-height: 1.02;
    letter-spacing: -0.055em;
}

.entity-page-header p {
    max-width: 860px;
    margin: 16px 0 0;
    color: var(--text-soft);
    line-height: 1.65;
}

.entity-total-card {
    min-width: 150px;
    padding: 18px 20px;
    border: 1px solid rgba(139, 92, 246, 0.28);
    border-radius: 16px;
    background: radial-gradient( circle at top left, rgba(139, 92, 246, 0.16), transparent 55% ), rgba(255, 255, 255, 0.025);
    box-shadow: 0 18px 42px rgba(0, 0, 0, 0.18);
    text-align: right;
}

    .entity-total-card span {
        display: block;
        color: var(--text-muted);
        font-size: 0.76rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.08em;
    }

    .entity-total-card strong {
        display: block;
        margin-top: 6px;
        color: white;
        font-size: 2rem;
        line-height: 1;
        letter-spacing: -0.04em;
    }

/* =========================================================
   BARRA DE ACCIONES Y MENSAJES
   ========================================================= */

.entity-toolbar {
    width: min(calc(100% - 40px), 1220px);
    margin: 0 auto 28px;
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 12px;
}

.entity-status {
    width: min(calc(100% - 40px), 1220px);
    margin: 0 auto 24px;
}

/* =========================================================
   DISTRIBUCIÓN PRINCIPAL
   ========================================================= */

.entity-designer-layout {
    width: min(calc(100% - 40px), 1220px);
    margin: 0 auto;
    padding-bottom: 100px;
    display: grid;
    grid-template-columns: minmax(250px, 0.3fr) minmax(0, 1fr);
    align-items: start;
    gap: 24px;
}

.entity-list-card,
.entity-editor-card {
    min-width: 0;
}

.entity-list-card {
    position: sticky;
    top: 102px;
    overflow: hidden;
}

.entity-editor-card {
    padding: 0;
    overflow: hidden;
}

/* =========================================================
   LISTADO DE ENTIDADES
   ========================================================= */

.entity-list-header {
    padding: 24px 24px 20px;
    border-bottom: 1px solid var(--border);
}

    .entity-list-header h2 {
        margin: 7px 0 0;
        font-size: 1.15rem;
        letter-spacing: -0.025em;
    }

.entity-list {
    padding: 14px;
    display: grid;
    gap: 6px;
}

.entity-list-button {
    width: 100%;
    min-height: 46px;
    padding: 0 11px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    border: 0;
    border-radius: 11px;
    background: transparent;
    color: var(--text-soft);
    cursor: pointer;
    text-align: left;
    transition: color 0.2s ease, background-color 0.2s ease, transform 0.2s ease;
}

    .entity-list-button:hover {
        color: white;
        background: rgba(255, 255, 255, 0.04);
        transform: translateX(2px);
    }

    .entity-list-button.active {
        color: white;
        background: rgba(139, 92, 246, 0.14);
    }

.entity-list-icon {
    width: 27px;
    height: 27px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: rgba(139, 92, 246, 0.1);
    color: var(--primary-light);
    font-size: 0.84rem;
}

.entity-list-name {
    min-width: 0;
    overflow: hidden;
    font-size: 0.83rem;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.entity-list-button strong {
    min-width: 27px;
    padding: 3px 7px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.09);
    color: var(--text-muted);
    font-size: 0.68rem;
    text-align: center;
}

.entity-list-button.active strong {
    background: rgba(139, 92, 246, 0.18);
    color: #d8ccff;
}

/* =========================================================
   ENCABEZADO DEL EDITOR
   ========================================================= */

.entity-editor-heading {
    padding: 28px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.018);
}

    .entity-editor-heading h2 {
        margin: 7px 0 0;
        font-size: clamp(1.55rem, 3vw, 2.15rem);
        line-height: 1.18;
        letter-spacing: -0.035em;
    }

.danger-text-button {
    flex-shrink: 0;
    padding: 8px 0;
    border: 0;
    background: transparent;
    color: #fda4af;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 750;
    transition: color 0.2s ease, opacity 0.2s ease;
}

    .danger-text-button:hover {
        color: #fecdd3;
    }

/* =========================================================
   DATOS BÁSICOS DE LA ENTIDAD
   ========================================================= */

.entity-basic-data {
    padding: 24px 28px;
    display: grid;
    grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
    gap: 18px;
    border-bottom: 1px solid var(--border);
}

    .entity-basic-data > div {
        min-width: 0;
    }

    .entity-basic-data label {
        display: block;
        margin-bottom: 9px;
        color: var(--text);
        font-size: 0.84rem;
        font-weight: 700;
    }

    .entity-basic-data .input {
        width: 100%;
    }

/* =========================================================
   CABECERA DE CAMPOS
   ========================================================= */

.fields-heading {
    padding: 24px 28px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

    .fields-heading h3 {
        margin: 0;
        font-size: 1.08rem;
        letter-spacing: -0.02em;
    }

    .fields-heading p {
        margin: 7px 0 0;
        color: var(--text-muted);
        font-size: 0.82rem;
        line-height: 1.55;
    }

/* =========================================================
   TABLA DE CAMPOS
   ========================================================= */

.fields-table-wrapper {
    margin: 0 28px 28px;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.018);
}

.fields-table {
    width: 100%;
    min-width: 860px;
    border-collapse: collapse;
}

    .fields-table th,
    .fields-table td {
        padding: 12px 10px;
        border-bottom: 1px solid var(--border);
        vertical-align: middle;
    }

    .fields-table th {
        background: rgba(255, 255, 255, 0.025);
        color: var(--text-muted);
        font-size: 0.7rem;
        font-weight: 800;
        text-align: left;
        text-transform: uppercase;
        letter-spacing: 0.06em;
        white-space: nowrap;
    }

    .fields-table tbody tr {
        transition: background-color 0.2s ease;
    }

        .fields-table tbody tr:hover {
            background: rgba(255, 255, 255, 0.018);
        }

        .fields-table tbody tr:last-child td {
            border-bottom: 0;
        }

.table-input,
.table-select,
.table-number {
    width: 100%;
    min-height: 38px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.028);
    color: var(--text);
    font: inherit;
    font-size: 0.78rem;
    outline: none;
    transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

.table-input,
.table-select {
    padding: 0 10px;
}

.table-number {
    max-width: 90px;
    padding: 0 8px;
}

    .table-input:focus,
    .table-select:focus,
    .table-number:focus {
        border-color: rgba(139, 92, 246, 0.62);
        background: rgba(255, 255, 255, 0.04);
        box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.11);
    }

.table-select {
    cursor: pointer;
}

.field-checkbox-cell {
    text-align: center;
}

    .field-checkbox-cell input[type="checkbox"] {
        width: 17px;
        height: 17px;
        accent-color: var(--primary);
        cursor: pointer;
    }

        .field-checkbox-cell input[type="checkbox"]:disabled {
            cursor: not-allowed;
            opacity: 0.42;
        }

.not-applicable {
    display: block;
    color: var(--text-muted);
    text-align: center;
}

.field-delete-button {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(251, 113, 133, 0.2);
    border-radius: 9px;
    background: rgba(127, 29, 29, 0.12);
    color: #fda4af;
    cursor: pointer;
    font-size: 1.05rem;
    line-height: 1;
    transition: border-color 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

    .field-delete-button:hover {
        border-color: rgba(251, 113, 133, 0.38);
        background: rgba(127, 29, 29, 0.22);
        color: #fecdd3;
    }

/* =========================================================
   ESTADO SIN ELEMENTOS DENTRO DEL EDITOR
   ========================================================= */

.entity-editor-card > .structure-no-items {
    margin: 28px;
}
