/* ===== Modal Reserva Chromebooks - REDISEÑO COMPLETO ===== */
.cbk-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(8px);
  z-index: 1000;
}

.cbk-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1001;
  padding: 20px;
}

.cbk-card {
  width: min(1000px, 95vw);
  max-height: 90vh;
  background: white;
  border-radius: 24px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Overlay de carga global del modal */
.cbk-busy-overlay {
  position: absolute;
  inset: 0;
  background: rgba(248, 250, 252, 0.72);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 60;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.cbk-busy-overlay.show {
  display: flex;
}

.cbk-busy-box {
  width: min(420px, 90%);
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.15);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.cbk-busy-spinner {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 3px solid rgba(59, 130, 246, 0.2);
  border-top-color: #3b82f6;
  animation: cbkBusySpin .7s linear infinite;
  flex: 0 0 34px;
}

.cbk-busy-copy { min-width: 0; }

.cbk-busy-title {
  font-size: 18px;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.2;
  margin-bottom: 2px;
}

.cbk-busy-sub {
  font-size: 14px;
  color: #64748b;
  font-weight: 600;
}

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

/* HEADER CON GRADIENTE - AZUL MANTENIMIENTO */
.cbk-header {
  background: linear-gradient(135deg, #2BB3FF, #1a9ce0);
  color: white;
  padding: 24px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
}

.cbk-header::after {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 32px;
  width: 60px;
  height: 4px;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 2px;
}

.cbk-title {
  font-size: 24px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 12px;
}

.cbk-title::before {
  content: none;
}

.cbk-header-icon {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  color: rgba(255,255,255,0.9);
}

.cbk-aula-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: #94a3b8;
}

.cbk-close {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  border-radius: 12px;
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s ease;
  backdrop-filter: blur(10px);
}

.cbk-close:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.05);
}

/* CUERPO */
.cbk-body {
  padding: 24px 28px;
  flex: 1;
  overflow-y: auto;
}

/* SELECTOR DE FECHA (nuevo - reemplaza form-grid completo) */
.cbk-date-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  background: #f8fafc;
  padding: 18px 18px 14px;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  text-align: center;
}

.cbk-label-upper {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
  text-align: center;
}

.cbk-field-date {
  flex-shrink: 0;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.cbk-field-date .cbk-input {
  text-align: center;
}

.cbk-date-hint {
  font-size: 12px;
  color: #94a3b8;
  font-weight: 500;
  line-height: 1.4;
}

/* MINI FORM dentro del dialog de reserva */
.cbk-res-device-label {
  font-size: 13px;
  color: #2BB3FF;
  font-weight: 700;
  text-align: center;
  margin: -6px 0 16px;
  background: rgba(43,179,255,.1);
  border-radius: 8px;
  padding: 6px 12px;
}

.cbk-mini-form-fields {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
}

.cbk-mini-form-fields .cbk-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cbk-mini-form-fields .cbk-textarea {
  min-height: 60px;
  grid-column: unset;
}

/* FORMULARIO ORIGINAL (se mantiene por compatibilidad) */
.cbk-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
  background: #f8fafc;
  padding: 20px;
  border-radius: 14px;
  border: 1px solid #e2e8f0;
}

.cbk-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cbk-label {
  font-size: 13px;
  color: #475569;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.cbk-input, .cbk-textarea {
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  color: #0f172a;
  background: white;
  transition: all 0.2s ease;
  font-family: inherit;
}

.cbk-input:focus, .cbk-textarea:focus {
  outline: none;
  border-color: #2BB3FF;
  box-shadow: 0 0 0 3px rgba(43, 179, 255, 0.1);
}

.cbk-textarea {
  min-height: 70px;
  resize: vertical;
  grid-column: 1 / -1;
}

/* GRID DE AULAS — una sola columna, cada aula es una fila */
.cbk-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

/* TARJETA DE AULA */
.cbk-aula {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 14px 16px 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
  transition: box-shadow 0.2s ease;
}

.cbk-aula:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,.08);
}

.cbk-aula h3 {
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
  margin: 0 0 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: center;
}

.cbk-aula h3::before {
  content: none; /* el emoji ya lo pone el JS */
}

/* FILA DE EQUIPOS — siempre 3 columnas iguales */
.cbk-devices {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

/* COLUMNA DE EQUIPO (icono + nombre + firma) */
.cbk-equipo-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 0; /* evita overflow en nombre largo */
}

/* BOTÓN ICONO — cuadrado compacto */
.cbk-device {
  width: 90px;
  height: 90px;
  flex-shrink: 0;
  user-select: none;
  cursor: pointer;
  border: 2px solid transparent;
  border-radius: 12px;
  padding: 10px 8px;
  text-align: center;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  position: relative;
  overflow: hidden;
}

.cbk-device::before {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 100%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
  transition: left 0.4s ease;
}
.cbk-device:hover::before { left: 100%; }

.cbk-laptop {
  width: 36px;
  height: auto;
  display: block;
  margin: 0 auto 4px;
  flex-shrink: 0;
}

.num {
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
}

/* Estados */
.cbk-available {
  background: linear-gradient(135deg, #f0fdf4, #dcfce7);
  border-color: #86efac;
}
.cbk-available .num { color: #15803d; }
.cbk-available .cbk-laptop { color: #16a34a; }
.cbk-available:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(16,185,129,.2);
  border-color: #4ade80;
}

.cbk-reserved {
  background: linear-gradient(135deg, #ef4444, #dc2626) !important;
  border-color: #b91c1c !important;
  box-shadow: 0 4px 12px rgba(220,38,38,.3);
}
.cbk-reserved .num { color: white !important; }
.cbk-reserved .cbk-laptop { color: white !important; filter: none !important; }
.cbk-reserved:hover {
  transform: translateY(-2px) !important;
  box-shadow: 0 8px 20px rgba(220,38,38,.4) !important;
}

.cbk-selected {
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
.cbk-selected .num { color: #1e40af; font-weight: 800; }
.cbk-selected .cbk-laptop { color: #1d4ed8; }
.cbk-selected:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(59,130,246,.25);
}

/* NOMBRE DEBAJO DEL ICONO */
.cbk-responsable-name {
  font-size: 12px;
  font-weight: 600;
  color: #1e293b;
  text-align: center;
  line-height: 1.3;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 2px;
}
.cbk-libre-label {
  font-size: 11px;
  color: #94a3b8;
  text-align: center;
  font-style: italic;
}

/* ÁREA DE FIRMA */
.cbk-firma-wrap {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cbk-firma-canvas {
  width: 100%;
  height: 52px;
  background: #f8fafc;
  border: 1.5px dashed #cbd5e1;
  border-radius: 8px;
  cursor: pointer;
  touch-action: none;
  display: block;
  transition: border-color .15s, background .15s;
}
.cbk-firma-canvas:hover:not(.firmado) {
  border-color: #2BB3FF;
  background: #f0f9ff;
}
.cbk-firma-canvas.firmado {
  border: 1.5px solid #10b981;
  cursor: default;
  background: #f0fdf4;
}
.cbk-firma-placeholder {
  position: absolute;
  pointer-events: none;
  font-size: 11px;
  color: #94a3b8;
  font-style: italic;
}
.cbk-firma-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}
.cbk-firma-status {
  font-size: 10px;
  color: #10b981;
  font-weight: 600;
  display: none;
}
.cbk-firma-status.visible { display: block; }
.cbk-firma-clear {
  font-size: 10px;
  color: #94a3b8;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  transition: color .15s;
}
.cbk-firma-clear:hover { color: #dc2626; }

/* Botón guardar firma */
.cbk-firma-save {
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: #10b981;
  border: none;
  border-radius: 6px;
  padding: 3px 10px;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s;
}
.cbk-firma-save:hover { background: #059669; }

/* === Refresh button (autosync) === */
.cbk-refresh{border:none;background:rgba(255,255,255,.2);color:#fff;width:38px;height:38px;border-radius:10px;cursor:pointer;margin-right:8px;display:flex;align-items:center;justify-content:center;font-size:18px;}
.cbk-refresh:hover{background:rgba(255,255,255,.3);}

/* =====================================================================
   Modal de firma expandida (para móvil)
   ===================================================================== */
.cbk-firma-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 10100;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

.cbk-firma-modal-box {
  width: 100%;
  max-height: 92dvh;
  background: #fff;
  border-radius: 22px 22px 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 -8px 40px rgba(0,0,0,0.18);
}

/* Handle visual */
.cbk-firma-modal-box::before {
  content: '';
  display: block;
  width: 40px;
  height: 4px;
  background: #cbd5e1;
  border-radius: 2px;
  margin: 12px auto 0;
  flex-shrink: 0;
}

.cbk-firma-modal-header {
  padding: 12px 20px 10px;
  font-size: 15px;
  font-weight: 700;
  color: #1e293b;
  border-bottom: 1px solid #e2e8f0;
  flex-shrink: 0;
}

.cbk-firma-modal-canvas-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8fafc;
  padding: 16px;
  position: relative;
}

.cbk-firma-modal-canvas {
  width: 100%;
  height: 100%;
  max-height: 340px;
  background: #fff;
  border: 2px dashed #cbd5e1;
  border-radius: 12px;
  cursor: crosshair;
  touch-action: none;
  display: block;
}

.cbk-firma-modal-canvas.firmado {
  border: 2px solid #10b981;
  background: #f0fdf4;
  cursor: default;
}

.cbk-firma-modal-footer {
  display: flex;
  gap: 10px;
  padding: 14px 16px 24px;
  border-top: 1px solid #e2e8f0;
  background: #fff;
  flex-shrink: 0;
}

.cbk-firma-modal-btn {
  flex: 1;
  padding: 14px 10px;
  border: none;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s, opacity .15s;
}

.cbk-firma-modal-btn--primary {
  background: #10b981;
  color: #fff;
  flex: 2;
}
.cbk-firma-modal-btn--primary:hover:not(:disabled) { background: #059669; }
.cbk-firma-modal-btn--primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.cbk-firma-modal-btn--secondary {
  background: #f1f5f9;
  color: #475569;
}
.cbk-firma-modal-btn--secondary:hover { background: #e2e8f0; }

.cbk-firma-modal-btn--ghost {
  background: transparent;
  color: #94a3b8;
  border: 1.5px solid #e2e8f0;
}
.cbk-firma-modal-btn--ghost:hover { background: #f8fafc; }

/* En desktop el modal también puede aparecer centrado */
@media (min-width: 641px) {
  .cbk-firma-modal-overlay {
    align-items: center;
    padding: 20px;
  }
  .cbk-firma-modal-box {
    width: min(680px, 95vw);
    max-height: 85vh;
    border-radius: 22px;
  }
  .cbk-firma-modal-box::before { display: none; }
  .cbk-firma-modal-canvas-wrap {
    padding: 24px 28px;
  }
  .cbk-firma-modal-canvas {
    max-height: 300px;
  }
  .cbk-firma-modal-header {
    padding: 18px 28px 14px;
    font-size: 17px;
  }
  .cbk-firma-modal-footer {
    padding: 16px 28px 24px;
    gap: 12px;
  }
  .cbk-firma-modal-btn {
    font-size: 14px;
    padding: 12px 16px;
    border-radius: 10px;
  }
}

/* =====================================================================
   Dialogs unificados (estilo Aulas Móviles)
   ===================================================================== */

.am-dialog-backdrop{
  position:fixed;inset:0;
  background:rgba(15,23,42,.35);
  backdrop-filter:blur(2px);
  z-index:10060;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:16px;
}

.am-dialog{
  width:min(560px,94vw);
  background:#fff;
  border-radius:18px;
  box-shadow:0 24px 60px rgba(2,6,23,.25);
  overflow:hidden;
  font-family:inherit;
}

.am-dialog-top{
  height:10px;
  background:linear-gradient(90deg,var(--am-accent-2,#60a5fa),var(--am-accent,#3b82f6));
}

.am-dialog-body{padding:26px 26px 20px;text-align:center}

.am-dialog-icon{
  width:82px;height:82px;border-radius:999px;margin:0 auto 14px;
  display:grid;place-items:center;
  background:var(--am-accent-soft,rgba(59,130,246,.12));
  color:var(--am-accent,#3b82f6);
}
.am-dialog-icon svg{width:42px;height:42px}

.am-dialog-title{font-size:34px;font-weight:800;color:#0f172a;margin:0 0 8px}
.am-dialog-text{font-size:18px;line-height:1.45;color:#475569;margin:0;white-space:pre-line}

.am-dialog-html{font-size:16px;line-height:1.45;color:#475569;margin:0;text-align:left}
.am-dialog-html .am-kv{display:grid;grid-template-columns:130px 1fr;gap:6px 12px;align-items:start;margin-top:14px}
.am-dialog-html .am-k{color:#64748b;font-weight:800}
.am-dialog-html .am-v{color:#0f172a;font-weight:600}
.am-dialog-html .am-warn{margin-top:14px;color:#b91c1c;font-weight:800;text-align:center}

.am-dialog-actions{display:flex;gap:14px;justify-content:center;padding:0 26px 24px}

.am-btn{
  min-width:160px;
  padding:14px 18px;
  border-radius:16px;
  border:0;
  font-weight:800;
  cursor:pointer;
}
.am-btn-secondary{background:#f1f5f9;color:#334155}
.am-btn-primary{background:var(--am-accent,#3b82f6);color:#fff}
.am-btn-primary:hover{background:var(--am-accent-dark,#2563eb)}
.am-btn-secondary:hover{filter:brightness(.98)}

/* ✅ Botón especial: Liberar siempre naranja */
.am-btn-liberar{
  background:#b45309 !important;
  color:#fff !important;
}
.am-btn-liberar:hover{
  background:#92400e !important;
}

/* =====================================================================
   📱 MOBILE — max-width: 640px
   ===================================================================== */
@media (max-width: 640px) {

  /* Modal como bottom-sheet que ocupa casi toda la pantalla */
  .cbk-modal {
    padding: 0;
    align-items: flex-end;
  }

  .cbk-backdrop {
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .cbk-card {
    width: 100vw;
    max-height: 96dvh;
    border-radius: 20px 20px 0 0;
    /* Handle visual */
    /* Asegurar position:relative para que el overlay cbk-busy-overlay
       quede posicionado correctamente dentro del bottom-sheet en móvil */
    position: relative;
  }

  /* Línea "handle" arriba del header (fondo azul) */
  .cbk-card::before {
    content: none;
  }

  .cbk-header {
    padding-top: 20px;
    position: relative;
  }

  .cbk-header::before {
    content: '';
    display: block;
    width: 40px;
    height: 4px;
    background: rgba(255, 255, 255, 0.45);
    border-radius: 2px;
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
  }

  .cbk-header {
    padding: 28px 16px 14px;
  }

  .cbk-header::after { display: none; }

  .cbk-title {
    font-size: 18px;
    gap: 8px;
  }

  .cbk-title::before {
    font-size: 20px;
  }

  .cbk-close {
    padding: 8px 12px;
    font-size: 13px;
  }

  /* Body con padding reducido */
  .cbk-body {
    padding: 14px 14px 16px;
  }

  /* Date row en mobile: apilado */
  .cbk-date-row {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 12px 14px;
    margin-bottom: 12px;
  }

  .cbk-field-date { min-width: unset; }

  .cbk-date-hint { font-size: 12px; }

  /* Formulario original (por si queda algo) */
  .cbk-form-grid {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 14px;
    margin-bottom: 14px;
  }

  /* Textarea ocupa 1 columna (ya que solo hay 1 columna) */
  .cbk-textarea {
    grid-column: 1;
    min-height: 56px;
  }

  /* iOS: evitar zoom automático en inputs — font-size mínimo 16px */
  .cbk-input,
  .cbk-textarea,
  .am-dialog input,
  .am-dialog textarea {
    font-size: 16px !important;
  }

  /* Aulas: padding más compacto */
  .cbk-aula {
    padding: 10px 10px 12px;
    border-radius: 12px;
  }

  .cbk-aula h3 {
    font-size: 12px;
    margin-bottom: 10px;
  }

  /* Dispositivos: 3 columnas iguales pero botones más pequeños */
  .cbk-devices {
    gap: 6px;
  }

  .cbk-device {
    width: 100%;
    height: 72px;
    padding: 6px 4px;
    border-radius: 10px;
  }

  .cbk-laptop {
    width: 28px;
    margin-bottom: 2px;
  }

  .num {
    font-size: 16px;
  }

  /* Nombre debajo del icono */
  .cbk-responsable-name {
    font-size: 10px;
  }

/* Firma en móvil: actúa como botón que abre el modal de firma */
  .cbk-firma-canvas {
    height: 44px;
    cursor: pointer !important;
  }

  /* Leyenda: texto más pequeño */
  .cbk-legend {
    font-size: 11px;
    gap: 6px;
  }

  /* Footer (ya no se usa) */
  /* .cbk-footer { padding: 10px 14px 16px; } */

  /* Btn reservar (ya no se usa) */
  /* .cbk-btn-reservar { ... } */

  /* Busy overlay */
  .cbk-busy-box {
    padding: 14px 16px;
    gap: 10px;
  }

  .cbk-busy-title {
    font-size: 15px;
  }

  .cbk-busy-sub {
    font-size: 12px;
  }

  /* Dialogs: más compactos */
  .am-dialog-title { font-size: 24px; }
  .am-dialog-text  { font-size: 15px; }
  .am-dialog-html  { font-size: 14px; }
  .am-dialog-html .am-kv { grid-template-columns: 100px 1fr; }
  .am-btn {
    min-width: 0;
    flex: 1;
    padding: 12px 10px;
    font-size: 14px;
    border-radius: 14px;
  }
  .am-dialog-actions { gap: 10px; }

  /* Botón refresh en header */
  .cbk-refresh {
    width: 32px;
    height: 32px;
    font-size: 15px;
  }
}
