/* ============================================================
   Checkealo PWA – Estilos globales
   Paleta: naranja #D67620, azul #00A6E0, fondo #F8F8F8, dark #303030
   ============================================================ */

/* ---------- Reset & base ---------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  width: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: #F8F8F8;
  color: #222;
  overflow: hidden;
}

/* ---------- Contenedor raíz ---------- */
#app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
}

/* ============================================================
   PANTALLA DE SPLASH / CARGA
   ============================================================ */
#screen-splash {
  position: fixed;
  inset: 0;
  background: #303030;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 900;
  transition: opacity 0.4s ease;
}

#screen-splash.hidden {
  opacity: 0;
  pointer-events: none;
}

#splash-logo {
  width: 190px;
  height: 190px;
  object-fit: contain;
  animation: fadeInScale 0.6s ease forwards;
}

#splash-bar-wrap {
  margin-top: 20px;
  width: 220px;
  height: 8px;
  background: rgba(255,255,255,0.15);
  border-radius: 4px;
  overflow: hidden;
}

#splash-bar {
  height: 100%;
  width: 30%;
  background: #00A6E0;
  border-radius: 4px;
  animation: indeterminate 1.4s infinite linear;
}

#splash-text {
  margin-top: 14px;
  color: #ffffff;
  font-size: 17px;
  letter-spacing: 0.5px;
}

@keyframes indeterminate {
  0%   { transform: translateX(-100%); width: 40%; }
  50%  { width: 60%; }
  100% { transform: translateX(370%); width: 40%; }
}

@keyframes fadeInScale {
  from { opacity: 0; transform: scale(0.85); }
  to   { opacity: 1; transform: scale(1); }
}

/* ============================================================
   PANTALLA OFFLINE
   ============================================================ */
#screen-offline {
  position: fixed;
  inset: 0;
  background: #000;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 800;
}

#screen-offline.visible {
  display: flex;
}

#offline-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Botón de logout invisible (igual que Android) */
#btn-logout-offline {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 58px;
  height: 58px;
  background: transparent;
  border: none;
  cursor: pointer;
  z-index: 810;
  /* Zona táctil invisible */
  opacity: 0;
}

/* ============================================================
   PANTALLA LOGIN
   ============================================================ */
#screen-login {
  position: fixed;
  inset: 0;
  background: #F8F8F8;
  overflow-y: auto;
  display: none;
  flex-direction: column;
  align-items: center;
  z-index: 700;
  /* Safe area para iPhone con notch */
  padding-top: env(safe-area-inset-top, 20px);
  padding-bottom: env(safe-area-inset-bottom, 16px);
}

#screen-login.visible {
  display: flex;
}

.login-inner {
  width: 100%;
  max-width: 420px;
  padding: 24px 24px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.login-title {
  font-size: 18px;
  font-weight: 700;
  color: #C65D00;
  margin-bottom: 16px;
  text-align: center;
}

.login-logo {
  width: 180px;
  height: 80px;
  object-fit: contain;
  margin-bottom: 20px;
}

.login-subtitle {
  font-size: 14px;
  font-weight: 700;
  color: #222;
  align-self: flex-start;
  margin-bottom: 10px;
}

/* Campos de formulario */
.login-field {
  position: relative;
  width: 100%;
  margin-bottom: 14px;
}

.login-field svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  fill: #888;
  pointer-events: none;
}

.login-field input {
  width: 100%;
  padding: 12px 12px 12px 40px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 15px;
  color: #222;
  background: #fff;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.login-field input:focus {
  border-color: #D67620;
  box-shadow: 0 0 0 2px rgba(214,118,32,0.2);
}

/* Botón login */
#btn-login {
  width: 100%;
  padding: 14px;
  background: #D67620;
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  margin-top: 4px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  -webkit-appearance: none;
  transition: background 0.2s;
}

#btn-login:active {
  background: #b55e14;
}

#btn-login svg {
  width: 20px;
  height: 20px;
  fill: #fff;
}

#btn-login.loading {
  opacity: 0.7;
  pointer-events: none;
}

/* Switch Recordar */
.login-switch-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.login-switch-label {
  font-size: 14px;
  color: #444;
}

/* Toggle switch iOS-style */
.toggle {
  position: relative;
  width: 48px;
  height: 28px;
  flex-shrink: 0;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-track {
  position: absolute;
  inset: 0;
  background: #ccc;
  border-radius: 28px;
  transition: background 0.25s;
  cursor: pointer;
}

.toggle input:checked + .toggle-track {
  background: #D67620;
}

.toggle-track::after {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.25s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.toggle input:checked + .toggle-track::after {
  transform: translateX(20px);
}

/* Error message */
#login-error {
  width: 100%;
  padding: 10px 14px;
  background: #fff0eb;
  border-left: 3px solid #D67620;
  border-radius: 4px;
  font-size: 13px;
  color: #a03000;
  margin-top: 8px;
  display: none;
}

#login-error.visible {
  display: block;
}

/* Biometría */
#btn-biometria {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-top: 20px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: #888;
  font-size: 13px;
}

#btn-biometria svg {
  width: 44px;
  height: 44px;
  fill: #888;
}

#btn-biometria.visible {
  display: flex;
}

/* ============================================================
   PANTALLA PRINCIPAL (iframe)
   ============================================================ */
#screen-main {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  z-index: 600;
  background: #303030;
  /* Safe area */
  padding-top: env(safe-area-inset-top, 0px);
}

#screen-main.visible {
  display: flex;
}

#app-iframe {
  flex: 1;
  width: 100%;
  border: none;
  background: transparent;
  display: block;
}

/* Botón logout invisible (esquina top-right, idéntico al Android) */
#btn-logout-main {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 8px);
  right: 8px;
  width: 58px;
  height: 58px;
  background: transparent;
  border: none;
  cursor: pointer;
  z-index: 650;
  opacity: 0;
}

/* ============================================================
   DIALOG / MODAL genérico
   ============================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
}

.modal-backdrop.visible {
  display: flex;
}

.modal-card {
  background: #fff;
  border-radius: 14px;
  padding: 24px 20px 20px;
  width: 100%;
  max-width: 340px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
}

.modal-title {
  font-size: 17px;
  font-weight: 700;
  color: #222;
  margin-bottom: 10px;
}

.modal-message {
  font-size: 14px;
  color: #555;
  line-height: 1.5;
  margin-bottom: 20px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.modal-btn {
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  border: none;
  cursor: pointer;
}

.modal-btn.primary {
  background: #D67620;
  color: #fff;
}

.modal-btn.secondary {
  background: #eee;
  color: #444;
}

/* ============================================================
   UTILIDADES
   ============================================================ */
.hidden { display: none !important; }
