/* =====================================================================
   MarcOS — Design System
   Sistema operativo personal de Marcos Castellano
   ---------------------------------------------------------------------
   Un único archivo con: tokens de color (claro/oscuro), tipografía,
   marca, y todos los componentes base (login, dashboard, sidebar).
   ===================================================================== */

/* ---- Fuente de marca (técnica/geométrica) ---- */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Inter:wght@400;450;500;600&display=swap');

/* =====================================================================
   1. TOKENS — Tema CLARO (por defecto)
   ===================================================================== */
:root {
  /* Neutros */
  --bg:          #f4f4f8;
  --bg-2:        #ececf2;
  --surface:     #ffffff;
  --surface-2:   #f7f7fb;
  --border:      #e3e3ec;
  --border-2:    #d3d3df;

  /* Texto */
  --text:        #17171f;
  --text-2:      #4b4b57;
  --muted:       #8a8a99;

  /* Acento — índigo/violeta eléctrico (identidad MarcOS) */
  --accent:      #6d5ef0;
  --accent-600:  #5b4de0;
  --accent-700:  #4a3fc4;
  --accent-soft: rgba(109, 94, 240, 0.10);
  --accent-glow: rgba(109, 94, 240, 0.28);
  --on-accent:   #ffffff;

  /* Acento secundario para degradados de marca */
  --accent-2:    #8b7cff;

  /* Estados */
  --success:     #21a67a;
  --danger:      #e5484d;
  --warning:     #e0a11b;

  /* Formas y sombras */
  --radius-sm:   8px;
  --radius:      14px;
  --radius-lg:   20px;
  --shadow-sm:   0 1px 2px rgba(23,23,31,0.06);
  --shadow:      0 8px 30px rgba(23,23,31,0.08);
  --shadow-lg:   0 20px 60px rgba(23,23,31,0.12);

  /* Tipografía */
  --font-brand:  'Space Grotesk', ui-sans-serif, system-ui, sans-serif;
  --font-body:   'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;

  color-scheme: light;
}

/* =====================================================================
   2. TOKENS — Tema OSCURO
   ===================================================================== */
:root[data-theme="dark"] {
  --bg:          #0c0c11;
  --bg-2:        #101017;
  --surface:     #16161f;
  --surface-2:   #1c1c27;
  --border:      #262633;
  --border-2:    #32323f;

  --text:        #e9e9f1;
  --text-2:      #b3b3c2;
  --muted:       #7c7c8c;

  --accent:      #7c6df6;
  --accent-600:  #6d5ef0;
  --accent-700:  #5b4de0;
  --accent-soft: rgba(124, 109, 246, 0.14);
  --accent-glow: rgba(124, 109, 246, 0.38);
  --on-accent:   #ffffff;
  --accent-2:    #a08fff;

  --success:     #3ecf8e;
  --danger:      #f06a6f;
  --warning:     #f0bf4a;

  --shadow-sm:   0 1px 2px rgba(0,0,0,0.4);
  --shadow:      0 8px 30px rgba(0,0,0,0.45);
  --shadow-lg:   0 24px 70px rgba(0,0,0,0.6);

  color-scheme: dark;
}

/* Respeta preferencia del sistema si el usuario no ha elegido tema */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:#0c0c11; --bg-2:#101017; --surface:#16161f; --surface-2:#1c1c27;
    --border:#262633; --border-2:#32323f;
    --text:#e9e9f1; --text-2:#b3b3c2; --muted:#7c7c8c;
    --accent:#7c6df6; --accent-600:#6d5ef0; --accent-700:#5b4de0;
    --accent-soft:rgba(124,109,246,0.14); --accent-glow:rgba(124,109,246,0.38);
    --accent-2:#a08fff;
    --success:#3ecf8e; --danger:#f06a6f; --warning:#f0bf4a;
    --shadow-sm:0 1px 2px rgba(0,0,0,0.4);
    --shadow:0 8px 30px rgba(0,0,0,0.45);
    --shadow-lg:0 24px 70px rgba(0,0,0,0.6);
    color-scheme: dark;
  }
}

/* =====================================================================
   3. RESET / BASE
   ===================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color .25s ease, color .25s ease;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-600); }
button { font-family: inherit; }
::selection { background: var(--accent-glow); color: var(--text); }

/* =====================================================================
   4. MARCA — Wordmark "MarcOS"
   ===================================================================== */
.brand {
  font-family: var(--font-brand);
  font-weight: 700;
  letter-spacing: -0.03em;
  display: inline-flex;
  align-items: center;
  gap: .1em;
  line-height: 1;
  user-select: none;
}
.brand__mark { color: var(--text); }
.brand__os {
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand__dot {
  width: .34em; height: .34em; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
  margin-left: .18em;
  align-self: flex-end;
  margin-bottom: .12em;
}
.brand--lg { font-size: 30px; }
.brand--md { font-size: 21px; }

/* =====================================================================
   5. LOGIN — centrado-centrado
   ===================================================================== */
.auth {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
}
/* Halo de fondo sutil de marca */
.auth::before {
  content: "";
  position: absolute;
  width: 620px; height: 620px;
  top: -180px; right: -160px;
  background: radial-gradient(circle, var(--accent-glow), transparent 62%);
  filter: blur(20px);
  opacity: .7;
  pointer-events: none;
}
.auth::after {
  content: "";
  position: absolute;
  width: 520px; height: 520px;
  bottom: -200px; left: -160px;
  background: radial-gradient(circle, var(--accent-soft), transparent 60%);
  pointer-events: none;
}

.auth-card {
  position: relative;
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 38px 34px 30px;
  text-align: center;
}
.auth-card .brand { margin-bottom: 6px; }
.auth-sub {
  color: var(--muted);
  font-size: 13.5px;
  margin: 0 0 26px;
}
.auth-card form { text-align: left; }

/* =====================================================================
   6. FORMULARIOS
   ===================================================================== */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 7px;
  letter-spacing: .01em;
}
.input {
  width: 100%;
  padding: 12px 14px;
  font-size: 14.5px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.input::placeholder { color: var(--muted); }
.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: var(--surface);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 18px;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--on-accent);
  background: linear-gradient(120deg, var(--accent), var(--accent-600));
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: transform .12s ease, box-shadow .18s ease, filter .18s;
  box-shadow: 0 6px 18px var(--accent-glow);
}
.btn:hover { filter: brightness(1.05); box-shadow: 0 8px 24px var(--accent-glow); }
.btn:active { transform: translateY(1px); }
.btn--ghost {
  background: transparent;
  color: var(--text-2);
  box-shadow: none;
  border: 1px solid var(--border);
}
.btn--ghost:hover { background: var(--surface-2); filter: none; color: var(--text); }

.auth-links {
  margin-top: 18px;
  text-align: center;
  font-size: 13px;
}
.auth-links a { color: var(--muted); }
.auth-links a:hover { color: var(--accent); }

/* Mensajes (alerta / éxito) */
.alert {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 18px;
  border: 1px solid transparent;
}
.alert--error   { color: var(--danger);  background: color-mix(in srgb, var(--danger) 12%, transparent);  border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.alert--success { color: var(--success); background: color-mix(in srgb, var(--success) 12%, transparent); border-color: color-mix(in srgb, var(--success) 30%, transparent); }

/* =====================================================================
   7. LAYOUT DASHBOARD
   Topbar NO fija, sin separación visual del resto de la página.
   ===================================================================== */
.app { min-height: 100%; display: flex; flex-direction: column; }

.topbar {
  /* Sin posición fija, sin borde ni sombra: se funde con la página */
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 26px;
  background: transparent;
}

.topbar__right { display: flex; align-items: center; gap: 14px; }

/* Botón de tema */
.icon-btn {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* Menú de usuario */
.user-menu { position: relative; }
.user-trigger {
  display: flex; align-items: center; gap: 10px;
  padding: 5px 10px 5px 5px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: background .15s;
}
.user-trigger:hover { background: var(--surface-2); }
.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--font-brand);
  font-weight: 600;
  font-size: 14px;
  color: var(--on-accent);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  flex: none;
}
.user-name { font-size: 14px; font-weight: 500; }
.user-caret { color: var(--muted); font-size: 11px; }

.dropdown {
  position: absolute;
  right: 0; top: calc(100% + 8px);
  min-width: 210px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  opacity: 0; visibility: hidden;
  transform: translateY(-6px);
  transition: opacity .15s, transform .15s, visibility .15s;
  z-index: 40;
}
.user-menu.open .dropdown { opacity: 1; visibility: visible; transform: translateY(0); }
.dropdown__head { padding: 10px 12px 8px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.dropdown__head .n { font-weight: 600; font-size: 13.5px; }
.dropdown__head .e { color: var(--muted); font-size: 12px; }
.dropdown a, .dropdown button {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border-radius: 9px;
  font-size: 13.5px;
  color: var(--text-2);
  background: transparent; border: none; text-align: left; cursor: pointer;
}
.dropdown a:hover, .dropdown button:hover { background: var(--surface-2); color: var(--text); }
.dropdown .danger { color: var(--danger); }

/* ---- Cuerpo: sidebar + contenido ---- */
.body { flex: 1; display: flex; align-items: stretch; padding: 0 18px 18px; gap: 18px; }

.sidebar {
  width: 236px; flex: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  display: flex; flex-direction: column;
}
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav__label {
  font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted);
  padding: 12px 12px 6px;
}
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px; font-weight: 500;
  color: var(--text-2);
  transition: background .13s, color .13s;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active {
  background: var(--accent-soft);
  color: var(--accent);
}
.nav a .ico { width: 18px; height: 18px; flex: none; opacity: .9; }
.nav a.active .ico { opacity: 1; }

.sidebar__foot { padding-top: 10px; border-top: 1px solid var(--border); margin-top: 8px; }
.logout {
  display: flex; align-items: center; gap: 11px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px; font-weight: 500;
  color: var(--text-2);
  background: transparent; border: none; cursor: pointer; text-align: left;
  transition: background .13s, color .13s;
}
.logout:hover { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }

/* ---- Contenido principal ---- */
.content { flex: 1; min-width: 0; }
.page-head { padding: 6px 4px 20px; }
.page-head h1 { font-family: var(--font-brand); font-size: 26px; font-weight: 600; letter-spacing: -.02em; margin: 0 0 4px; }
.page-head p { color: var(--muted); margin: 0; font-size: 14px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
}
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }

.stat { }
.stat .k { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.stat .v { font-family: var(--font-brand); font-size: 30px; font-weight: 600; letter-spacing: -.02em; margin-top: 6px; }
.stat .d { font-size: 12.5px; color: var(--success); margin-top: 4px; }

.empty {
  text-align: center; padding: 60px 20px; color: var(--muted);
}
.empty .icon { font-size: 34px; margin-bottom: 10px; opacity: .6; }

/* =====================================================================
   8. RESPONSIVE
   ===================================================================== */
@media (max-width: 860px) {
  .body { flex-direction: column; }
  .sidebar { width: auto; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav__label { display: none; }
  .sidebar__foot { margin-top: 4px; }
  .user-name { display: none; }
}

/* Accesibilidad: menos movimiento */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
