/* ==========================================================
   BoletasX - Estilos principales
   Variables CSS controladas por branding (multi-empresa)
   ========================================================== */

:root {
  --c-primary: #1e3a8a;
  --c-secondary: #0f172a;
  --c-accent: #10b981;
  --c-bg: #f8fafc;
  --c-surface: #ffffff;
  --c-text: #0f172a;
  --c-text-muted: #64748b;
  --c-border: #e2e8f0;
  --c-danger: #dc2626;
  --c-warning: #f59e0b;
  --c-info: #0ea5e9;
  --c-success: #10b981;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12);

  --font-sans: 'Outfit', 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: var(--font-sans);
  background: var(--c-bg);
  color: var(--c-text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ==========================================================
   LAYOUT DE LOGIN
   ========================================================== */
.login-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--c-bg);
}

.login-side {
  position: relative;
  background: linear-gradient(135deg, var(--c-primary) 0%, var(--c-secondary) 100%);
  color: #fff;
  padding: 64px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}

.login-side::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(255,255,255,0.08) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(255,255,255,0.05) 0%, transparent 50%);
  pointer-events: none;
}

.login-side > * { position: relative; z-index: 1; }

.brand-mark {
  display: flex;
  align-items: center;
  gap: 14px;
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.02em;
}

.brand-mark img { height: 40px; width: auto; }

.brand-mark .mark-fallback {
  width: 40px; height: 40px;
  background: rgba(255,255,255,0.15);
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 18px;
}

.login-headline {
  margin-top: 80px;
}
.login-headline h1 {
  font-size: 44px;
  line-height: 1.05;
  letter-spacing: -0.03em;
  font-weight: 700;
  margin-bottom: 20px;
}
.login-headline p {
  font-size: 17px;
  opacity: 0.85;
  max-width: 420px;
  line-height: 1.55;
}

.login-features {
  display: grid;
  gap: 16px;
  margin-top: 40px;
}
.login-feature {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  font-size: 14px;
  opacity: 0.9;
}
.login-feature .icon {
  width: 22px; height: 22px;
  background: rgba(255,255,255,0.15);
  border-radius: 6px;
  display: grid; place-items: center;
  font-size: 13px;
  flex-shrink: 0;
}

.login-footer {
  font-size: 13px;
  opacity: 0.6;
}

.login-form-side {
  display: grid;
  place-items: center;
  padding: 40px;
}

.login-card {
  width: 100%;
  max-width: 420px;
}

.login-card h2 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.login-card .subtitle {
  color: var(--c-text-muted);
  margin-bottom: 32px;
  font-size: 15px;
}

/* ==========================================================
   FORMULARIOS
   ========================================================== */
.field {
  margin-bottom: 18px;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 7px;
  color: var(--c-text);
}

.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="number"],
.field input[type="date"],
.field select,
.field textarea {
  width: 100%;
  padding: 12px 14px;
  font-size: 15px;
  font-family: inherit;
  border: 1.5px solid var(--c-border);
  border-radius: var(--radius);
  background: var(--c-surface);
  color: var(--c-text);
  transition: all 0.15s ease;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--c-primary) 15%, transparent);
}

.field .hint {
  font-size: 12px;
  color: var(--c-text-muted);
  margin-top: 6px;
}

.field.error input,
.field.error select { border-color: var(--c-danger); }
.field .error-msg {
  font-size: 12px;
  color: var(--c-danger);
  margin-top: 6px;
  font-weight: 500;
}

/* ==========================================================
   BOTONES
   ========================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--c-primary);
  color: #fff;
}
.btn-primary:hover { filter: brightness(1.1); transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--c-surface);
  color: var(--c-text);
  border: 1.5px solid var(--c-border);
}
.btn-secondary:hover { background: var(--c-bg); border-color: var(--c-text-muted); }

.btn-danger { background: var(--c-danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.1); }

.btn-ghost { background: transparent; color: var(--c-text-muted); }
.btn-ghost:hover { background: var(--c-bg); color: var(--c-text); }

.btn-block { width: 100%; }
.btn-lg { padding: 14px 24px; font-size: 15px; }
.btn-sm { padding: 8px 14px; font-size: 13px; }

/* ==========================================================
   ALERTAS / MENSAJES
   ========================================================== */
.alert {
  padding: 14px 16px;
  border-radius: var(--radius);
  margin-bottom: 18px;
  font-size: 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border-left: 4px solid;
}

.alert-error {
  background: #fef2f2;
  border-color: var(--c-danger);
  color: #991b1b;
}

.alert-success {
  background: #f0fdf4;
  border-color: var(--c-success);
  color: #166534;
}

.alert-warning {
  background: #fffbeb;
  border-color: var(--c-warning);
  color: #92400e;
}

.alert-info {
  background: #f0f9ff;
  border-color: var(--c-info);
  color: #075985;
}

/* ==========================================================
   APP LAYOUT (interno - dashboard)
   ========================================================== */
.app-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--c-secondary);
  color: rgba(255,255,255,0.85);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar .brand-mark {
  padding: 8px 12px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  margin-bottom: 16px;
  font-size: 17px;
}

.sidebar a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 8px;
  color: rgba(255,255,255,0.75);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.12s ease;
}

.sidebar a:hover {
  background: rgba(255,255,255,0.07);
  color: #fff;
  text-decoration: none;
}

.sidebar a.active {
  background: var(--c-primary);
  color: #fff;
}

.sidebar .sidebar-section {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.4);
  padding: 16px 14px 8px;
  font-weight: 600;
}

.sidebar-bottom {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.main-content {
  padding: 32px 40px;
  background: var(--c-bg);
  overflow-x: auto;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 28px;
  gap: 20px;
  flex-wrap: wrap;
}

.page-header h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.page-header .subtitle {
  color: var(--c-text-muted);
  font-size: 14px;
}

.page-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* ==========================================================
   CARDS / TABLAS
   ========================================================== */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--c-border);
}

.card-header h3 {
  font-size: 17px;
  font-weight: 600;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

table.data th {
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--c-text-muted);
  padding: 12px 14px;
  border-bottom: 1px solid var(--c-border);
  background: var(--c-bg);
}

table.data td {
  padding: 14px;
  border-bottom: 1px solid var(--c-border);
  vertical-align: middle;
}

table.data tr:hover td { background: rgba(15, 23, 42, 0.02); }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-neutral { background: #f1f5f9; color: #475569; }

/* ==========================================================
   USER MENU (esquina superior)
   ========================================================== */
.user-menu {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--c-primary);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
}

.user-info { font-size: 13px; line-height: 1.3; }
.user-info strong { display: block; font-weight: 600; }
.user-info span { color: var(--c-text-muted); font-size: 12px; }

/* ==========================================================
   RESPONSIVE
   ========================================================== */
@media (max-width: 900px) {
  .login-wrap { grid-template-columns: 1fr; }
  .login-side { padding: 32px 28px; min-height: 280px; }
  .login-headline { margin-top: 28px; }
  .login-headline h1 { font-size: 32px; }
  .login-features { display: none; }

  .app-layout { grid-template-columns: 1fr; }
  .sidebar {
    flex-direction: row;
    overflow-x: auto;
    padding: 12px;
    gap: 6px;
  }
  .sidebar .brand-mark,
  .sidebar .sidebar-section,
  .sidebar-bottom { display: none; }
  .main-content { padding: 20px; }
}

/* ==========================================================
   COMPONENTES MÓDULO 2/7
   ========================================================== */

/* Botón de archivo / drop zone */
.dropzone {
  border: 2px dashed var(--c-border);
  border-radius: var(--radius-lg);
  padding: 40px 24px;
  text-align: center;
  background: var(--c-surface);
  cursor: pointer;
  transition: all 0.2s ease;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--c-primary);
  background: color-mix(in srgb, var(--c-primary) 4%, transparent);
}
.dropzone.dragover {
  transform: scale(1.01);
}
.dropzone .dz-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.6;
}
.dropzone .dz-title {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 6px;
}
.dropzone .dz-hint {
  font-size: 14px;
  color: var(--c-text-muted);
}

/* Tabs */
.tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--c-border);
  margin-bottom: 24px;
}
.tabs a {
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 600;
  color: var(--c-text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.15s;
}
.tabs a:hover { color: var(--c-text); text-decoration: none; }
.tabs a.active {
  color: var(--c-primary);
  border-bottom-color: var(--c-primary);
}

/* Filas de archivos en upload */
.file-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  background: var(--c-surface);
  font-size: 14px;
}
.file-row .file-icon {
  width: 36px; height: 36px;
  background: #f1f5f9;
  border-radius: 8px;
  display: grid; place-items: center;
  font-size: 16px;
  flex-shrink: 0;
}
.file-row.ok .file-icon { background: #dcfce7; color: #166534; }
.file-row.error .file-icon { background: #fee2e2; color: #991b1b; }
.file-row.warn .file-icon { background: #fef3c7; color: #92400e; }
.file-row .file-info { flex: 1; min-width: 0; }
.file-row .file-name {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-row .file-meta { color: var(--c-text-muted); font-size: 12px; margin-top: 2px; }

/* Modales */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: grid;
  place-items: center;
  z-index: 1000;
  padding: 20px;
  animation: fadein 0.15s ease;
}
@keyframes fadein {
  from { opacity: 0; }
  to { opacity: 1; }
}
.modal {
  background: var(--c-surface);
  border-radius: var(--radius-lg);
  max-width: 600px;
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--c-border);
  display: flex; justify-content: space-between; align-items: center;
}
.modal-header h3 { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.modal-body { padding: 24px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--c-border);
  display: flex; gap: 10px; justify-content: flex-end;
}

/* Stat boxes (resumen post-carga) */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin: 16px 0;
}
.stat-box {
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--c-border);
  background: var(--c-surface);
}
.stat-box.ok { border-color: #86efac; background: #f0fdf4; }
.stat-box.warn { border-color: #fcd34d; background: #fffbeb; }
.stat-box.err { border-color: #fca5a5; background: #fef2f2; }
.stat-box .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  color: var(--c-text-muted);
}
.stat-box.ok .label { color: #166534; }
.stat-box.warn .label { color: #92400e; }
.stat-box.err .label { color: #991b1b; }
.stat-box .value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-top: 4px;
}

/* Search box */
.search-box {
  position: relative;
  width: 100%;
  max-width: 360px;
}
.search-box input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  border: 1.5px solid var(--c-border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  background: var(--c-surface);
}
.search-box::before {
  content: '🔍';
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  opacity: 0.5;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--c-text-muted);
}
.empty-state .icon {
  font-size: 56px;
  margin-bottom: 12px;
  opacity: 0.5;
}
.empty-state h4 {
  font-size: 17px;
  font-weight: 600;
  color: var(--c-text);
  margin-bottom: 6px;
}

/* Form grid */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

/* Toolbar */
.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}
.toolbar .spacer { flex: 1; }

/* Helper de utilidad */
.muted { color: var(--c-text-muted); }
.text-success { color: var(--c-success); }
.text-warn { color: var(--c-warning); }
.text-danger { color: var(--c-danger); }

/* ================================================
   FOOTER GLOBAL DE PANEL INTERNO
   ================================================ */
.app-footer {
  margin-left: 240px;
  padding: 16px 32px;
  font-size: 12px;
  color: var(--c-text-muted);
  border-top: 1px solid var(--c-border);
  background: white;
  text-align: center;
}
@media (max-width: 900px) {
  .app-footer { margin-left: 0; padding: 14px 16px; }
}

/* ================================================
   PALETA DE COLORES (componente reusable para branding)
   ================================================ */
.color-palette {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
}
.color-swatch {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: #f8fafc;
  border-radius: 10px;
  border: 1px solid var(--c-border);
}
.color-swatch .chip {
  width: 44px; height: 44px; border-radius: 8px;
  border: 1px solid rgba(0,0,0,.1);
  flex-shrink: 0;
}
.color-swatch .info { flex: 1; min-width: 0; }
.color-swatch .info strong { font-size: 13px; display: block; }
.color-swatch .info code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--c-text-muted);
}

/* ================================================
   PREVIEW DE IMAGEN
   ================================================ */
.image-preview {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}
.image-preview img {
  max-width: 240px;
  max-height: 120px;
  background: white;
  border: 1px solid var(--c-border);
  border-radius: 8px;
  padding: 8px;
}
.image-preview .meta { font-size: 11px; color: var(--c-text-muted); }

/* ================================================
   TARJETA PELIGRO (zona crítica)
   ================================================ */
.danger-zone {
  border: 2px solid #fecaca;
  background: #fef2f2;
  border-radius: 12px;
  padding: 20px;
}
.danger-zone h3 { color: #b91c1c; }
.danger-zone p { color: #7f1d1d; margin-bottom: 12px; }


/* ==============================================
   v1.6.0 — Badge en sidebar (contador pendientes)
   ============================================== */
.sidebar-badge {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: #ef4444;
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  min-width: 20px;
  text-align: center;
  animation: badgePulse 2s ease-in-out infinite;
  box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
}
@keyframes badgePulse {
  0%, 100% { transform: translateY(-50%) scale(1); box-shadow: 0 0 0 0 rgba(239,68,68,0.7); }
  50% { transform: translateY(-50%) scale(1.06); box-shadow: 0 0 0 6px rgba(239,68,68,0); }
}

/* Banner de pendientes en la bandeja del trabajador */
.pending-banner {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border: 1px solid #f59e0b;
  border-left: 4px solid #d97706;
  border-radius: 12px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  animation: bannerSlide 0.4s ease-out;
}
.pending-banner .pending-icon {
  font-size: 34px;
  animation: bannerWave 1.6s ease-in-out infinite;
}
.pending-banner .pending-body { flex: 1; min-width: 200px; }
.pending-banner .pending-title {
  font-size: 15px;
  font-weight: 700;
  color: #78350f;
  margin-bottom: 4px;
}
.pending-banner .pending-sub {
  font-size: 13px;
  color: #92400e;
  line-height: 1.4;
}
@keyframes bannerSlide {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes bannerWave {
  0%, 100% { transform: rotate(-8deg); }
  50% { transform: rotate(8deg); }
}

/* Toast de bienvenida */
.pending-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #78350f;
  color: white;
  padding: 14px 20px;
  border-radius: 10px;
  box-shadow: 0 10px 40px rgba(120,53,15,0.35);
  z-index: 999;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 340px;
  animation: toastIn 0.4s ease-out;
}
.pending-toast .toast-icon { font-size: 22px; }
.pending-toast .toast-text { font-size: 13.5px; line-height: 1.4; }
.pending-toast .toast-text strong { color: #fef3c7; }
.pending-toast .toast-close {
  background: transparent;
  border: none;
  color: #fef3c7;
  font-size: 20px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  opacity: 0.7;
}
.pending-toast .toast-close:hover { opacity: 1; }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Card de boleta bloqueada (secuencial) */
.boleta-bloqueada {
  opacity: 0.65;
  filter: grayscale(0.4);
  pointer-events: none;
  position: relative;
}
.boleta-bloqueada::after {
  content: "🔒 Firma primero la anterior";
  position: absolute;
  top: 10px;
  right: 10px;
  background: #64748b;
  color: white;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
}
