/* ==========================================
   BLOQUE 1 — VARIABLES GLOBALES
========================================== */
:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;

  --bg-dark: #111827;
  --bg-body: #f4f6f8;
  --bg-card: #ffffff;
  --bg-soft: #f3f4f6;
  --bg-soft-2: #eef2ff;
  --bg-warning: #fef3c7;
  --bg-active: #dbeafe;

  --text-main: #111827;
  --text-muted: #4b5563;
  --text-light: #ffffff;

  --border-color: #e5e7eb;
  --input-border: #cbd5e1;
  --disabled: #94a3b8;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.10);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.10);
  --shadow-lg: 4px 0 14px rgba(0, 0, 0, 0.18);

  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 12px;

  --transition-fast: 0.2s ease;
  --transition-menu: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}


/* ==========================================
   BLOQUE 2 — RESET BÁSICO
========================================== */
* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
}

body {
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  background-color: var(--bg-body);
  color: var(--text-main);
  line-height: 1.5;
}


/* ==========================================
   BLOQUE 3 — CABECERA SUPERIOR
========================================== */
.topbar {
  position: sticky;
  top: 0;
  left: 0;
  width: 100%;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0 16px;
  background: var(--bg-dark);
  color: var(--text-light);
  z-index: 1000;
  box-shadow: var(--shadow-sm);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  width: auto;
}

.topbar-title {
  margin: 0;
  padding: 0;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1;
  text-align: left;
  color: var(--text-light);
}


/* ==========================================
   BLOQUE 4 — BOTONES DEL MENÚ
========================================== */
.menu-btn,
.close-menu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  min-width: 40px;
  height: 40px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-light);
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  box-shadow: none;
  flex: 0 0 auto;
}

.menu-btn:hover,
.close-menu-btn:hover {
  opacity: 0.8;
}

.menu-btn:active,
.close-menu-btn:active {
  transform: scale(0.98);
}


/* ==========================================
   BLOQUE 5 — MENÚ LATERAL
========================================== */
.side-menu {
  position: fixed;
  top: 0;
  left: 0;
  width: 260px;
  max-width: 85%;
  height: 100%;
  background: var(--bg-card);
  z-index: 1200;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  transform: translateX(0);
  transition: transform var(--transition-menu);
}

.side-menu.hidden {
  transform: translateX(-100%);
}

.side-menu-header {
  height: 60px;
  background: var(--bg-dark);
  color: var(--text-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  font-size: 1.125rem;
  font-weight: 700;
}

.side-menu-nav {
  display: flex;
  flex-direction: column;
  padding: 12px;
  gap: 10px;
}

.menu-item {
  width: 100%;
  margin: 0;
  padding: 14px 16px;
  border: none;
  border-radius: var(--radius-md);
  text-align: left;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  background: var(--bg-soft);
  color: var(--text-main);
  transition: background var(--transition-fast);
  box-shadow: none;
}

.menu-item:hover {
  background: #e5e7eb;
}

.menu-item.active {
  background: var(--bg-active);
  color: var(--primary);
  font-weight: 700;
}


/* ==========================================
   BLOQUE 6 — OVERLAY DEL MENÚ
========================================== */
.menu-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.40);
  z-index: 1100;
  opacity: 1;
  transition: opacity var(--transition-menu);
}

.menu-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}


/* ==========================================
   BLOQUE 7 — CONTENEDOR PRINCIPAL
========================================== */
.container {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 20px;
}


/* ==========================================
   BLOQUE 8 — TÍTULO PRINCIPAL DE LA APP
   Solo afecta al h1 dentro del contenido
========================================== */
.container > h1 {
  text-align: center;
  margin: 20px 0 30px 0;
  font-size: 1.75rem;
  line-height: 1.2;
  color: var(--text-main);
}


/* ==========================================
   BLOQUE 9 — TARJETA PRINCIPAL
========================================== */
.card {
  background: var(--bg-card);
  padding: 24px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}


/* ==========================================
   BLOQUE 10 — TEXTO GENERAL
========================================== */
p {
  font-size: 1.125rem;
  margin: 12px 0;
  line-height: 1.5;
}


/* ==========================================
   BLOQUE 11 — LOGIN
========================================== */
#pantalla-login {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#pantalla-login label {
  display: block;
  font-size: 1rem;
  font-weight: 700;
  margin-top: 6px;
  color: var(--text-main);
}

#pantalla-login input {
  display: block;
  width: 100%;
  padding: 12px 14px;
  font-size: 1.125rem;
  border: 1px solid var(--input-border);
  border-radius: var(--radius-md);
  outline: none;
  background-color: var(--bg-card);
  color: var(--text-main);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

#pantalla-login input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}


/* ==========================================
   BLOQUE 12 — BOTONES PRINCIPALES DE LA APP
   Solo botones reales de trabajo, no menú
========================================== */
#btn-cargar,
#btn-fichar {
  width: 100%;
  padding: 15px;
  margin-top: 20px;
  font-size: 1.125rem;
  font-weight: 700;
  border: none;
  border-radius: var(--radius-xl);
  cursor: pointer;
  background-color: var(--primary);
  color: var(--text-light);
  transition: background-color var(--transition-fast), transform 0.1s ease;
}

#btn-cargar:hover:not(:disabled),
#btn-fichar:hover:not(:disabled) {
  background-color: var(--primary-hover);
}

#btn-cargar:active:not(:disabled),
#btn-fichar:active:not(:disabled) {
  transform: scale(0.99);
}

#btn-cargar:disabled,
#btn-fichar:disabled {
  background-color: var(--disabled);
  cursor: not-allowed;
}


/* ==========================================
   BLOQUE 13 — MENSAJES
========================================== */
#mensaje {
  margin-top: 20px;
  margin-bottom: 10px;
  font-weight: 700;
  text-align: center;
  min-height: 24px;
  color: var(--text-main);
}


/* ==========================================
   BLOQUE 14 — PANTALLA PRINCIPAL APP
========================================== */
#pantalla-app {
  margin-top: 10px;
}

#estado-actual {
  font-weight: 700;
}


/* ==========================================
   BLOQUE 15 — HORAS TRABAJADAS HOY
========================================== */
#horas-hoy {
  display: inline;
  font-weight: 700;
  color: var(--text-main);
  background-color: var(--bg-warning);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}


/* ==========================================
   BLOQUE 16 — RELOJ ACTUAL
========================================== */
#reloj-actual {
  margin-top: 14px;
  text-align: center;
  font-size: 1.0625rem;
  font-weight: 700;
  color: #1f2937;
  background-color: var(--bg-soft-2);
  padding: 10px 12px;
  border-radius: var(--radius-md);
}



/* =========================
   BLOQUE 17 — HISTORIAL POR DÍAS
========================== */
#historial-fichajes {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.bloque-dia-historial {
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.titulo-dia-historial {
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 10px;
  color: #111827;
}

.fila-fichaje-historial {
  background: #f3f4f6;
  padding: 10px 12px;
  margin-top: 8px;
  border-radius: 8px;
  font-size: 14px;
  color: #374151;
}

.fila-fichaje-historial:first-of-type {
  margin-top: 0;
}

.separador-dia-historial {
  margin-top: 10px;
  color: #9ca3af;
  font-size: 12px;
  letter-spacing: 1px;
}
.fila-vacia-historial {
  color: #6b7280;
  font-style: italic;
}

.btn-mostrar-mas-dia {
  margin-top: 10px;
  width: 100%;
  background: #e5e7eb;
  border: none;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 600;
  color: #374151;
  cursor: pointer;
}

.btn-mostrar-mas-dia:hover {
  background: #d1d5db;
}


/* ==========================================
   BLOQUE 18 — LÍNEAS DIVISORIAS
========================================== */
hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 20px 0;
}


/* ==========================================
   BLOQUE 19 — BASE RESERVADA PARA FUTURO MENÚ
========================================== */
.menu-panel {
  display: none;
}


/* ==========================================
   BLOQUE 20 — TABLET
========================================== */
@media (min-width: 641px) and (max-width: 1024px) {
  .container {
    max-width: 820px;
    padding: 24px;
  }

  .card {
    padding: 28px;
  }

  .container h1 {
    font-size: 2rem;
  }
}


/* ==========================================
   BLOQUE 21 — MÓVIL
========================================== */
@media (max-width: 640px) {
  .container {
    padding: 14px;
    margin-top: 20px;
  }

  .container h1 {
    font-size: 1.5rem;
    margin-bottom: 22px;
  }

  .card {
    padding: 18px;
    border-radius: 14px;
  }

  p {
    font-size: 1rem;
  }

  #pantalla-login label {
    font-size: 0.9375rem;
  }

  #pantalla-login input {
    font-size: 1rem;
    padding: 11px 12px;
  }

  #btn-cargar,
  #btn-fichar {
    font-size: 1.0625rem;
    padding: 14px;
  }

  #reloj-actual {
    font-size: 0.9375rem;
    padding: 9px 10px;
  }

  .topbar-title {
    font-size: 1.125rem;
  }
}


/* ==========================================
   BLOQUE 22 — PC GRANDE
========================================== */
@media (min-width: 1025px) {
  .container {
    max-width: 900px;
    padding: 30px;
  }

  .container h1 {
    font-size: 2.5rem;
    margin-top: 30px;
    margin-bottom: 34px;
  }

  .card {
    padding: 34px;
  }
}

/* =========================
   BLOQUE CSS — VISTAS DE NAVEGACIÓN
========================== */

.vista-app {
  display: none;
}

.vista-app.activa {
  display: block;
}

/* =========================
   BLOQUE CSS — MENÚ ACTIVO
========================== */

.menu-item {
  width: 100%;
  padding: 14px;
  border: none;
  background: transparent;
  text-align: left;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.2s;
}

.menu-item:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

.menu-item.active {
  background-color: #111827;
  color: white;
  font-weight: bold;
}
/* =========================
   BLOQUE X — ESTADO CONEXIÓN TEXTO
========================== */
.app-status {
  text-align: right;
  margin-bottom: 10px;
}

#estado-conexion {
  font-weight: bold;
}

#estado-conexion.online {
  color: #16a34a;
}

#estado-conexion.offline {
  color: #dc2626;
  font-style: italic;
}
/* =========================
   BLOQUE X — ESTADO DE CONEXIÓN
========================== */
.app-status {
  text-align: right;
  margin-bottom: 10px;
}

#estado-conexion {
  font-weight: bold;
}

#estado-conexion.online {
  color: #16a34a;
}

#estado-conexion.offline {
  color: #dc2626;
  font-style: italic;
}

/* =========================
   BLOQUE xX  BOTON MOSTRAR MAS HISTORIAL
========================== */

.btn-mostrar-mas-historial {
  display: block;
  margin: 8px 0 0 auto;
  padding: 6px 12px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}


/* =========================
   BLOQUE 30 — BOTÓN SUBIR ARRIBA
========================== */
.btn-subir-arriba {
  position: fixed;
  right: 8px;
  bottom: 20px;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: #111827;
  color: white;
  font-size: 22px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  display: none;
  z-index: 999;
}

.btn-subir-arriba.visible {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* =========================
   BLOQUE CSS — VISTA PERSONAS
========================== */
.acciones-personas {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 16px;
}

.tabla-responsive {
  width: 100%;
  overflow-x: auto;
}

.tabla-personas {
  width: 100%;
  border-collapse: collapse;
  background: #ffffff;
  border-radius: 12px;
  overflow: hidden;
}

.tabla-personas th,
.tabla-personas td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid #e5e7eb;
}

.tabla-personas th {
  font-weight: 700;
  background: #f8fafc;
}

.tabla-personas tbody tr:hover {
  background: #f9fafb;
}

.mensaje-bloque {
  margin-bottom: 16px;
  padding: 12px;
  border-radius: 10px;
  background: #f3f4f6;
}

/* =========================
   BLOQUE CSS — FICHA PERSONA
========================== */
#vista-ficha-persona {
  max-width: 1000px;
  margin: 0 auto;
  padding-top: 90px;
  padding-bottom: 40px;
}

.ficha-persona-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
  margin-top: 24px;
  margin-bottom: 24px;
}

.grupo-formulario {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.grupo-formulario label {
  font-weight: 600;
  color: #0f172a;
}

.grupo-formulario input,
.grupo-formulario select,
.grupo-formulario textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  font-size: 15px;
  background: #ffffff;
  box-sizing: border-box;
}

.grupo-formulario input:focus,
.grupo-formulario select:focus,
.grupo-formulario textarea:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.acciones-formulario-persona {
  display: flex;
  gap: 12px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.acciones-formulario-persona button {
  padding: 12px 18px;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

#btn-guardar-ficha-persona {
  background: #2563eb;
  color: #ffffff;
}

#btn-volver-personas {
  background: #e2e8f0;
  color: #0f172a;
}

#btn-guardar-ficha-persona:hover {
  opacity: 0.92;
}

#btn-volver-personas:hover {
  background: #cbd5e1;
}

/* =========================
   BLOQUE CSS — ACCIONES PLANTILLA PERSONAS
========================== */
.acciones-plantilla-personas {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.acciones-plantilla-personas button {
  padding: 10px 16px;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

#btn-descargar-plantilla-personas {
  background: #0ea5e9;
  color: #ffffff;
}

#btn-subir-plantilla-personas {
  background: #10b981;
  color: #ffffff;
}

#btn-descargar-plantilla-personas:hover,
#btn-subir-plantilla-personas:hover {
  opacity: 0.92;
}

#vista-ficha-persona {
  position: relative;
  z-index: 20;
}

#vista-ficha-persona .acciones-formulario-persona {
  position: relative;
  z-index: 30;
}

#vista-ficha-persona #btn-guardar-persona,
#vista-ficha-persona #btn-cancelar-persona {
  position: relative;
  z-index: 40;
  pointer-events: auto;
}