/* ============================================================================
 * base.css — DEMO LIGHT · Cofoundy design system (LIGHT MODE)
 * ----------------------------------------------------------------------------
 * Light-mode conversion of v2 (dark) for traditional Peruvian board readers
 * who consume PDFs and dashboards under fluorescent meeting-room light.
 *
 * Light palette decisions (locked):
 *  - Page bg:     #F7F8FB (warm cool gray, not pure white — eye strain)
 *  - Card bg:     #FFFFFF
 *  - Primary txt: #0F1620 (almost-black, not #000)
 *  - Brand cyan:  #2C7BA8 (deepened from #46A0D0 for AAA contrast on white)
 *  - Brand cyan accent: #46A0D0 still used for fills, sparklines, badges
 *  - Status red:  #DC2626 on #FEF2F2
 *  - Status amber:#D97706 on #FFFBEB
 *  - Status green:#059669 on #F0FDF4
 *  - Tier A:      #7C3AED on #F5F3FF (violet)
 *  - Tier B:      #2C7BA8 on #F0F9FF (brand)
 *  - Tier C:      #475569 on #F1F5F9 (slate)
 * ============================================================================ */

:root {
  /* ============================================================================
   * COLOR — LIGHT mode
   * ============================================================================ */

  /* Surfaces (warm-cool gray stack, never pure white at canvas) */
  --bg-primary:    #F7F8FB;   /* page canvas */
  --bg-secondary:  #FFFFFF;   /* card surface (one step up = paper white) */
  --bg-tertiary:   #F9FAFB;   /* elevated panels, table headers */
  --bg-elevated:   #F3F4F6;   /* hover, inputs, segmented controls */
  --bg-overlay:    rgba(15, 22, 32, 0.45);

  /* Glass surfaces (in light mode = solid white with shadow, no blur magic) */
  --glass-card:        #FFFFFF;
  --glass-card-hover:  #F9FAFB;
  --glass-border:      rgba(15, 22, 32, 0.08);
  --glass-border-soft: rgba(15, 22, 32, 0.04);

  /* Text (warm-dark hierarchy, not black) */
  --text-primary:   #0F1620;   /* almost black */
  --text-secondary: #374151;   /* gray-700 */
  --text-muted:     #6B7280;   /* gray-500 */
  --text-faint:     #9CA3AF;   /* gray-400 */
  --text-inverse:   #FFFFFF;

  /* Borders (warm-dark on light) */
  --border-subtle: rgba(15, 22, 32, 0.06);
  --border-strong: rgba(15, 22, 32, 0.10);
  --border-accent: rgba(15, 22, 32, 0.14);

  /* Brand · primary blue — DIMEXA cyan (alineado con isotipo bicolor) */
  /* Match casi exacto con Cofoundy deepened cyan; serendipia visual. */
  --cofoundy-primary:    #2D8DC4;   /* DIMEXA cyan exact — passes AAA on white */
  --cofoundy-primary-hi: #46A0D0;   /* hover/highlight (Cofoundy original) */
  --cofoundy-primary-lo: #1F627F;   /* DIMEXA dark teal (heading color del sitio) */
  --cofoundy-deep:       #0F3957;
  --cofoundy-midnight:   #020b1b;

  /* DIMEXA brand accents — extraidos del logo + theme CSS oficial */
  --dimexa-blue:        #2D8DC4;   /* arco superior del isotipo */
  --dimexa-blue-light:  #68C8EA;   /* highlight cyan claro */
  --dimexa-blue-deep:   #1F627F;   /* heading color del sitio */
  --dimexa-green:       #82B446;   /* arco inferior del isotipo (lime) */
  --dimexa-green-light: #BDE583;   /* highlight verde */
  --dimexa-green-deep:  #537322;   /* verde oscuro */

  /* Brand · semantic accents */
  --cofoundy-accent:    var(--cofoundy-primary);
  --cofoundy-accent-hi: var(--cofoundy-primary-hi);
  --cofoundy-purple:    #7C3AED;

  /* Tier colors — light-aligned, AAA-readable on white */
  --tier-a: #7C3AED;   /* violet (premium / strategic) */
  --tier-b: #2C7BA8;   /* brand deep blue (medium) */
  --tier-c: #475569;   /* slate (small / standard) */

  /* Status — DEEPENED for white bg readability */
  --status-regular:  #059669;   /* emerald-600 */
  --status-amarillo: #D97706;   /* amber-600 */
  --status-rojo:     #DC2626;   /* red-600 */
  --status-success:  var(--status-regular);
  --status-warning:  var(--status-amarillo);
  --status-error:    var(--status-rojo);
  --status-info:     var(--cofoundy-primary);

  /* Channel colors */
  --channel-whatsapp: #128C3D;   /* WhatsApp green deepened for white bg */
  --channel-email:    #6B7280;

  /* Convenience semantic aliases */
  --color-success: var(--status-regular);
  --color-warning: var(--status-amarillo);
  --color-danger:  var(--status-rojo);
  --color-info:    var(--cofoundy-primary);

  /* ============================================================================
   * TYPOGRAPHY — unchanged from v2
   * ============================================================================ */
  --font-display: 'Space Grotesk', system-ui, -apple-system, sans-serif;
  --font-sans:    'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:    'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;

  --fs-2xs: 11px;
  --fs-xs:  12px;
  --fs-sm:  13px;
  --fs-md:  14px;
  --fs-lg:  16px;
  --fs-xl:  20px;
  --fs-2xl: 26px;
  --fs-3xl: 36px;
  --fs-4xl: 52px;
  --fs-5xl: 72px;

  --fw-normal:   400;
  --fw-medium:   500;
  --fw-semibold: 600;
  --fw-bold:     700;

  --lh-tight:  1.15;
  --lh-snug:   1.3;
  --lh-normal: 1.5;
  --lh-loose:  1.65;

  --tracking-tight:   -0.02em;
  --tracking-tighter: -0.03em;
  --tracking-wide:    0.06em;
  --tracking-wider:   0.12em;

  /* ============================================================================
   * SPACING — unchanged
   * ============================================================================ */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  24px;
  --space-6:  32px;
  --space-7:  40px;
  --space-8:  48px;
  --space-9:  64px;
  --space-10: 80px;
  --space-12: 96px;

  /* ============================================================================
   * RADII — unchanged
   * ============================================================================ */
  --radius-xs:   6px;
  --radius-sm:   8px;
  --radius-md:   12px;
  --radius-lg:   16px;
  --radius-xl:   20px;
  --radius-2xl:  24px;
  --radius-pill: 999px;

  /* ============================================================================
   * SHADOWS — light-mode soft, layered
   * ============================================================================ */
  --shadow-sm:       0 1px 2px rgba(15, 22, 32, 0.06);
  --shadow-card:     0 1px 3px rgba(15, 22, 32, 0.06), 0 1px 2px rgba(15, 22, 32, 0.04);
  --shadow-elevated: 0 8px 24px rgba(15, 22, 32, 0.08), 0 2px 6px rgba(15, 22, 32, 0.04);
  --shadow-modal:    0 20px 60px rgba(15, 22, 32, 0.18), 0 4px 12px rgba(15, 22, 32, 0.08);
  --shadow-glow:     0 0 0 1px rgba(70, 160, 208, 0.32), 0 8px 20px rgba(70, 160, 208, 0.18);

  /* ============================================================================
   * MOTION — unchanged
   * ============================================================================ */
  --ease-default: cubic-bezier(0.19, 1, 0.22, 1);
  --ease-out:     cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring:  cubic-bezier(0.34, 1.3, 0.64, 1);

  --t-fast: 140ms var(--ease-default);
  --t-base: 200ms var(--ease-default);
  --t-slow: 320ms var(--ease-default);

  /* ============================================================================
   * LAYOUT — unchanged
   * ============================================================================ */
  --topbar-h:    64px;
  --sidebar-w:   232px;
  --content-max: 1440px;
  --z-topbar:    50;
  --z-sidebar:   40;
  --z-modal:     200;
  --z-toast:     300;
}

/* ============================================================================
 * Reset
 * ============================================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  line-height: var(--lh-normal);
  color: var(--text-primary);
  background-color: var(--bg-primary);
  /* Subtle warm-cool gradient — barely visible, gives the page presence
     without the dark-mode glow vibe. */
  background-image:
    radial-gradient(ellipse at 0% 0%, rgba(70, 160, 208, 0.05), transparent 55%),
    radial-gradient(ellipse at 100% 100%, rgba(124, 58, 237, 0.04), transparent 55%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv11', 'ss01';
  overflow-x: hidden;
}

a {
  color: var(--cofoundy-primary);
  text-decoration: none;
  transition: color var(--t-fast);
}
a:hover { color: var(--cofoundy-primary-lo); text-decoration: none; }

button { font: inherit; cursor: pointer; }
img, svg { display: block; max-width: 100%; }

/* Scrollbars — light theme */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(15, 22, 32, 0.14);
  border-radius: var(--radius-pill);
  border: 2px solid var(--bg-primary);
}
::-webkit-scrollbar-thumb:hover { background: rgba(15, 22, 32, 0.24); }

::selection { background: rgba(70, 160, 208, 0.22); color: var(--text-primary); }

/* ============================================================================
 * App shell — topbar + sidebar + main
 * ============================================================================ */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas:
    "topbar  topbar"
    "sidebar main";
  min-height: 100vh;
}

/* --- Topbar -------------------------------------------------------------- */
.topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-5);
  padding: 0 var(--space-6);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  border-bottom: 1px solid var(--border-strong);
  z-index: var(--z-topbar);
  position: sticky;
  top: 0;
}

.topbar__brand {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

/* Topbar logo cluster: small Cofoundy mark + DIMEXA isotype dominant */
.topbar__logo-cluster {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}

.topbar__logo-cofoundy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  opacity: 0.95;
}

.topbar__logo-cofoundy img,
.topbar__logo-cofoundy svg {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.topbar__logo-divider {
  color: var(--text-faint);
  font-size: 18px;
  font-weight: 300;
  line-height: 1;
  user-select: none;
  margin: 0 -2px;
}

.topbar__logo-dimexa {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
}

.topbar__logo-dimexa svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Legacy single-logo fallback (kept for compatibility) */
.topbar__logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
}
.topbar__logo svg { width: 100%; height: 100%; display: block; }

.topbar__title {
  color: var(--text-primary);
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}

.topbar__title-brand {
  color: var(--dimexa-blue-deep);
  font-weight: 700;
  letter-spacing: 0.01em;
}

.topbar__title-suffix {
  color: var(--text-muted);
  font-weight: 400;
  margin-left: 4px;
}

.topbar__breadcrumb {
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-weight: 500;
  padding-left: var(--space-4);
  margin-left: var(--space-2);
  border-left: 1px solid var(--border-strong);
}

.topbar__meta {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  font-size: var(--fs-sm);
}

.topbar__date {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-muted);
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.topbar__date::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--status-regular);
  box-shadow: 0 0 6px rgba(5, 150, 105, 0.45);
}

.topbar__user {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  padding-left: var(--space-5);
  border-left: 1px solid var(--border-strong);
}

.topbar__user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cofoundy-primary-hi), var(--cofoundy-primary-lo));
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 11px;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(70, 160, 208, 0.28);
}

.topbar__user-info {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.topbar__user-name {
  color: var(--text-primary);
  font-size: var(--fs-sm);
  font-weight: 600;
}

.topbar__user-role {
  color: var(--text-faint);
  font-size: var(--fs-2xs);
  font-weight: 500;
}

/* --- Sidebar ------------------------------------------------------------- */
.sidebar-nav {
  grid-area: sidebar;
  display: flex;
  flex-direction: column;
  background: #F9FAFB;
  border-right: 1px solid var(--border-strong);
  padding: var(--space-5) var(--space-3);
  gap: 2px;
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  z-index: var(--z-sidebar);
}

.sidebar-nav__section-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  padding: var(--space-2) var(--space-3) var(--space-2);
  margin-top: var(--space-2);
}

.sidebar-nav__section-label:first-child { margin-top: 0; }

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  font-weight: 500;
  text-decoration: none;
  transition: background var(--t-fast), color var(--t-fast);
  position: relative;
}

.sidebar-nav .nav-link__icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: currentColor;
  opacity: 0.7;
}

.sidebar-nav .nav-link:hover {
  background: rgba(15, 22, 32, 0.04);
  color: var(--text-primary);
  text-decoration: none;
}

.sidebar-nav .nav-link:hover .nav-link__icon { opacity: 1; }

.sidebar-nav .nav-link--active {
  background: #EFF6FF;
  color: var(--cofoundy-primary);
  font-weight: 600;
}

.sidebar-nav .nav-link--active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--cofoundy-primary);
}

.sidebar-nav .nav-link--active .nav-link__icon { opacity: 1; color: var(--cofoundy-primary); }

.sidebar-nav .nav-link__badge {
  margin-left: auto;
  background: var(--status-rojo);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  min-width: 18px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 1px 3px rgba(220, 38, 38, 0.32);
}

.sidebar-nav__footer {
  margin-top: auto;
  padding: var(--space-4) var(--space-3) var(--space-2);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-nav__footer small {
  color: var(--text-faint);
  font-size: var(--fs-2xs);
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}

.sidebar-nav__footer small.tag-demo {
  color: var(--cofoundy-primary);
  font-weight: 600;
}

/* --- Main ---------------------------------------------------------------- */
.main-content {
  grid-area: main;
  padding: var(--space-6) var(--space-7) var(--space-8);
  min-width: 0;
  max-width: var(--content-max);
}

.main-content > * + * { margin-top: var(--space-6); }

/* --- Page header --------------------------------------------------------- */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-5);
  padding-bottom: var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
}

.page-header__title {
  font-family: var(--font-display);
  font-size: var(--fs-3xl);
  font-weight: 700;
  color: var(--text-primary);
  line-height: var(--lh-tight);
  letter-spacing: var(--tracking-tight);
  margin-bottom: var(--space-2);
}

.page-header__subtitle {
  color: var(--text-muted);
  font-size: var(--fs-md);
  font-weight: 400;
  max-width: 720px;
  line-height: var(--lh-loose);
}

.page-header__actions {
  display: flex;
  gap: var(--space-2);
  flex-shrink: 0;
}

/* --- Section ------------------------------------------------------------- */
.section {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.section__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.section__title {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: var(--tracking-tight);
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
}

.section__subtitle {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  margin-top: 2px;
}

/* --- Utility primitives -------------------------------------------------- */
.stack { display: flex; flex-direction: column; gap: var(--space-3); }
.stack--sm { gap: var(--space-2); }
.stack--lg { gap: var(--space-5); }

.row { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.row--between { justify-content: space-between; }

.grid { display: grid; gap: var(--space-4); }
.grid--2 { grid-template-columns: repeat(2, 1fr); }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid--4 { grid-template-columns: repeat(4, 1fr); }

.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.mono  {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.text-2xs { font-size: var(--fs-2xs); }
.text-xs  { font-size: var(--fs-xs); }
.text-sm  { font-size: var(--fs-sm); }
.text-lg  { font-size: var(--fs-lg); }
.text-xl  { font-size: var(--fs-xl); }
.text-2xl { font-size: var(--fs-2xl); }

.weight-medium   { font-weight: 500; }
.weight-semibold { font-weight: 600; }
.weight-bold     { font-weight: 700; }

.display { font-family: var(--font-display); letter-spacing: var(--tracking-tight); }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* --- Demo banner --------------------------------------------------------- */
/* Light: brand cyan banner instead of amber — feels less "warning",
   more "informational" which is closer to truth (it is a demo, not a hazard).
   NOT sticky — scrolls away on scroll so the topbar can sit alone at top:0
   without z-index collisions. */
.demo-banner {
  position: relative;
  z-index: 1;
  background: linear-gradient(90deg, rgba(70, 160, 208, 0.14), rgba(70, 160, 208, 0.06));
  border-bottom: 1px solid rgba(70, 160, 208, 0.28);
  color: var(--cofoundy-primary-lo);
  font-size: var(--fs-2xs);
  font-weight: 600;
  text-align: center;
  padding: 6px var(--space-4);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}

.demo-banner::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cofoundy-primary);
  animation: pulse 2.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.5; transform: scale(1); }
  50%      { opacity: 1;   transform: scale(1.2); }
}
