/* Reserva de salas · Refineria — estilo inspirado en la vista "Semana laboral" de Outlook */
:root {
  --marca: #323e48;
  --marca-claro: #b6dce1;
  --azul: #0f6cbd;
  --azul-hover: #115ea3;
  --azul-evento: #b7d7f2;
  --azul-evento-borde: #0f6cbd;
  --propia: #d6efe5;
  --propia-borde: #107c41;
  --privado: #e6e6e6;
  --privado-borde: #8a8886;
  --texto: #242424;
  --texto-suave: #616161;
  --borde: #e0e0e0;
  --borde-suave: #efefef;
  --fondo: #faf9f8;
  --blanco: #ffffff;
  --pasado: #f5f5f5;
  --peligro: #c50f1f;
  --alto-hora: 52px;
  --ancho-horas: 52px;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--texto);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--fondo); font-size: 14px; }
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 32px; padding: 0 12px; border: 1px solid #d1d1d1; border-radius: 4px;
  background: var(--blanco); cursor: pointer; white-space: nowrap;
}
.btn:hover { background: #f5f5f5; }
.btn:focus-visible, .pestana:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--azul); outline-offset: 1px;
}
.btn.primario { background: var(--azul); border-color: var(--azul); color: #fff; font-weight: 600; }
.btn.primario:hover { background: var(--azul-hover); }
.btn.peligro { color: var(--peligro); border-color: var(--peligro); }
.btn.peligro:hover { background: #fdf3f4; }
.btn.enlace { border: 0; background: none; color: var(--azul); }
.btn.icono { width: 32px; padding: 0; font-size: 18px; }
.btn.ancho { width: 100%; }
.btn:disabled { opacity: .6; cursor: default; }

/* ---------- Login ---------- */
.vista-centrada { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; background: var(--marca); }
.tarjeta {
  width: 100%; max-width: 380px; background: var(--blanco); border-radius: 8px;
  padding: 32px 28px; box-shadow: 0 8px 32px rgba(0,0,0,.25); display: grid; gap: 14px;
}
.tarjeta h1 { margin: 4px 0 0; font-size: 22px; }
.sub { margin: 0; color: var(--texto-suave); line-height: 1.4; }
.nota { margin: 0; color: var(--texto-suave); font-size: 12px; text-align: center; }
.marca { display: flex; align-items: center; gap: 10px; height: 32px; }
.marca .logo { height: 28px; }
.marca-texto { font-weight: 700; font-size: 20px; color: var(--marca); }
.marca .logo:not([hidden]) + .marca-texto { display: none; }
label { display: grid; gap: 4px; font-weight: 600; font-size: 13px; }
input, select {
  min-height: 34px; padding: 4px 8px; border: 1px solid #d1d1d1; border-radius: 4px;
  background: var(--blanco); font-weight: 400; width: 100%;
}
.error { margin: 0; color: var(--peligro); font-size: 13px; }

/* ---------- Barra superior ---------- */
#vista-app { height: 100%; display: flex; flex-direction: column; }
.barra {
  height: 48px; flex: none; background: var(--marca); color: #fff;
  display: flex; align-items: center; justify-content: space-between; padding: 0 16px;
}
.barra-izq, .barra-der { display: flex; align-items: center; gap: 12px; }
.barra .logo { height: 22px; filter: brightness(0) invert(1); }
.barra-titulo { font-weight: 600; font-size: 15px; }
.barra-btn { background: transparent; color: #fff; border-color: rgba(255,255,255,.4); }
.barra-btn:hover { background: rgba(255,255,255,.12); }
.menu-usuario { position: relative; }
.menu-usuario summary {
  list-style: none; cursor: pointer; padding: 6px 10px; border-radius: 4px; max-width: 220px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.menu-usuario summary::-webkit-details-marker { display: none; }
.menu-usuario summary::after { content: " ▾"; }
.menu-usuario summary:hover { background: rgba(255,255,255,.12); }
.menu {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 30; min-width: 220px;
  background: var(--blanco); color: var(--texto); border-radius: 6px; padding: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,.18); display: grid;
}
.menu button { text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 4px; cursor: pointer; }
.menu button:hover { background: #f0f0f0; }
.menu-email { margin: 4px 10px 8px; color: var(--texto-suave); font-size: 12px; word-break: break-all; }

/* ---------- Cuerpo ---------- */
.cuerpo { flex: 1; display: flex; min-height: 0; }
.lateral {
  width: 240px; flex: none; border-right: 1px solid var(--borde); background: var(--blanco);
  padding: 14px 12px; overflow-y: auto;
}
.nuevo { width: 100%; margin-bottom: 18px; }
.lateral-titulo { font-size: 13px; font-weight: 600; margin: 8px 6px 6px; }
.lista-salas { display: grid; gap: 2px; margin-bottom: 18px; }
.sala-opcion {
  display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 4px;
  cursor: pointer; font-weight: 400; font-size: 14px; border: 0; background: none; text-align: left; width: 100%;
}
.sala-opcion:hover { background: #f3f2f1; }
.sala-opcion .circulo {
  width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid #8a8886; flex: none; display: grid; place-items: center;
}
.sala-opcion[aria-checked="true"] { background: #ebf3fc; font-weight: 600; }
.sala-opcion[aria-checked="true"] .circulo { border-color: var(--azul); background: var(--azul); }
.sala-opcion[aria-checked="true"] .circulo::after { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #fff; }
.mis-reservas { list-style: none; margin: 0; padding: 0 4px; display: grid; gap: 6px; }
.mis-reservas li {
  border-left: 3px solid var(--propia-borde); background: var(--propia); padding: 6px 8px; border-radius: 3px;
  font-size: 12px; line-height: 1.35; cursor: pointer;
}
.mis-reservas li b { display: block; font-size: 13px; }
.mis-reservas .vacio { background: none; border: 0; color: var(--texto-suave); cursor: default; padding-left: 2px; }

.principal { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.herramientas {
  display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--borde);
  background: var(--blanco); flex-wrap: wrap;
}
.rango { margin: 0 0 0 8px; font-size: 18px; font-weight: 600; }
.estado-sync { margin-left: auto; color: var(--texto-suave); font-size: 12px; }
.estado-sync.error { color: var(--peligro); }
.select-sala { display: none; width: auto; }

/* ---------- Calendario ---------- */
.calendario-scroll { flex: 1; overflow: auto; background: var(--blanco); }
.calendario {
  display: grid; grid-template-columns: var(--ancho-horas) repeat(5, minmax(120px, 1fr));
  min-width: 660px; position: relative;
}
.cab-vacia, .cab-dia {
  position: sticky; top: 0; z-index: 5; background: var(--blanco); border-bottom: 1px solid var(--borde);
}
.cab-dia { padding: 8px 10px 6px; border-left: 1px solid var(--borde-suave); }
.cab-dia .num { font-size: 20px; line-height: 1; color: var(--azul); }
.cab-dia .nombre { font-size: 12px; color: var(--texto); }
.cab-dia.hoy { border-top: 3px solid var(--azul); padding-top: 5px; }
.cab-dia.hoy .num { font-weight: 700; }
.col-horas { position: relative; }
.etiqueta-hora {
  height: var(--alto-hora); font-size: 11px; color: var(--texto-suave); text-align: right; padding: 2px 8px 0 0;
  border-top: 1px solid transparent;
}
.col-dia {
  position: relative; border-left: 1px solid var(--borde-suave); cursor: pointer;
  background-image:
    linear-gradient(to bottom, var(--borde) 1px, transparent 1px),
    linear-gradient(to bottom, transparent calc(var(--alto-hora) / 2), var(--borde-suave) calc(var(--alto-hora) / 2), var(--borde-suave) calc(var(--alto-hora) / 2 + 1px), transparent calc(var(--alto-hora) / 2 + 1px));
  background-size: 100% var(--alto-hora);
}
.col-dia:hover { background-color: #fbfdff; }
.zona-pasada { position: absolute; left: 0; right: 0; top: 0; background: rgba(0,0,0,.035); pointer-events: none; }
.linea-ahora { position: absolute; left: 0; right: 0; height: 2px; background: var(--azul); z-index: 4; pointer-events: none; }
.linea-ahora::before {
  content: ""; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--azul);
}
.evento {
  position: absolute; z-index: 3; border-radius: 4px; padding: 3px 6px; overflow: hidden;
  background: var(--azul-evento); border-left: 4px solid var(--azul-evento-borde);
  font-size: 12px; line-height: 1.3; cursor: pointer; text-align: left; border-top: 0; border-right: 0; border-bottom: 0;
  box-shadow: 0 0 0 1px #fff;
}
.evento:hover { filter: brightness(.97); }
.evento b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.evento span { color: #3b3a39; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.evento.propia { background: var(--propia); border-left-color: var(--propia-borde); }
.evento.privado { background: var(--privado); border-left-color: var(--privado-borde); }
.evento.corto { padding-top: 1px; }
.evento.corto b { display: inline; }
.evento.corto span { display: inline; margin-left: 4px; }
.fila-todo-dia { grid-column: 2 / -1; }
.chip-todo-dia {
  font-size: 11px; background: var(--azul-evento); border-left: 3px solid var(--azul-evento-borde);
  padding: 1px 6px; margin: 2px 4px 0; border-radius: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ---------- Modales ---------- */
.modal {
  border: 0; border-radius: 8px; padding: 0; width: min(460px, calc(100vw - 32px));
  box-shadow: 0 16px 48px rgba(0,0,0,.28);
}
.modal.ancho { width: min(1000px, calc(100vw - 32px)); }
.modal::backdrop { background: rgba(0,0,0,.35); }
.modal > form, .modal > div { padding: 22px 24px; display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
.modal { overflow-x: hidden; }
.modal h2 { margin: 0; font-size: 18px; }
.fila { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 10px; }
.acciones { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.detalle { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; }
.detalle dt { color: var(--texto-suave); }
.detalle dd { margin: 0; }
.modal-cabecera { display: flex; align-items: center; gap: 16px; }
.modal-cabecera .btn.icono { margin-left: auto; }
.pestanas { display: flex; gap: 4px; }
.pestana { border: 0; background: none; padding: 6px 10px; border-bottom: 2px solid transparent; cursor: pointer; }
.pestana.activa { border-bottom-color: var(--azul); font-weight: 600; }
.form-linea { display: grid; grid-template-columns: 1.3fr 1.3fr 1fr 110px auto; gap: 8px; }
.aviso { background: #fff8e6; border: 1px solid #f2d27a; padding: 10px 12px; border-radius: 4px; line-height: 1.5; }
.aviso code { font-size: 15px; background: #fff; padding: 2px 6px; border-radius: 3px; border: 1px solid #eee; user-select: all; }
.tabla-scroll { overflow: auto; max-height: 50vh; border: 1px solid var(--borde); border-radius: 4px; }
.tabla-scroll.alto { max-height: 65vh; }
.tabla { width: 100%; border-collapse: collapse; font-size: 13px; }
.tabla th, .tabla td { padding: 7px 10px; border-bottom: 1px solid var(--borde-suave); text-align: left; vertical-align: top; }
.tabla th { position: sticky; top: 0; background: #f7f7f7; font-weight: 600; }
.tabla td.acciones-fila { white-space: nowrap; }
.tabla td.acciones-fila .btn + .btn { margin-left: 4px; }
.tabla td.acciones-fila .btn { min-height: 26px; padding: 0 8px; font-size: 12px; }
.tabla .inactivo { color: var(--texto-suave); }
.tabla td.nowrap { white-space: nowrap; }
.etiqueta { display: inline-block; white-space: nowrap; padding: 1px 6px; border-radius: 10px; font-size: 11px; background: #eee; }
.etiqueta.ok { background: #dff6dd; color: #0e700e; }
.etiqueta.no { background: #fde7e9; color: var(--peligro); }
.tabla code { font-size: 11px; color: var(--texto-suave); word-break: break-all; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100;
  background: #242424; color: #fff; padding: 10px 16px; border-radius: 6px; box-shadow: 0 6px 20px rgba(0,0,0,.25);
  max-width: calc(100vw - 32px);
}
.toast.error { background: var(--peligro); }

/* ---------- Móvil ---------- */
@media (max-width: 820px) {
  .lateral { display: none; }
  .select-sala { display: block; flex: 1 1 100%; }
  .rango { font-size: 15px; margin-left: 4px; }
  .estado-sync { flex: 1 1 100%; margin-left: 0; }
  .barra-titulo { display: none; }
  .fila { grid-template-columns: 1fr 1fr; }
  .fila label:first-child { grid-column: 1 / -1; }
  .form-linea { grid-template-columns: 1fr; }
}
/* Aviso de sincronización: no desbordar la barra de herramientas */
.estado-sync { min-width: 0; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right; }
@media (max-width: 820px) { .estado-sync { max-width: 100%; text-align: left; } }
