/**
 * HRZ OPS — Design Tokens (Three-layer architecture)
 * Version: 1.0.20260429UX3
 *
 * Layer 1 (Primitive): Raw color/scale values, never used directly in components
 * Layer 2 (Semantic):  Intent-based aliases (bg-primary, text-secondary, status-success-fg)
 * Layer 3 (Component): Component-specific tokens reuse semantic layer
 *
 * Coexistence note: this file ADDS new tokens. Legacy variables in
 * design-system.css (--bg-primary, --text-primary, --emerald, etc) are
 * preserved as-is to avoid breaking existing views.  New components
 * should prefer the namespaced tokens defined here (e.g. --hrz-color-blue-500,
 * --hrz-status-success-bg, --hrz-elev-md).
 */

:root {
  /* ============================================================ */
  /* PRIMITIVE LAYER — raw scale values                            */
  /* ============================================================ */

  /* Slate (neutral) */
  --hrz-color-slate-50:  #f8fafc;
  --hrz-color-slate-100: #f1f5f9;
  --hrz-color-slate-200: #e2e8f0;
  --hrz-color-slate-300: #cbd5e1;
  --hrz-color-slate-400: #94a3b8;
  --hrz-color-slate-500: #64748b;
  --hrz-color-slate-600: #475569;
  --hrz-color-slate-700: #334155;
  --hrz-color-slate-800: #1e293b;
  --hrz-color-slate-900: #0f172a;
  --hrz-color-slate-950: #020617;

  /* Blue (info / brand-primary) */
  --hrz-color-blue-50:  #eff6ff;
  --hrz-color-blue-100: #dbeafe;
  --hrz-color-blue-300: #93c5fd;
  --hrz-color-blue-500: #3b82f6;
  --hrz-color-blue-600: #2563eb;
  --hrz-color-blue-700: #1d4ed8;

  /* Emerald (success) */
  --hrz-color-emerald-50:  #ecfdf5;
  --hrz-color-emerald-100: #d1fae5;
  --hrz-color-emerald-300: #6ee7b7;
  --hrz-color-emerald-500: #10b981;
  --hrz-color-emerald-600: #059669;
  --hrz-color-emerald-700: #047857;

  /* Amber (warning) */
  --hrz-color-amber-50:  #fffbeb;
  --hrz-color-amber-100: #fef3c7;
  --hrz-color-amber-300: #fcd34d;
  --hrz-color-amber-500: #f59e0b;
  --hrz-color-amber-700: #b45309;
  --hrz-color-amber-800: #92400e;

  /* Rose (error / critical) */
  --hrz-color-rose-50:  #fff1f2;
  --hrz-color-rose-100: #ffe4e6;
  --hrz-color-rose-300: #fda4af;
  --hrz-color-rose-500: #ef4444;
  --hrz-color-rose-600: #e11d48;
  --hrz-color-rose-700: #be123c;

  /* Violet (premium / AI) */
  --hrz-color-violet-50:  #f5f3ff;
  --hrz-color-violet-100: #ede9fe;
  --hrz-color-violet-500: #8b5cf6;
  --hrz-color-violet-600: #7c3aed;
  --hrz-color-violet-700: #6d28d9;

  /* ============================================================ */
  /* SEMANTIC LAYER — intent (light defaults; dark overrides below) */
  /* ============================================================ */

  /* Surfaces */
  --hrz-surface-1: #ffffff;                       /* Cards, modals */
  --hrz-surface-2: var(--hrz-color-slate-50);     /* App background */
  --hrz-surface-3: var(--hrz-color-slate-100);    /* Subtle fills */
  --hrz-surface-overlay: rgba(15, 23, 42, 0.5);   /* Modal backdrop */

  /* Text */
  --hrz-text-primary:   var(--hrz-color-slate-900);
  --hrz-text-secondary: var(--hrz-color-slate-600);
  --hrz-text-tertiary:  var(--hrz-color-slate-400);
  --hrz-text-inverse:   #ffffff;
  --hrz-text-link:      var(--hrz-color-blue-600);

  /* Borders */
  --hrz-border-subtle:   var(--hrz-color-slate-200);
  --hrz-border-default:  var(--hrz-color-slate-300);
  --hrz-border-emphasis: var(--hrz-color-slate-400);
  --hrz-border-focus:    var(--hrz-color-blue-500);

  /* Status — backgrounds + foregrounds (4.5:1 contrast pairs) */
  --hrz-status-success-bg: var(--hrz-color-emerald-50);
  --hrz-status-success-fg: var(--hrz-color-emerald-700);
  --hrz-status-success-border: var(--hrz-color-emerald-300);

  --hrz-status-warning-bg: var(--hrz-color-amber-50);
  --hrz-status-warning-fg: var(--hrz-color-amber-800);
  --hrz-status-warning-border: var(--hrz-color-amber-300);

  --hrz-status-error-bg: var(--hrz-color-rose-50);
  --hrz-status-error-fg: var(--hrz-color-rose-700);
  --hrz-status-error-border: var(--hrz-color-rose-300);

  --hrz-status-info-bg: var(--hrz-color-blue-50);
  --hrz-status-info-fg: var(--hrz-color-blue-700);
  --hrz-status-info-border: var(--hrz-color-blue-300);

  --hrz-status-premium-bg: var(--hrz-color-violet-50);
  --hrz-status-premium-fg: var(--hrz-color-violet-700);

  /* Brand accent (matches existing emerald gradient) */
  --hrz-brand-primary:        var(--hrz-color-emerald-500);
  --hrz-brand-primary-hover:  var(--hrz-color-emerald-600);
  --hrz-brand-primary-bg:     var(--hrz-color-emerald-50);
  --hrz-brand-secondary:      var(--hrz-color-blue-500);
  --hrz-brand-secondary-hover: var(--hrz-color-blue-600);

  /* ============================================================ */
  /* ELEVATION SCALE — unified shadow ramp                         */
  /* ============================================================ */
  --hrz-elev-0:  none;
  --hrz-elev-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --hrz-elev-md: 0 4px 8px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
  --hrz-elev-lg: 0 12px 24px rgba(15, 23, 42, 0.12), 0 4px 8px rgba(15, 23, 42, 0.06);
  --hrz-elev-xl: 0 24px 48px rgba(15, 23, 42, 0.16), 0 8px 16px rgba(15, 23, 42, 0.08);
  --hrz-elev-focus: 0 0 0 3px rgba(59, 130, 246, 0.35);

  /* ============================================================ */
  /* RADIUS SCALE                                                  */
  /* ============================================================ */
  --hrz-radius-xs:   4px;
  --hrz-radius-sm:   6px;
  --hrz-radius-md:  10px;
  --hrz-radius-lg:  14px;
  --hrz-radius-xl:  20px;
  --hrz-radius-2xl: 28px;
  --hrz-radius-full: 9999px;

  /* ============================================================ */
  /* SPACING SCALE (4pt grid)                                      */
  /* ============================================================ */
  --hrz-space-0:   0;
  --hrz-space-1:   4px;
  --hrz-space-2:   8px;
  --hrz-space-3:  12px;
  --hrz-space-4:  16px;
  --hrz-space-5:  20px;
  --hrz-space-6:  24px;
  --hrz-space-8:  32px;
  --hrz-space-10: 40px;
  --hrz-space-12: 48px;
  --hrz-space-16: 64px;

  /* ============================================================ */
  /* TYPOGRAPHY SCALE                                              */
  /* ============================================================ */
  --hrz-font-xs:    11px;
  --hrz-font-sm:    13px;
  --hrz-font-base:  14px;
  --hrz-font-lg:    16px;
  --hrz-font-xl:    18px;
  --hrz-font-2xl:   22px;
  --hrz-font-3xl:   28px;
  --hrz-font-display: 36px;

  --hrz-leading-tight:   1.2;
  --hrz-leading-normal:  1.5;
  --hrz-leading-relaxed: 1.7;

  --hrz-tracking-tight:  -0.01em;
  --hrz-tracking-normal:  0;
  --hrz-tracking-wide:   0.05em;
  --hrz-tracking-wider:  0.1em;

  /* ============================================================ */
  /* MOTION — 60fps friendly easings                               */
  /* ============================================================ */
  --hrz-motion-fast:    150ms;
  --hrz-motion-default: 250ms;
  --hrz-motion-slow:    400ms;

  --hrz-easing-default: cubic-bezier(0.4, 0, 0.2, 1);
  --hrz-easing-out:     cubic-bezier(0, 0, 0.2, 1);
  --hrz-easing-in:      cubic-bezier(0.4, 0, 1, 1);
  --hrz-easing-spring:  cubic-bezier(0.175, 0.885, 0.32, 1.275);

  /* ============================================================ */
  /* Z-INDEX SCALE                                                 */
  /* ============================================================ */
  --hrz-z-base:     0;
  --hrz-z-dropdown: 100;
  --hrz-z-sticky:   200;
  --hrz-z-overlay:  500;
  --hrz-z-modal:    1000;
  --hrz-z-toast:    2000;
  --hrz-z-tour:     9000;
  --hrz-z-max:      9999;

  /* ============================================================ */
  /* COMPONENT-LEVEL TOKENS (sidebar, chips, etc)                  */
  /* ============================================================ */
  /* Sidebar nav-item */
  --hrz-nav-item-bg-hover:   rgba(15, 23, 42, 0.04);
  --hrz-nav-item-bg-active:  rgba(16, 185, 129, 0.1);
  --hrz-nav-item-fg-active:  var(--hrz-color-emerald-700);
  --hrz-nav-item-bar-active: var(--hrz-color-emerald-500);
  --hrz-nav-section-fg:      var(--hrz-color-slate-400);

  /* Notification dot (sidebar) */
  --hrz-notif-dot-bg: var(--hrz-color-rose-500);
  --hrz-notif-dot-ring: rgba(239, 68, 68, 0.25);
}

/* ================================================================ */
/* DARK MODE — override semantic + component tokens only             */
/* (primitive layer never changes)                                  */
/* ================================================================ */
[data-theme="dark"] {
  /* Surfaces */
  --hrz-surface-1: var(--hrz-color-slate-900);
  --hrz-surface-2: var(--hrz-color-slate-950);
  --hrz-surface-3: var(--hrz-color-slate-800);
  --hrz-surface-overlay: rgba(0, 0, 0, 0.6);

  /* Text */
  --hrz-text-primary:   var(--hrz-color-slate-100);
  --hrz-text-secondary: var(--hrz-color-slate-400);
  --hrz-text-tertiary:  var(--hrz-color-slate-500);
  --hrz-text-inverse:   var(--hrz-color-slate-900);
  --hrz-text-link:      var(--hrz-color-blue-300);

  /* Borders */
  --hrz-border-subtle:   var(--hrz-color-slate-800);
  --hrz-border-default:  var(--hrz-color-slate-700);
  --hrz-border-emphasis: var(--hrz-color-slate-600);

  /* Status — softer dark variants (4.5:1 contrast on slate-900) */
  --hrz-status-success-bg: rgba(16, 185, 129, 0.12);
  --hrz-status-success-fg: var(--hrz-color-emerald-300);
  --hrz-status-success-border: rgba(16, 185, 129, 0.3);

  --hrz-status-warning-bg: rgba(245, 158, 11, 0.12);
  --hrz-status-warning-fg: var(--hrz-color-amber-300);
  --hrz-status-warning-border: rgba(245, 158, 11, 0.3);

  --hrz-status-error-bg: rgba(239, 68, 68, 0.12);
  --hrz-status-error-fg: var(--hrz-color-rose-300);
  --hrz-status-error-border: rgba(239, 68, 68, 0.3);

  --hrz-status-info-bg: rgba(59, 130, 246, 0.12);
  --hrz-status-info-fg: var(--hrz-color-blue-300);
  --hrz-status-info-border: rgba(59, 130, 246, 0.3);

  --hrz-status-premium-bg: rgba(139, 92, 246, 0.12);
  --hrz-status-premium-fg: var(--hrz-color-violet-500);

  /* Brand accent stays the same hue, adjusts surface */
  --hrz-brand-primary-bg: rgba(16, 185, 129, 0.12);

  /* Elevation — heavier, since dark surfaces need more depth */
  --hrz-elev-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --hrz-elev-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --hrz-elev-lg: 0 12px 24px rgba(0, 0, 0, 0.5);
  --hrz-elev-xl: 0 24px 48px rgba(0, 0, 0, 0.6);
  --hrz-elev-focus: 0 0 0 3px rgba(59, 130, 246, 0.45);

  /* Component-level overrides */
  --hrz-nav-item-bg-hover:   rgba(255, 255, 255, 0.05);
  --hrz-nav-item-bg-active:  rgba(52, 211, 153, 0.12);
  --hrz-nav-item-fg-active:  var(--hrz-color-emerald-300);
  --hrz-nav-item-bar-active: var(--hrz-color-emerald-500);
  --hrz-nav-section-fg:      var(--hrz-color-slate-500);
}

/* ================================================================ */
/* REDUCED MOTION — accessibility                                    */
/* ================================================================ */
@media (prefers-reduced-motion: reduce) {
  :root {
    --hrz-motion-fast:    0ms;
    --hrz-motion-default: 0ms;
    --hrz-motion-slow:    0ms;
  }
}

/* ================================================================ */
/* SIDEBAR REFINEMENT — uses new tokens (entrega 2)                  */
/* ================================================================ */

/* Active state: filled bar + soft tint background (Material 3-inspired) */
.sidebar .nav-item.active {
  background: var(--hrz-nav-item-bg-active);
  color: var(--hrz-nav-item-fg-active);
}

.sidebar .nav-item.active::before {
  width: 4px;            /* up from 3px for stronger visual anchor */
  height: 65%;
  background: var(--hrz-nav-item-bar-active);
  border-radius: 0 var(--hrz-radius-xs) var(--hrz-radius-xs) 0;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.4);
}

/* Smooth hover transition (motion token) */
.sidebar .nav-item {
  transition:
    background-color var(--hrz-motion-fast) var(--hrz-easing-default),
    color var(--hrz-motion-fast) var(--hrz-easing-default),
    transform var(--hrz-motion-fast) var(--hrz-easing-default);
}

.sidebar .nav-item:hover:not(.active) {
  background: var(--hrz-nav-item-bg-hover);
}

/* Section header — uppercase tracked label */
.sidebar .nav-section-title {
  color: var(--hrz-nav-section-fg);
  letter-spacing: var(--hrz-tracking-wider);
  text-transform: uppercase;
  font-size: var(--hrz-font-xs);
  font-weight: 700;
}

/* Notification dot — pulse animation on items with pending counter > 0 */
.sidebar .nav-item.has-pending::after {
  content: '';
  position: absolute;
  top: 10px;
  right: 10px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--hrz-notif-dot-bg);
  box-shadow: 0 0 0 3px var(--hrz-notif-dot-ring);
  animation: hrz-notif-pulse 2s ease-in-out infinite;
  pointer-events: none;
}

@keyframes hrz-notif-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.7; transform: scale(1.15); }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar .nav-item.has-pending::after {
    animation: none;
  }
}

/* Sidebar footer — Help / Tour replay button */
.sidebar-help-actions {
  display: flex;
  flex-direction: column;
  gap: var(--hrz-space-1);
  padding: var(--hrz-space-2) var(--hrz-space-3) 0;
  border-top: 1px solid var(--hrz-border-subtle);
  margin-top: var(--hrz-space-2);
}

.sidebar-help-btn {
  all: unset;
  display: flex;
  align-items: center;
  gap: var(--hrz-space-2);
  padding: var(--hrz-space-2) var(--hrz-space-3);
  border-radius: var(--hrz-radius-md);
  color: var(--hrz-text-secondary);
  font-size: var(--hrz-font-sm);
  font-weight: 500;
  cursor: pointer;
  transition: background var(--hrz-motion-fast) var(--hrz-easing-default),
              color    var(--hrz-motion-fast) var(--hrz-easing-default);
}

.sidebar-help-btn:hover,
.sidebar-help-btn:focus-visible {
  background: var(--hrz-nav-item-bg-hover);
  color: var(--hrz-text-primary);
  outline: none;
}

.sidebar-help-btn:focus-visible {
  box-shadow: var(--hrz-elev-focus);
}

.sidebar-help-btn .help-icon {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sidebar.collapsed .sidebar-help-btn-label {
  display: none;
}

/* ================================================================ */
/* CONTEXTUAL MINI-TOUR CTA BANNER (entrega 3)                       */
/* ================================================================ */
.hrz-mini-tour-cta {
  display: flex;
  align-items: center;
  gap: var(--hrz-space-3);
  padding: var(--hrz-space-3) var(--hrz-space-4);
  margin-bottom: var(--hrz-space-4);
  background: linear-gradient(135deg,
    var(--hrz-status-info-bg),
    var(--hrz-status-premium-bg));
  border: 1px solid var(--hrz-status-info-border);
  border-radius: var(--hrz-radius-lg);
  font-size: var(--hrz-font-sm);
  color: var(--hrz-text-primary);
  animation: hrz-cta-slide-in var(--hrz-motion-default) var(--hrz-easing-spring);
}

@keyframes hrz-cta-slide-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.hrz-mini-tour-cta__icon {
  flex-shrink: 0;
  font-size: 18px;
}

.hrz-mini-tour-cta__body {
  flex: 1;
  line-height: var(--hrz-leading-normal);
}

.hrz-mini-tour-cta__title {
  font-weight: 600;
  margin-bottom: 2px;
}

.hrz-mini-tour-cta__subtitle {
  font-size: var(--hrz-font-xs);
  color: var(--hrz-text-secondary);
}

.hrz-mini-tour-cta__actions {
  display: flex;
  gap: var(--hrz-space-2);
  flex-shrink: 0;
}

.hrz-mini-tour-cta__btn {
  all: unset;
  padding: 6px 12px;
  border-radius: var(--hrz-radius-md);
  font-size: var(--hrz-font-xs);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--hrz-motion-fast) var(--hrz-easing-default);
}

.hrz-mini-tour-cta__btn--primary {
  background: var(--hrz-color-blue-600);
  color: #ffffff;
}

.hrz-mini-tour-cta__btn--primary:hover,
.hrz-mini-tour-cta__btn--primary:focus-visible {
  background: var(--hrz-color-blue-700);
  outline: none;
  box-shadow: var(--hrz-elev-focus);
}

.hrz-mini-tour-cta__btn--ghost {
  color: var(--hrz-text-secondary);
}

.hrz-mini-tour-cta__btn--ghost:hover,
.hrz-mini-tour-cta__btn--ghost:focus-visible {
  background: var(--hrz-nav-item-bg-hover);
  color: var(--hrz-text-primary);
  outline: none;
}

@media (max-width: 640px) {
  .hrz-mini-tour-cta {
    flex-direction: column;
    align-items: flex-start;
  }
  .hrz-mini-tour-cta__actions {
    width: 100%;
    justify-content: flex-end;
  }
}
