/* ============================================================
   Planificador Campus de Verano — estilos base (tipo Notion)
   ============================================================ */

:root {
    /* Paleta tipo Notion: lienzo blanco, grises neutros, mínimo color */
    --bg: #ffffff;
    --surface: #ffffff;
    --surface-2: #f7f6f3;
    --sidebar-bg: #f7f7f5;
    --border: rgba(55,53,47,.09);
    --border-strong: rgba(55,53,47,.16);
    --text: #37352f;
    --text-soft: #787774;
    --text-faint: #9b9a97;
    --hover: rgba(55,53,47,.06);
    --active: rgba(55,53,47,.09);

    --primary: #2383e2;
    --primary-dark: #0b6bcb;
    --primary-soft: #e9f3fc;
    --accent: #d9730d;
    --accent-soft: #f8ecdf;
    --danger: #e03e3e;
    --danger-soft: #fdecec;
    --ok: #0f7b6c;
    --warn: #cb912f;
    --warn-soft: #fbf3db;

    --radius: 6px;
    --radius-sm: 4px;
    --shadow: 0 0 0 1px rgba(15,15,15,.05), 0 3px 12px rgba(15,15,15,.08);
    --shadow-sm: 0 1px 2px rgba(15,15,15,.04);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0 0 .4em; font-weight: 650; line-height: 1.25; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .8em; }
a { color: var(--primary-dark); }

/* -------------------- Layout general -------------------- */

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

.sidebar {
    width: 240px;
    flex: 0 0 240px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    padding: 18px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: sticky;
    top: 0;
    height: 100vh;
}
.sidebar .brand {
    font-weight: 700;
    font-size: 1.05rem;
    padding: 6px 10px 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.sidebar .brand .logo {
    width: 26px; height: 26px; border-radius: 7px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    flex: 0 0 26px;
}
.nav-link {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    color: var(--text-soft);
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
    /* Reset para cuando .nav-link es un <button> (p. ej. Ayuda) */
    width: 100%; text-align: left;
    background: transparent; border: none;
    font-family: inherit; font-size: inherit;
}
.nav-link:hover { background: var(--hover); color: var(--text); }
.nav-link.active { background: var(--active); color: var(--text); font-weight: 600; }
.nav-link .ico { width: 18px; text-align: center; }
.sidebar .spacer { flex: 1; }
.sidebar .user-box {
    border-top: 1px solid var(--border);
    padding-top: 12px; margin-top: 8px;
    font-size: .85rem; color: var(--text-faint);
}

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    height: 56px; display: flex; align-items: center; gap: 12px;
    padding: 0 24px; border-bottom: 1px solid var(--border);
    background: var(--surface); position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 1.15rem; margin: 0; }
.topbar .grow { flex: 1; }
.page { padding: 24px; max-width: 1100px; width: 100%; margin: 0 auto; flex: 1; }
.app-footer { text-align: center; padding: 16px 24px; color: var(--text-faint);
    font-size: .8rem; border-top: 1px solid var(--border); }
.app-footer strong { color: var(--text-soft); }
.print-footer { display: none; } /* solo visible al imprimir (ver print.css) */

/* -------------------- Botones -------------------- */

.btn {
    display: inline-flex; align-items: center; gap: 7px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: .9rem; font-weight: 550; font-family: inherit;
    cursor: pointer; text-decoration: none; line-height: 1;
    transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--hover); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover { filter: brightness(.95); }
.btn-danger { color: var(--danger); border-color: var(--danger-soft); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-soft); }
.btn-ghost:hover { background: var(--hover); }
.btn-sm { padding: 5px 9px; font-size: .82rem; }
.btn-block { width: 100%; justify-content: center; }

/* -------------------- Formularios -------------------- */

.field { margin-bottom: 14px; }
label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 5px; color: var(--text-soft); }
input[type=text], input[type=password], input[type=number], input[type=date],
input[type=time], input[type=email], select, textarea {
    width: 100%; padding: 9px 11px;
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    font-family: inherit; font-size: .92rem; background: var(--surface); color: var(--text);
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}
textarea { resize: vertical; min-height: 64px; }
.hint { font-size: .8rem; color: var(--text-faint); margin-top: 4px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 120px; }

/* -------------------- Tarjetas -------------------- */

.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: none;
    padding: 18px; margin-bottom: 16px;
}
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-head h2, .card-head h3 { margin: 0; }
.card-head .grow { flex: 1; }

/* -------------------- Badges / chips -------------------- */

.badge {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: .76rem; font-weight: 500; padding: 2px 8px; border-radius: var(--radius-sm);
    background: var(--surface-2); color: var(--text-soft);
}
.badge.ok { background: var(--primary-soft); color: var(--primary-dark); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }

/* Colores por tipo de actividad */
.chip-tipo { display:inline-flex; align-items:center; gap:6px; font-size:.8rem; font-weight:500;
    padding:2px 8px; border-radius:var(--radius-sm); background: var(--surface-2); color: var(--text-soft); }
.chip-tipo .dot { width:9px; height:9px; border-radius:50%; background: var(--text-faint); }

/* -------------------- Tablas -------------------- */

table.tabla { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.tabla th, table.tabla td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); }
table.tabla th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--text-faint); }
table.tabla tr:hover td { background: var(--hover); }

/* -------------------- Pantalla de acceso / instalador -------------------- */

.auth-wrap {
    min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 18px; padding: 24px;
    background: var(--surface-2);
}
.auth-footer { margin: 0; text-align: center; color: var(--text-faint); font-size: .78rem; max-width: 400px; }
.auth-footer strong { color: var(--text-soft); }
.auth-card {
    width: 100%; max-width: 400px; background: var(--surface);
    border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow);
    padding: 30px 28px;
}
.auth-card .logo-big {
    width: 52px; height: 52px; border-radius: 13px; margin-bottom: 14px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
}
.auth-card h1 { font-size: 1.35rem; }
.auth-card .sub { color: var(--text-soft); margin-bottom: 22px; font-size: .92rem; }

/* -------------------- Avisos -------------------- */

.notice { padding: 11px 14px; border-radius: var(--radius-sm); font-size: .9rem; margin-bottom: 16px; border: 1px solid; }
.notice.error { background: var(--danger-soft); border-color: #eccabf; color: var(--danger); }
.notice.ok { background: var(--primary-soft); border-color: #c4e4df; color: var(--primary-dark); }
.notice.info { background: var(--warn-soft); border-color: #efdcae; color: var(--warn); }

/* Toast flotante */
#toast {
    position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px);
    background: #2b2a27; color: #fff; padding: 10px 18px; border-radius: 999px;
    font-size: .88rem; opacity: 0; pointer-events: none; transition: all .25s; z-index: 1000;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* -------------------- Utilidades -------------------- */

.muted { color: var(--text-faint); }
.small { font-size: .82rem; }
.center { text-align: center; }
.flex { display: flex; align-items: center; gap: 10px; }
.flex-wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.hidden { display: none !important; }
.empty-state { text-align: center; color: var(--text-faint); padding: 40px 20px; }
.empty-state .big { font-size: 2rem; margin-bottom: 8px; }

/* -------------------- Responsive -------------------- */

/* -------------------- Modal -------------------- */

.modal-overlay {
    position: fixed; inset: 0; background: rgba(30,28,24,.45);
    display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 500;
}
.modal-card {
    background: var(--surface); border-radius: 10px; box-shadow: var(--shadow);
    width: 100%; max-width: 460px; max-height: 90vh; overflow: auto;
}
.modal-head { display: flex; align-items: center; padding: 16px 18px 6px; }
.modal-head h3 { margin: 0; flex: 1; }
.modal-body { padding: 6px 18px 12px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px 18px; }

/* -------------------- Planificador (lista de días) -------------------- */

.dias-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.dia-card { display: flex; flex-direction: column; margin-bottom: 0; }
.dia-card-head { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 10px; }
.dia-card-head .grow { flex: 1; }
.dia-fecha { font-weight: 650; }
.dia-titulo { color: var(--text-soft); font-size: .9rem; }
.dia-acts { flex: 1; display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.dia-act-fila { display: flex; align-items: center; gap: 7px; font-size: .86rem; }
.dia-act-hora { font-variant-numeric: tabular-nums; color: var(--text-soft); min-width: 38px; font-weight: 600; }
.dia-act-tit { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dia-card-pie { display: flex; flex-wrap: wrap; gap: 6px; border-top: 1px solid var(--border); padding-top: 12px; }

.lista-plantillas, .plantilla-fila { display: flex; flex-direction: column; gap: 8px; }
.plantilla-fila { flex-direction: row; align-items: center; gap: 8px; }

/* -------------------- Detalle de día -------------------- */

.dia-head .row { align-items: flex-end; }
.horario-fila { display: flex; align-items: center; gap: 10px; padding: 5px 0; border-bottom: 1px dashed var(--border); }
.horario-fila:last-child { border-bottom: none; }
.horario-hora { font-variant-numeric: tabular-nums; font-weight: 650; min-width: 90px; color: var(--primary-dark); }
.horario-tit { color: var(--text); }

.act-card { margin-bottom: 14px; }
.act-top { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.act-tipo { width: auto; min-width: 150px; }
.act-horas { display: flex; align-items: center; gap: 6px; }
.act-hora { width: 110px; }
.act-titulo { font-size: 1.05rem; font-weight: 600; border: none; border-bottom: 1px solid transparent; border-radius: 0; padding: 6px 2px; }
.act-titulo:focus { box-shadow: none; border-bottom: 1px solid var(--primary); }
.act-desc { margin-bottom: 6px; }
.act-sub { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--text-faint); margin: 12px 0 6px; font-weight: 600; }

.mat-box { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.mat-fila { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mat-fila .mat-chk { width: 18px; height: 18px; flex: 0 0 auto; }
.mat-nombre { flex: 1; min-width: 130px; }
.mat-cant { width: 66px; flex: 0 0 66px; text-align: center; }
.mat-unidad { width: 78px; flex: 0 0 78px; }
.mat-precio { width: 90px; flex: 0 0 90px; text-align: center; }
.mat-sub { min-width: 62px; font-variant-numeric: tabular-nums; }
.mat-fila.comprado .mat-nombre { text-decoration: line-through; color: var(--text-faint); }

/* Gasto en materiales */
.dia-gasto { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.gasto-resumen { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 10px 14px; margin-bottom: 14px; }
.agg-gasto { color: var(--primary-dark); font-weight: 600; font-variant-numeric: tabular-nums;
    min-width: 70px; text-align: right; }

.aniadir-act { margin: 6px 0 30px; }
.tipo-picker { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

/* -------------------- Tutorial -------------------- */

.tutorial { padding: 26px 24px 20px; text-align: center; }
.tutorial .t-icono { font-size: 2.6rem; margin-bottom: 6px; }
.tutorial h3 { font-size: 1.2rem; }
.tutorial p { color: var(--text-soft); }
.t-dots { display: flex; justify-content: center; gap: 6px; margin: 16px 0; }
.t-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); }
.t-dot.on { background: var(--primary); }
.t-nav { display: flex; align-items: center; gap: 8px; }

/* -------------------- Responsive -------------------- */

@media (max-width: 820px) {
    .app { flex-direction: column; }
    .sidebar {
        width: 100%; flex: none; height: auto; position: static;
        flex-direction: row; flex-wrap: wrap; align-items: center;
        border-right: none; border-bottom: 1px solid var(--border); padding: 10px;
    }
    .sidebar .brand { padding: 6px 10px; }
    .sidebar .spacer, .sidebar .user-box { display: none; }
    .nav-link { padding: 7px 10px; }
    .cal-grid { font-size: .8rem; }
}

/* -------------------- Calendario -------------------- */

.cal-nav { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.cal-nav-lbl { font-weight: 700; font-size: 1.05rem; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow { text-align: center; font-size: .75rem; font-weight: 700; color: var(--text-faint); padding: 4px 0; }
.cal-cell { min-height: 78px; border: 1px solid var(--border); border-radius: 8px; padding: 4px; background: var(--surface); }
.cal-cell.empty { background: transparent; border: none; }
.cal-cell.has { background: var(--surface-2); }
.cal-daynum { font-size: .78rem; color: var(--text-faint); font-weight: 600; }
.cal-dia { cursor: pointer; background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
    padding: 4px 6px; margin-top: 3px; transition: border-color .12s, box-shadow .12s; }
.cal-dia:hover { border-color: var(--primary); box-shadow: var(--shadow-sm); }
.cal-dia-tit { font-size: .8rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-dots { display: flex; flex-wrap: wrap; gap: 3px; margin: 3px 0; }
.cal-dots .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.sinfecha-lista { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }

/* -------------------- Materiales agregados -------------------- */

.agg-lista { display: flex; flex-direction: column; }
.agg-fila { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--border); cursor: pointer; }
.agg-fila:last-child { border-bottom: none; }
.agg-fila input[type=checkbox] { width: 18px; height: 18px; }
.agg-nombre { font-weight: 550; }
.agg-cant { color: var(--text-soft); font-variant-numeric: tabular-nums; }
.agg-fila.comprado .agg-nombre { text-decoration: line-through; color: var(--text-faint); }

/* -------------------- Panel admin -------------------- */

.admin-tabs { display: flex; gap: 6px; margin-bottom: 18px; border-bottom: 1px solid var(--border); }
.tabbtn { border: none; background: transparent; padding: 10px 14px; cursor: pointer; font-family: inherit;
    font-size: .92rem; font-weight: 600; color: var(--text-soft); border-bottom: 2px solid transparent; }
.tabbtn:hover { color: var(--text); }
.tabbtn.active { color: var(--primary-dark); border-bottom-color: var(--primary); }

.tiempo-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.tiempo-bloque { background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px 14px; }
.tb-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--text-faint); font-weight: 600; }
.tb-val { font-size: 1.25rem; font-weight: 700; margin: 4px 0 8px; }
.tb-val.rojo { color: var(--danger); }
.barra { height: 7px; background: var(--border); border-radius: 999px; overflow: hidden; }
.barra-fill { height: 100%; border-radius: 999px; }
.barra-fill.verde { background: var(--ok); }
.barra-fill.ambar { background: var(--warn); }
.barra-fill.rojo { background: var(--danger); }

.acciones-u { white-space: nowrap; }
.acciones-u .btn { margin-right: 4px; }

/* -------------------- Documento imprimible (vista en pantalla) -------------------- */

.doc { max-width: 820px; margin: 0 auto; }
.doc-portada { text-align: center; padding: 56px 20px; border: 1px solid var(--border);
    border-radius: 12px; margin-bottom: 18px; background: var(--surface); }
.doc-portada h1 { font-size: 2rem; margin-bottom: 4px; }
.doc-sub { color: var(--text-soft); }
.doc-meta { margin: 2px 0; }
.doc-logo { width: 64px; height: 64px; border-radius: 16px; margin: 0 auto 14px;
    background: linear-gradient(135deg, var(--primary), var(--accent)); }

.doc-dia, .doc-global { border: 1px solid var(--border); border-radius: 12px; padding: 22px;
    margin-bottom: 18px; background: var(--surface); }
.doc-dia-head { border-bottom: 1px solid var(--border); padding-bottom: 8px; margin-bottom: 12px; }
.doc-dia-head h2 { margin: 0; }
.doc-dia-tit { color: var(--text-soft); }
.doc-notas { color: var(--text-soft); white-space: normal; }
.doc-h3 { font-size: .95rem; text-transform: uppercase; letter-spacing: .03em; color: var(--text-faint); margin: 10px 0 4px; }
.doc-horario { width: 100%; border-collapse: collapse; margin: 4px 0 16px; }
.doc-horario td { padding: 5px 6px; border-bottom: 1px solid var(--border); }
.dh-hora { font-weight: 700; width: 130px; font-variant-numeric: tabular-nums; }

.doc-act { padding: 10px 0; border-top: 1px dashed var(--border); }
.doc-act-head { display: flex; align-items: center; gap: 8px; }
.doc-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: 0 0 auto; }
.doc-act-tipo { font-size: .8rem; color: var(--text-faint); }
.doc-act-hora { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; }
.doc-act-desc { margin: 6px 0; }
.doc-act-notas { margin: 4px 0; color: var(--text-soft); font-size: .9rem; }
.doc-mats { margin-top: 6px; }
.doc-mats-label { font-size: .82rem; font-weight: 600; color: var(--text-soft); }
.doc-mats ul, .doc-global-lista { list-style: none; padding-left: 0; margin: 4px 0; }
.doc-mats li, .doc-global-lista li { padding: 3px 0; }
.doc-global-lista { column-count: 2; column-gap: 28px; }
.check-box { display: inline-block; width: 13px; height: 13px; border: 1.5px solid var(--text-soft);
    border-radius: 3px; margin-right: 7px; vertical-align: middle; }
.doc-cant { color: var(--text-soft); font-variant-numeric: tabular-nums; }
.doc-precio { color: var(--primary-dark); font-weight: 600; font-variant-numeric: tabular-nums; margin-left: 8px; }
.doc-dia-total { margin-top: 12px; padding-top: 8px; border-top: 1px solid var(--border); }
.doc-total-campus { margin-top: 16px; padding-top: 10px; border-top: 2px solid var(--text); font-size: 1.1rem; }
.doc-footer { margin-top: 22px; color: var(--text-faint); font-size: .82rem; }
.doc-footer strong { color: var(--text-soft); }
