/* ==========================================================================
   SIRH Design System v2.0 — Elegant · Moroccan · All Templates
   ========================================================================== */

/* ── Design Tokens ── */
:root {
  /* === COLOR PALETTE — Moroccan Elegance === */
  /* Primary: Deep sapphire blues */
  --ds-blue-950: #071D36;
  --ds-blue-900: #0A2A4E;
  --ds-blue-800: #0F3D6B;
  --ds-blue-700: #14508A;
  --ds-blue-600: #1A5A9B;
  --ds-blue-500: #1E6DB5;
  --ds-blue-400: #2E8BD6;
  --ds-blue-200: #8FC2EE;
  --ds-blue-100: #C5DFF6;
  --ds-blue-50:  #EBF3FC;

  /* Accent: Warm terracotta + saffron */
  --ds-amber-600: #D4A04A;
  --ds-amber-500: #E8C97A;
  --ds-amber-100: #FAF1DC;
  --ds-terra-600: #C8553D;
  --ds-terra-500: #E07D68;

  /* Supporting: Teal, violet, emerald */
  --ds-teal-600:  #25938F;
  --ds-teal-500:  #36B5B1;
  --ds-teal-50:   #E6F4F3;
  --ds-violet-600:#7C3AED;
  --ds-emerald-600:#059669;

  /* Neutrals */
  --ds-slate-900: #0F172A;
  --ds-slate-800: #1E293B;
  --ds-slate-700: #334155;
  --ds-slate-600: #475569;
  --ds-slate-500: #64748B;
  --ds-slate-400: #94A3B8;
  --ds-slate-300: #CBD5E1;
  --ds-slate-200: #E2E8F0;
  --ds-slate-100: #F1F5F9;
  --ds-slate-50:  #F8FAFC;

  /* Semantic tokens */
  --ds-brand:         var(--ds-blue-600);
  --ds-brand-deep:    var(--ds-blue-900);
  --ds-brand-dark:    var(--ds-blue-800);
  --ds-brand-light:   var(--ds-blue-50);
  --ds-accent:        var(--ds-amber-600);
  --ds-accent-soft:   var(--ds-amber-500);
  --ds-surface:       #FFFFFF;
  --ds-surface-alt:   var(--ds-slate-50);
  --ds-ink:           var(--ds-slate-800);
  --ds-ink-soft:      var(--ds-slate-500);
  --ds-ink-muted:     var(--ds-slate-400);
  --ds-line:          var(--ds-slate-200);
  --ds-line-light:    var(--ds-slate-100);
  --ds-danger:        #DC2626;
  --ds-success:       #16A34A;

  /* === TYPOGRAPHY === */
  --ds-font-display: 'Fraunces', 'Georgia', 'Times New Roman', serif;
  --ds-font-body:    'Inter Variable', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --ds-font-mono:    'IBM Plex Mono', 'JetBrains Mono', 'Fira Code', monospace;

  /* Type scale */
  --ds-text-xs:   0.75rem;   /* 12px */
  --ds-text-sm:   0.8125rem; /* 13px */
  --ds-text-base: 0.9375rem; /* 15px */
  --ds-text-lg:   1.0625rem; /* 17px */
  --ds-text-xl:   1.25rem;   /* 20px */
  --ds-text-2xl:  1.5rem;    /* 24px */
  --ds-text-3xl:  1.875rem;  /* 30px */
  --ds-text-4xl:  2.25rem;   /* 36px */

  /* === SPACING === */
  --ds-space-1: 0.25rem;
  --ds-space-2: 0.5rem;
  --ds-space-3: 0.75rem;
  --ds-space-4: 1rem;
  --ds-space-5: 1.25rem;
  --ds-space-6: 1.5rem;
  --ds-space-8: 2rem;
  --ds-space-10: 2.5rem;
  --ds-space-12: 3rem;
  --ds-space-16: 4rem;
  --ds-space-20: 5rem;

  /* === RADII === */
  --ds-radius-sm:  6px;
  --ds-radius-md:  10px;
  --ds-radius-lg:  16px;
  --ds-radius-xl:  24px;

  /* === SHADOWS === */
  --ds-shadow-xs:  0 1px 2px rgba(10,42,78,0.04);
  --ds-shadow-sm:  0 1px 3px rgba(10,42,78,0.06), 0 1px 2px rgba(10,42,78,0.04);
  --ds-shadow-md:  0 4px 12px rgba(10,42,78,0.06), 0 1px 3px rgba(10,42,78,0.04);
  --ds-shadow-lg:  0 8px 24px rgba(10,42,78,0.08), 0 2px 8px rgba(10,42,78,0.04);
  --ds-shadow-xl:  0 16px 48px rgba(10,42,78,0.10), 0 4px 16px rgba(10,42,78,0.04);

  /* === TRANSITIONS === */
  --ds-ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ds-ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --ds-duration-fast: 150ms;
  --ds-duration-base: 250ms;
  --ds-duration-slow: 400ms;
}

/* ── Base Typography ── */
body {
  font-family: var(--ds-font-body);
  font-size: var(--ds-text-base);
  line-height: 1.6;
  color: var(--ds-ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Heading elegance */
h1, h2, h3, h4 {
  font-family: var(--ds-font-display);
  font-weight: 640;
  letter-spacing: -0.02em;
  color: var(--ds-blue-900);
  line-height: 1.2;
}

h1 { font-size: var(--ds-text-4xl); }
h2 { font-size: var(--ds-text-3xl); }
h3 { font-size: var(--ds-text-2xl); }
h4 { font-size: var(--ds-text-xl); }

/* ── Card Elegance ── */
.ds-card {
  background: var(--ds-surface);
  border: 1px solid var(--ds-line);
  border-radius: var(--ds-radius-xl);
  box-shadow: var(--ds-shadow-sm);
  transition: box-shadow var(--ds-duration-base) var(--ds-ease-out),
              transform var(--ds-duration-base) var(--ds-ease-out);
}

.ds-card:hover {
  box-shadow: var(--ds-shadow-md);
  transform: translateY(-1px);
}

/* ── Button Elegance ── */
.ds-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--ds-space-2);
  padding: 0.625rem 1.25rem;
  font-family: var(--ds-font-body);
  font-size: var(--ds-text-sm);
  font-weight: 600;
  letter-spacing: 0.01em;
  border: none;
  border-radius: var(--ds-radius-md);
  cursor: pointer;
  transition: all var(--ds-duration-base) var(--ds-ease-out);
  text-decoration: none;
  line-height: 1;
}

.ds-btn-primary {
  background: var(--ds-brand);
  color: #FFF;
}

.ds-btn-primary:hover {
  background: var(--ds-brand-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(26,90,155,0.25);
}

.ds-btn-primary:active {
  transform: scale(0.98);
}

.ds-btn-ghost {
  background: transparent;
  color: var(--ds-ink-soft);
}

.ds-btn-ghost:hover {
  background: var(--ds-slate-100);
  color: var(--ds-ink);
}

/* ── Input Elegance ── */
.ds-input {
  width: 100%;
  padding: 0.625rem 0.875rem;
  font-family: var(--ds-font-body);
  font-size: var(--ds-text-base);
  color: var(--ds-ink);
  background: var(--ds-slate-50);
  border: 1.5px solid var(--ds-line);
  border-radius: var(--ds-radius-md);
  transition: all var(--ds-duration-fast) var(--ds-ease-out);
  outline: none;
  box-sizing: border-box;
}

.ds-input:focus {
  background: var(--ds-surface);
  border-color: var(--ds-brand);
  box-shadow: 0 0 0 3px rgba(26,90,155,0.12);
}

.ds-input::placeholder {
  color: var(--ds-slate-400);
}

/* ── Slogan / Display Typography ── */
.ds-slogan {
  font-family: var(--ds-font-display);
  font-weight: 560;
  font-style: italic;
  letter-spacing: -0.015em;
  line-height: 1.3;
}

.ds-display {
  font-family: var(--ds-font-display);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
}

/* ── Animations ── */
@keyframes ds-fade-up {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes ds-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes ds-scale-in {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes ds-float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50%      { transform: translateY(-12px) rotate(1deg); }
}

@keyframes ds-shimmer {
  0%   { background-position: -200% center; }
  100% { background-position: 200% center; }
}

@keyframes ds-pulse-glow {
  0%, 100% { opacity: 0.4; }
  50%      { opacity: 0.8; }
}

.ds-animate-up {
  animation: ds-fade-up 0.6s var(--ds-ease-out) both;
}

.ds-animate-in {
  animation: ds-fade-in 0.5s var(--ds-ease-out) both;
}

.ds-animate-scale {
  animation: ds-scale-in 0.5s var(--ds-ease-out) both;
}

/* Staggered children */
.ds-stagger > * {
  opacity: 0;
  animation: ds-fade-up 0.5s var(--ds-ease-out) forwards;
}

.ds-stagger > *:nth-child(1) { animation-delay: 0.1s; }
.ds-stagger > *:nth-child(2) { animation-delay: 0.2s; }
.ds-stagger > *:nth-child(3) { animation-delay: 0.3s; }
.ds-stagger > *:nth-child(4) { animation-delay: 0.4s; }
.ds-stagger > *:nth-child(5) { animation-delay: 0.5s; }
.ds-stagger > *:nth-child(6) { animation-delay: 0.6s; }
.ds-stagger > *:nth-child(7) { animation-delay: 0.7s; }
.ds-stagger > *:nth-child(8) { animation-delay: 0.8s; }

/* ==========================================================================
   SIDEBAR — Premium Brand Header + Navigation
   ========================================================================== */

/* ── Sidebar structure ── */
.app-sidebar {
  display: flex;
  flex-direction: column;
  position: fixed;
  inset-y: 0;
  left: 0;
  z-index: 40;
  width: 17rem; /* 272px */
  background: var(--ds-surface);
  border-right: 1px solid var(--ds-line-light);
  box-shadow: var(--ds-shadow-sm);
  overflow: hidden;
}

/* ── Brand header — gradient like login panel ── */
.sidebar-brand {
  position: relative;
  flex-shrink: 0;
  padding: 32px 24px 28px;
  background:
    radial-gradient(ellipse 100% 60% at 20% 15%, rgba(46,139,214,0.3) 0%, transparent 55%),
    radial-gradient(ellipse 80% 50% at 85% 10%, rgba(54,181,177,0.2) 0%, transparent 50%),
    radial-gradient(ellipse 60% 40% at 80% 90%, rgba(212,160,74,0.15) 0%, transparent 45%),
    linear-gradient(165deg, #0A2A4E 0%, #1A5A9B 40%, #25938F 100%);
  overflow: hidden;
  isolation: isolate;
}

/* Subtle pattern overlay */
.sidebar-brand::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    repeating-linear-gradient(45deg, transparent 0px, transparent 20px, rgba(255,255,255,0.02) 20px, rgba(255,255,255,0.02) 21px),
    repeating-linear-gradient(-45deg, transparent 0px, transparent 20px, rgba(255,255,255,0.02) 20px, rgba(255,255,255,0.02) 21px);
}

/* Arch glow */
.sidebar-brand::after {
  content: '';
  position: absolute;
  top: -15%;
  left: 50%;
  transform: translateX(-50%);
  width: 130%;
  height: 50%;
  background: radial-gradient(ellipse at center, rgba(255,255,255,0.04) 0%, transparent 60%);
  border-radius: 50%;
  z-index: 1;
  pointer-events: none;
  animation: ds-pulse-glow 6s ease-in-out infinite;
}

/* Brand content container */
.sidebar-brand-content {
  position: relative;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

/* Brand mark */
.sidebar-brand-mark {
  width: 42px;
  height: 42px;
  margin-bottom: 14px;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.2));
  animation: ds-fade-up 0.5s var(--ds-ease-out) 0.1s both;
}

.sidebar-brand-mark svg { width: 100%; height: 100%; }

/* Wordmark */
.sidebar-brand-wordmark {
  font-family: var(--ds-font-display);
  font-size: 1.625rem; /* 26px */
  font-weight: 700;
  letter-spacing: -0.03em;
  color: #fff;
  margin-bottom: 8px;
  animation: ds-fade-up 0.5s var(--ds-ease-out) 0.15s both;
  text-decoration: none;
  display: block;
}

/* Slogan */
.sidebar-brand-slogan {
  font-family: var(--ds-font-display);
  font-size: 0.75rem; /* 12px */
  font-weight: 520;
  font-style: italic;
  line-height: 1.5;
  color: rgba(232,201,122,0.85);
  letter-spacing: -0.005em;
  max-width: 180px;
  animation: ds-fade-up 0.5s var(--ds-ease-out) 0.2s both;
}

/* Divider */
.sidebar-brand-divider {
  width: 32px;
  height: 1.5px;
  background: rgba(255,255,255,0.18);
  margin: 14px 0;
  animation: ds-fade-in 0.4s var(--ds-ease-out) 0.25s both;
}

/* Tagline below divider */
.sidebar-brand-tagline {
  font-size: 0.625rem; /* 10px */
  font-weight: 400;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.45);
  animation: ds-fade-in 0.4s var(--ds-ease-out) 0.3s both;
}

/* ── Navigation ── */
.sidebar-nav {
  flex: 1;
  padding: 20px 14px;
  overflow-y: auto;
}

/* Enhanced nav items */
.sidebar-nav .nav-item {
  position: relative;
  margin-bottom: 2px;
  padding: 10px 14px;
  border-radius: 10px;
  font-family: var(--ds-font-body);
  font-size: var(--ds-text-sm);
  font-weight: 500;
  transition: all var(--ds-duration-fast) var(--ds-ease-out);
}

.sidebar-nav .nav-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 0;
  background: var(--module-accent, var(--ds-brand));
  border-radius: 0 3px 3px 0;
  transition: height var(--ds-duration-fast) var(--ds-ease-out);
}

.sidebar-nav .nav-item.active::before {
  height: 60%;
}

.sidebar-nav .nav-item.active {
  background: var(--module-accent-50, var(--ds-brand-light));
  color: var(--module-accent-600, var(--ds-brand-dark));
  font-weight: 600;
}

.sidebar-nav .nav-item:hover::before {
  height: 30%;
}

.sidebar-nav .nav-item:hover {
  background: var(--module-accent-50, #F0F4FA);
  color: var(--module-accent, var(--ds-brand));
  transform: translateX(2px);
}

/* Nav section separator */
.sidebar-nav-separator {
  margin: 16px 14px 12px;
  border: none;
  border-top: 1px solid var(--ds-line-light);
}

/* ── Sidebar footer ── */
.sidebar-footer {
  flex-shrink: 0;
  padding: 16px 20px;
  border-top: 1px solid var(--ds-line-light);
  text-align: center;
}

.sidebar-footer-text {
  font-size: 0.625rem;
  color: var(--ds-ink-muted);
  letter-spacing: 0.02em;
}

/* ── Sidebar staggered reveal ── */
.sidebar-nav-stagger .nav-item {
  opacity: 0;
  animation: ds-fade-up 0.4s var(--ds-ease-out) forwards;
}

.sidebar-nav-stagger .nav-item:nth-child(1)  { animation-delay: 0.35s; }
.sidebar-nav-stagger .nav-item:nth-child(2)  { animation-delay: 0.40s; }
.sidebar-nav-stagger .nav-item:nth-child(3)  { animation-delay: 0.45s; }
.sidebar-nav-stagger .nav-item:nth-child(4)  { animation-delay: 0.50s; }
.sidebar-nav-stagger .nav-item:nth-child(5)  { animation-delay: 0.55s; }
.sidebar-nav-stagger .nav-item:nth-child(6)  { animation-delay: 0.60s; }
.sidebar-nav-stagger .nav-item:nth-child(7)  { animation-delay: 0.65s; }
.sidebar-nav-stagger .nav-item:nth-child(8)  { animation-delay: 0.70s; }
.sidebar-nav-stagger .nav-item:nth-child(9)  { animation-delay: 0.75s; }
.sidebar-nav-stagger .nav-item:nth-child(10) { animation-delay: 0.80s; }
.sidebar-nav-stagger .nav-item:nth-child(11) { animation-delay: 0.85s; }

/* ==========================================================================
   REDUCED MOTION
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
