* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: #f5f7fa;
    color: #222;
}

.container {
    max-width: 1200px;
    margin: 40px auto;
    padding: 20px;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin-bottom: 25px;
}

.header h1 {
    margin: 0;
}

.header p {
    margin: 5px 0 0;
    color: #666;
}

.acciones-header {
    display: flex;
    gap: 10px;
    align-items: center;
}


/* TARJETAS */

.card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,.08);
}


/* TABLAS */

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

th {
    background: #fafafa;
}


/* FORMULARIOS */

label {
    display: block;
    margin-top: 15px;
    margin-bottom: 6px;
    font-weight: bold;
}

input,
select {
    width: 100%;
    padding: 11px;
    border: 1px solid #ccc;
    border-radius: 6px;
}


/* BOTONES */

button {
    cursor: pointer;
}

.btn-primary,
.btn-guardar {
    background: #198754;
    color: white;
    border: none;
    padding: 11px 18px;
    border-radius: 7px;
}

.btn-horarios,
.btn-volver {
    display: inline-block;
    text-decoration: none;
    background: #0d6efd;
    color: white;
    padding: 11px 18px;
    border-radius: 7px;
}

.btn-volver {
    background: #6c757d;
}

.btn-editar {
    background: #ffc107;
    color: #222;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
}

.btn-estado {
    background: #0d6efd;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
}

.btn-eliminar {
    background: #dc3545;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
}

.btn-cancelar {
    background: #6c757d;
    color: white;
    border: none;
    padding: 11px 18px;
    border-radius: 7px;
}


/* ACCIONES */

.acciones {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}


/* MODAL */

.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.activo {
    display: flex;
}

.modal-contenido {
    background: white;
    width: 90%;
    max-width: 450px;
    border-radius: 12px;
    padding: 25px;
}

.acciones-modal {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 25px;
}


/* HORARIOS */

.formulario-horarios {
    padding: 25px;
    margin-bottom: 25px;
}

.formulario-horarios h2 {
    margin-top: 0;
}

.dias {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin: 15px 0 25px;
}

.dias label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
}

.dias input {
    width: auto;
}

.grid-horarios {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

.tabla-horarios-card {
    padding: 25px;
}

.tabla-horarios-card h2 {
    margin-top: 0;
}


/* RESPONSIVE */

@media (max-width: 800px) {

    .header {
        flex-direction: column;
        align-items: flex-start;
    }

    .grid-horarios {
        grid-template-columns: 1fr 1fr;
    }

    .card {
        overflow-x: auto;
    }

}

@media (max-width: 500px) {

    .grid-horarios {
        grid-template-columns: 1fr;
    }

    .acciones-header {
        flex-wrap: wrap;
    }

}
/* RESERVAS */

.reserva-card {
    padding: 25px;
    margin-bottom: 25px;
}

.grid-reserva {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

.lista-horarios {
    display: grid;
    grid-template-columns:
        repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    margin-top: 20px;
}

.horario-disponible,
.horario-reservado {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 15px;
    border-radius: 10px;
    text-align: left;
}

.horario-disponible {
    background: #ecfdf3;
    border: 1px solid #86efac;
    color: #166534;
}

.horario-disponible:hover {
    background: #dcfce7;
}

.horario-disponible.seleccionado {
    outline: 3px solid #198754;
}

.horario-reservado {
    background: #fef2f2;
    border: 1px solid #fca5a5;
    color: #991b1b;
    cursor: not-allowed;
}

.horario-disponible span,
.horario-reservado span {
    font-size: 16px;
    font-weight: bold;
}

.horario-disponible small,
.horario-reservado small {
    font-size: 14px;
}

.resumen-reserva {
    background: #f8f9fa;
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.resumen-reserva p {
    margin: 8px 0;
}

.oculto {
    display: none;
}

.mensaje-info {
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
}

@media (max-width: 600px) {

    .grid-reserva {
        grid-template-columns: 1fr;
    }

}
/* ==================================================
   LAYOUT PRINCIPAL
================================================== */

body {
    background: #f4f6f9;
}

.app-layout {
    min-height: 100vh;
    display: flex;
}


/* ==================================================
   SIDEBAR
================================================== */

.sidebar {
    width: 250px;
    min-height: 100vh;
    background: #111827;
    color: white;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
}

.sidebar-logo {
    height: 80px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 25px;
    font-size: 20px;
    font-weight: bold;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-menu {
    padding: 20px 12px;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 15px;
    color: #cbd5e1;
    text-decoration: none;
    border-radius: 8px;
    margin-bottom: 6px;
    transition: .2s;
}

.menu-item:hover {
    background: #1f2937;
    color: white;
}

.menu-item.activo {
    background: #198754;
    color: white;
}


/* ==================================================
   CONTENIDO
================================================== */

.main-content {
    flex: 1;
    margin-left: 250px;
    padding: 30px;
}


/* ==================================================
   TOPBAR
================================================== */

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.topbar h1 {
    margin: 0;
    font-size: 28px;
}

.topbar p {
    margin: 5px 0 0;
    color: #6b7280;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.topbar-user div:last-child {
    display: flex;
    flex-direction: column;
}

.topbar-user span {
    font-size: 13px;
    color: #777;
}

.avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #198754;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}


/* ==================================================
   CARDS
================================================== */

.dashboard-cards {
    display: grid;
    grid-template-columns:
        repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    padding: 22px;
    border-radius: 14px;
    box-shadow:
        0 3px 15px
        rgba(0,0,0,.06);
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
}

.stat-card p {
    margin: 0 0 5px;
    color: #6b7280;
}

.stat-card h2 {
    margin: 0;
    font-size: 27px;
}


/* ==================================================
   SECCIONES
================================================== */

.dashboard-section {
    margin-bottom: 30px;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
}

.section-header h2 {
    margin: 0;
}

.section-header p {
    margin: 4px 0 0;
    color: #777;
}

.btn-primary-link {
    text-decoration: none;
    background: #198754;
    color: white;
    padding: 10px 16px;
    border-radius: 8px;
}


/* ==================================================
   TABLA
================================================== */

.table-card {
    background: white;
    border-radius: 14px;
    box-shadow:
        0 3px 15px
        rgba(0,0,0,.06);
    overflow: hidden;
}

.table-responsive {
    overflow-x: auto;
}


/* ==================================================
   ACCIONES RÁPIDAS
================================================== */

.quick-actions {
    display: grid;
    grid-template-columns:
        repeat(4, 1fr);
    gap: 18px;
}

.quick-card {
    background: white;
    border-radius: 14px;
    padding: 22px;
    text-decoration: none;
    color: #222;
    box-shadow:
        0 3px 15px
        rgba(0,0,0,.06);
    display: flex;
    flex-direction: column;
    gap: 7px;
    transition: .2s;
}

.quick-card:hover {
    transform: translateY(-3px);
    box-shadow:
        0 7px 22px
        rgba(0,0,0,.10);
}

.quick-card span {
    font-size: 28px;
}

.quick-card strong {
    font-size: 16px;
}

.quick-card small {
    color: #777;
}


/* ==================================================
   RESPONSIVE
================================================== */

@media (max-width: 1100px) {

    .dashboard-cards,
    .quick-actions {
        grid-template-columns:
            1fr 1fr;
    }

}

@media (max-width: 800px) {

    .sidebar {
        width: 70px;
    }

    .sidebar-logo span,
    .menu-item span {
        display: none;
    }

    .sidebar-logo {
        justify-content: center;
        padding: 0;
    }

    .menu-item {
        justify-content: center;
    }

    .main-content {
        margin-left: 70px;
        padding: 20px;
    }

}

@media (max-width: 600px) {

    .dashboard-cards,
    .quick-actions {
        grid-template-columns:
            1fr;
    }

    .topbar {
        align-items: flex-start;
        gap: 15px;
    }

    .topbar-user {
        display: none;
    }

}
/* AJUSTES DE GESTIÓN DE CANCHAS */
.topbar > .btn-primary {
    flex-shrink: 0;
}

@media (max-width: 600px) {
    .topbar > .btn-primary {
        width: 100%;
    }
}

/* ==================================================
   MÓDULOS UNIFICADOS
================================================== */
.module-card {
    border: 1px solid #eef1f4;
}

.module-title {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 15px;
    margin-bottom: 18px;
}

.module-title h2 {
    margin: 0;
    font-size: 20px;
}

.module-title p {
    margin: 5px 0 0;
    color: #6b7280;
}

.compact-title {
    margin-bottom: 8px;
}

.subtitulo-form {
    margin: 22px 0 10px;
    font-size: 15px;
    color: #374151;
}

.page-grid {
    display: grid;
    gap: 24px;
    margin-bottom: 28px;
}

.page-grid-horarios {
    grid-template-columns: 1fr;
}

.form-actions-left {
    display: flex;
    justify-content: flex-start;
    margin-top: 4px;
}

.form-grid-client {
    margin-bottom: 0;
}

.main-content .card {
    border-radius: 14px;
}

.main-content .reserva-card,
.main-content .formulario-horarios,
.main-content .tabla-horarios-card {
    box-shadow: 0 3px 15px rgba(0,0,0,.06);
}

.main-content input:focus,
.main-content select:focus {
    outline: none;
    border-color: #198754;
    box-shadow: 0 0 0 3px rgba(25,135,84,.10);
}

.main-content button,
.main-content .btn-primary-link {
    transition: transform .15s ease, opacity .15s ease, box-shadow .15s ease;
}

.main-content button:hover,
.main-content .btn-primary-link:hover {
    transform: translateY(-1px);
}

@media (max-width: 800px) {
    .module-title,
    .section-header {
        align-items: flex-start;
        gap: 12px;
    }

    .grid-filtros {
        grid-template-columns: 1fr;
    }

    .filtro-botones {
        justify-content: flex-start;
    }
}

/* ==================================================
   AUTENTICACIÓN
================================================== */

.auth-protected-page {
    visibility: visible;
}

.auth-protected-page.auth-ready {
    visibility: visible;
}

.sidebar {
    display: flex;
    flex-direction: column;
}

.sidebar-menu {
    flex: 1;
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid rgba(255,255,255,.08);
}

.logout-button {
    width: 100%;
    border: 0;
    background: transparent;
    font: inherit;
    cursor: pointer;
}

.logout-button:hover {
    background: #7f1d1d;
    color: #fff;
}

/* LOGIN */
.login-page {
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(25,135,84,.18), transparent 34%),
        #0f172a;
    color: #111827;
}

.login-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(320px, 1fr) minmax(360px, 480px);
    align-items: center;
    gap: 70px;
    max-width: 1180px;
    margin: 0 auto;
    padding: 50px 32px;
}

.login-brand-panel {
    color: #fff;
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 18px;
    margin-bottom: 42px;
}

.login-brand-icon {
    width: 68px;
    height: 68px;
    display: grid;
    place-items: center;
    border-radius: 18px;
    background: #198754;
    font-size: 34px;
    box-shadow: 0 18px 45px rgba(25,135,84,.28);
}

.login-brand h1 {
    margin: 0 0 7px;
    font-size: clamp(30px, 4vw, 46px);
}

.login-brand p {
    margin: 0;
    color: #cbd5e1;
}

.login-feature-list {
    display: grid;
    gap: 16px;
    max-width: 520px;
}

.login-feature-list > div {
    display: flex;
    gap: 14px;
    align-items: center;
    padding: 17px 19px;
    border: 1px solid rgba(255,255,255,.09);
    background: rgba(255,255,255,.04);
    border-radius: 14px;
}

.login-feature-list > div > span {
    font-size: 26px;
}

.login-feature-list p {
    display: flex;
    flex-direction: column;
    margin: 0;
}

.login-feature-list small {
    color: #94a3b8;
    margin-top: 3px;
}

.login-card {
    background: #fff;
    border-radius: 22px;
    padding: 36px;
    box-shadow: 0 28px 80px rgba(0,0,0,.28);
}

.login-card-header {
    margin-bottom: 26px;
}

.login-card-header h2 {
    font-size: 29px;
    margin: 10px 0 8px;
}

.login-card-header p {
    color: #6b7280;
    line-height: 1.55;
    margin: 0;
}

.login-badge {
    display: inline-block;
    font-size: 11px;
    letter-spacing: .08em;
    font-weight: 700;
    color: #166534;
    background: #dcfce7;
    border-radius: 999px;
    padding: 6px 9px;
}

.btn-login {
    width: 100%;
    margin-top: 8px;
    border: 0;
    border-radius: 9px;
    background: #198754;
    color: #fff;
    padding: 13px 18px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
}

.btn-login:hover {
    background: #157347;
}

.btn-login:disabled {
    opacity: .7;
    cursor: wait;
}

.login-message {
    min-height: 24px;
    margin: 12px 0 2px;
    font-size: 14px;
}

.login-message.error {
    color: #b91c1c;
}

.login-message.success {
    color: #15803d;
}

.login-public-link {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid #e5e7eb;
    text-align: center;
    color: #6b7280;
    font-size: 14px;
}

.login-public-link a {
    color: #198754;
    font-weight: 700;
    text-decoration: none;
}

@media (max-width: 850px) {
    .login-shell {
        grid-template-columns: 1fr;
        gap: 28px;
        max-width: 600px;
    }

    .login-brand-panel {
        padding-top: 20px;
    }

    .login-feature-list {
        display: none;
    }
}

@media (max-width: 520px) {
    .login-shell {
        padding: 22px 16px;
    }

    .login-card {
        padding: 25px 20px;
    }

    .login-brand-icon {
        width: 54px;
        height: 54px;
        font-size: 27px;
    }
}

/* MODULOS COMPLETOS */
.sidebar{overflow-y:auto}.sidebar-menu{padding-bottom:100px}.badge{display:inline-block;padding:4px 8px;border-radius:999px;background:#eef2ff}.btn-editar{text-decoration:none;display:inline-block}.mensaje-info{padding:14px;border-radius:8px;background:#eef6ff;color:#1e3a5f}.modal-contenido{max-height:90vh;overflow:auto}

/* CLIENTE EN NUEVA RESERVA */
.cliente-registrado {
    margin-bottom: 18px;
}

.texto-ayuda {
    display: block;
    margin-top: 6px;
    color: #6b7280;
    font-size: 13px;
}

/* ==================================================
   AUTH ESTABLE - nunca ocultar toda la interfaz
================================================== */
.auth-protected-page,
.auth-protected-page.auth-ready {
    visibility: visible !important;
    opacity: 1 !important;
}

.auth-aviso-error {
    position: relative;
    z-index: 9999;
    width: 100%;
    padding: 10px 16px;
    background: #fff1f2;
    border-top: 5px solid #b91c1c;
    border-bottom: 1px solid #fecdd3;
    color: #991b1b;
    font-size: 14px;
}

.permiso-denegado-card {
    padding: 48px 28px;
    text-align: center;
}

.permiso-denegado-card h2 {
    margin: 12px 0 8px;
}

.permiso-denegado-card p {
    max-width: 560px;
    margin: 0 auto 24px;
    color: #6b7280;
    line-height: 1.55;
}

.permiso-denegado-icon {
    font-size: 46px;
}

/* AUTH V4: nunca transformar ni ocultar toda la pantalla */
.auth-protected-page,
.auth-protected-page.auth-ready {
    visibility: visible !important;
    opacity: 1 !important;
    display: block !important;
}
#authAviso,
.auth-aviso-error {
    display: none !important;
}

/* ==================================================
   AUTH DEFINITIVO V5
   La autenticación NO puede ocultar ni reemplazar la interfaz.
================================================== */
html, body {
    visibility: visible !important;
    opacity: 1 !important;
}
body.auth-protected-page,
body.auth-protected-page.auth-ready {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}
#authAviso, .auth-aviso-error { display: none !important; }

/* ==================================================
   MANTENIMIENTO / BACKUP
================================================== */
.mantenimiento-estado{padding:13px 16px;border-radius:10px;margin-bottom:22px;background:#eef2ff;color:#3730a3}.mantenimiento-ok{background:#ecfdf5;color:#166534}.mantenimiento-denegado{background:#fff1f2;color:#991b1b}.mantenimiento-denegado a{color:inherit;font-weight:700}.maintenance-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:20px}.maintenance-card{background:#fff;border-radius:14px;padding:24px;box-shadow:0 3px 15px rgba(0,0,0,.06);display:flex;gap:16px;align-items:flex-start;border:1px solid #eef0f3}.maintenance-card h2{margin:0 0 8px}.maintenance-card p{margin:0 0 17px;color:#6b7280;line-height:1.55}.maintenance-icon{font-size:34px}.safe-card{border-left:5px solid #198754}.warning-card{border-left:5px solid #d97706}.danger-card{border-left:5px solid #dc2626}.danger-zone{margin-top:32px;padding-top:24px;border-top:1px solid #e5e7eb}.maintenance-button{margin-top:12px}.btn-warning{background:#d97706;color:#fff;border:0;padding:11px 16px;border-radius:8px;font-weight:700;cursor:pointer}.btn-danger-strong{background:#b91c1c;color:#fff;border:0;padding:11px 16px;border-radius:8px;font-weight:700;cursor:pointer}.btn-danger-strong:hover{background:#991b1b}.btn-danger-strong:disabled,.btn-warning:disabled{opacity:.6;cursor:wait}.maintenance-modal{max-width:520px}.confirm-box{background:#fff7ed;border:1px solid #fed7aa;border-radius:9px;padding:12px 14px;margin:16px 0}.confirm-box strong{display:block;margin-bottom:7px}.confirm-box code{font-size:15px;font-weight:700;color:#9a3412}.maintenance-card input[type=file]{margin-top:3px;padding:10px;background:#f9fafb}.oculto{display:none!important}@media(max-width:850px){.maintenance-grid{grid-template-columns:1fr}}

/* MIGRACIÓN SUPABASE */
.migration-zone { margin-top: 28px; }
.migration-import-card { grid-column: span 1; }
.migration-import-card label { margin-top: 12px; }
.migration-import-card input { margin-bottom: 4px; }
.migration-actions { display:flex; gap:10px; flex-wrap:wrap; margin-top:16px; }
.migration-steps { background:#eef6ff; border:1px solid #bfdbfe; border-radius:10px; padding:14px 16px; color:#1e3a5f; margin-top:14px; line-height:1.5; }
.migration-status-ok { color:#166534; font-weight:600; }
.migration-status-error { color:#991b1b; font-weight:600; }
