/* Broadcast Booking UI */
:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface2: #243044;
  --border: #2d3a4f;
  --text: #e8eef7;
  --muted: #8b9bb4;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --chosen: #1d4ed8;
  --ok: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 10px;
  --font: "Inter", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100%;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.25rem 1rem;
  flex-shrink: 0;
}
.sidebar .brand { font-weight: 700; font-size: 1.05rem; margin-bottom: .25rem; }
.sidebar .sub { color: var(--muted); font-size: .8rem; margin-bottom: 1.5rem; }
.sidebar nav a {
  display: block;
  padding: .55rem .75rem;
  border-radius: 8px;
  color: var(--text);
  margin-bottom: .25rem;
}
.sidebar nav a:hover,
.sidebar nav a.active {
  background: var(--surface2);
  text-decoration: none;
  color: #fff;
}
.sidebar nav a.active { background: var(--chosen); }
.main { flex: 1; padding: 1.5rem 1.5rem 2rem; max-width: none; width: 100%; min-width: 0; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.topbar h1 { margin: 0; font-size: 1.45rem; }
.topbar-right {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: .75rem;
  justify-content: flex-end;
}
.user-chip { color: var(--muted); font-size: .9rem; white-space: nowrap; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  margin-bottom: 1rem;
}
.card h2, .card h3 { margin-top: 0; }

.grid { display: grid; gap: 1rem; }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

.kpi { background: var(--surface2); border-radius: 8px; padding: 1rem; }
.kpi .label { color: var(--muted); font-size: .8rem; }
.kpi .value { font-size: 1.6rem; font-weight: 700; margin-top: .25rem; }

table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th, table.data td {
  text-align: left;
  padding: .65rem .55rem;
  border-bottom: 1px solid var(--border);
}
table.data th {
  color: var(--muted);
  font-weight: 600;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .03em;
}
table.data tr:hover td { background: rgba(255,255,255,.03); }
.right { text-align: right; }

/* Contenedor con scroll propio (independiente de la página), cabecera fija */
.table-scroll {
  max-height: 480px;
  overflow-y: auto;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.table-scroll table.data { margin-bottom: 0; }
.table-scroll table.data th, .table-scroll table.data td {
  border-bottom: 1px solid var(--border);
}
.table-scroll table.data thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface);
}

.badge {
  display: inline-block;
  padding: .15rem .5rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-NEW { background: #334155; color: #e2e8f0; }
.badge-REQUEST { background: #854d0e; color: #fef3c7; }
.badge-CONFIRMED { background: #065f46; color: #d1fae5; }
.badge-REJECTED, .badge-NOT_AVAILABLE { background: #7f1d1d; color: #fee2e2; }
.badge-CANCELLED { background: #374151; color: #d1d5db; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  border: none;
  border-radius: 8px;
  padding: .55rem 1rem;
  font-weight: 600;
  font-size: .9rem;
  cursor: pointer;
  background: var(--accent);
  color: white;
  text-decoration: none;
}
.btn:hover { background: var(--accent-hover); text-decoration: none; color: white; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #2c3b52; color: #fff; }
.btn-danger { background: var(--danger); }
.btn-ok { background: var(--ok); }
.btn-sm { padding: .35rem .7rem; font-size: .8rem; }
.btn.chosen, .btn.active-choice {
  background: var(--chosen);
  box-shadow: 0 0 0 2px rgba(59,130,246,.45);
}

.flash { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; }
.flash-ok { background: #064e3b; color: #a7f3d0; }
.flash-err { background: #7f1d1d; color: #fecaca; }
.flash-info { background: #1e3a5f; color: #bfdbfe; }

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
}
.login-card {
  width: min(440px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 2rem;
}
.login-card h1 { margin-top: 0; }
.login-card p { color: var(--muted); }

label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .35rem; }
input, select, textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: .6rem .75rem;
  margin-bottom: 1rem;
  font: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  border-color: transparent;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: .75rem;
}
.choice {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  cursor: pointer;
  background: var(--surface2);
}
.choice:hover, .choice.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(59,130,246,.35);
}
.choice strong { display: block; margin-bottom: .35rem; }
.choice span { color: var(--muted); font-size: .85rem; }

.steps {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.step {
  padding: .4rem .75rem;
  border-radius: 999px;
  background: var(--surface2);
  color: var(--muted);
  font-size: .8rem;
  font-weight: 600;
}
.step.on { background: var(--chosen); color: #fff; }

.row-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.empty { color: var(--muted); padding: 1rem 0; }
.muted { color: var(--muted); }
.qty-input, .tech-input { margin-bottom: 0; max-width: 110px; }
.tech-input { max-width: 160px; }

@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
}

/* ===== Language: one horizontal row of checkboxes ===== */
.lang-boxes {
  display: inline-flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: center;
  gap: .3rem;
  padding: .25rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  white-space: nowrap;
}
.lang-boxes-login {
  display: flex !important;
  flex-wrap: wrap !important;
  width: 100%;
  margin-bottom: 1.1rem;
  box-sizing: border-box;
}
/* 4 idiomas: 2 x 2 en la tarjeta de login */
.lang-boxes-login .lang-box { flex: 1 1 calc(50% - .3rem); justify-content: center; }
.lang-box {
  display: inline-flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: .4rem;
  margin: 0;
  padding: .35rem .55rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text) !important;
  cursor: pointer;
  user-select: none;
  font-size: .8rem;
  font-weight: 600;
  white-space: nowrap;
}
.lang-box input[type="checkbox"] {
  -webkit-appearance: checkbox;
  appearance: checkbox;
  width: 14px !important;
  height: 14px !important;
  min-width: 14px !important;
  max-width: 14px !important;
  margin: 0 !important;
  padding: 0 !important;
  accent-color: #3b82f6;
  cursor: pointer;
  flex: 0 0 14px;
}
.lang-box:hover { border-color: var(--accent); }
.lang-box.on {
  background: #1e3a8a;
  border-color: #60a5fa;
  color: #fff !important;
  box-shadow: 0 0 0 2px rgba(59,130,246,.3);
}
.lang-code { font-weight: 800; letter-spacing: .04em; }
.lang-name { font-weight: 500; font-size: .78rem; }
/* En pantallas estrechas la topbar muestra solo el código (ES/FR/EN/PT) */
@media (max-width: 1200px) {
  .topbar .lang-name { display: none; }
}

/* ===== Month calendar: real 7-column grid ===== */
.cal-toolbar { margin-bottom: 1rem; }
.cal-month-title {
  font-size: 1.4rem;
  font-weight: 800;
  padding: .25rem .6rem;
}
.cal-help { margin: .75rem 0 0; color: var(--muted); font-size: .92rem; line-height: 1.4; }

.cal-wrap {
  overflow-x: auto;
  padding: 1rem !important;
  background: #0b1220 !important;
}

/* Force 7 equal columns — do not let content collapse */
.cal-grid {
  display: grid !important;
  grid-template-columns: repeat(7, minmax(0, 1fr)) !important;
  gap: 8px;
  width: 100%;
  margin: 0 0 8px 0;
}
.cal-head {
  margin-bottom: 8px;
}
.cal-head > div {
  text-align: center;
  font-size: .75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #c7d2fe;
  padding: .6rem .2rem;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 8px;
}

.cal-cell {
  min-height: 110px;
  min-width: 0;
  background: #152033;
  border: 1px solid #334155;
  border-radius: 10px;
  padding: .4rem;
  display: flex;
  flex-direction: column;
  gap: .3rem;
  overflow: hidden;
}
.cal-cell.out { opacity: .28; background: #0f172a; }
.cal-cell.today {
  border-color: #38bdf8;
  box-shadow: inset 0 0 0 2px rgba(56,189,248,.35);
}
.cal-cell.has { background: #1a2740; }
.cal-cell.picked {
  border-color: #fbbf24;
  box-shadow: inset 0 0 0 2px rgba(251,191,36,.45);
}

.cal-daynum {
  font-size: 1rem;
  font-weight: 800;
  color: #f1f5f9;
  line-height: 1;
  margin-bottom: .15rem;
}

.cal-sports {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  min-width: 0;
}

.cal-chip {
  display: block !important;
  min-width: 0;
  padding: .3rem .4rem;
  border-radius: 6px;
  text-decoration: none !important;
  color: #0f172a !important;
  font-size: .72rem;
  font-weight: 700;
  line-height: 1.25;
  border: 1px solid rgba(0,0,0,.12);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cal-chip strong { font-weight: 900; margin-right: .2rem; }
.cal-chip-name { font-weight: 600; }
.cal-chip-count {
  display: inline-block;
  margin-left: .2rem;
  background: rgba(0,0,0,.2);
  border-radius: 999px;
  padding: 0 .35rem;
  font-size: .68rem;
}
.cal-chip.selected {
  outline: 2px solid #fff;
  outline-offset: 1px;
}
.cal-chip:hover { filter: brightness(1.08); text-decoration: none !important; }

.cal-legend { display: flex; flex-wrap: wrap; gap: .5rem; }
.cal-legend-item {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .45rem .7rem;
  border-radius: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text) !important;
  text-decoration: none !important;
  font-size: .88rem;
}
.cal-legend-item.on {
  border-color: #60a5fa;
  box-shadow: 0 0 0 2px rgba(96,165,250,.3);
}
.cal-dot {
  width: .85rem;
  height: .85rem;
  border-radius: 4px;
  flex-shrink: 0;
}

.cal-sessions-panel { border: 1px solid #334155; }
.cal-sessions-table td,
.cal-sessions-table th {
  font-size: .92rem !important;
  padding: .75rem .6rem !important;
}
.cal-time { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.cal-sessions-table code {
  font-size: .85rem;
  background: #0f172a;
  padding: .15rem .4rem;
  border-radius: 4px;
}

@media (max-width: 900px) {
  .cal-chip-name { display: none; }
  .lang-name { display: none; }
}

/* Stable sport colors (index = sport_id % 12) */
.cal-chip.sport-0 { background: #7dd3fc; }
.cal-dot.sport-0 { background: #7dd3fc; }
.cal-chip.sport-1 { background: #86efac; }
.cal-dot.sport-1 { background: #86efac; }
.cal-chip.sport-2 { background: #fcd34d; }
.cal-dot.sport-2 { background: #fcd34d; }
.cal-chip.sport-3 { background: #f9a8d4; }
.cal-dot.sport-3 { background: #f9a8d4; }
.cal-chip.sport-4 { background: #c4b5fd; }
.cal-dot.sport-4 { background: #c4b5fd; }
.cal-chip.sport-5 { background: #fda4af; }
.cal-dot.sport-5 { background: #fda4af; }
.cal-chip.sport-6 { background: #a5b4fc; }
.cal-dot.sport-6 { background: #a5b4fc; }
.cal-chip.sport-7 { background: #6ee7b7; }
.cal-dot.sport-7 { background: #6ee7b7; }
.cal-chip.sport-8 { background: #fdba74; }
.cal-dot.sport-8 { background: #fdba74; }
.cal-chip.sport-9 { background: #67e8f9; }
.cal-dot.sport-9 { background: #67e8f9; }
.cal-chip.sport-10 { background: #d8b4fe; }
.cal-dot.sport-10 { background: #d8b4fe; }
.cal-chip.sport-11 { background: #fde047; }
.cal-dot.sport-11 { background: #fde047; }

/* Calendar chip as button */
button.cal-chip {
  width: 100%;
  text-align: left;
  font: inherit;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

/* Sessions popup */
.cal-popup-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(2, 6, 23, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}
.cal-popup-backdrop[hidden] { display: none !important; }
.cal-popup {
  width: min(720px, 100%);
  max-height: min(80vh, 640px);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(0,0,0,.45);
  padding: 1rem 1.15rem 1.15rem;
}
.cal-popup-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}
.cal-popup-head h2 {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.3;
}
.cal-popup-close {
  border: none;
  background: var(--surface2);
  color: var(--text);
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}
.cal-popup-close:hover { background: #334155; }
.cal-popup-sub {
  margin: .5rem 0 1rem;
  color: var(--muted);
  font-size: .92rem;
}
.cal-popup-loading {
  color: var(--muted);
  padding: 1rem 0;
}


/* Permissions FO / BO visual split */
.perm-legend {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  margin: 0 0 1rem;
}
.perm-pill {
  display: inline-flex;
  align-items: center;
  padding: .4rem .75rem;
  border-radius: 999px;
  font-size: .85rem;
  font-weight: 700;
  border: 1px solid transparent;
}
.perm-pill-bo {
  background: #1e3a8a;
  color: #dbeafe;
  border-color: #3b82f6;
}
.perm-pill-fo {
  background: #065f46;
  color: #d1fae5;
  border-color: #10b981;
}
.perms-table th.perm-role-head {
  vertical-align: bottom;
  text-align: center;
  font-size: .75rem;
  line-height: 1.25;
  min-width: 7.5rem;
}
.perm-role-office {
  display: inline-block;
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .06em;
  padding: .12rem .4rem;
  border-radius: 4px;
  margin-bottom: .35rem;
}
.perm-col-bo .perm-role-office,
th.perm-col-bo .perm-role-office {
  background: #1e3a8a;
  color: #bfdbfe;
}
.perm-col-fo .perm-role-office,
th.perm-col-fo .perm-role-office {
  background: #065f46;
  color: #a7f3d0;
}
.perm-role-name { display: block; }
th.perm-col-bo { background: rgba(30, 58, 138, 0.35) !important; }
th.perm-col-fo { background: rgba(6, 95, 70, 0.35) !important; }
td.perm-col-bo { background: rgba(30, 58, 138, 0.12); }
td.perm-col-fo { background: rgba(6, 95, 70, 0.12); }
.perms-section-bo td {
  background: linear-gradient(90deg, #1e3a8a, #1e40af) !important;
  color: #eff6ff !important;
  font-size: .95rem;
  padding: .75rem .65rem !important;
  border-bottom: 2px solid #60a5fa !important;
}
.perms-section-fo td {
  background: linear-gradient(90deg, #065f46, #047857) !important;
  color: #ecfdf5 !important;
  font-size: .95rem;
  padding: .75rem .65rem !important;
  border-bottom: 2px solid #34d399 !important;
}
.perm-section-badge {
  display: inline-block;
  font-size: .75rem;
  font-weight: 900;
  letter-spacing: .08em;
  padding: .2rem .45rem;
  border-radius: 5px;
  margin-right: .5rem;
  vertical-align: middle;
}
.perm-badge-bo { background: #93c5fd; color: #1e3a8a; }
.perm-badge-fo { background: #6ee7b7; color: #064e3b; }
.perm-section-hint { font-weight: 500; font-size: .82rem; margin-left: .35rem; }
.perm-row-bo:hover td.perm-col-bo { background: rgba(30, 58, 138, 0.22); }
.perm-row-fo:hover td.perm-col-fo { background: rgba(6, 95, 70, 0.22); }
