/* ============================================================
   CONEXA — Design System v2.0 (Mobile-First)
   ============================================================ */

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

:root {
  /* Colores */
  --bg:           #f5f7fa;
  --surface:      #ffffff;
  --surface2:     #eef1f6;
  --surface3:     #e4e9f2;
  --ink:          #0d1b2a;
  --ink2:         #4a5568;
  --ink3:         #8a97a8;
  --ufv-blue:     #003087;
  --ufv-blue-l:   #1a4fbd;
  --ufv-blue-d:   #001f5c;
  --ufv-red:      #c0392b;
  --gold:         #f59e0b;
  --green:        #10b981;
  --green-l:      #d1fae5;
  --border:       #d8e0eb;
  --border-l:     #eef1f6;
  --radius:       14px;
  --radius-sm:    8px;
  --radius-lg:    20px;
  --shadow:       0 1px 3px rgba(0,0,0,0.08), 0 4px 16px rgba(0,48,135,0.07);
  --shadow-md:    0 4px 24px rgba(0,48,135,0.12);
  --shadow-lg:    0 8px 40px rgba(0,48,135,0.16);

  /* Navegación */
  --nav-h:        60px;
  --bottom-nav-h: 64px;
  --safe-bottom:  env(safe-area-inset-bottom, 0px);
}

/* ════════════════════════════════════════════════════════════
   DARK MODE
════════════════════════════════════════════════════════════ */
body.dark {
  --bg:        #0d1117;
  --surface:   #161b22;
  --surface2:  #1c2230;
  --surface3:  #222a3a;
  --ink:       #e6edf3;
  --ink2:      #8b949e;
  --ink3:      #6e7681;
  --ufv-blue:  #4f8ef7;
  --ufv-blue-l:#6aa3ff;
  --ufv-blue-d:#1a3a7a;
  --ufv-red:   #f87171;
  --green:     #34d399;
  --green-l:   #064e3b;
  --border:    #30363d;
  --border-l:  #21262d;
  --shadow:    0 1px 3px rgba(0,0,0,0.4), 0 4px 16px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 24px rgba(0,0,0,0.5);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.6);
  color-scheme: dark;
}

/* Transición suave al cambiar tema */
body, body * {
  transition: background-color 0.25s ease, border-color 0.25s ease, color 0.2s ease;
}
/* Excepciones: no animar lo que no debe */
body *, body *::before, body *::after {
  transition-property: background-color, border-color, color, box-shadow;
}

/* Ajustes específicos dark mode */
body.dark nav { background: var(--surface); border-bottom: 1px solid var(--border); }
body.dark .nav-stripe { background: var(--border); }
body.dark .sidebar { background: var(--surface); }
body.dark .match-card { background: var(--surface); }
body.dark .msg.theirs { background: var(--surface2); border-color: var(--border); }
body.dark .form-input { background: var(--surface2); border-color: var(--border); color: var(--ink); }
body.dark .form-input:focus { border-color: var(--ufv-blue); background: var(--surface3); }
body.dark .btn-secondary { background: var(--surface2); border-color: var(--border); color: var(--ink); }
body.dark .btn-secondary:hover { background: var(--surface3); }
body.dark .notif-drawer { background: var(--surface); }
body.dark .modal-sheet  { background: var(--surface); }
body.dark .filter-chip  { background: var(--surface2); border-color: var(--border); }
body.dark .filter-chip.active { background: rgba(79,142,247,0.15); border-color: var(--ufv-blue); color: var(--ufv-blue); }
body.dark .home-hero { background: linear-gradient(135deg, #1a3a7a 0%, #1e4fc2 100%); }
body.dark .home-action-btn { background: var(--surface2); border-color: var(--border); }
body.dark .home-action-btn:hover { background: var(--surface3); border-color: var(--ufv-blue); }
body.dark .home-event-card { background: var(--surface2); border-color: var(--border); }
body.dark .home-grupo-card { background: var(--surface2); border-color: var(--border); }
body.dark .home-connection-row { background: var(--surface2); border-color: var(--border); }
body.dark .home-cta-card { background: rgba(79,142,247,0.06); border-color: rgba(79,142,247,0.2); }
body.dark .novedad-card { background: var(--surface2); border-color: var(--border); }
body.dark .grupo-item:hover { background: var(--surface3); }
body.dark .grupo-item.selected { background: rgba(79,142,247,0.08); }
body.dark .event-card { background: var(--surface2); border-color: var(--border); }
body.dark .suggestion-card { background: var(--surface2); border-color: var(--border); }
body.dark input[type="datetime-local"], body.dark input[type="date"] { color-scheme: dark; }


/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', 'Source Sans 3', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

/* ── Scrollbar suave ────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── Navegación top ─────────────────────────────────────────── */
nav {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--nav-h);
  padding: 0 20px;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--ufv-blue);
  z-index: 200;
  box-shadow: 0 1px 0 rgba(255,255,255,0.06), 0 4px 20px rgba(0,0,0,0.2);
}
.nav-stripe {
  position: fixed; top: var(--nav-h); left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--ufv-red) 0%, #e74c3c 100%);
  z-index: 199;
}
.logo {
  font-family: 'Inter', sans-serif;
  font-weight: 900; font-size: 1.4rem;
  color: #fff; text-decoration: none;
  letter-spacing: -0.03em;
}
.logo span { color: var(--gold); }
.nav-user { display: flex; align-items: center; gap: 10px; }
.nav-user-name { color: rgba(255,255,255,0.85); font-size: 0.88rem; font-weight: 500; }
.nav-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.78rem; font-weight: 700;
  border: 2px solid rgba(255,255,255,0.25);
  cursor: pointer; overflow: hidden;
  transition: border-color 0.15s;
}
.nav-avatar img { width: 100%; height: 100%; object-fit: cover; }
.nav-avatar:hover { border-color: rgba(255,255,255,0.6); }
.btn-logout {
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.7);
  border: 1px solid rgba(255,255,255,0.2);
  padding: 5px 12px; border-radius: 6px;
  font-size: 0.8rem; font-weight: 500; cursor: pointer;
  transition: all 0.15s;
}
.btn-logout:hover { background: rgba(255,255,255,0.16); color: #fff; }

/* ── Bottom navigation (móvil) ──────────────────────────────── */
.bottom-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  height: calc(var(--bottom-nav-h) + var(--safe-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 200;
  padding-bottom: var(--safe-bottom);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
}
.bottom-nav-inner {
  height: var(--bottom-nav-h);
  display: flex; align-items: center; justify-content: space-around;
}
.bottom-nav-btn {
  flex: 1; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; cursor: pointer; transition: all 0.15s;
  color: var(--ink3); font-size: 0.62rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
  position: relative;
}
.bottom-nav-btn svg {
  width: 22px; height: 22px;
  stroke: currentColor; stroke-width: 1.8;
  fill: none; stroke-linecap: round; stroke-linejoin: round;
  transition: all 0.15s;
}
.bottom-nav-btn.active { color: var(--ufv-blue); }
.bottom-nav-btn.active svg { stroke: var(--ufv-blue); stroke-width: 2.2; }
.bottom-nav-btn .nav-badge {
  position: absolute; top: 6px; right: calc(50% - 18px);
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--ufv-red); color: #fff;
  font-size: 0.58rem; font-weight: 700;
  display: none; align-items: center; justify-content: center;
  border: 2px solid var(--surface);
}
.bottom-nav-btn .nav-badge.show { display: flex; }

/* ── Botones ────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-family: 'Inter', sans-serif; font-weight: 600;
  font-size: 0.92rem; padding: 11px 22px;
  border-radius: var(--radius-sm); border: none; cursor: pointer;
  transition: all 0.18s; text-decoration: none;
  white-space: nowrap; user-select: none;
}
.btn-primary {
  background: var(--ufv-blue); color: #fff;
  box-shadow: 0 2px 8px rgba(0,48,135,0.28);
}
.btn-primary:hover { background: var(--ufv-blue-l); transform: translateY(-1px); box-shadow: 0 4px 16px rgba(0,48,135,0.35); }
.btn-primary:active { transform: translateY(0); }
.btn-secondary { background: var(--surface); color: var(--ufv-blue); border: 1.5px solid var(--border); }
.btn-secondary:hover { background: var(--surface2); border-color: var(--ufv-blue); }
.btn-ghost { background: transparent; color: var(--ink2); }
.btn-ghost:hover { background: var(--surface2); }
.btn-danger { background: var(--ufv-red); color: #fff; }
.btn-success { background: var(--green); color: #fff; }
.btn-sm { padding: 7px 14px; font-size: 0.82rem; }
.btn-lg { padding: 14px 28px; font-size: 1rem; }
.btn-full { width: 100%; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

/* ── Formularios ────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; position: relative; }
.form-label { display: block; font-weight: 600; font-size: 0.85rem; margin-bottom: 6px; color: var(--ink); }
.form-input {
  width: 100%;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px;
  font-family: 'Inter', sans-serif; font-size: 0.95rem; color: var(--ink);
  outline: none; transition: border-color 0.15s, box-shadow 0.15s;
}
.form-input:focus { border-color: var(--ufv-blue); box-shadow: 0 0 0 3px rgba(0,48,135,0.1); }
.form-input.valid { border-color: var(--green); }
.form-input.invalid { border-color: var(--ufv-red); }
.form-input::placeholder { color: var(--ink3); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-hint { font-size: 0.78rem; color: var(--ink3); margin-top: 5px; }

/* Indicadores de validación inline */
.field-indicator {
  position: absolute; right: 12px; top: 38px;
  font-size: 0.9rem; opacity: 0; transition: opacity 0.2s;
}
.field-indicator.show { opacity: 1; }

.form-error {
  display: none;
  background: #fff5f5; color: var(--ufv-red);
  border: 1px solid #fed7d7; border-radius: var(--radius-sm);
  padding: 10px 14px; font-size: 0.86rem; margin-bottom: 14px;
  animation: fadeUp 0.2s ease both;
}

/* Barra de fuerza de contraseña */
.password-strength {
  display: none; margin-top: 6px; gap: 4px;
}
.password-strength.show { display: flex; }
.ps-bar { flex: 1; height: 3px; border-radius: 2px; background: var(--border); transition: background 0.25s; }
.ps-bar.weak   { background: var(--ufv-red); }
.ps-bar.medium { background: var(--gold); }
.ps-bar.strong { background: var(--green); }
.ps-label { font-size: 0.72rem; color: var(--ink3); margin-top: 3px; font-weight: 600; }

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ── Avatar ─────────────────────────────────────────────────── */
.avatar {
  border-radius: 50%; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-weight: 700;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm  { width: 36px; height: 36px; font-size: 0.78rem; }
.avatar-md  { width: 48px; height: 48px; font-size: 1rem; }
.avatar-lg  { width: 72px; height: 72px; font-size: 1.5rem; }
.avatar-xl  { width: 96px; height: 96px; font-size: 2rem; }

/* ── Chips ──────────────────────────────────────────────────── */
.chips-grid { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  display: inline-flex; align-items: center;
  padding: 6px 14px; border-radius: 100px;
  border: 1.5px solid var(--border);
  background: var(--surface); font-size: 0.82rem; font-weight: 500;
  cursor: pointer; transition: all 0.15s; user-select: none;
}
.chip:hover { border-color: var(--ufv-blue); background: rgba(0,48,135,0.04); }
.chip.selected { background: var(--ufv-blue); color: #fff; border-color: var(--ufv-blue); font-weight: 600; }
.chip.selected:hover { background: var(--ufv-blue-l); }

/* ── Toast / notificaciones ─────────────────────────────────── */
.toast {
  position: fixed; bottom: calc(var(--bottom-nav-h) + 16px + var(--safe-bottom)); left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--ink); color: #fff;
  padding: 11px 20px; border-radius: 10px;
  font-size: 0.86rem; font-weight: 500;
  z-index: 9999; transition: transform 0.3s cubic-bezier(.22,.68,0,1.2);
  pointer-events: none; white-space: nowrap;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  max-width: calc(100vw - 40px); text-align: center;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.error   { background: var(--ufv-red); }
.toast.success { background: var(--green); }

/* ── Progress bar (onboarding) ──────────────────────────────── */
.progress-wrap { margin-bottom: 28px; }
.progress-top  { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.progress-label { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink3); }
.progress-pct   { font-size: 0.72rem; font-weight: 700; color: var(--ufv-blue); }
.progress-bar  { display: flex; gap: 4px; }
.progress-step { flex: 1; height: 4px; border-radius: 2px; background: var(--border); transition: background 0.4s; }
.progress-step.done   { background: var(--ufv-blue); }
.progress-step.active { background: linear-gradient(90deg, var(--ufv-blue), var(--ufv-blue-l)); }

/* ── Animaciones ────────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes popIn {
  from { opacity: 0; transform: scale(0.8); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.6; transform: scale(1.4); }
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes celebrationPop {
  0%   { opacity: 0; transform: scale(0.5) rotate(-10deg); }
  60%  { transform: scale(1.15) rotate(3deg); }
  100% { opacity: 1; transform: scale(1) rotate(0deg); }
}

.fade-up { animation: fadeUp 0.35s ease both; }
.fade-in { animation: fadeIn 0.25s ease both; }
.pop-in  { animation: popIn 0.3s cubic-bezier(.2,1.4,.5,1) both; }

/* ── Spinner ─────────────────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  animation: spin 0.7s linear infinite; display: inline-block;
}
.spinner.dark {
  border-color: rgba(0,48,135,0.2);
  border-top-color: var(--ufv-blue);
}

/* ── Badge ──────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--ufv-red); color: #fff;
  font-size: 0.62rem; font-weight: 700;
  padding: 2px 6px; border-radius: 100px; min-width: 18px;
}

/* ── Loading state ──────────────────────────────────────────── */
.loading-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 12px; padding: 48px 24px;
  color: var(--ink3); text-align: center;
}
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 10px; padding: 48px 24px;
  color: var(--ink3); text-align: center;
}
.empty-state svg { opacity: 0.3; }
.empty-state h3  { font-size: 1.1rem; color: var(--ink2); font-weight: 700; }
.empty-state p   { font-size: 0.86rem; line-height: 1.6; max-width: 260px; }

/* ── FAB (Floating Action Button) ───────────────────────────── */
.fab {
  position: absolute; bottom: 20px; right: 20px;
  width: 54px; height: 54px; border-radius: 50%;
  background: var(--ufv-blue); color: #fff; border: none;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; box-shadow: 0 4px 20px rgba(0,48,135,0.4);
  transition: all 0.2s; z-index: 10;
}
.fab:hover { transform: scale(1.08) rotate(90deg); background: var(--ufv-blue-l); }
.fab:active { transform: scale(0.95); }

/* ── Responsive — Mobile-first breakpoints ──────────────────── */
@media (max-width: 768px) {
  .bottom-nav { display: flex; flex-direction: column; }
  .hide-mobile { display: none !important; }
  nav { padding: 0 16px; }
  .form-row { grid-template-columns: 1fr; }
  .toast { bottom: calc(var(--bottom-nav-h) + 12px + var(--safe-bottom)); }
}

@media (min-width: 769px) {
  .hide-desktop { display: none !important; }
}
