/* =============================================
   PrevenNorte — Estilos globales
   Fichero: css/prevennorte.css
   ============================================= */

/* ===========================================
   1. VARIABLES
   =========================================== */
:root {
  --color-brand:      #001384;
  --color-brand-dark: #000d5c;
  --color-accent:     #e8002d;
  --color-bg:         #f4f6fb;
  --color-surface:    #ffffff;
  --color-border:     #d1d9ee;
  --color-text:       #1a1f3c;
  --color-muted:      #5a6282;
  --color-error:      #cc0022;
  --color-success:    #007a3d;

  --font-main: 'Segoe UI', Calibri, Arial, sans-serif;

  --radius-sm:   6px;
  --radius-md:   12px;
  --shadow-card: 0 4px 24px rgba(0, 19, 132, 0.10);
  --transition:   0.2s ease;
  --header-height: 160px;  /* ajustar si la imagen del encabezado cambia de alto */
}

/* ===========================================
   2. RESET
   =========================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-main);
  font-size: 1rem;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===========================================
   3. LAYOUT GLOBAL: HEADER / MAIN / FOOTER
   =========================================== */

/* --- Encabezado --- */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 200;
  background: var(--color-surface);
  border-bottom: 3px solid var(--color-brand);
  padding: 0;
  margin: 0;
  line-height: 0;
  font-size: 0;
  text-align: center;
  flex-shrink: 0;      /* evita que flex comprima el header */
  align-self: stretch; /* ocupa todo el ancho del flex container */
  overflow: hidden;    /* recorta cualquier espacio residual */
}

.site-header img {
  max-width: 962px;  /* limita el logo al mismo ancho que el contenido */
  width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
  vertical-align: top;
}

/* --- Botón cerrar sesión (todas las páginas con sesión) --- */
.btn-logout {
  position: fixed;
  top: 12px;
  right: 16px;
  z-index: 300;
  background: transparent;
  color: var(--color-brand);
  border: 1.5px solid var(--color-brand);
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  font-size: 0.82rem;   /* restablecer tras font-size:0 del padre */
  font-weight: 600;
  font-family: var(--font-main);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--transition), color var(--transition);
}

.btn-logout:hover {
  background: var(--color-brand);
  color: #fff;
}

/* --- Contenido principal --- */
.main-content {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: var(--header-height) 16px 100px;
}

/* Variante ancha para páginas con tabla (carpetas_e, carpetas_c) */
.main-content--wide {
  flex-direction: column;
  align-items: stretch;
  padding: var(--header-height) 24px 100px;
  max-width: 100%;
}

/* --- Footer fijo --- */
.site-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: var(--color-surface);
  border-top: 2px solid var(--color-border);
  text-align: center;
  padding: 8px 0;
  z-index: 100;
}

.site-footer img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
}

/* ===========================================
   4. COMPONENTES DE FORMULARIO
   =========================================== */

/* --- Grupos de campo --- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--color-brand);
}

.form-group input,
.form-group textarea {
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 1rem;
  font-family: var(--font-main);
  color: var(--color-text);
  background: #fafbff;
  width: 100%;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-group textarea {
  resize: vertical;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--color-brand);
  box-shadow: 0 0 0 3px rgba(0, 19, 132, 0.12);
}

/* --- Checkbox --- */
.form-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.92rem;
  color: var(--color-muted);
}

.form-check input[type="checkbox"] {
  margin-top: 3px;
  accent-color: var(--color-brand);
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  cursor: pointer;
}

.form-check label {
  cursor: pointer;
  color: var(--color-muted);
  font-weight: normal;
}

/* --- Botón principal --- */
.btn-primary {
  background: var(--color-brand);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 32px;
  font-size: 1rem;
  font-weight: 700;
  font-family: var(--font-main);
  cursor: pointer;
  align-self: flex-start;
  transition: background var(--transition), transform var(--transition);
}

.btn-primary:hover,
.btn-primary:focus {
  background: var(--color-brand-dark);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

/* --- Divisor --- */
.divider {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 8px 0 20px;
}

/* ===========================================
   5. MENSAJES DE ESTADO
   =========================================== */
.msg {
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-top: 4px;
}

.msg--error {
  color: var(--color-error);
  background: #fff0f3;
  border: 1px solid #f5c2cc;
}

.msg--success {
  color: var(--color-success);
  background: #edfaf4;
  border: 1px solid #b2e8ce;
}

/* ===========================================
   6. TARJETAS (LOGIN, EPISODIOS)
   =========================================== */

/* --- Tarjeta base compartida --- */
.login-card,
.episodes-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  width: 100%;
  max-width: 480px;
  padding: 36px 40px;
}

/* --- Título de tarjeta --- */
.card-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--color-brand);
  margin-bottom: 16px;
}

/* --- Aviso condiciones de uso --- */
.notice-box {
  background: #eef1fb;
  border-left: 4px solid var(--color-brand);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.88rem;
  color: var(--color-muted);
  margin-bottom: 28px;
}

/* --- Formulario de login --- */
.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
}

/* --- Secciones de ayuda --- */
.help-sections {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.help-item {
  font-size: 0.92rem;
  color: var(--color-muted);
}

.help-item b {
  color: var(--color-text);
}

.help-item a {
  color: var(--color-brand);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color var(--transition);
}

.help-item a:hover {
  color: var(--color-accent);
}

/* ===========================================
   7. LISTA DE EPISODIOS (carpetas/index.php)
   =========================================== */
.episodes-intro {
  font-size: 0.95rem;
  color: var(--color-muted);
  margin-bottom: 24px;
}

.episodes-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.episodes-list__item {
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.episodes-list__item:hover {
  border-color: var(--color-brand);
  box-shadow: 0 2px 8px rgba(0, 19, 132, 0.10);
}

.episodes-list__item a {
  display: block;
  padding: 12px 18px;
  color: var(--color-brand);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  transition: color var(--transition);
}

.episodes-list__item a:hover {
  color: var(--color-accent);
}

/* --- Enlace "volver" (carpetas/carpeta.php) --- */
.back-link-wrap {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
}

.back-link {
  font-size: 0.88rem;
  color: var(--color-muted);
  text-decoration: none;
  transition: color var(--transition);
}

.back-link:hover {
  color: var(--color-brand);
}

/* ===========================================
   8. REQUISITOS DE CONTRASEÑA (indexclave.php)
   =========================================== */
.password-rules {
  list-style: none;
  background: #eef1fb;
  border-left: 4px solid var(--color-brand);
  border-radius: var(--radius-sm);
  padding: 12px 16px 12px 20px;
  font-size: 0.85rem;
  color: var(--color-muted);
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.password-rules li::before {
  content: '✓ ';
  color: var(--color-brand);
  font-weight: 700;
}

.password-rules code {
  font-family: monospace;
  background: #dde3f5;
  border-radius: 3px;
  padding: 1px 4px;
  font-size: 0.82rem;
}

/* ===========================================
   9. TABLA DE DATOS (carpetas_e, carpetas_c)
   =========================================== */

/* --- Barra de filtros --- */
.filter-bar {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 20px 24px;
  margin-bottom: 24px;
  width: 100%;
}

.filter-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 16px;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.filter-group--wide {
  flex: 1;
  min-width: 200px;
}

.filter-group label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-brand);
}

.filter-group input[type="date"],
.filter-group input[type="text"] {
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 0.9rem;
  font-family: var(--font-main);
  color: var(--color-text);
  background: #fafbff;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.filter-group input:focus {
  outline: none;
  border-color: var(--color-brand);
  box-shadow: 0 0 0 3px rgba(0, 19, 132, 0.10);
}

/* --- Tabla --- */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  font-size: 0.9rem;
}

.data-table thead tr {
  background: var(--color-brand);
  color: #fff;
}

.data-table thead th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
  border-bottom: 2px solid var(--color-brand-dark);
}

.data-table thead th a {
  color: #fff;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 4px;
}

.data-table thead th a:hover {
  color: #d0d8ff;
}

.data-table thead th.th-activo {
  background: var(--color-brand-dark);
}

.data-table tbody tr.data-row {
  border-bottom: 1px solid var(--color-border);
  transition: background var(--transition);
}

.data-table tbody tr.data-row:hover {
  background: #f0f3fb;
}

.data-table tbody tr.data-row.visto {
  background: #e8e8e8;
  color: var(--color-muted);
}

.data-table tbody tr.data-row.visto a {
  color: var(--color-muted);
}

.data-table td {
  padding: 10px 16px;
  vertical-align: middle;
}

.data-table td a {
  color: var(--color-brand);
  text-decoration: none;
  font-weight: 500;
}

.data-table td a:hover {
  color: var(--color-accent);
  text-decoration: underline;
}

.col-nombre   { width: 50%; }
.col-nif      { width: 15%; white-space: nowrap; }
.col-fecha    { width: 12%; white-space: nowrap; }
.col-descarga { width: 15%; }
.col-check    { width: 5%;  text-align: center; }

.link-descarga {
  display: inline-block;
  padding: 4px 10px;
  border: 1px solid var(--color-brand);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-brand) !important;
  transition: background var(--transition), color var(--transition);
}

.link-descarga:hover {
  background: var(--color-brand);
  color: #fff !important;
  text-decoration: none !important;
}

.table-empty {
  text-align: center;
  padding: 32px !important;
  color: var(--color-muted);
  font-style: italic;
}

.table-actions {
  text-align: center;
  padding: 16px !important;
  background: #f4f6fb;
  border-top: 2px solid var(--color-border);
}

/* ===========================================
   10. RESPONSIVE
   =========================================== */
@media (max-width: 768px) {
  .filter-form {
    flex-direction: column;
    align-items: stretch;
  }

  .data-table thead {
    display: none;
  }

  .data-table tbody tr {
    display: block;
    margin-bottom: 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 8px;
  }

  .data-table td {
    display: block;
    text-align: right;
    padding: 6px 12px;
  }

  .data-table td::before {
    content: attr(data-label);
    float: left;
    font-weight: 600;
    color: var(--color-brand);
  }

  .col-nombre, .col-nif, .col-fecha, .col-descarga, .col-check {
    width: 100%;
  }
}

@media (max-width: 600px) {
  .login-card,
  .episodes-card {
    padding: 24px 18px;
  }

  .btn-primary {
    width: 100%;
    text-align: center;
  }

  .btn-logout {
    font-size: 0.75rem;
    padding: 5px 10px;
    right: 8px;
    top: 8px;
  }

  /* Reservar espacio a la derecha para el botón de cerrar sesión */
  .site-header img {
    padding-right: 110px;
  }
}

@media (max-width: 360px) {
  html {
    font-size: 14px;
  }
}

/* ---------- Detalle de trabajador (carpetas_e/carpeta.php) ---------- */
.worker-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 4px;
}

.worker-nif {
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--color-muted);
  margin-left: 8px;
}

/* Fila con fecha + botón de descarga en línea */
.episodes-list__item--row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
}

.informe-fecha {
  color: var(--color-brand);
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  transition: color var(--transition);
}

.informe-fecha:hover {
  color: var(--color-accent);
}
