/* Claude Licenses - consola de turnos de la licencia premium flotante */

@font-face {
  font-family: 'Cal Sans';
  src: url('/fonts/CalSans-Regular-subset.ttf') format('truetype');
  font-weight: 400;
  font-display: swap;
}

:root {
  --ink: #0b0b18;
  --petrol: #1a1a2e;
  --deep: #2c2f5a;
  --violet: #5e63c9;
  --royal: #7163db;
  --lavender: #9aa4ff;
  --ether: #c0b6f2;

  --surface: #14142a;
  --surface-2: #191934;
  --line: rgba(154, 164, 255, 0.14);
  --line-strong: rgba(154, 164, 255, 0.28);
  --text: #e8e6f7;
  --muted: #8f8fb4;
  --dim: #5f5f86;
  --good: #46d9a4;
  --warn: #ffbe5c;
  --bad: #ff6b81;

  --display: 'Cal Sans', 'Futura', 'Avenir Next', sans-serif;
  --mono: ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, monospace;
  --body: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;

  --row-h: 46px;
  --gutter: 58px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1100px 620px at 78% -8%, rgba(113, 99, 219, 0.2), transparent 62%),
    radial-gradient(760px 520px at 4% 108%, rgba(44, 47, 90, 0.5), transparent 60%),
    var(--ink);
  color: var(--text);
  font-family: var(--body);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    linear-gradient(rgba(154, 164, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(154, 164, 255, 0.045) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(120% 90% at 50% 0%, #000 20%, transparent 85%);
}

.shell { position: relative; z-index: 1; max-width: 1560px; margin: 0 auto; padding: 22px 26px 60px; }

/* --- Cabecera ------------------------------------------------------------ */

header.top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: baseline; gap: 14px; }

.brand h1 {
  font-family: var(--display);
  font-size: 30px;
  letter-spacing: 0.01em;
  margin: 0;
  line-height: 1;
}
.brand h1 em { font-style: normal; color: var(--royal); }

.brand .sub {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--dim);
}

.top-right { display: flex; flex-direction: column; align-items: flex-end; gap: 9px; }
.status-strip { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  padding: 6px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(20, 20, 42, 0.7);
  white-space: nowrap;
}
.pill b { color: var(--text); font-weight: 500; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); }
.dot.ok { background: var(--good); box-shadow: 0 0 10px rgba(70, 217, 164, 0.7); }
.dot.bad { background: var(--bad); box-shadow: 0 0 10px rgba(255, 107, 129, 0.7); }
.dot.warn { background: var(--warn); }

.pill.preview {
  border-color: rgba(255, 190, 92, 0.42);
  background: rgba(255, 190, 92, 0.1);
  color: #ffd79a;
}

/* --- Rejilla principal --------------------------------------------------- */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 316px;
  gap: 20px;
  margin-top: 20px;
  align-items: stretch;
}

@media (max-width: 1100px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
}

.card {
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}

.card > h2 {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--dim);
  margin: 0;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

/* --- Tarjeta de estado actual -------------------------------------------- */

.now {
  padding: 20px 22px 22px;
  position: relative;
  background:
    radial-gradient(520px 200px at 88% 0%, rgba(113, 99, 219, 0.22), transparent 70%),
    linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  margin-bottom: 18px;
  overflow: hidden;
}

.now .label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ether);
  opacity: 0.75;
}

.now .holder {
  font-family: var(--display);
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.05;
  margin: 8px 0 6px;
}
.now .holder.free { color: var(--dim); }

.now .detail { color: var(--muted); font-size: 13px; }
.now .detail strong { color: var(--ether); font-weight: 500; }

.now-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }

.fixed-notice {
  margin-top: 14px;
  padding: 11px 14px;
  border: 1px solid rgba(255, 190, 92, 0.32);
  background: rgba(255, 190, 92, 0.08);
  border-radius: 10px;
  color: #ffd79a;
  font-size: 13px;
  line-height: 1.45;
  max-width: 560px;
}
.fixed-notice b { color: #fff; font-weight: 600; }

.beam {
  position: absolute;
  right: -40px;
  top: -60px;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: conic-gradient(from 210deg, rgba(113, 99, 219, 0.45), rgba(154, 164, 255, 0.08) 40%, transparent 65%);
  filter: blur(26px);
  pointer-events: none;
  animation: drift 14s ease-in-out infinite alternate;
}
@keyframes drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(-22px, 16px, 0) scale(1.12); }
}

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

button, .btn {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text);
  background: rgba(113, 99, 219, 0.12);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 8px 13px;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.1s ease;
}
button:hover { background: rgba(113, 99, 219, 0.26); border-color: var(--royal); }
button:active { transform: translateY(1px); }
button.primary { background: var(--royal); border-color: var(--royal); color: #fff; }
button.primary:hover { background: #8375e6; }
button.ghost { background: transparent; }
button.danger { color: var(--bad); border-color: rgba(255, 107, 129, 0.35); background: rgba(255, 107, 129, 0.08); }
button.danger:hover { background: rgba(255, 107, 129, 0.18); border-color: var(--bad); }
button:disabled { opacity: 0.4; cursor: not-allowed; }

.icon-btn { padding: 6px 10px; }

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

.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
/* En mono porque Cal Sans no trae el glifo "/" de las fechas. */
.cal-range {
  font-family: var(--mono);
  font-size: 15px;
  letter-spacing: 0.02em;
  color: var(--text);
}
.cal-nav { display: flex; gap: 6px; }

/* Sin scroll propio: la rejilla se pinta entera y scrollea la pagina.
   Solo en pantallas estrechas se permite arrastrar en horizontal. */
.cal-scroll { overflow: visible; }

@media (max-width: 860px) {
  .cal-scroll { overflow-x: auto; }
}

.cal-grid {
  display: grid;
  grid-template-columns: var(--gutter) repeat(7, minmax(88px, 1fr));
  position: relative;
  min-width: 720px;
}

.cal-corner,
.day-head {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #12122a;
  box-shadow: 0 6px 14px rgba(11, 11, 24, 0.5);
  border-bottom: 1px solid var(--line-strong);
  padding: 9px 8px;
  text-align: center;
}
.cal-corner { z-index: 4; border-right: 1px solid var(--line); }

.day-head .dow {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--dim);
}
.day-head .dnum { font-family: var(--display); font-size: 17px; line-height: 1.15; }
.day-head .dmonth { font-family: var(--mono); font-size: 9px; color: var(--dim); letter-spacing: 0.06em; }
.day-head.today .dnum { color: var(--royal); }
.day-head.today .dow { color: var(--lavender); }

.hours { grid-column: 1; border-right: 1px solid var(--line); }
.hour-label {
  height: var(--row-h);
  font-family: var(--mono);
  font-size: 10px;
  color: var(--dim);
  text-align: right;
  padding: 4px 8px 0 0;
}

.day-col {
  position: relative;
  border-right: 1px solid rgba(154, 164, 255, 0.07);
  cursor: crosshair;
}
.day-col:last-child { border-right: none; }

.slot {
  height: var(--row-h);
  border-bottom: 1px solid rgba(154, 164, 255, 0.07);
}
.slot.half { border-bottom-style: dashed; }

.nowline {
  position: absolute;
  left: 0;
  right: 0;
  height: 0;
  border-top: 1px solid var(--bad);
  z-index: 2;
  pointer-events: none;
}
.nowline::before {
  content: '';
  position: absolute;
  left: -4px;
  top: -4px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--bad);
}

.ev {
  position: absolute;
  left: 4px;
  right: 4px;
  border-radius: 7px;
  padding: 6px 8px;
  overflow: hidden;
  background: linear-gradient(160deg, rgba(113, 99, 219, 0.95), rgba(94, 99, 201, 0.82));
  border: 1px solid rgba(192, 182, 242, 0.5);
  box-shadow: 0 6px 18px rgba(11, 11, 24, 0.55);
  cursor: pointer;
  z-index: 1;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.ev:hover { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(11, 11, 24, 0.7); }
.ev .who { font-family: var(--display); font-size: 14px; line-height: 1.15; }
.ev .when { font-family: var(--mono); font-size: 10px; opacity: 0.82; margin-top: 2px; }
.ev.past { opacity: 0.44; filter: saturate(0.5); }
.ev.live {
  background: linear-gradient(160deg, #8375e6, #6a5fd6);
  border-color: var(--ether);
  box-shadow: 0 0 0 1px rgba(192, 182, 242, 0.35), 0 8px 26px rgba(113, 99, 219, 0.45);
}
.ev.ghost {
  background: rgba(113, 99, 219, 0.28);
  border: 1px dashed var(--ether);
  pointer-events: none;
}

/* --- Panel lateral ------------------------------------------------------- */

/* La columna de la derecha llega hasta el final del calendario: la tarjeta de
   actividad se come el hueco que sobra en vez de dejar un vacio. */
.side { display: flex; flex-direction: column; gap: 16px; min-height: 0; }
.side > .card { flex: none; }
.side > #log-card { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; }
/* base 0 para que el registro no empuje la altura de la columna: la manda el
   calendario y aqui dentro se hace scroll. */
.side > #log-card .log { flex: 1 1 0; min-height: 0; }

@media (max-width: 1100px) {
  .side > #log-card { flex: none; }
}

.member {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-bottom: 1px solid rgba(154, 164, 255, 0.07);
}
.member:last-child { border-bottom: none; }
.member .avatar {
  width: 28px; height: 28px; border-radius: 8px;
  display: grid; place-items: center;
  font-family: var(--mono); font-size: 11px;
  background: rgba(113, 99, 219, 0.18);
  border: 1px solid var(--line);
  color: var(--ether);
  flex: none;
}
.member .who { min-width: 0; flex: 1; }
.member .name { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member .mail {
  font-family: var(--mono); font-size: 10px; color: var(--dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.tag {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 3px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  flex: none;
}
.tag.premium { color: var(--ether); border-color: var(--royal); background: rgba(113, 99, 219, 0.2); }
.tag.locked { color: var(--warn); border-color: rgba(255, 190, 92, 0.3); }
.tag.none { color: var(--dim); }

.log { max-height: none; overflow: auto; }
.log-row {
  display: grid;
  grid-template-columns: 62px 1fr;
  gap: 8px;
  padding: 7px 14px;
  font-family: var(--mono);
  font-size: 11px;
  border-bottom: 1px solid rgba(154, 164, 255, 0.06);
  color: var(--muted);
}
.log-row time { color: var(--dim); }
.log-row span {
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
}
.log-row.err { color: var(--bad); }

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

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 5, 14, 0.72);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: 20px;
}
.overlay[hidden] { display: none; }

.modal {
  width: min(430px, 100%);
  background: linear-gradient(180deg, #16162e, #101024);
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  padding: 22px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  animation: rise 0.22s cubic-bezier(0.2, 0.9, 0.3, 1);
}
@keyframes rise {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.modal h3 { font-family: var(--display); font-size: 22px; margin: 0 0 4px; }
.modal .hint { font-family: var(--mono); font-size: 11px; color: var(--dim); margin-bottom: 16px; }

label.field { display: block; margin-bottom: 13px; }
label.field span {
  display: block;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 5px;
}

input, select, textarea {
  width: 100%;
  background: rgba(11, 11, 24, 0.7);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  padding: 9px 11px;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--royal);
  box-shadow: 0 0 0 3px rgba(113, 99, 219, 0.2);
}

.modal-actions { display: flex; justify-content: space-between; gap: 8px; margin-top: 18px; }

.error-box {
  border: 1px solid rgba(255, 107, 129, 0.4);
  background: rgba(255, 107, 129, 0.1);
  color: #ffc2cb;
  font-family: var(--mono);
  font-size: 11px;
  padding: 9px 11px;
  border-radius: 8px;
  margin-bottom: 12px;
}

.toast-wrap { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 80; }
.toast {
  font-family: var(--mono);
  font-size: 12px;
  padding: 11px 15px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: #17172f;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.5);
  animation: rise 0.2s ease;
  max-width: 340px;
}
.toast.err { border-color: rgba(255, 107, 129, 0.5); color: #ffc2cb; }
.toast.ok { border-color: rgba(70, 217, 164, 0.45); color: #b6f3de; }

/* --- Login --------------------------------------------------------------- */

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; position: relative; z-index: 1; }
.login-card {
  width: min(380px, 100%);
  background: linear-gradient(180deg, var(--surface), #101024);
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  padding: 30px 28px;
  text-align: center;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.55);
}
.login-card h1 { font-family: var(--display); font-size: 27px; margin: 14px 0 4px; }
.login-card h1 em { font-style: normal; color: var(--royal); }
.login-card p { font-family: var(--mono); font-size: 11px; color: var(--dim); letter-spacing: 0.14em; text-transform: uppercase; margin: 0 0 22px; }
.mark {
  width: 54px; height: 54px; margin: 0 auto; border-radius: 16px;
  display: grid; place-items: center;
  background: linear-gradient(150deg, var(--royal), var(--deep));
  box-shadow: 0 10px 30px rgba(113, 99, 219, 0.35);
  font-family: var(--display); font-size: 24px; color: #fff;
}

/* --- Acceso por correo --------------------------------------------------- */

.ok-box {
  border: 1px solid rgba(70, 217, 164, 0.4);
  background: rgba(70, 217, 164, 0.1);
  color: #b6f3de;
  font-family: var(--mono);
  font-size: 11px;
  padding: 9px 11px;
  border-radius: 8px;
  margin-bottom: 12px;
}

.code-input {
  text-align: center;
  font-size: 26px;
  letter-spacing: 0.42em;
  padding: 12px 0 12px 12px;
}

.login-links { display: flex; justify-content: space-between; margin-top: 14px; }

button.link {
  background: none;
  border: none;
  padding: 0;
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0.02em;
  font-size: 11px;
  text-decoration: underline;
}
button.link:hover { background: none; color: var(--ether); }

/* Identidad de quien ha entrado */
.whoami {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}
.whoami b { color: var(--text); font-weight: 500; }
.badge-admin {
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid var(--royal);
  background: rgba(113, 99, 219, 0.22);
  color: var(--ether);
}

.member.me { background: rgba(113, 99, 219, 0.08); }
.ev.mine { border-color: var(--ether); }
.ev.other { background: linear-gradient(160deg, rgba(94, 99, 201, 0.55), rgba(44, 47, 90, 0.7)); }

/* --- Bloqueo mientras se procesa una peticion ---------------------------- */

.veil {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  background: rgba(5, 5, 14, 0.42);
  backdrop-filter: blur(1.5px);
  cursor: progress;
  animation: veil-in 0.12s ease both;
}
.veil[hidden] { display: none; }

@keyframes veil-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.veil .ring {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid rgba(154, 164, 255, 0.22);
  border-top-color: var(--royal);
  animation: spin 0.7s linear infinite;
}

.veil .veil-text {
  position: absolute;
  margin-top: 74px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Boton que esta esperando respuesta: texto fuera, rueda dentro */
button.loading {
  color: transparent !important;
  position: relative;
  pointer-events: none;
}
button.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 13px;
  height: 13px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  border: 2px solid rgba(232, 230, 247, 0.28);
  border-top-color: #fff;
  animation: spin 0.6s linear infinite;
}
