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

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  height: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
  color: var(--text-primary);
  background: var(--bg-app);
  min-height: 100%;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

img, svg { display: block; max-width: 100%; }
button { cursor: pointer; font-family: inherit; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }

/* ── Utilidades globales ─────────────────────────────────────────────────────── */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ── Layout de la app ─────────────────────────────────────────────────────────
   Header fijo arriba + nav fijo abajo + contenido scrollable en el medio
   ─────────────────────────────────────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-height);
  background: var(--bg-header);
  color: var(--text-on-primary);
  display: flex;
  align-items: center;
  padding: 0 var(--space-4);
  z-index: 100;
  box-shadow: var(--shadow-md);
}

.app-header__title {
  font-size: var(--font-size-xl);
  font-weight: 700;
  letter-spacing: -0.02em;
  flex: 1;
}

.app-header__actions {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

.app-content {
  flex: 1;
  margin-top: var(--header-height);
  margin-bottom: var(--bottom-nav-height);
  overflow-y: auto;
  padding: var(--space-4);
  max-width: var(--max-content-width);
  width: 100%;
  margin-left: auto;
  margin-right: auto;
}

/* ── Bottom nav ──────────────────────────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bottom-nav-height);
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
  display: flex;
  z-index: 100;
  box-shadow: 0 -2px 10px rgba(0,0,0,.06);
}

.bottom-nav__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-secondary);
  font-size: var(--font-size-xs);
  font-weight: 500;
  transition: color var(--transition-fast);
  border: none;
  background: transparent;
  padding: var(--space-2) 0;
}

.bottom-nav__item.active,
.bottom-nav__item:hover {
  color: var(--color-primary-600);
}

.bottom-nav__item svg {
  width: 20px; height: 20px;
}

/* 6 ítems en mobile: reducir font y padding */
@media (max-width: 400px) {
  .bottom-nav__item {
    font-size: .6rem;
    padding: var(--space-1) 0;
    gap: 2px;
  }
  .bottom-nav__item svg {
    width: 18px; height: 18px;
  }
}

/* ── Componentes base ────────────────────────────────────────────────────────── */

/* Card */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
}

/* Botones */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: 600;
  border: none;
  transition: opacity var(--transition-fast), box-shadow var(--transition-fast);
}
.btn:hover { opacity: .88; }
.btn:active { opacity: .75; }

.btn--primary {
  background: var(--color-primary-600);
  color: #fff;
  box-shadow: 0 2px 8px rgba(13,148,136,.30);
}
.btn--secondary {
  background: var(--color-slate-100);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}
.btn--danger {
  background: var(--color-danger);
  color: #fff;
}
.btn--danger {
  background: #ef4444;
  color: #fff;
  box-shadow: 0 2px 8px rgba(239,68,68,.25);
}
.btn--ghost {
  background: transparent;
  color: var(--color-primary-600);
}
.btn--sm {
  padding: var(--space-2) var(--space-3);
  font-size: var(--font-size-xs);
}
.btn--full { width: 100%; }
.btn:disabled { opacity: .45; pointer-events: none; }

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: 600;
}
.badge--green  { background: #dcfce7; color: #15803d; }
.badge--red    { background: #fee2e2; color: #b91c1c; }
.badge--yellow { background: #fef9c3; color: #a16207; }
.badge--blue   { background: #dbeafe; color: #1d4ed8; }
.badge--slate  { background: var(--color-slate-100); color: var(--text-secondary); }

/* Input */
.input {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  font-family: inherit;
  background: var(--bg-card);
  color: var(--text-primary);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
}
.input:focus {
  border-color: var(--color-primary-500);
  box-shadow: 0 0 0 3px rgba(20,184,166,.15);
}

/* Avatar */
.avatar {
  border-radius: var(--radius-full);
  object-fit: cover;
  background: var(--color-primary-100);
  color: var(--color-primary-700);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
}
.avatar--sm  { width: 32px;  height: 32px;  font-size: var(--font-size-sm); }
.avatar--md  { width: 40px;  height: 40px;  font-size: var(--font-size-base); }
.avatar--lg  { width: 56px;  height: 56px;  font-size: var(--font-size-xl); }

/* Loader */
.spinner {
  width: 24px; height: 24px;
  border: 3px solid var(--border-color);
  border-top-color: var(--color-primary-600);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Toast */
#toast-container {
  position: fixed;
  bottom: calc(var(--bottom-nav-height) + var(--space-4));
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
  max-width: calc(var(--max-content-width) - var(--space-8));
  width: 100%;
}

.toast {
  background: var(--color-slate-800);
  color: #fff;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  box-shadow: var(--shadow-lg);
  animation: toast-in .25s ease;
}
.toast--success { background: var(--color-success); }
.toast--error   { background: var(--color-danger); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Vista vacía */
.empty-state {
  text-align: center;
  padding: var(--space-8) var(--space-4);
  color: var(--text-secondary);
}
.empty-state__icon {
  font-size: 3rem;
  margin-bottom: var(--space-3);
}
.empty-state__title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

/* Divider */
.divider {
  height: 1px;
  background: var(--border-color);
  margin: var(--space-4) 0;
}

/* Pantalla de carga inicial */
#loading-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-app);
  z-index: 999;
  flex-direction: column;
  gap: var(--space-4);
}
#loading-screen h1 {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  color: var(--color-primary-600);
}
