/* ============================================================
   VitalFace eval — Dark navy theme with marine-blue gradients
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* Background layers */
  --bg-base: #050816;
  --bg-1:    #0a0f24;
  --bg-2:    #111733;
  --bg-3:    #1a2247;

  /* Surfaces */
  --surface:        rgba(20, 28, 56, 0.6);
  --surface-solid:  #141c38;
  --surface-hover:  rgba(30, 41, 78, 0.7);
  --border:         rgba(99, 122, 184, 0.18);
  --border-strong:  rgba(99, 122, 184, 0.35);

  /* Text */
  --text:        #eaf0ff;
  --text-muted:  #8aa0c9;
  --text-dim:    #5d6f96;

  /* Brand — marine navy */
  --navy-900: #0c1e4a;
  --navy-800: #0f2b6e;
  --navy-700: #143a8f;
  --navy-600: #1d4ed8;
  --navy-500: #2563eb;
  --navy-400: #3b82f6;
  --navy-300: #60a5fa;
  --navy-200: #93c5fd;

  /* Accents (status) */
  --ok:     #34d399;
  --warn:   #fbbf24;
  --danger: #f87171;

  /* Effects */
  --glow:        0 0 40px rgba(37, 99, 235, 0.25);
  --shadow-sm:   0 2px 8px rgba(0, 0, 0, 0.35);
  --shadow-md:   0 10px 30px -10px rgba(0, 0, 0, 0.6);
  --shadow-lg:   0 25px 50px -12px rgba(0, 0, 0, 0.75);

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;

  --gradient-primary:   linear-gradient(135deg, #0f2b6e 0%, #1d4ed8 50%, #2563eb 100%);
  --gradient-primary-h: linear-gradient(135deg, #143a8f 0%, #2563eb 50%, #3b82f6 100%);
  --gradient-page:      radial-gradient(ellipse at top, rgba(29, 78, 216, 0.15) 0%, transparent 60%),
                        radial-gradient(ellipse at bottom right, rgba(15, 43, 110, 0.20) 0%, transparent 50%),
                        linear-gradient(180deg, var(--bg-base) 0%, var(--bg-1) 100%);
  --gradient-text:      linear-gradient(135deg, #eaf0ff 0%, #93c5fd 100%);
  --gradient-card:      linear-gradient(135deg, rgba(20, 28, 56, 0.7) 0%, rgba(15, 23, 51, 0.5) 100%);
}

* { box-sizing: border-box; }

*::selection {
  background: var(--navy-600);
  color: white;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  background: var(--gradient-page);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
}

code, .mono {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.9em;
}

/* ----- Layout ----- */

.container {
  max-width: 560px;
  margin: 0 auto;
  padding: 32px 20px 56px;
}

.container--wide {
  max-width: 1400px;
}

.container--scan {
  max-width: 1100px;
}

/* ----- Header ----- */

.app-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 36px;
  animation: fadeInDown 0.6s ease both;
}

.app-logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--gradient-primary);
  box-shadow: var(--shadow-md), 0 0 30px rgba(37, 99, 235, 0.4);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

.app-logo::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.18) 0%, transparent 60%);
  pointer-events: none;
}

.app-logo svg {
  width: 24px;
  height: 24px;
  color: white;
  filter: drop-shadow(0 0 6px rgba(147, 197, 253, 0.6));
  position: relative;
  z-index: 1;
}

.app-title {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  background: var(--gradient-text);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.app-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 500;
  margin-top: 2px;
}

/* ----- Typography ----- */

h1 {
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
  background: var(--gradient-text);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: fadeInUp 0.5s ease 0.1s both;
}

h2 {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--navy-300);
  margin: 32px 0 14px;
}

.subtitle {
  color: var(--text-muted);
  margin: 0 0 28px;
  font-size: 0.95rem;
  animation: fadeInUp 0.5s ease 0.15s both;
}

.muted   { color: var(--text-muted); font-size: 0.85rem; }
.dim     { color: var(--text-dim); }

/* ----- Card ----- */

.card {
  background: var(--gradient-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-bottom: 18px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow-md);
  position: relative;
  animation: fadeInUp 0.6s ease 0.2s both;
}

.card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius-lg);
  padding: 1px;
  background: linear-gradient(135deg, rgba(96, 165, 250, 0.25), transparent 50%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  pointer-events: none;
}

.card--flush {
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
}

/* ----- Form ----- */

.field {
  margin-bottom: 16px;
  position: relative;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field-row-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

@media (max-width: 480px) {
  .field-row-3 { grid-template-columns: 1fr 1fr; }
}

label {
  display: block;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}

input, select, textarea {
  width: 100%;
  padding: 12px 14px;
  background: rgba(5, 8, 22, 0.6);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  transition: all 0.18s ease;
  -webkit-appearance: none;
  appearance: none;
}

input::placeholder { color: var(--text-dim); }

input:hover, select:hover, textarea:hover {
  border-color: var(--border-strong);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--navy-400);
  background: rgba(5, 8, 22, 0.9);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
}

select {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%238aa0c9' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
  cursor: pointer;
}

.field--error input,
.field--error select,
.field--error textarea {
  border-color: var(--danger);
  box-shadow: 0 0 0 4px rgba(248, 113, 113, 0.12);
}

.field--ok input,
.field--ok select {
  border-color: rgba(52, 211, 153, 0.4);
}

.field-error {
  display: none;
  font-size: 0.78rem;
  color: var(--danger);
  margin-top: 6px;
  padding-left: 2px;
}

.field--error .field-error { display: block; }

.field-help {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-top: 6px;
  padding-left: 2px;
}

/* Checkbox custom */
.checkbox {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 20px 0;
  cursor: pointer;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(5, 8, 22, 0.4);
  transition: all 0.18s ease;
}

.checkbox:hover {
  border-color: var(--border-strong);
  background: rgba(5, 8, 22, 0.6);
}

.checkbox input {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin-top: 1px;
  accent-color: var(--navy-500);
  cursor: pointer;
}

.checkbox-text {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ----- Buttons ----- */

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 22px;
  background: var(--gradient-primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  letter-spacing: 0.01em;
  cursor: pointer;
  text-decoration: none;
  width: 100%;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.25),
              inset 0 1px 0 rgba(255, 255, 255, 0.15);
  transition: all 0.18s ease;
}

button::after, .btn::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.18), transparent);
  transition: left 0.6s ease;
  pointer-events: none;
}

button:hover:not(:disabled), .btn:hover {
  background: var(--gradient-primary-h);
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.4),
              inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

button:hover:not(:disabled)::after, .btn:hover::after {
  left: 100%;
}

button:active:not(:disabled), .btn:active {
  transform: translateY(0);
}

button:disabled {
  background: rgba(40, 50, 80, 0.6);
  color: var(--text-dim);
  cursor: not-allowed;
  box-shadow: none;
}

.btn-secondary {
  background: transparent;
  color: var(--navy-300);
  border: 1px solid var(--border-strong);
  box-shadow: none;
}

.btn-secondary:hover {
  background: rgba(37, 99, 235, 0.08);
  border-color: var(--navy-400);
  color: var(--navy-200);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.15);
}

.btn-small {
  width: auto;
  padding: 8px 14px;
  font-size: 0.82rem;
}

.btn-icon {
  width: auto;
  padding: 10px 12px;
}

/* ----- Alerts ----- */

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 0.88rem;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  animation: fadeIn 0.3s ease;
}

.alert-warn {
  background: rgba(251, 191, 36, 0.08);
  border: 1px solid rgba(251, 191, 36, 0.3);
  color: #fde68a;
}

.alert-danger {
  background: rgba(248, 113, 113, 0.08);
  border: 1px solid rgba(248, 113, 113, 0.3);
  color: #fecaca;
}

.alert-info {
  background: rgba(96, 165, 250, 0.08);
  border: 1px solid rgba(96, 165, 250, 0.3);
  color: var(--navy-200);
}

.alert-ok {
  background: rgba(52, 211, 153, 0.08);
  border: 1px solid rgba(52, 211, 153, 0.3);
  color: #a7f3d0;
}

.hidden { display: none !important; }

/* ----- Scan widget ----- */

#vital-face-widget {
  background: var(--bg-2);
  border-radius: var(--radius-md);
  width: 100%;
  height: 85vh;
  min-height: 640px;
}

#vital-face-widget iframe {
  width: 100% !important;
  height: 100% !important;
  border: 0;
  display: block;
}

.scan-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: var(--gradient-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
}

.scan-progress-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--navy-400);
  box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.7);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.7); }
  70%  { box-shadow: 0 0 0 14px rgba(59, 130, 246, 0); }
  100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); }
}

/* ----- Metric cards ----- */

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 8px;
}

.metric {
  background: var(--gradient-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  position: relative;
  overflow: hidden;
  transition: all 0.2s ease;
  animation: fadeInUp 0.5s ease both;
}

.metric:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.metric::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--gradient-primary);
  opacity: 0.7;
}

.metric-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
}

.metric-value {
  font-size: 1.65rem;
  font-weight: 700;
  margin-top: 4px;
  color: var(--text);
  letter-spacing: -0.02em;
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.metric-unit {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ----- Admin table ----- */

.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
  flex-wrap: wrap;
  align-items: center;
}

.toolbar .grow { flex: 1; }

.table-wrap {
  background: var(--gradient-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.table-scroll {
  overflow-x: auto;
  max-height: 70vh;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

th, td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th {
  background: rgba(5, 8, 22, 0.85);
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.72rem;
  position: sticky;
  top: 0;
  z-index: 1;
  border-bottom: 1px solid var(--border-strong);
}

tbody tr {
  transition: background 0.15s ease;
}

tbody tr:hover {
  background: rgba(37, 99, 235, 0.05);
}

.pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pill-completed { background: rgba(52, 211, 153, 0.15); color: var(--ok); border: 1px solid rgba(52, 211, 153, 0.3); }
.pill-errored   { background: rgba(248, 113, 113, 0.15); color: var(--danger); border: 1px solid rgba(248, 113, 113, 0.3); }
.pill-draft     { background: rgba(251, 191, 36, 0.15); color: var(--warn); border: 1px solid rgba(251, 191, 36, 0.3); }

/* ----- Dialog ----- */

dialog {
  background: var(--surface-solid);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 0;
  max-width: 520px;
  width: 92%;
  box-shadow: var(--shadow-lg);
  animation: dialogIn 0.25s ease;
}

dialog::backdrop {
  background: rgba(5, 8, 22, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.dialog-inner { padding: 24px 26px; }

@keyframes dialogIn {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ----- Animations ----- */

@keyframes fadeIn   { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeInDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

/* Spinner para botón loading */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ----- Footer / disclaimer ----- */

.footer-note {
  margin-top: 24px;
  padding: 14px 16px;
  background: rgba(5, 8, 22, 0.4);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.footer-note strong {
  color: var(--navy-300);
}

/* Stagger animation for metric grid items */
.metrics-grid .metric:nth-child(1) { animation-delay: 0.05s; }
.metrics-grid .metric:nth-child(2) { animation-delay: 0.10s; }
.metrics-grid .metric:nth-child(3) { animation-delay: 0.15s; }
.metrics-grid .metric:nth-child(4) { animation-delay: 0.20s; }
.metrics-grid .metric:nth-child(5) { animation-delay: 0.25s; }
.metrics-grid .metric:nth-child(6) { animation-delay: 0.30s; }

/* Empty state */
.empty-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 2rem;
  opacity: 0.5;
  margin-bottom: 8px;
}
