/* ── Reset & Variables ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --accent: #10B981;
  --accent-dark: #059669;
  --accent-light: #D1FAE5;
  --bg: #F8F9FA;
  --white: #FFFFFF;
  --gray-50: #F9FAFB;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-400: #9CA3AF;
  --gray-600: #4B5563;
  --gray-800: #1F2937;
  --yellow-bg: #FEF3C7;
  --yellow-text: #92400E;
  --red: #EF4444;
  --red-light: #FEE2E2;
  --orange: #F59E0B;
  --orange-light: #FEF3C7;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --font: 'Inter', system-ui, sans-serif;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--gray-800);
  font-size: 14px;
  line-height: 1.5;
}

/* ── Layout ── */
.app-layout { display: flex; flex-direction: column; min-height: 100vh; }
.main-content { flex: 1; padding: 24px; max-width: 1400px; margin: 0 auto; width: 100%; }

/* ── Navbar ── */
.navbar {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}
.navbar-brand {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
}
.navbar-search { flex: 1; max-width: 400px; position: relative; }
.navbar-search input {
  width: 100%;
  padding: 8px 14px 8px 36px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  font-size: 13px;
  background: var(--gray-50);
  outline: none;
  transition: border-color .2s;
}
.navbar-search input:focus { border-color: var(--accent); background: var(--white); }
.navbar-search .search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
  font-size: 14px;
}
.search-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  z-index: 200;
  max-height: 400px;
  overflow-y: auto;
}
.navbar-nav { display: flex; align-items: center; gap: 4px; }
.nav-link {
  padding: 6px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--gray-600);
  font-weight: 500;
  font-size: 13px;
  transition: background .15s, color .15s;
}
.nav-link:hover, .nav-link.active { background: var(--accent-light); color: var(--accent-dark); }
/* ── Nav dropdown (Nómina) ── */
.nav-dropdown { position: relative; }
.nav-dropdown-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  font-size: 13px;
}
.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  min-width: 200px;
  z-index: 200;
  padding: 4px 0;
}
.nav-dropdown-menu.open { display: block; }
.nav-dropdown-menu a {
  display: block;
  padding: 8px 16px;
  font-size: 13px;
  color: var(--gray-800);
  text-decoration: none;
}
.nav-dropdown-menu a:hover { background: var(--gray-50); color: var(--accent-dark); }

.navbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  white-space: nowrap;
}
.navbar-user .user-name { font-weight: 600; font-size: 13px; }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
}
.badge-green  { background: var(--accent-light); color: var(--accent-dark); }
.badge-yellow { background: var(--yellow-bg); color: var(--yellow-text); }
.badge-orange { background: #FEF3C7; color: #92400E; }
.badge-gray   { background: var(--gray-100); color: var(--gray-600); }
.badge-red    { background: var(--red-light); color: var(--red); }
.badge-admin  { background: var(--accent-light); color: var(--accent-dark); }
.badge-operador { background: var(--gray-100); color: var(--gray-600); }

/* ── Cards ── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-title { font-size: 15px; font-weight: 600; }

/* ── Metric cards ── */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.metric-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
}
.metric-label {
  font-size: 12px;
  color: var(--gray-400);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 8px;
}
.metric-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--gray-800);
}
.metric-value.accent { color: var(--accent); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  border: none;
  transition: all .15s;
}
.btn-primary { background: var(--accent); color: var(--white); }
.btn-primary:hover { background: var(--accent-dark); }
.btn-secondary { background: transparent; color: var(--gray-600); border: 1px solid var(--gray-200); }
.btn-secondary:hover { background: var(--gray-100); }
.btn-danger { background: var(--red-light); color: var(--red); border: 1px solid #FCA5A5; }
.btn-danger:hover { background: var(--red); color: var(--white); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--gray-600); margin-bottom: 6px; }
.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  font-size: 13px;
  font-family: var(--font);
  outline: none;
  transition: border-color .2s;
  background: var(--white);
}
.form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(16,185,129,.1); }
.form-control.low-confidence { background: var(--yellow-bg); border-color: #FCD34D; }
textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239CA3AF' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.form-error { color: var(--red); font-size: 12px; margin-top: 4px; }
.form-hint { color: var(--gray-400); font-size: 12px; margin-top: 4px; }

/* ── Tables ── */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--gray-400);
  border-bottom: 1px solid var(--gray-200);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
thead th:hover { color: var(--gray-800); }
tbody tr {
  border-bottom: 1px solid var(--gray-100);
  transition: background .1s;
  cursor: pointer;
}
tbody tr:hover { background: var(--gray-50); }
tbody tr:nth-child(even) { background: #FAFAFA; }
tbody tr:nth-child(even):hover { background: var(--gray-50); }
td { padding: 10px 14px; font-size: 13px; vertical-align: middle; }

/* ── Pagination ── */
.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: center;
  margin-top: 20px;
}
.page-btn {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  text-decoration: none;
  color: var(--gray-600);
  border: 1px solid var(--gray-200);
  transition: all .15s;
}
.page-btn:hover, .page-btn.active { background: var(--accent); color: var(--white); border-color: var(--accent); }
.page-btn.disabled { opacity: .4; pointer-events: none; }

/* ── Upload zone ── */
.upload-zone {
  border: 2px dashed var(--gray-200);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-light);
}
.upload-zone-icon { font-size: 40px; margin-bottom: 12px; }
.upload-zone-text { color: var(--gray-600); }
.upload-zone-hint { font-size: 12px; color: var(--gray-400); margin-top: 6px; }

/* ── Split layout (validación) ── */
.split-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}
.preview-panel {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  position: sticky;
  top: 80px;
}
.preview-panel iframe, .preview-panel img {
  width: 100%;
  max-height: 80vh;
  display: block;
}
.preview-toolbar {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
}

/* ── Modal de confirmación ── */
.confirm-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.45);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity .2s, visibility .2s;
  backdrop-filter: blur(2px);
}
.confirm-backdrop.visible {
  opacity: 1;
  visibility: visible;
}
.confirm-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,0.18);
  padding: 28px 32px 24px;
  max-width: 420px;
  width: calc(100% - 32px);
  transform: scale(0.96) translateY(8px);
  transition: transform .2s;
}
.confirm-backdrop.visible .confirm-card {
  transform: scale(1) translateY(0);
}
.confirm-icon {
  font-size: 32px;
  margin-bottom: 12px;
  display: block;
}
.confirm-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--gray-800);
  margin-bottom: 8px;
}
.confirm-message {
  font-size: 14px;
  color: var(--gray-600);
  margin-bottom: 24px;
  line-height: 1.6;
}
.confirm-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ── Selection bar ── */
.selection-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--gray-800);
  color: var(--white);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  z-index: 500;
  transform: translateY(100%);
  transition: transform .25s ease;
}
.selection-bar.visible { transform: translateY(0); }
.selection-bar .count { font-weight: 700; }
.selection-bar .total { color: var(--accent); font-weight: 700; }
.selection-bar .spacer { flex: 1; }

/* ── Alert ── */
.alert { padding: 12px 16px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }
.alert-error { background: var(--red-light); color: var(--red); border: 1px solid #FCA5A5; }
.alert-success { background: var(--accent-light); color: var(--accent-dark); }
.alert-warning { background: var(--yellow-bg); color: var(--yellow-text); }

/* ── Page header ── */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.page-title { font-size: 22px; font-weight: 700; }
.page-subtitle { font-size: 13px; color: var(--gray-400); margin-top: 2px; }

/* ── Filters bar ── */
.filters-bar {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 20px;
  margin-bottom: 20px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  align-items: end;
}
.filters-bar .form-group { margin-bottom: 0; }

/* ── Login page ── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--bg) 0%, var(--accent-light) 100%);
}
.login-card {
  background: var(--white);
  border-radius: 20px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo-text { font-size: 22px; font-weight: 800; color: var(--accent); }
.login-logo-sub { font-size: 12px; color: var(--gray-400); margin-top: 4px; }

/* ── Checkbox ── */
.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input[type=checkbox] { accent-color: var(--accent); width: 15px; height: 15px; }

/* ── Misc ── */
.text-muted { color: var(--gray-400); }
.text-accent { color: var(--accent); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.fw-600 { font-weight: 600; }
.divider { border: none; border-top: 1px solid var(--gray-200); margin: 20px 0; }

/* ── Progress bar ── */
.progress { background: var(--gray-200); border-radius: 99px; height: 6px; overflow: hidden; margin-top: 8px; }
.progress-bar { background: var(--accent); height: 100%; transition: width .3s; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .split-layout { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .form-row-3 { grid-template-columns: 1fr; }
  .metrics-grid { grid-template-columns: 1fr 1fr; }
  .main-content { padding: 16px; }
  .navbar { padding: 0 16px; }
  .navbar-search { max-width: none; flex: 1; }
}

/* ── Confidence indicator ── */
.confidence-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-left: 6px;
}
.confidence-high { background: var(--accent); }
.confidence-low  { background: var(--orange); }
.confidence-none { background: var(--gray-400); }

/* ── HTMX loading indicator ── */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline-block; }
