/* =====================================================================
   More Requests - Sistema de diseno
   Parte 1: tokens, base, layout, navegacion
   ===================================================================== */

/* ---------- Tokens -------------------------------------------------- */
:root {
  /* Marca (se sobrescribe con el color de acento configurado) */
  --brand: #4F46E5;
  --brand-rgb: 79, 70, 229;
  --brand-700: #4338CA;
  --brand-800: #3730A3;
  --brand-100: #E0E7FF;
  --brand-50: #EEF2FF;

  /* Semantica */
  --success: #10B981;
  --success-rgb: 16, 185, 129;
  --warning: #F59E0B;
  --warning-rgb: 245, 158, 11;
  --danger: #EF4444;
  --danger-rgb: 239, 68, 68;
  --info: #0EA5E9;
  --info-rgb: 14, 165, 233;
  --purple: #8B5CF6;
  --purple-rgb: 139, 92, 246;

  /* Neutrales - tema claro */
  --bg: #F4F6FB;
  --bg-soft: #EEF1F8;
  --surface: #FFFFFF;
  --surface-2: #F8FAFC;
  --surface-3: #F1F5F9;
  --border: #E4E8F0;
  --border-strong: #CBD5E1;
  --text: #0F172A;
  --text-soft: #334155;
  --text-muted: #64748B;
  --text-faint: #94A3B8;

  /* Sidebar */
  --sidebar-bg: #101835;
  --sidebar-bg-2: #0B1229;
  --sidebar-text: #B6C2DE;
  --sidebar-text-strong: #FFFFFF;
  --sidebar-hover: rgba(255, 255, 255, 0.07);
  --sidebar-active: rgba(var(--brand-rgb), 0.9);

  /* Sombras */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08), 0 2px 4px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12), 0 4px 8px rgba(15, 23, 42, 0.05);
  --shadow-xl: 0 24px 60px rgba(15, 23, 42, 0.18);

  /* Radios */
  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 18px;
  --r-full: 999px;

  /* Espaciado */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;

  /* Layout */
  --sidebar-w: 268px;
  --topbar-h: 68px;

  /* Tipografia */
  --font-sans: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;

  --transition: 180ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 320ms cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --bg: #070B18;
  --bg-soft: #0B1224;
  --surface: #101830;
  --surface-2: #131C38;
  --surface-3: #1A2444;
  --border: #22304F;
  --border-strong: #33456B;
  --text: #E8EDF8;
  --text-soft: #C7D2E5;
  --text-muted: #93A1BC;
  --text-faint: #64748B;

  --sidebar-bg: #0A1023;
  --sidebar-bg-2: #070B18;
  --sidebar-text: #93A1BC;
  --sidebar-text-strong: #FFFFFF;
  --sidebar-hover: rgba(255, 255, 255, 0.06);

  --brand-100: #312E81;
  --brand-50: #1E1B4B;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.45);
  --shadow-md: 0 6px 16px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.55);
  --shadow-xl: 0 28px 64px rgba(0, 0, 0, 0.6);

  color-scheme: dark;
}

/* ---------- Reset --------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}

h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 650; letter-spacing: -0.015em; color: var(--text); }
h1 { font-size: 25px; }
h2 { font-size: 20px; }
h3 { font-size: 17px; }
h4 { font-size: 15px; }
p { margin: 0 0 12px; }
p:last-child { margin-bottom: 0; }
a { color: var(--brand); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--brand-700); }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
ul, ol { margin: 0; padding: 0; list-style: none; }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--sp-6) 0; }
code, pre, kbd { font-family: var(--font-mono); font-size: 0.86em; }
::selection { background: rgba(var(--brand-rgb), 0.22); }

:focus-visible {
  outline: 2px solid rgba(var(--brand-rgb), 0.65);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

/* Scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--r-full); border: 3px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ---------- Layout -------------------------------------------------- */
.mr-app { display: flex; min-height: 100vh; }

.mr-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: linear-gradient(185deg, var(--sidebar-bg) 0%, var(--sidebar-bg-2) 100%);
  display: flex;
  flex-direction: column;
  z-index: 60;
  transition: transform var(--transition-slow);
  border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.mr-sidebar__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.mr-logo {
  width: 40px; height: 40px; flex: none;
  border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(140deg, var(--brand) 0%, #7C3AED 100%);
  box-shadow: 0 6px 18px rgba(var(--brand-rgb), 0.45);
  color: #fff;
}

.mr-sidebar__brand-text { min-width: 0; }
.mr-sidebar__brand-name {
  display: block; color: #fff; font-weight: 700; font-size: 15px;
  letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mr-sidebar__brand-tag {
  display: block; color: var(--sidebar-text); font-size: 11.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.mr-sidebar__nav { flex: 1; overflow-y: auto; padding: 14px 12px 20px; }
.mr-sidebar__nav::-webkit-scrollbar { width: 6px; }
.mr-sidebar__nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.14); border: none; }

.mr-nav-group { margin-bottom: 18px; }
.mr-nav-group__title {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  color: rgba(255, 255, 255, 0.34); padding: 0 12px 8px;
}

.mr-nav-link {
  display: flex; align-items: center; gap: 11px;
  padding: 9.5px 12px; border-radius: var(--r-md);
  color: var(--sidebar-text); font-size: 13.8px; font-weight: 500;
  transition: background var(--transition), color var(--transition);
  position: relative; margin-bottom: 2px;
}
.mr-nav-link:hover { background: var(--sidebar-hover); color: var(--sidebar-text-strong); }
.mr-nav-link.is-active {
  background: linear-gradient(90deg, rgba(var(--brand-rgb), 0.95) 0%, rgba(var(--brand-rgb), 0.72) 100%);
  color: #fff; font-weight: 600;
  box-shadow: 0 6px 16px rgba(var(--brand-rgb), 0.35);
}
.mr-nav-link.is-active .mr-icon { opacity: 1; }
.mr-nav-link .mr-icon { flex: none; opacity: 0.82; }
.mr-nav-link__text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mr-nav-link__badge {
  flex: none; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: var(--r-full); background: rgba(255, 255, 255, 0.16);
  color: #fff; font-size: 11px; font-weight: 700;
  display: grid; place-items: center;
}
.mr-nav-link.is-active .mr-nav-link__badge { background: rgba(255, 255, 255, 0.28); }

.mr-sidebar__footer { padding: 14px; border-top: 1px solid rgba(255, 255, 255, 0.06); }

.mr-user-card {
  display: flex; align-items: center; gap: 11px;
  padding: 10px; border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.05);
  transition: background var(--transition);
}
.mr-user-card:hover { background: rgba(255, 255, 255, 0.09); }
.mr-user-card__meta { min-width: 0; flex: 1; }
.mr-user-card__name {
  display: block; color: #fff; font-size: 13.2px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mr-user-card__role {
  display: block; color: var(--sidebar-text); font-size: 11.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.mr-main {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
}

.mr-topbar {
  position: sticky; top: 0; z-index: 50;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: var(--sp-4);
  padding: 0 var(--sp-6);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
[data-theme="dark"] .mr-topbar { background: rgba(16, 24, 48, 0.85); }

.mr-topbar__title { min-width: 0; flex: 1; }
.mr-topbar__title h1 {
  font-size: 19px; line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mr-breadcrumb {
  display: flex; align-items: center; gap: 6px;
  font-size: 12.2px; color: var(--text-muted); margin-top: 2px;
}
.mr-breadcrumb a { color: var(--text-muted); }
.mr-breadcrumb a:hover { color: var(--brand); }
.mr-breadcrumb span.sep { opacity: 0.5; }

.mr-topbar__actions { display: flex; align-items: center; gap: var(--sp-2); flex: none; }

.mr-content { padding: var(--sp-6); flex: 1; }
.mr-content--narrow { max-width: 920px; margin: 0 auto; width: 100%; }

.mr-icon-btn {
  width: 40px; height: 40px; flex: none;
  display: grid; place-items: center;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  background: transparent; color: var(--text-muted);
  cursor: pointer; position: relative;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.mr-icon-btn:hover { background: var(--surface-3); color: var(--text); }
.mr-icon-btn--bordered { border-color: var(--border); background: var(--surface); }
.mr-icon-btn__dot {
  position: absolute; top: 8px; right: 8px;
  min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: var(--r-full); background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 700; line-height: 17px; text-align: center;
  border: 2px solid var(--surface);
}

.mr-sidebar-toggle { display: none; }

.mr-sidebar-backdrop {
  position: fixed; inset: 0; z-index: 55;
  background: rgba(8, 12, 24, 0.55);
  backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none;
  transition: opacity var(--transition);
}
.mr-sidebar-backdrop.is-visible { opacity: 1; pointer-events: auto; }

/* ---------- Page header -------------------------------------------- */
.mr-page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--sp-4); margin-bottom: var(--sp-5); flex-wrap: wrap;
}
.mr-page-head__text { min-width: 0; }
.mr-page-head h1 { font-size: 23px; }
.mr-page-head p { color: var(--text-muted); font-size: 13.5px; margin: 4px 0 0; }
.mr-page-head__actions { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }

/* ---------- Grid ---------------------------------------------------- */
.mr-grid { display: grid; gap: var(--sp-5); }
.mr-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.mr-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.mr-grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.mr-grid--sidebar { grid-template-columns: minmax(0, 1fr) 360px; }
.mr-grid--sidebar-left { grid-template-columns: 340px minmax(0, 1fr); }

.mr-stack { display: flex; flex-direction: column; gap: var(--sp-5); }
.mr-stack--sm { gap: var(--sp-3); }
.mr-row { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.mr-row--between { justify-content: space-between; }
.mr-row--end { justify-content: flex-end; }
.mr-spacer { flex: 1; }

/* ---------- Avatares ------------------------------------------------ */
.mr-avatar {
  width: 38px; height: 38px; flex: none;
  border-radius: var(--r-full);
  display: grid; place-items: center;
  background: linear-gradient(140deg, rgba(var(--brand-rgb), 0.9), rgba(124, 58, 237, 0.9));
  color: #fff; font-weight: 700; font-size: 13px; letter-spacing: 0.02em;
  overflow: hidden; text-transform: uppercase;
}
.mr-avatar img { width: 100%; height: 100%; object-fit: cover; }
.mr-avatar--sm { width: 30px; height: 30px; font-size: 11.5px; }
.mr-avatar--lg { width: 56px; height: 56px; font-size: 18px; border-radius: var(--r-lg); }
.mr-avatar--xl { width: 84px; height: 84px; font-size: 26px; border-radius: var(--r-xl); }

.mr-avatar-stack { display: flex; }
.mr-avatar-stack .mr-avatar { margin-left: -10px; border: 2px solid var(--surface); }
.mr-avatar-stack .mr-avatar:first-child { margin-left: 0; }

/* ---------- Auth ---------------------------------------------------- */
.auth-page {
  background:
    radial-gradient(1100px 620px at 12% -5%, rgba(var(--brand-rgb), 0.28), transparent 62%),
    radial-gradient(900px 560px at 100% 100%, rgba(14, 165, 233, 0.22), transparent 58%),
    linear-gradient(160deg, #0B1229 0%, #131C3C 55%, #0B1229 100%);
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--sp-6);
}

.auth-shell {
  width: 100%; max-width: 1040px;
  display: grid; grid-template-columns: 1.05fr 0.95fr;
  background: var(--surface);
  border-radius: 24px;
  overflow: hidden;
  box-shadow: var(--shadow-xl);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.auth-aside {
  padding: 46px 42px;
  background: linear-gradient(165deg, #131C3C 0%, #0B1229 100%);
  color: #fff;
  display: flex; flex-direction: column; gap: 26px;
  position: relative; overflow: hidden;
}
.auth-aside::after {
  content: ""; position: absolute; width: 340px; height: 340px;
  right: -140px; bottom: -150px; border-radius: 50%;
  background: radial-gradient(circle, rgba(var(--brand-rgb), 0.55), transparent 68%);
}
.auth-aside__brand { display: flex; align-items: center; gap: 13px; position: relative; z-index: 1; }
.auth-aside h2 { color: #fff; font-size: 26px; line-height: 1.25; position: relative; z-index: 1; }
.auth-aside p { color: #A9B6D4; font-size: 14px; position: relative; z-index: 1; }
.auth-features { display: flex; flex-direction: column; gap: 15px; position: relative; z-index: 1; margin-top: auto; }
.auth-feature { display: flex; gap: 12px; align-items: flex-start; }
.auth-feature__icon {
  width: 34px; height: 34px; flex: none; border-radius: 10px;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, 0.1); color: #fff;
}
.auth-feature strong { display: block; color: #fff; font-size: 13.6px; font-weight: 600; }
.auth-feature span { color: #98A6C6; font-size: 12.6px; }

.auth-form { padding: 46px 42px; display: flex; flex-direction: column; justify-content: center; }
.auth-form__head { margin-bottom: 26px; }
.auth-form__head h1 { font-size: 24px; }
.auth-form__head p { color: var(--text-muted); font-size: 13.6px; margin-top: 6px; }
.auth-footer { margin-top: 26px; font-size: 12.4px; color: var(--text-faint); text-align: center; }

/* ---------- Responsive --------------------------------------------- */
@media (max-width: 1280px) {
  .mr-grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mr-grid--sidebar, .mr-grid--sidebar-left { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 1024px) {
  .mr-grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  :root { --sidebar-w: 250px; }
}

@media (max-width: 900px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-aside { display: none; }

  .mr-sidebar { transform: translateX(-100%); box-shadow: var(--shadow-xl); }
  .mr-sidebar.is-open { transform: translateX(0); }
  .mr-main { margin-left: 0; }
  .mr-sidebar-toggle { display: grid; }
  .mr-content { padding: var(--sp-4); }
  .mr-topbar { padding: 0 var(--sp-4); }
  .mr-grid--2, .mr-grid--3, .mr-grid--4 { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 560px) {
  .mr-topbar__title h1 { font-size: 16.5px; }
  .mr-breadcrumb { display: none; }
  .mr-page-head h1 { font-size: 20px; }
  .auth-form { padding: 32px 22px; }
  :root { --topbar-h: 60px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
