/* main.css – Global resets, CSS variables, utility classes */

/* GDPR Consent Banner */
.gdpr-consent-banner {
  display: none; position: fixed; bottom: 0; left: 0; right: 0;
  background: #1f2937; color: #f9fafb; padding: 16px 24px;
  z-index: 9999; box-shadow: 0 -4px 12px rgba(0,0,0,0.2);
  font-family: Arial, sans-serif;
}
.gdpr-consent-inner {
  max-width: 1200px; margin: 0 auto;
  display: flex; flex-wrap: wrap; align-items: center; gap: 16px;
}
.gdpr-consent-text { flex: 1; min-width: 200px; }
.gdpr-consent-text strong { font-size: 14px; }
.gdpr-consent-text p { margin: 4px 0 0; font-size: 12px; color: #d1d5db; }
.gdpr-consent-text a { color: #60a5fa; text-decoration: underline; }
.gdpr-consent-actions { display: flex; gap: 8px; flex-shrink: 0; }
.gdpr-btn-accept {
  background: #0072c6; color: #fff; border: none;
  padding: 8px 20px; border-radius: 8px;
  cursor: pointer; font-weight: 600; font-size: 13px;
}
.gdpr-btn-decline {
  background: transparent; color: #9ca3af;
  border: 1px solid #4b5563; padding: 8px 20px;
  border-radius: 8px; cursor: pointer; font-size: 13px;
}

:root {
  /* Core palette */
  --color-primary: #0072c6;
  --color-primary-strong: #005ea3;
  --color-primary-soft: #ecf3ff;
  --color-secondary: #0f766e;
  --color-secondary-soft: #ecfeff;
  --color-success: #059669;
  --color-warning: #d97706;
  --color-error: #dc2626;
  --color-info: #0284c7;
  --color-reference: #0072c6;
  --color-background: #f8f9ff;
  --color-text: #172033;

  /* App tokens used by JSP/Tailwind utility classes */
  --surface-0: #f8f9ff;
  --surface-1: #ffffff;
  --surface-2: #eef3f8;
  --surface-3: #e4ebf4;
  --surface-elevated: #ffffff;
  --border: #dbe4ef;
  --border-subtle: #edf2f7;
  --text-primary: #172033;
  --text-secondary: #526070;
  --text-tertiary: #8390a2;
  --accent: #0072c6;
  --accent-hover: #005ea3;
  --accent-soft: #e1ecff;
  --accent-glow: rgba(0, 114, 198, 0.16);
  --success: #059669;
  --success-soft: #e9fbf3;
  --warning: #d97706;
  --warning-soft: #fff7ed;
  --danger: #dc2626;
  --danger-soft: #fef2f2;

  --radius-sm: 0.5rem;
  --radius-base: 0.75rem;
  --radius-lg: 1rem;
  --radius-xl: 1.25rem;
  --shadow-base: 0 1px 2px rgba(15, 23, 42, 0.04), 0 10px 26px rgba(15, 23, 42, 0.06);
  --shadow-soft: 0 18px 45px rgba(15, 23, 42, 0.08);
  --shadow-focus: 0 0 0 4px var(--accent-glow);
}

/* Reset & box-sizing */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; scroll-behavior: smooth; }
body {
  min-height: 100%;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--surface-0);
  color: var(--text-primary);
  text-rendering: geometricPrecision;
  -webkit-font-smoothing: antialiased;
}

main { min-width: 0; }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
img, svg { max-width: 100%; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  box-shadow: var(--shadow-focus);
}

::selection {
  background: rgba(0, 114, 198, 0.18);
  color: var(--text-primary);
}

body:not(.auth-page) {
  accent-color: var(--accent);
}

body:not(.auth-page) :where(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]), select, textarea) {
  border-color: var(--border);
  background-color: var(--surface-1);
  color: var(--text-primary);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

body:not(.auth-page) :where(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]), select, textarea):focus {
  border-color: var(--accent);
  box-shadow: var(--shadow-focus);
}

body:not(.auth-page) :where(input::placeholder, textarea::placeholder) {
  color: #9aa7b8;
}

body:not(.auth-page) :where(input[readonly], input:disabled, select:disabled, textarea:disabled) {
  background-color: var(--surface-2);
  color: var(--text-tertiary);
  cursor: not-allowed;
}

/* Utility helpers */
.hidden { display: none !important; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.text-center { text-align: center; }
.mt-1 { margin-top: 0.25rem; }
.mb-1 { margin-bottom: 0.25rem; }
.p-2 { padding: 0.5rem; }
.rounded { border-radius: var(--radius-base); }
.shadow { box-shadow: var(--shadow-base); }

/* UI Enhancements */
.hover-lift {
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
}
.hover-lift:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}
.hover-lift:active {
  transform: translateY(0);
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.5rem;
  text-align: center;
  color: #6B7280;
  opacity: 0.8;
}
.empty-state svg {
  margin-bottom: 1rem;
  color: #9CA3AF;
  width: 48px;
  height: 48px;
}

/* Shared app surfaces */
.bg-grid {
  background-color: var(--surface-0);
  background-image:
    linear-gradient(rgba(0, 114, 198, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 114, 198, 0.045) 1px, transparent 1px);
  background-size: 28px 28px;
}

.glass-card,
.section-shell,
.app-card {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-base);
  backdrop-filter: blur(14px);
}

.section-shell {
  padding: clamp(1rem, 2vw, 1.5rem);
}

.surface-muted {
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.custom-input {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-primary);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

.custom-input:focus {
  border-color: var(--accent);
  box-shadow: var(--shadow-focus);
  outline: none;
}

.btn,
.btn-primary,
.btn-secondary,
.btn-outline,
.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 2.5rem;
  border-radius: var(--radius-base);
  border: 1px solid transparent;
  padding: 0.65rem 1rem;
  font-weight: 800;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.18s ease, background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.btn:hover,
.btn-primary:hover,
.btn-secondary:hover,
.btn-outline:hover,
.btn-ghost:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 10px 22px rgba(0, 114, 198, 0.2);
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--color-secondary);
  color: #ffffff;
  box-shadow: 0 10px 22px rgba(15, 118, 110, 0.18);
}

.btn-outline {
  background: var(--surface-1);
  border-color: var(--border);
  color: var(--text-primary);
}

.btn-outline:hover {
  border-color: rgba(0, 114, 198, 0.35);
  color: var(--accent);
  box-shadow: var(--shadow-base);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text-primary);
}

.badge,
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-secondary);
  padding: 0.25rem 0.65rem;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1;
}

.badge-success,
.chip-success {
  background: var(--success-soft);
  border-color: rgba(5, 150, 105, 0.18);
  color: var(--success);
}

.badge-warning,
.chip-warning {
  background: var(--warning-soft);
  border-color: rgba(217, 119, 6, 0.2);
  color: var(--warning);
}

.badge-danger,
.chip-danger {
  background: var(--danger-soft);
  border-color: rgba(220, 38, 38, 0.18);
  color: var(--danger);
}

.app-table,
body:not(.auth-page) table {
  border-collapse: separate;
  border-spacing: 0;
}

body:not(.auth-page) :where(table thead tr) {
  background: var(--surface-2);
}

body:not(.auth-page) :where(table th) {
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

body:not(.auth-page) :where(table td, table th) {
  border-color: var(--border-subtle);
}

body:not(.auth-page) :where(table tbody tr) {
  transition: background-color 0.15s ease;
}

body:not(.auth-page) :where(table tbody tr:hover) {
  background: rgba(0, 114, 198, 0.035);
}

/* Shared topbar fragment */
.topbar-shell {
  min-height: 4rem;
  padding: 0.8rem 1.5rem;
  background: rgba(255, 255, 255, 0.86);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 30;
  backdrop-filter: blur(16px);
}

.topbar-status,
.topbar-links {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 800;
}

.topbar-status {
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-1);
}

.topbar-status__dot,
.topbar-links__dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 999px;
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(5, 150, 105, 0.1);
}

.topbar-links span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.search-bar {
  position: relative;
  min-width: 18rem;
}

.search-bar__icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  width: 1rem;
  height: 1rem;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  pointer-events: none;
}

.search-bar__input {
  width: 100%;
  min-height: 2.45rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-primary);
  padding: 0.55rem 1rem 0.55rem 2.45rem;
  font-size: 0.82rem;
  font-weight: 700;
  outline: none;
}

.search-bar__input:focus {
  background: var(--surface-1);
  border-color: var(--accent);
  box-shadow: var(--shadow-focus);
}

.user-dropdown {
  position: relative;
}

.user-dropdown__trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 2.5rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-1);
  color: var(--text-primary);
  padding: 0.25rem 0.75rem 0.25rem 0.25rem;
  font-weight: 800;
  cursor: pointer;
}

.user-dropdown__avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 900;
}

.user-dropdown__menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.6rem);
  width: min(16rem, calc(100vw - 2rem));
  display: none;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-1);
  box-shadow: var(--shadow-soft);
  z-index: 80;
}

.user-dropdown__menu.is-open {
  display: flex;
}

.user-dropdown__header {
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
}

.user-dropdown__name {
  color: var(--text-primary);
  font-size: 0.9rem;
  font-weight: 900;
}

.user-dropdown__email {
  color: var(--text-tertiary);
  font-size: 0.75rem;
  font-weight: 700;
  margin-top: 0.1rem;
}

.user-dropdown__item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.75rem 1rem;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  text-align: left;
  text-decoration: none;
  font-size: 0.84rem;
  font-weight: 800;
  cursor: pointer;
}

.user-dropdown__item svg {
  width: 1rem;
  height: 1rem;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.user-dropdown__item:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.user-dropdown__divider {
  height: 1px;
  background: var(--border-subtle);
}

@media (max-width: 768px) {
  .topbar-shell {
    padding-inline: 1rem;
  }

  .search-bar {
    min-width: 0;
    width: 100%;
  }

  body:not(.auth-page) :where(.glass-card, .section-shell, .app-card) {
    border-radius: var(--radius-lg);
  }
}

/* Tipografía del landing: Inter en el cuerpo (body) y Plus Jakarta Sans en títulos y cifras. */
h1, h2, h3, h4,
.auth-card-title, .auth-hero-title, .auth-brand-name, .auth-stat-value {
  font-family: 'Plus Jakarta Sans', 'Inter', system-ui, sans-serif;
  letter-spacing: -0.015em;
}

/* ════════════════════════════════════════════
   PANEL UNIFICADO (mismo estilo que "Mi importación" y el landing)
   ════════════════════════════════════════════ */
body:not(.auth-page) .bg-grid {
  background-color: #F8FAFC;
  background-image: none;
}

body:not(.auth-page) :where(.glass-card, .section-shell, .app-card) {
  background: #ffffff;
  border: 1px solid #E8EAED;
  border-radius: 24px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.05);
  backdrop-filter: none;
}

/* Barras superiores de las herramientas: sólidas como el resto del panel */
body:not(.auth-page) main > header.h-16 {
  background: #ffffff;
  backdrop-filter: none;
}

/* Textos diminutos -> tamaño legible */
body:not(.auth-page) main :where(.text-\[8px\], .text-\[9px\]) { font-size: 11px; }
body:not(.auth-page) main :where(.text-\[10px\]) { font-size: 12px; }

/* Título de pantalla con ícono ilustrado (caja / documento / calculadora...) */
.pu-titulo { display: flex; align-items: center; gap: 24px; margin-bottom: 24px; }
.pu-h2 { font-size: 34px; font-weight: 800; color: #001a3d; letter-spacing: -0.5px; line-height: 1.1; margin-top: 10px; }
.pu-sub { font-size: 14px; color: #64748B; font-weight: 500; margin-top: 4px; }
.pu-icono {
  position: relative;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: #e1ecff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.pu-destello1 { position: absolute; top: 8px; right: 6px; width: 15px; height: 15px; }
.pu-destello2 { position: absolute; top: 28px; right: -2px; width: 10px; height: 10px; }
.pu-check {
  position: absolute;
  bottom: 2px;
  left: -4px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #10B981;
  border: 3px solid #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.4);
}
@media (max-width: 640px) {
  .pu-titulo { flex-direction: column; align-items: flex-start; gap: 16px; }
}

/* Variante dentro de tarjetas / cabeceras: sin margen inferior y títulos grandes con el mismo estilo */
.pu-titulo--en-linea { margin-bottom: 0; }
.pu-titulo :where(h1, h2).text-4xl {
  font-size: 34px;
  font-weight: 800;
  color: #001a3d;
  letter-spacing: -0.5px;
  line-height: 1.15;
}

/* Morados / índigos sueltos de Tailwind -> paleta del landing (las ilustraciones conservan su morado) */
body:not(.auth-page) :is(.bg-indigo-600, .bg-purple-600) { background-color: #0072c6; }
body:not(.auth-page) :is(.hover\:bg-indigo-700, .hover\:bg-purple-700):hover { background-color: #0b3566; }
body:not(.auth-page) :is(.text-indigo-500, .text-indigo-600, .text-purple-600, .text-violet-500) { color: #0072c6; }
body:not(.auth-page) :is(.text-indigo-900, .text-purple-700) { color: #0b3566; }
body:not(.auth-page) :is(.hover\:text-indigo-600, .hover\:text-indigo-700):hover { color: #0b3566; }
body:not(.auth-page) :is(.bg-indigo-50, .bg-purple-50, .bg-violet-50) { background-color: #ecf3ff; }
body:not(.auth-page) .bg-purple-100 { background-color: #e1ecff; }
body:not(.auth-page) .bg-purple-500\/10 { background-color: rgba(0, 114, 198, 0.1); }
body:not(.auth-page) :is(.border-indigo-100, .border-indigo-200\/50, .border-violet-100, .border-purple-200) { border-color: #c4e1ff; }
body:not(.auth-page) .border-indigo-600 { border-color: #0072c6; }
body:not(.auth-page) .border-purple-500\/20 { border-color: rgba(0, 114, 198, 0.2); }

/* ════════════════════════════════════════════
   BOTONES ESTÁNDAR (patrón de "Mi importación")
   Principal: azul plano #0072c6, radio 12 px, sin sombra.
   Secundario: blanco con borde gris suave y texto navy.
   ════════════════════════════════════════════ */
body:not(.auth-page) :is(
    .primary-button, .seg-btn-new, .btn-continuar, .ie-btn-start, .ie-btn-search,
    .sa-btn:not(.sec):not(.peligro), .expediente-page .primary-button,
    button[class*="bg-[#0072c6]"], a[class*="bg-[#0072c6]"],
    button[class*="bg-[var(--accent)]"], a[class*="bg-[var(--accent)]"],
    button.bg-indigo-600, a.bg-indigo-600, button.bg-blue-600, a.bg-blue-600, button.bg-purple-600
) {
  background: #0072c6 !important;
  color: #ffffff !important;
  border: 0 !important;
  border-radius: 12px !important;
  box-shadow: none !important;
  font-weight: 700;
  letter-spacing: normal;
  text-transform: none;
  transition: background-color 0.2s ease;
}

body:not(.auth-page) :is(
    .primary-button, .seg-btn-new, .btn-continuar, .ie-btn-start, .ie-btn-search,
    .sa-btn:not(.sec):not(.peligro),
    button[class*="bg-[#0072c6]"], a[class*="bg-[#0072c6]"],
    button[class*="bg-[var(--accent)]"], a[class*="bg-[var(--accent)]"],
    button.bg-indigo-600, a.bg-indigo-600, button.bg-blue-600, a.bg-blue-600, button.bg-purple-600
):hover {
  background: #0b3566 !important;
}

body:not(.auth-page) :is(.primary-button, .ie-btn-start, .sa-btn:not(.sec):not(.peligro)) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  font-size: 14px !important;
  text-decoration: none;
  cursor: pointer;
}
body:not(.auth-page) .primary-button.w-full { display: flex; }

body:not(.auth-page) :is(.btn-outline, .ie-hero-btn-outline, .sa-btn.sec, .soft-button) {
  background: #ffffff !important;
  color: #001a3d !important;
  border: 1.5px solid #E2E8F0 !important;
  border-radius: 12px !important;
  box-shadow: none !important;
  font-weight: 600;
  letter-spacing: normal;
  text-transform: none;
}

body:not(.auth-page) :is(.btn-outline, .ie-hero-btn-outline, .sa-btn.sec, .soft-button):hover {
  border-color: #0072c6 !important;
  color: #0072c6 !important;
}

/* Botón "Continuar" del asistente: mismo botón principal estándar */
body:not(.auth-page) .ev-btn-continue {
  background: #0072c6 !important;
  color: #ffffff !important;
  border-radius: 12px !important;
  box-shadow: none !important;
}
body:not(.auth-page) .ev-btn-continue:hover { background: #0b3566 !important; }
html.dark-mode body:not(.auth-page) .ev-btn-continue:hover { background: #1a8fe3 !important; }

/* Misma letra en todo el panel que en Inicio y Mi importación. Las clases de Tailwind usaban la letra del
   sistema (font-sans) y Consolas (font-mono); las cifras siguen alineadas con números de ancho fijo. */
.font-sans { font-family: 'Inter', system-ui, sans-serif; }
.font-mono { font-family: 'Inter', system-ui, sans-serif; font-variant-numeric: tabular-nums; }
