/* ============================================================
   main.css — Variables, reset, layout base
   TrackiFy — Fase 2 Frontend
   ============================================================ */

/* ── Google Fonts ── */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600;700&family=DM+Mono:wght@400;500&display=swap');

/* ── Variables CSS ── */
:root {
  /* Paleta base */
  --bg-primary:    #0f172a;
  --bg-secondary:  #1e293b;
  --bg-tertiary:   #334155;
  --bg-card:       #1e293b;
  --bg-hover:      #2d3f55;

  /* Acentos */
  --accent-blue:   #3b82f6;
  --accent-blue-hover: #2563eb;
  --accent-green:  #22c55e;
  --accent-yellow: #f59e0b;
  --accent-red:    #ef4444;
  --accent-purple: #a855f7;

  /* Texto */
  --text-primary:  #f1f5f9;
  --text-secondary:#94a3b8;
  --text-muted:    #64748b;
  --text-inverse:  #0f172a;

  /* Bordes */
  --border:        #334155;
  --border-light:  #475569;

  /* Sombras */
  --shadow-sm:   0 1px 3px rgba(0,0,0,.4);
  --shadow-md:   0 4px 12px rgba(0,0,0,.5);
  --shadow-lg:   0 10px 30px rgba(0,0,0,.6);

  /* Sidebar */
  --sidebar-width: 240px;
  --sidebar-collapsed: 64px;

  /* Espaciado */
  --space-xs:  4px;
  --space-sm:  8px;
  --space-md:  16px;
  --space-lg:  24px;
  --space-xl:  32px;
  --space-2xl: 48px;

  /* Radio */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  /* Tipografía */
  --font-sans: 'DM Sans', sans-serif;
  --font-mono: 'DM Mono', monospace;

  /* Transiciones */
  --transition: 150ms ease;
  --transition-md: 250ms ease;
}

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

html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
}

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

/* ── Scrollbar personalizada ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--bg-tertiary); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ── Layout base: sidebar + contenido ── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  transition: width var(--transition-md);
}

/* Área de contenido */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition-md);
}

/* Topbar */
.topbar {
  height: 56px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-lg);
  position: sticky;
  top: 0;
  z-index: 50;
}

/* Área de contenido de página */
.page-content {
  flex: 1;
  padding: var(--space-xl);
}

/* ── Sidebar: logo ── */
.sidebar-logo {
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 var(--space-md);
  border-bottom: 1px solid var(--border);
  gap: var(--space-sm);
}

.sidebar-logo .logo-icon {
  width: 32px;
  height: 32px;
  background: var(--accent-blue);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.sidebar-logo .logo-text {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
}

.logo-text span {
  color: var(--accent-blue);
}

/* ── Sidebar: navegación ── */
.sidebar-nav {
  flex: 1;
  padding: var(--space-md) var(--space-sm);
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  padding: var(--space-md) var(--space-sm) var(--space-xs);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-sm);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: rgba(59, 130, 246, .15);
  color: var(--accent-blue);
}

.nav-item .nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: .7;
}

.nav-item.active .nav-icon { opacity: 1; }

/* ── Sidebar: usuario ── */
.sidebar-user {
  padding: var(--space-md);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.sidebar-user .user-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--accent-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}

.sidebar-user .user-info {
  overflow: hidden;
  flex: 1;
}

.sidebar-user .user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user .user-role {
  font-size: 11px;
  color: var(--text-muted);
}

.btn-logout {
  color: var(--text-muted);
  padding: var(--space-xs);
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
  flex-shrink: 0;
}
.btn-logout:hover { color: var(--accent-red); background: rgba(239,68,68,.1); }

/* ── Topbar contenido ── */
.topbar-title {
  font-size: 16px;
  font-weight: 600;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

/* ── Utilidades de texto ── */
.text-primary   { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted     { color: var(--text-muted); }
.text-blue      { color: var(--accent-blue); }
.text-green     { color: var(--accent-green); }
.text-yellow    { color: var(--accent-yellow); }
.text-red       { color: var(--accent-red); }

.font-mono { font-family: var(--font-mono); }

/* ── Loading spinner ── */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--bg-tertiary);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}

.spinner-lg {
  width: 40px;
  height: 40px;
  border-width: 3px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Estado vacío ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl);
  gap: var(--space-md);
  text-align: center;
}

.empty-state .empty-icon {
  font-size: 48px;
  opacity: .3;
}

.empty-state h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
}

.empty-state p {
  font-size: 13px;
  color: var(--text-muted);
}

/* ── Estado de error ── */
.error-banner {
  background: rgba(239,68,68,.1);
  border: 1px solid rgba(239,68,68,.3);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  color: var(--accent-red);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

/* ── Sidebar v2: animaciones y hover ───────────────────────── */

.sidebar {
  transition: width 0.3s cubic-bezier(.4,0,.2,1);
}

.sidebar-logo .logo-icon {
  background: linear-gradient(135deg, var(--accent-blue), #6366f1);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  transition: transform 0.3s cubic-bezier(.34,1.56,.64,1);
}
.sidebar-logo:hover .logo-icon {
  transform: rotate(-8deg) scale(1.12);
}

.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 16px 12px 4px;
  opacity: 0.6;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  margin: 1px 4px;
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  transition:
    background 0.18s ease,
    color 0.18s ease,
    transform 0.18s cubic-bezier(.34,1.56,.64,1),
    box-shadow 0.18s ease;
  overflow: hidden;
}

/* Ripple de fondo al hover */
.nav-item::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--accent-blue);
  opacity: 0;
  border-radius: 10px;
  transform: scaleX(0.6);
  transform-origin: left;
  transition:
    opacity 0.2s ease,
    transform 0.25s cubic-bezier(.4,0,.2,1);
}
.nav-item:hover::before {
  opacity: 0.08;
  transform: scaleX(1);
}

/* Barra indicadora izquierda */
.nav-indicator {
  position: absolute;
  left: 0;
  top: 20%;
  height: 60%;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent-blue);
  opacity: 0;
  transform: scaleY(0);
  transition:
    opacity 0.2s ease,
    transform 0.25s cubic-bezier(.34,1.56,.64,1);
}

.nav-item:hover {
  color: var(--text-primary);
  transform: translateX(3px);
}

.nav-item:hover .nav-icon {
  transform: scale(1.18) rotate(-4deg);
  color: var(--accent-blue);
}

.nav-item:hover .nav-indicator {
  opacity: 0.5;
  transform: scaleY(1);
}

.nav-item.active {
  background: rgba(59,130,246,.13);
  color: var(--accent-blue);
  font-weight: 600;
}

.nav-item.active .nav-indicator {
  opacity: 1;
  transform: scaleY(1);
}

.nav-item.active .nav-icon {
  color: var(--accent-blue);
  opacity: 1;
}

/* Click bounce */
.nav-item:active {
  transform: translateX(3px) scale(0.97);
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.7;
  transition:
    transform 0.25s cubic-bezier(.34,1.56,.64,1),
    color 0.18s ease,
    opacity 0.18s ease;
}
.nav-icon svg {
  width: 18px;
  height: 18px;
}

.nav-label {
  transition: transform 0.18s ease;
}
.nav-item:hover .nav-label {
  transform: translateX(1px);
}

/* Avatar usuario con pulso al hover */
.user-avatar {
  transition: transform 0.25s cubic-bezier(.34,1.56,.64,1), box-shadow 0.2s ease;
}
.sidebar-user:hover .user-avatar {
  transform: scale(1.1);
  box-shadow: 0 0 0 3px rgba(59,130,246,.25);
}

.btn-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 6px;
  transition: color 0.18s ease, background 0.18s ease, transform 0.2s cubic-bezier(.34,1.56,.64,1);
}
.btn-logout:hover {
  color: var(--accent-red);
  background: rgba(239,68,68,.1);
  transform: scale(1.15) rotate(8deg);
}
