/* BitFARMA Calendar v2 */
:root {
  --brand: #0fa0bf;
  --brand-dark: #0b7f98;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #f3f6f9;
  --card: #fff;
  --danger: #dc2626;
  --warn: #f59e0b;
  --ok: #16a34a;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.05);
  --font: "Montserrat", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* colores de tipos (iguales que assets/js/fc.js) */
  --t-festivo: #f6c811; --t-vacaciones: #f59e0b; --t-vacaciones_ano_pasado: #e7c400; --t-licencia: #db7093;
  --t-baja: #d2691e; --t-ausencia: #f59e0b; --t-cumpleanos: #d8135a; --t-desarrollo: #7e3838;
  --t-instalaciones: #2563eb; --t-guardia: #15803d; --t-pending: #9ca3af;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { font-family: var(--font); color: var(--ink); background: var(--bg); font-size: 14px; line-height: 1.45; }
a { color: var(--brand-dark); }
h1, h2, h3, h4 { margin: 0 0 .6em; line-height: 1.2; }
h4 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-top: 1.2em; }
h4:first-child { margin-top: 0; }

/* ---------- Barra superior ---------- */
.topbar {
  display: flex; align-items: center; gap: 1.5rem; padding: .5rem 1.25rem;
  background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.brand img { height: 36px; display: block; }
.mainnav { display: flex; gap: .25rem; flex: 1; }
.mainnav a { padding: .5rem .9rem; border-radius: 8px; text-decoration: none; color: var(--ink); font-weight: 600; }
.mainnav a:hover { background: var(--bg); }
.mainnav a.active { background: var(--brand); color: #fff; }
.userbox { display: flex; align-items: center; gap: .75rem; }
.username { font-weight: 600; }
.nav-toggle { display: none; background: none; border: 0; font-size: 1.4rem; cursor: pointer; }

.main { padding: 1.25rem; max-width: 1800px; margin: 0 auto; }

/* ---------- Layouts ---------- */
.layout-3 { display: grid; grid-template-columns: 230px 1fr 280px; gap: 1rem; align-items: start; }
.layout-2 { display: grid; grid-template-columns: 230px 1fr; gap: 1rem; align-items: start; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; max-width: 1100px; margin: 0 auto; }
.span-2 { grid-column: span 2; }
.panel, .card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; }
.layout-3 > aside, .layout-2 > aside { position: sticky; top: 70px; }
.narrow { max-width: 520px; margin: 3rem auto; }

/* ---------- Formularios ---------- */
label { display: block; font-weight: 600; margin-bottom: .8rem; }
label.inline { display: inline-flex; align-items: center; gap: .4rem; font-weight: 500; margin: 0 .8rem .4rem 0; }
input, select, textarea {
  display: block; width: 100%; margin-top: .3rem; padding: .55rem .7rem; font: inherit;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink);
}
label.inline input { width: auto; margin: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 40%, transparent); border-color: var(--brand); }
.w-num { width: 90px !important; display: inline-block !important; margin-left: .3rem; }
fieldset.checks { border: 1px solid var(--line); border-radius: 8px; padding: .5rem .8rem; margin: 0 0 .8rem; }
fieldset.checks legend { font-weight: 600; padding: 0 .3rem; }
.hint { color: var(--muted); font-size: .85rem; font-weight: 400; display: block; margin: .3rem 0 .6rem; }
.form-error { color: var(--danger); font-weight: 600; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .55rem 1rem;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; transition: background .15s, opacity .15s;
}
.btn:hover { background: var(--bg); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; margin-top: .5rem; }
.btn-sm { padding: .3rem .6rem; font-size: .85rem; }
.btn-icon { background: none; border: 0; font-size: 1.2rem; line-height: 1; cursor: pointer; color: var(--muted); padding: .2rem .4rem; }
.btn-icon:hover { color: var(--danger); }

/* ---------- Leyenda / filtros ---------- */
.legend { list-style: none; padding: 0; margin: 0; }
.legend li { display: flex; align-items: center; gap: .5rem; padding: .2rem 0; }
.legend label { display: flex; align-items: center; gap: .5rem; font-weight: 500; margin: 0; cursor: pointer; }
.legend input { width: auto; margin: 0; }
.sw { display: inline-block; width: 14px; height: 14px; border-radius: 4px; flex: none; }
.t-festivo { background: var(--t-festivo); } .t-vacaciones { background: var(--t-vacaciones); }
.t-vacaciones_ano_pasado { background: var(--t-vacaciones_ano_pasado); } .t-licencia { background: var(--t-licencia); }
.t-baja { background: var(--t-baja); } .t-ausencia { background: var(--t-ausencia); } .t-cumpleanos { background: var(--t-cumpleanos); }
.t-desarrollo { background: var(--t-desarrollo); } .t-instalaciones { background: var(--t-instalaciones); }
.t-guardia { background: var(--t-guardia); } .t-pending { background: repeating-linear-gradient(45deg, #9ca3af 0 4px, #d1d5db 4px 8px); }

/* ---------- Saldo ---------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.toolbar label.inline { margin: 0; }
.toolbar label.inline .w-num { margin-top: 0; }
.toolbar input[type=search] { max-width: 320px; margin: 0; }
.user-select { margin: 0; min-width: 220px; }
.stats { display: flex; flex-wrap: wrap; gap: .6rem; margin-left: auto; }
.stat { background: var(--bg); border-radius: 8px; padding: .45rem .8rem; min-width: 120px; }
.stat span { display: block; font-size: .75rem; color: var(--muted); font-weight: 600; }
.stat strong { font-size: 1.35rem; color: var(--brand-dark); }
.card .stats { margin: 1rem 0 0; }

/* ---------- Carrito ---------- */
.pill { display: inline-block; min-width: 1.8em; padding: .1em .5em; border-radius: 999px; background: var(--brand); color: #fff; text-align: center; }
.cart { list-style: none; padding: 0; margin: 0 0 .5rem; max-height: 50vh; overflow: auto; }
.cart-item { display: flex; justify-content: space-between; align-items: start; gap: .5rem; padding: .55rem .6rem; border: 1px dashed var(--line); border-radius: 8px; margin-bottom: .4rem; }
.cart .empty { color: var(--muted); padding: .5rem 0; }

/* ---------- FullCalendar ---------- */
.fc { --fc-border-color: var(--line); --fc-today-bg-color: color-mix(in srgb, var(--brand) 10%, transparent); --fc-button-bg-color: var(--brand); --fc-button-border-color: var(--brand); --fc-button-hover-bg-color: var(--brand-dark); --fc-button-hover-border-color: var(--brand-dark); --fc-button-active-bg-color: var(--brand-dark); --fc-button-active-border-color: var(--brand-dark); }
.fc .fc-toolbar-title { font-size: 1.25rem; }
.fc .fc-toolbar-title::first-letter, .fc .fc-multimonth-title::first-letter { text-transform: uppercase; }
.fc .fc-button { text-transform: capitalize; font-weight: 600; }
.fc .fc-event { cursor: pointer; font-size: .78rem; }
.fc .ev-pending { opacity: .85; border-style: dashed !important; }
.fc .fc-day-sat, .fc .fc-day-sun { background: #fafafa; }
/* Vista anual: barras finas de color, el texto va en el tooltip */
.fc .fc-multimonth-daygrid .fc-daygrid-event { font-size: 0; min-height: 6px; margin-top: 1px; border-radius: 3px; }
/* Calendario general, vista año: barras más gruesas */
.page-calendar .fc .fc-multimonth-daygrid .fc-daygrid-event { min-height: 11px; margin-top: 2px; border-radius: 4px; }
.fc .fc-multimonth-daygrid .fc-daygrid-day-events { margin: 0 1px 2px; min-height: 0; }
.fc .fc-multimonth-daygrid .fc-daygrid-day-top { justify-content: center; }
.fc .fc-multimonth-title { font-size: 1rem; }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .55rem .6rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #fafbfc; position: sticky; top: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .neg { color: var(--danger); font-weight: 700; }
.table .actions { white-space: nowrap; text-align: right; }
.table tr.inactive td { color: var(--muted); }
.table .empty { text-align: center; color: var(--muted); padding: 1.5rem; }
.badge { display: inline-block; font-size: .7rem; font-weight: 700; padding: .1em .5em; border-radius: 6px; background: color-mix(in srgb, var(--brand) 15%, #fff); color: var(--brand-dark); vertical-align: middle; }
.badge-warn { background: #fef3c7; color: #92400e; }

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; }
.tab { background: none; border: 0; padding: .6rem 1rem; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; }
.tab.active { color: var(--brand-dark); border-bottom-color: var(--brand); }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1rem; margin: 0; }
.kv dt { color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; }
.alert { padding: .8rem 1rem; border-radius: 8px; font-weight: 600; }
.alert-warn { background: #fef3c7; color: #92400e; }
.temp-pw code { font-size: 1.4rem; padding: .3rem .6rem; background: var(--bg); border-radius: 6px; user-select: all; }

/* ---------- Login ---------- */
.page-public { background: linear-gradient(135deg, #0fa0bf 0%, #0b5f73 100%); min-height: 100vh; }
.login-wrap { display: grid; place-items: center; min-height: calc(100vh - 2.5rem); }
.login-card { width: min(380px, 100%); padding: 2rem; }
.login-logo { height: 56px; display: block; margin: 0 auto 1rem; }
.login-card h1 { text-align: center; font-size: 1.2rem; color: var(--muted); font-weight: 600; margin-bottom: 1.5rem; }

/* ---------- Modal ---------- */
.modal { border: 0; border-radius: 12px; padding: 0; width: min(480px, calc(100vw - 2rem)); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal::backdrop { background: rgba(15, 23, 42, .45); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.2rem .5rem; }
.modal-head h3 { margin: 0; }
.modal-x { background: none; border: 0; font-size: 1.6rem; cursor: pointer; color: var(--muted); }
.modal-body { padding: .5rem 1.2rem; max-height: 65vh; overflow: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: .5rem; padding: .8rem 1.2rem 1.1rem; }
.modal-actions .btn-danger { margin-right: auto; }

/* ---------- Avisos ---------- */
.toasts { position: fixed; right: 1rem; bottom: 1rem; display: grid; gap: .5rem; z-index: 100; }
.toast { background: var(--ink); color: #fff; padding: .7rem 1rem; border-radius: 8px; box-shadow: var(--shadow); max-width: 380px; transition: opacity .3s, transform .3s; }
.toast-ok { background: var(--ok); }
.toast-error { background: var(--danger); }
.toast.out { opacity: 0; transform: translateY(8px); }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .layout-3 { grid-template-columns: 1fr 280px; }
  .layout-3 > aside:first-child { grid-column: span 2; position: static; display: grid; grid-template-columns: 1fr 2fr; gap: 1rem; }
}
@media (max-width: 860px) {
  .layout-3, .layout-2, .grid-2 { grid-template-columns: 1fr; }
  .layout-3 > aside, .layout-2 > aside { position: static; grid-column: auto !important; display: block !important; }
  .span-2 { grid-column: auto; }
  .stats { margin-left: 0; }
  .nav-toggle { display: block; margin-left: auto; }
  .topbar { flex-wrap: wrap; }
  .mainnav, .userbox { display: none; width: 100%; }
  .nav-open .mainnav { display: flex; flex-direction: column; }
  .nav-open .userbox { display: flex; justify-content: space-between; padding-bottom: .5rem; }
  .main { padding: .75rem; }
  /* Leyenda compacta y el carrito encima del calendario (si no, quedaría debajo de los 12 meses) */
  .legend { display: flex; flex-wrap: wrap; gap: .1rem 1rem; }
  .layout-3 > .panel-main { order: 2; }
  .stat { min-width: 0; flex: 1 1 40%; }
  .cart { max-height: 30vh; }
  .fc .fc-toolbar { flex-wrap: wrap; gap: .5rem; }
  .fc .fc-toolbar-title { font-size: 1.05rem; }
}
.fc .bg-shade { opacity: .28; }

/* ---------- Calendarios a pantalla completa (escritorio) ----------
   La página ocupa exactamente la ventana: paneles y contadores fijos, solo se desplaza el calendario. */
@media (min-width: 861px) {
  body.page-calendar { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
  body.page-calendar .main { flex: 1; min-height: 0; max-width: none; width: 100%; padding: 1rem; }
  .page-calendar .layout-2 { height: 100%; align-items: stretch; }
  .page-calendar .layout-2 > aside { position: static; align-self: start; max-height: 100%; overflow: auto; }
  .page-calendar .panel-main { display: flex; flex-direction: column; min-height: 0; }
  .page-calendar #calendar { flex: 1; min-height: 0; }
}
@media (min-width: 1201px) {
  body.page-holidays { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
  body.page-holidays .main { flex: 1; min-height: 0; max-width: none; width: 100%; padding: 1rem; }
  .page-holidays .layout-3 { height: 100%; align-items: stretch; }
  .page-holidays .layout-3 > aside { position: static; align-self: start; max-height: 100%; overflow: auto; }
  .page-holidays .panel-main { display: flex; flex-direction: column; min-height: 0; }
  .page-holidays .panel-main .toolbar { flex: none; }
  .page-holidays #calendar { flex: 1; min-height: 0; }
}

/* ---------- Mostrar/ocultar contraseña ---------- */
.pw-wrap { position: relative; display: block; margin-top: .3rem; }
.pw-wrap input { margin-top: 0; padding-right: 2.6rem; }
.pw-toggle {
  position: absolute; top: 50%; right: .35rem; transform: translateY(-50%);
  display: grid; place-items: center; width: 2rem; height: 2rem; padding: 0;
  background: none; border: 0; border-radius: 6px; color: var(--muted); cursor: pointer;
}
.pw-toggle:hover, .pw-toggle:focus-visible { color: var(--brand-dark); background: var(--bg); }
