/* =========================================================
   ZAINTZAK — components.css
   Componentes reutilizables
   ========================================================= */


/* =========================================================
   1. CHIPS
   ========================================================= */

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;

    max-width: 100%;
    padding: 5px 9px;

    border: 1px solid transparent;
    border-radius: 999px;

    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.2;

    white-space: nowrap;
}

.chip-clickable {
    cursor: pointer;

    transition:
        transform 0.05s ease,
        box-shadow 0.15s ease;
}

.chip-clickable:hover {
    box-shadow: var(--shadow-small);
}

.chip-clickable:active {
    transform: translateY(1px);
}

.chip-ordinary {
    color: #56376f;
    background: #eee8f3;
    border-color: #ddd0e7;
}

.chip-workgroup {
    color: #725218;
    background: #fff3d8;
    border-color: #ead8ae;
}

.chip-direction {
    color: #345d7a;
    background: #e8f1f7;
    border-color: #ccdee9;
}

.chip-support {
    color: #32664e;
    background: #e7f3ec;
    border-color: #cce4d6;
}

.chip-disabled {
    color: #747a80;
    background: #f0f1f2;
    border-color: #dfe1e3;
}


/* =========================================================
   2. BADGES
   ========================================================= */

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    padding: 4px 8px;

    border-radius: 999px;

    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1;
}

.badge-success {
    color: var(--color-success);
    background: var(--color-success-bg);
}

.badge-warning {
    color: var(--color-warning);
    background: var(--color-warning-bg);
}

.badge-danger {
    color: var(--color-danger);
    background: var(--color-danger-bg);
}

.badge-info {
    color: var(--color-info);
    background: var(--color-info-bg);
}

.badge-neutral {
    color: var(--color-text-soft);
    background: #eef0f2;
}


/* =========================================================
   3. BOTÓN AÑADIR
   ========================================================= */

.add-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 27px;
    height: 27px;
    padding: 0;

    color: var(--color-primary);
    background: transparent;

    border: 1px dashed #c9b9d5;
    border-radius: 50%;

    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1;

    cursor: pointer;

    transition:
        background-color 0.15s ease,
        border-color 0.15s ease,
        transform 0.05s ease;
}

.add-button:hover {
    background: var(--color-primary-light);
    border-color: var(--color-primary);
}

.add-button:active {
    transform: scale(0.96);
}


/* =========================================================
   4. MODALES
   ========================================================= */

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 20px;

    background: rgba(20, 20, 30, 0.48);
}

.modal {
    width: 100%;
    max-width: 540px;
    max-height: calc(100vh - 40px);

    overflow-x: hidden;
    overflow-y: auto;

    background: var(--color-surface);

    border: 1px solid var(--color-border);
    border-radius: var(--radius-large);

    box-shadow: var(--shadow-large);
}

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;

    padding: 18px 20px;

    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}

.modal-title {
    margin: 0;

    font-size: 1.05rem;
    font-weight: 700;
}

.modal-subtitle {
    margin: 4px 0 0;

    color: var(--color-text-soft);
    font-size: 0.82rem;
}

.modal-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 32px;
    height: 32px;
    padding: 0;

    color: var(--color-text-soft);
    background: transparent;

    border: 0;
    border-radius: 50%;

    font-size: 1.3rem;
    line-height: 1;

    cursor: pointer;
}

.modal-close:hover {
    color: var(--color-text);
    background: #f0f1f2;
}

.modal-body {
    padding: 20px;
    background: var(--color-surface);
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;

    padding: 16px 20px;

    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
}


/* =========================================================
   5. SELECTORES VISUALES
   ========================================================= */

.option-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.option-card {
    position: relative;

    display: flex;
    align-items: flex-start;
    gap: 10px;

    padding: 12px;

    background: var(--color-surface);

    border: 1px solid var(--color-border);
    border-radius: var(--radius-medium);

    cursor: pointer;

    transition:
        border-color 0.15s ease,
        background-color 0.15s ease,
        box-shadow 0.15s ease;
}

.option-card:hover {
    border-color: #c9b9d5;
}

.option-card:has(input:checked) {
    background: var(--color-primary-light);
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(111, 75, 139, 0.08);
}

.option-card input {
    margin: 3px 0 0;
}

.option-content {
    min-width: 0;
}

.option-title {
    display: block;

    font-size: 0.87rem;
    font-weight: 700;
}

.option-description {
    display: block;

    margin-top: 2px;

    color: var(--color-text-soft);
    font-size: 0.76rem;
}


/* =========================================================
   6. SWITCH
   ========================================================= */

.switch {
    position: relative;

    display: inline-flex;
    align-items: center;

    width: 42px;
    height: 24px;
}

.switch input {
    position: absolute;

    width: 1px;
    height: 1px;

    opacity: 0;
}

.switch-slider {
    position: absolute;
    inset: 0;

    background: #cfd3d7;

    border-radius: 999px;

    cursor: pointer;

    transition: background-color 0.15s ease;
}

.switch-slider::after {
    content: "";

    position: absolute;
    top: 3px;
    left: 3px;

    width: 18px;
    height: 18px;

    background: #ffffff;

    border-radius: 50%;

    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);

    transition: transform 0.15s ease;
}

.switch input:checked + .switch-slider {
    background: var(--color-primary);
}

.switch input:checked + .switch-slider::after {
    transform: translateX(18px);
}


/* =========================================================
   7. ESTADOS VACÍOS
   ========================================================= */

.empty-state {
    padding: 32px 20px;

    text-align: center;
}

.empty-state-title {
    margin: 0 0 5px;

    font-weight: 700;
}

.empty-state-text {
    margin: 0;

    color: var(--color-text-soft);
    font-size: 0.87rem;
}


/* =========================================================
   8. CARGA
   ========================================================= */

.loading {
    display: inline-flex;
    align-items: center;
    gap: 8px;

    color: var(--color-text-soft);
    font-size: 0.85rem;
}

.spinner {
    width: 16px;
    height: 16px;

    border: 2px solid #dedfe2;
    border-top-color: var(--color-primary);
    border-radius: 50%;

    animation: zaintzak-spin 0.7s linear infinite;
}

@keyframes zaintzak-spin {
    to {
        transform: rotate(360deg);
    }
}


/* =========================================================
   9. DASHBOARD
   ========================================================= */

.dashboard {
    padding-bottom: 30px;
}

.dashboard-intro {
    margin-bottom: 22px;
    padding: 24px 26px;

    background:
        linear-gradient(
            135deg,
            var(--color-primary-soft),
            var(--color-surface)
        );

    border: 1px solid #e6dcea;
    border-radius: var(--radius-large);
}

.dashboard-eyebrow {
    display: block;

    margin-bottom: 5px;

    color: var(--color-primary);

    font-size: 0.76rem;
    font-weight: 700;

    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.dashboard-intro h2 {
    margin: 0;

    font-size: 1.35rem;
}

.dashboard-intro p {
    max-width: 650px;

    margin: 7px 0 0;

    color: var(--color-text-soft);
}

.dashboard-grid {
    display: grid;
    gap: 16px;
}

.dashboard-grid-profesor,
.dashboard-grid-admin {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.dashboard-grid-secondary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.dashboard-card {
    position: relative;

    display: flex;
    align-items: center;
    gap: 15px;

    min-height: 125px;
    padding: 20px;

    color: var(--color-text);
    background: var(--color-surface);

    border: 1px solid var(--color-border);
    border-radius: var(--radius-large);

    box-shadow: var(--shadow-small);

    transition:
        transform 0.15s ease,
        border-color 0.15s ease,
        box-shadow 0.15s ease;
}

.dashboard-card:hover {
    color: var(--color-text);

    border-color: #cbbbd6;

    box-shadow: var(--shadow-medium);

    text-decoration: none;

    transform: translateY(-2px);
}

.dashboard-card-icon {
    display: flex;
    align-items: center;
    justify-content: center;

    flex: 0 0 auto;

    width: 44px;
    height: 44px;

    color: var(--color-primary);
    background: var(--color-primary-light);

    border-radius: 12px;

    font-size: 1.15rem;
    font-weight: 700;
}

.dashboard-card-content {
    min-width: 0;
    flex: 1;
}

.dashboard-card-content h3 {
    margin: 0 0 5px;

    font-size: 1rem;
}

.dashboard-card-content p {
    margin: 0;

    color: var(--color-text-soft);

    font-size: 0.83rem;
    line-height: 1.4;
}

.dashboard-card-arrow {
    flex: 0 0 auto;

    color: var(--color-primary);

    font-size: 1.2rem;
}

.dashboard-card-primary {
    border-top: 3px solid #d7c4e2;
}

.dashboard-secondary {
    margin-top: 30px;
}

.dashboard-section-heading {
    margin-bottom: 13px;
}

.dashboard-section-heading h3 {
    margin: 0;

    font-size: 1rem;
}

.dashboard-section-heading p {
    margin: 3px 0 0;

    color: var(--color-text-soft);
    font-size: 0.8rem;
}

.dashboard-card-small {
    min-height: 105px;
}


/* =========================================================
   10. RESPONSIVE
   ========================================================= */

@media (max-width: 900px) {

    .dashboard-grid-profesor,
    .dashboard-grid-admin,
    .dashboard-grid-secondary {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {

    .option-grid {
        grid-template-columns: 1fr;
    }

    .modal-backdrop {
        padding: 10px;
    }

    .modal {
        max-height: calc(100vh - 20px);
    } 

    .dashboard-intro {
        padding: 20px;
    }

    .dashboard-card {
        min-height: auto;
    }
}

/* =========================================================
   AVISOS VISUALES
   ========================================================= */

.notification-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    min-width: 20px;
    height: 20px;
    margin-left: 5px;
    padding: 0 6px;

    color: #fff;
    background: #b42318;

    border-radius: 999px;

    font-size: 0.72rem;
    font-weight: 800;
    line-height: 1;
}

.notification-badge-card {
    position: relative;
    top: -1px;
    min-width: 22px;
    height: 22px;
    margin-left: 7px;
}


/* =========================================================
   AJUSTES
   ========================================================= */

.settings-layout {
    max-width: 760px;
}

.settings-card {
    overflow: hidden;
}

.settings-card-header {
    align-items: flex-start;
}

.settings-eyebrow {
    display: block;
    margin-bottom: 5px;
    color: var(--color-primary);
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.settings-description {
    margin: 0 0 22px;
    color: var(--color-text-soft);
    font-size: 0.9rem;
    line-height: 1.55;
}

.settings-form {
    max-width: 650px;
}

.settings-password-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.settings-actions {
    display: flex;
    justify-content: flex-end;
    padding-top: 2px;
}

@media (max-width: 720px) {
    .settings-password-grid {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .settings-actions {
        justify-content: stretch;
    }

    .settings-actions .btn {
        width: 100%;
    }
}


/* =========================================================
   NAVEGACIÓN DESPLEGABLE
   ========================================================= */

.zaintzak-top-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 14px;
    flex-wrap: nowrap;
    margin-bottom: 0;
}

.zone-switcher {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 3px;
    border: 1px solid var(--border-color, #dcdfe4);
    border-radius: 999px;
    background: #fff;
}

.zone-option {
    padding: 8px 15px;
    border-radius: 999px;
    color: var(--color-text);
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
}

.zone-option:hover {
    background: #f5f1f8;
    text-decoration: none;
}

.zone-option-active {
    color: #fff;
    background: var(--color-primary);
}

.main-menu {
    position: relative;
    z-index: 1000;
}

.main-menu > summary,
.submenu > summary {
    list-style: none;
}

.main-menu > summary::-webkit-details-marker,
.submenu > summary::-webkit-details-marker {
    display: none;
}

.main-menu-button {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 108px;
    cursor: pointer;
    user-select: none;
}

.main-menu-icon {
    font-size: 1rem;
    line-height: 1;
}

.main-menu-chevron {
    margin-left: 2px;
    font-size: 1rem;
    transition: transform 0.18s ease;
}

.main-menu[open] .main-menu-chevron {
    transform: rotate(180deg);
}

.menu-alert-dot {
    width: 8px;
    height: 8px;
    margin-left: 1px;
    border-radius: 50%;
    background: #b42318;
}

.main-menu-panel {
    position: absolute;
    top: calc(100% + 9px);
    right: 0;
    width: 250px;
    padding: 8px;
    background: #fff;
    border: 1px solid var(--border-color, #dcdfe4);
    border-radius: 14px;
    box-shadow: 0 12px 32px rgba(31, 35, 41, 0.14);
}

.menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    padding: 10px 12px;
    border-radius: 9px;
    color: var(--color-text);
    font-size: 0.88rem;
    font-weight: 600;
    line-height: 1.25;
    text-decoration: none;
    cursor: pointer;
}

.menu-item:hover {
    color: var(--color-text);
    background: #f6f2f8;
    text-decoration: none;
}

.menu-item-active {
    color: var(--color-primary);
    background: var(--color-primary-light);
    font-weight: 800;
}

.submenu {
    margin: 1px 0;
}

.submenu-title {
    user-select: none;
}

.submenu-chevron {
    font-size: 1.25rem;
    transition: transform 0.18s ease;
}

.submenu[open] .submenu-chevron {
    transform: rotate(90deg);
}

.submenu-panel {
    margin: 2px 0 5px 12px;
    padding-left: 8px;
    border-left: 2px solid #e8dfee;
}

.submenu-item {
    padding: 9px 11px;
    font-size: 0.84rem;
}

.menu-separator {
    height: 1px;
    margin: 7px 4px;
    background: var(--border-color, #e1e3e7);
}

.menu-item-exit {
    color: #9b2c2c;
}

.menu-item-exit:hover {
    color: #842525;
    background: #fff1f1;
}

@media (max-width: 600px) {
    .zaintzak-top-actions {
        gap: 8px;
    }

    .zone-option {
        padding: 7px 10px;
        font-size: 11px;
    }

    .main-menu-button {
        min-width: auto;
    }

    .main-menu-panel {
        position: fixed;
        top: 76px;
        right: 12px;
        left: 12px;
        width: auto;
    }
}

/* =========================================================
   CABECERA GLOBAL · LOGO + VOLVER
   ========================================================= */

.zaintzak-top-actions {
    margin-bottom: 0;
    flex-wrap: wrap;
}

.app-brand-tools {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-right: 4px;
}

.app-logo-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 44px;
    padding: 4px 8px;
    background: #ffffff;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    box-shadow: var(--shadow-small);
    text-decoration: none;
}

.app-logo-link:hover {
    border-color: #cfbfd9;
    background: #fdfbfe;
    text-decoration: none;
}

.app-logo {
    display: block;
    width: auto;
    height: 34px;
    max-width: 150px;
    object-fit: contain;
}

.app-back-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    color: var(--color-primary-dark);
    background: #ffffff;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    box-shadow: var(--shadow-small);
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
}

.app-back-button:hover {
    background: var(--color-primary-soft);
    border-color: #cfbfd9;
}

@media (max-width: 760px) {
    .app-logo {
        max-width: 112px;
        height: 30px;
    }

    .app-logo-link {
        height: 40px;
        padding-inline: 6px;
    }

    .app-back-button {
        width: 38px;
        height: 38px;
    }
}

/* =========================================================
   LOGO COMPLETO INTEGRADO EN EL BLOQUE DE TÍTULO
   ========================================================= */

.page-header {
    position: relative;
}

/*
 * Reservamos a la izquierda el espacio del logo completo
 * (escudo + LA ASUNCIÓN IKASTETXEA DONOSTIA).
 */
.page-header > :first-child:not(.zaintzak-top-actions),
.page-header > .admin-header-main {
    padding-left: 190px;
}

.app-brand-tools {
    margin-right: 4px;
}

/* Logo completo, sin recortes. */
.app-logo-link {
    position: absolute;
    left: 0;
    top: 50%;
    z-index: 2;

    display: flex;
    align-items: center;
    justify-content: flex-start;

    width: 174px;
    height: 76px;
    padding: 0;

    transform: translateY(-50%);

    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    overflow: visible;
}

.app-logo-link:hover {
    background: transparent;
    border-color: transparent;
    box-shadow: none;
    text-decoration: none;
    opacity: 0.92;
}

.app-logo {
    display: block;
    width: 174px;
    height: auto;
    max-width: none;
    object-fit: contain;
}

@media (max-width: 900px) {
    .page-header > :first-child:not(.zaintzak-top-actions),
    .page-header > .admin-header-main {
        padding-left: 158px;
    }

    .app-logo-link,
    .app-logo {
        width: 145px;
    }
}

@media (max-width: 680px) {
    .page-header > :first-child:not(.zaintzak-top-actions),
    .page-header > .admin-header-main {
        padding-left: 0;
        padding-top: 62px;
    }

    .app-logo-link {
        top: 0;
        width: 138px;
        height: 54px;
        transform: none;
    }

    .app-logo {
        width: 138px;
    }
}


/* ===== PRUEBA CABECERA CENTRADA ===== */
.page-header {
    position: relative;
}

.page-header > .dashboard-welcome {
    position: absolute !important;
    left: 50% !important;
    top: 50% !important;
    transform: translate(-50%, -50%) !important;
    padding-left: 0 !important;
    margin: 0 !important;
    text-align: center !important;
    white-space: nowrap;
    z-index: 2;
}

.dashboard-welcome h1,
.dashboard-welcome p {
    margin-left: 0 !important;
    margin-right: 0 !important;
}

@media (max-width: 900px) {
    .page-header > .dashboard-welcome {
        position: static !important;
        transform: none !important;
        margin: 0 auto !important;
    }
}

/* OPCIÓN 1: dos líneas */
.dashboard-welcome {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
}
.dashboard-welcome h1 {
    margin-top: 0 !important;
    margin-bottom: 3px !important;
}
.dashboard-welcome p {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}


/* ===== CORRECCIÓN: mantener ADMIN / PROFESOR / MENÚ a la derecha ===== */
.page-header > .zaintzak-top-actions {
    margin-left: auto !important;
    margin-right: 0 !important;
    flex: 0 0 auto;
}


/* =========================================================
   CABECERA UNIFICADA · TÍTULO Y SUBTÍTULO CENTRADOS
   Logo a la izquierda · navegación a la derecha
   ========================================================= */

.page-header {
    position: relative !important;
}

/* El bloque principal de texto de cualquier cabecera queda
   centrado respecto al ancho completo de la pantalla. */
.page-header > :first-child:not(.zaintzak-top-actions):not(.app-logo-link),
.page-header > .admin-header-main,
.page-header > .dashboard-welcome {
    position: absolute !important;
    left: 50% !important;
    top: 50% !important;
    transform: translate(-50%, -50%) !important;
    padding-left: 0 !important;
    margin: 0 !important;
    text-align: center !important;
    white-space: nowrap;
    z-index: 2;
}

/* Título y subtítulo centrados entre sí. */
.page-header > :first-child:not(.zaintzak-top-actions):not(.app-logo-link) h1,
.page-header > :first-child:not(.zaintzak-top-actions):not(.app-logo-link) h2,
.page-header > :first-child:not(.zaintzak-top-actions):not(.app-logo-link) p,
.page-header > .admin-header-main h1,
.page-header > .admin-header-main h2,
.page-header > .admin-header-main p,
.page-header > .dashboard-welcome h1,
.page-header > .dashboard-welcome p {
    text-align: center !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

/* Los controles permanecen siempre en el extremo derecho. */
.page-header > .zaintzak-top-actions {
    margin-left: auto !important;
    margin-right: 0 !important;
    flex: 0 0 auto !important;
    position: static !important;
}

/* El logo permanece en el extremo izquierdo. */
.page-header .app-logo-link {
    z-index: 4;
}

/* En pantallas estrechas evitamos solapamientos. */
@media (max-width: 900px) {
    .page-header > :first-child:not(.zaintzak-top-actions):not(.app-logo-link),
    .page-header > .admin-header-main,
    .page-header > .dashboard-welcome {
        position: static !important;
        transform: none !important;
        margin: 0 auto !important;
        padding-left: 158px !important;
    }
}

@media (max-width: 680px) {
    .page-header > :first-child:not(.zaintzak-top-actions):not(.app-logo-link),
    .page-header > .admin-header-main,
    .page-header > .dashboard-welcome {
        padding-left: 0 !important;
        padding-top: 62px !important;
        white-space: normal;
    }
}


/* ===== CORRECCIÓN LOGO: su referencia vuelve a ser .page-header ===== */
.page-header > .zaintzak-top-actions,
.page-header .app-brand-tools {
    position: static !important;
}

.page-header .app-logo-link {
    position: absolute !important;
    left: 0 !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    z-index: 5 !important;
}

/* ===== MODO DEMO ===== */
.demo-mode-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    padding: 7px 12px;
    text-align: center;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .04em;
    background: #f3edf7;
    border-bottom: 1px solid #d8c8e2;
}

body:has(.demo-mode-banner) {
    padding-top: 32px;
}
