/* ═══════════════════════════════════════════════════════════════════
 * Berny's CRM — Shell Styles (login + sidebar + module container)
 * Extraído del monolito public/index.html para preservar el look-and-feel.
 * ═══════════════════════════════════════════════════════════════════ */

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: #f5f7fa;
  color: #2d3748;
}

/* ═══ LOGIN ═══ */
.login-screen {
  position: fixed; inset: 0;
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 40%, #4338ca 100%);
  display: flex; justify-content: center; align-items: center;
  z-index: 10000;
}
.login-card {
  background: white; border-radius: 20px;
  padding: 40px 36px; width: 90%; max-width: 400px;
  box-shadow: 0 25px 80px rgba(0,0,0,0.4);
  font-family: 'DM Sans', sans-serif;
}
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo .emoji { font-size: 48px; margin-bottom: 12px; display: block; }
.login-logo h2 { font-size: 22px; font-weight: 700; color: #1e293b; }
.login-logo p { font-size: 13px; color: #94a3b8; margin-top: 4px; }
.login-field { margin-bottom: 20px; position: relative; }
.login-field label { display: block; font-size: 13px; font-weight: 600; color: #475569; margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.3px; }
.login-field input { width: 100%; padding: 12px 16px; border: 2px solid #e2e8f0; border-radius: 10px; font-size: 15px; font-family: inherit; transition: all 0.2s; background: #f8fafc; }
.login-field input:focus { outline: none; border-color: #5a67d8; background: white; box-shadow: 0 0 0 4px rgba(90,103,216,0.1); }
.password-wrapper { position: relative; }
.password-wrapper input { padding-right: 48px; }
.eye-toggle { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; font-size: 18px; color: #94a3b8; padding: 4px; }
.eye-toggle:hover { color: #5a67d8; }
.forgot-link { display: block; text-align: right; margin-top: 8px; font-size: 13px; color: #5a67d8; font-weight: 600; cursor: pointer; }
.forgot-link:hover { color: #4338ca; text-decoration: underline; }
.login-btn { width: 100%; padding: 14px; background: linear-gradient(135deg, #5a67d8 0%, #4c51bf 100%); color: white; border: none; border-radius: 10px; font-size: 16px; font-weight: 700; cursor: pointer; transition: all 0.2s; font-family: inherit; }
.login-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(90,103,216,0.4); }
.login-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.login-error { background: #fef2f2; border: 1px solid #fecaca; color: #dc2626; padding: 10px 14px; border-radius: 8px; font-size: 13px; font-weight: 600; margin-bottom: 16px; display: none; }
.reset-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #16a34a; padding: 10px 14px; border-radius: 8px; font-size: 13px; font-weight: 600; margin-bottom: 16px; display: none; }

/* ═══ APP SHELL ═══ */
.app-shell { display: flex; height: 100vh; overflow: hidden; }

/* ═══ SIDEBAR ═══ */
.sidebar {
  width: 220px; height: 100vh;
  background: linear-gradient(180deg, #1a202c 0%, #2d3748 100%);
  display: flex; flex-direction: column;
  box-shadow: 4px 0 12px rgba(0,0,0,0.15);
  flex-shrink: 0;
}
.sidebar-logo { padding: 24px 20px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.sidebar-logo h2 { color: white; font-size: 18px; font-weight: 700; margin: 0; }
.sidebar-logo span { color: #a0aec0; font-size: 12px; }
.sidebar-version { font-size: 9px !important; color: #667eea !important; display: block; margin-top: 2px; }
.sidebar-nav { padding: 16px 0; flex: 1; overflow-y: auto; min-height: 0; }
.sidebar-item { display: flex; align-items: center; gap: 12px; padding: 14px 20px; color: #a0aec0; font-size: 15px; font-weight: 600; cursor: pointer; transition: all 0.2s; border-left: 3px solid transparent; }
.sidebar-item:hover { background: rgba(255,255,255,0.05); color: #e2e8f0; }
.sidebar-item.active { background: rgba(102, 126, 234, 0.15); color: white; border-left-color: #667eea; }
.sidebar-item .icon { font-size: 18px; }
.sidebar-user { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,0.1); }
.sidebar-user-info { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.sidebar-user-avatar { width: 32px; height: 32px; border-radius: 50%; background: #667eea; display: flex; align-items: center; justify-content: center; color: white; font-size: 13px; font-weight: 700; }
.sidebar-user-name { color: #e2e8f0; font-size: 13px; font-weight: 600; display: block; }
.sidebar-user-role { color: #a0aec0; font-size: 11px; display: block; }
.sidebar-logout { width: 100%; padding: 7px; background: rgba(239,68,68,0.15); color: #fca5a5; border: 1px solid rgba(239,68,68,0.3); border-radius: 6px; font-size: 12px; font-weight: 600; cursor: pointer; font-family: inherit; transition: all 0.2s; }
.sidebar-logout:hover { background: rgba(239,68,68,0.3); color: white; }

/* ═══ MODULE CONTAINER ═══ */
.module-container {
  flex: 1;
  background: #f5f7fa;
  position: relative;
  overflow: hidden;
  min-width: 0;
  min-height: 0;
}
/* Sub-contenedor persistente por módulo (keep-alive). Stack absoluto: uno
   visible a la vez en circunstancias normales. En el caso del overlay WO
   también se activa mod-mapa sobre el módulo origen (Mapa con .detail-only
   es position:fixed transparente → Tasks/Reports se ven por detrás). */
.mod-subcontainer {
  display: none;
  position: absolute;
  inset: 0;
  overflow-y: auto;
  padding: 20px;
  box-sizing: border-box;
}
/* Mapa ocupa todo el alto sin padding alrededor (layout propio del módulo) */
.mod-subcontainer#mod-mapa { padding: 0; }
.module-placeholder {
  max-width: 640px; margin: 80px auto;
  background: white; border-radius: 16px;
  padding: 40px 32px; text-align: center;
  box-shadow: 0 4px 20px rgba(0,0,0,0.06);
}
.placeholder-icon { font-size: 64px; margin-bottom: 16px; opacity: 0.6; }
.placeholder-title { font-size: 26px; font-weight: 700; color: #1e293b; margin-bottom: 8px; }
.placeholder-sub { font-size: 14px; color: #64748b; margin-bottom: 8px; line-height: 1.5; }
.placeholder-sub code { background: #f1f5f9; padding: 2px 8px; border-radius: 4px; color: #5a67d8; font-family: 'Courier New', monospace; font-size: 13px; }
.placeholder-meta { margin-top: 24px; padding-top: 24px; border-top: 1px solid #e2e8f0; display: flex; justify-content: center; gap: 24px; flex-wrap: wrap; font-size: 13px; color: #64748b; }

/* ═══ LOADING ═══ */
.loading-overlay {
  position: fixed; inset: 0;
  background: rgba(255,255,255,0.98);
  display: none; flex-direction: column;
  justify-content: center; align-items: center;
  z-index: 9999;
}
.loading-spinner {
  width: 60px; height: 60px;
  border: 6px solid #e2e8f0;
  border-top-color: #667eea;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { margin-top: 24px; font-size: 18px; color: #4a5568; font-weight: 600; }

/* ═══ LOCKED OVERLAY (suspended / disabled / version / device block) ═══ */
.locked-overlay {
  position: fixed; inset: 0;
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 100%);
  display: none; flex-direction: column;
  justify-content: center; align-items: center;
  text-align: center; padding: 20px;
  z-index: 10001;
  color: #e2e8f0;
}
.locked-icon { font-size: 72px; margin-bottom: 24px; }
.locked-title { font-size: 28px; font-weight: 700; margin-bottom: 16px; }
.locked-sub { font-size: 15px; line-height: 1.8; max-width: 500px; margin-bottom: 32px; color: #cbd5e1; }
.locked-logout {
  background: rgba(255,255,255,0.1); color: #e2e8f0;
  border: 1px solid rgba(255,255,255,0.2);
  padding: 12px 32px; border-radius: 10px;
  cursor: pointer; font-size: 14px; font-weight: 600;
  transition: all 0.2s;
}
.locked-logout:hover { background: rgba(255,255,255,0.2); }

/* ═══ ATTENDANCE (Asistente check-in / check-out) ═══ */
.checkin-overlay {
  position: fixed; inset: 0;
  display: none; flex-direction: column;
  justify-content: center; align-items: center;
  text-align: center; padding: 20px;
  z-index: 10003;
  color: white;
  font-family: 'DM Sans', sans-serif;
}
.checkin-overlay.show { display: flex; }
.checkin-overlay.checkin-screen {
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 50%, #3b82f6 100%);
}
.checkin-overlay.checkout-done {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #334155 100%);
}
.checkin-icon { font-size: 80px; margin-bottom: 16px; }
.checkin-greeting { font-size: 22px; font-weight: 500; color: rgba(255,255,255,0.85); margin-bottom: 4px; }
.checkin-title { font-size: 36px; font-weight: 800; margin-bottom: 8px; letter-spacing: -0.5px; }
.checkin-time { font-size: 52px; font-weight: 700; font-variant-numeric: tabular-nums; color: #fbbf24; margin: 8px 0 4px 0; }
.checkin-date { font-size: 15px; font-weight: 500; color: rgba(255,255,255,0.75); margin-bottom: 32px; text-transform: capitalize; }
.checkin-sub { font-size: 15px; color: rgba(255,255,255,0.8); max-width: 500px; line-height: 1.6; }
.checkin-btn {
  background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
  color: white; border: none;
  padding: 18px 56px; border-radius: 12px;
  font-size: 20px; font-weight: 700;
  cursor: pointer; font-family: inherit;
  box-shadow: 0 10px 40px rgba(22,163,74,0.45);
  transition: all 0.2s;
  letter-spacing: 0.5px;
}
.checkin-btn:hover { transform: translateY(-2px); box-shadow: 0 14px 48px rgba(22,163,74,0.6); }
.checkin-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.checkin-hours-info {
  background: rgba(255,255,255,0.1);
  padding: 14px 28px;
  border-radius: 999px;
  font-size: 15px;
  margin: 16px 0 8px 0;
}
.checkin-hours-info b { color: #fbbf24; font-weight: 700; }

/* Floating CHECK OUT button — visible during shift.
   left:244px = justo después del sidebar (220px) + 24px de aire. */
.checkout-fab {
  position: fixed; bottom: 24px; left: 244px;
  background: linear-gradient(135deg, #ea580c 0%, #c2410c 100%);
  color: white; border: none;
  padding: 12px 24px; border-radius: 999px;
  font-size: 14px; font-weight: 700;
  cursor: pointer; font-family: inherit;
  box-shadow: 0 8px 24px rgba(234,88,12,0.4);
  display: none; align-items: center; gap: 8px;
  z-index: 10002;
  transition: all 0.2s;
}
.checkout-fab.show { display: inline-flex; }
.checkout-fab:hover { transform: translateY(-2px); box-shadow: 0 12px 32px rgba(234,88,12,0.55); }
.checkout-fab i { font-size: 16px; }
@media (max-width: 768px) {
  .checkout-fab { left: 16px; bottom: 16px; padding: 10px 18px; font-size: 13px; }
}

/* ═══ TOAST ═══ */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #1e293b; color: white;
  padding: 12px 24px; border-radius: 10px;
  font-size: 14px; font-weight: 600;
  z-index: 10002;
  transition: transform 0.3s;
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  max-width: 90vw;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.error { background: #dc2626; }

/* ═══ MOBILE ═══ */
@media (max-width: 768px) {
  .sidebar { width: 200px; }
  .module-placeholder { margin: 40px 16px; padding: 28px 20px; }
  .placeholder-title { font-size: 22px; }
  .placeholder-icon { font-size: 48px; }
}

/* ═══════════════════════════════════════════════════════════════════
   FCM Push — Blocker overlay refinements
   ═══════════════════════════════════════════════════════════════════ */
.locked-overlay .fcm-retry-btn {
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 600;
    background: #dc2626;
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    margin-top: 8px;
    transition: background 120ms ease, transform 80ms ease;
}
.locked-overlay .fcm-retry-btn:hover { background: #b91c1c; }
.locked-overlay .fcm-retry-btn:active { transform: scale(0.97); }

@keyframes fcm-bell-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

/* ═══ BUTTON LOADING SPINNER (Session 52 v45) ═══
 * Spinner CSS minimal 14px inline para botones con accion async.
 * GPU-only animation (transform). Usado por window.withLoading helper.
 * Hereda color del botón (currentColor) — works on any colored button. */
.btn-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: btn-spin 0.7s linear infinite;
    vertical-align: -2px;
    margin-right: 6px;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }

/* Sidebar version footer — click para changelog (Session 52 v45 — regla de oro) */
.sidebar-version-clickable {
    cursor: pointer;
    user-select: none;
    transition: color 150ms ease;
}
.sidebar-version-clickable:hover { color: #818cf8 !important; }
