/* ============================================================
   Forge by Uncles&Co — Design System
   base.css — Complete CSS foundation
   ============================================================ */

/* ============================================================
   1. CSS CUSTOM PROPERTIES / DESIGN TOKENS
   ============================================================ */

:root {
  /* --- typography ------------------------------------------- */
  --font-heading:   'Sora', system-ui, -apple-system, sans-serif;
  --font-body:      'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  --font-mono:      'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

  --fs-xs:    0.75rem;   /* 12px — badges, micro labels */
  --fs-sm:    0.8125rem; /* 13px — labels, helpers, table headers */
  --fs-base:  0.875rem;  /* 14px — body, inputs, nav, buttons */
  --fs-md:    1rem;      /* 16px — enfasis, modal titles */
  --fs-lg:    1.125rem;  /* 18px — card titles */
  --fs-xl:    1.25rem;   /* 20px — section headers */
  --fs-2xl:   1.5rem;    /* 24px — page titles */
  --fs-3xl:   1.875rem;  /* 30px — KPI values */
  --fs-4xl:   2.25rem;   /* 36px — hero numbers */

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

  --lh-tight:  1.25;
  --lh-normal: 1.5;
  --lh-relaxed:1.75;

  /* --- spacing — escala 4px base ---------------------------- */
  --space-1:  0.25rem;  /* 4px */
  --space-2:  0.5rem;   /* 8px */
  --space-3:  0.75rem;  /* 12px */
  --space-4:  1rem;     /* 16px */
  --space-5:  1.25rem;  /* 20px */
  --space-6:  1.5rem;   /* 24px */
  --space-8:  2rem;     /* 32px */
  --space-10: 2.5rem;   /* 40px */
  --space-12: 3rem;     /* 48px */
  --space-16: 4rem;     /* 64px */

  /* --- layout ----------------------------------------------- */
  --topnav-h:            54px;
  --sidebar-w:           220px;
  --sidebar-w-collapsed: 64px;
  --content-max-w:       1200px;
  --radius-sm:  4px;
  --radius-md:  8px;
  --radius-lg:  12px;
  --radius-xl:  16px;
  --radius-full:9999px;

  /* --- shadows ---------------------------------------------- */
  --shadow-sm:  0 1px 2px rgba(0,0,0,.06);
  --shadow-md:  0 4px 12px rgba(0,0,0,.08);
  --shadow-lg:  0 8px 24px rgba(0,0,0,.12);
  --shadow-xl:  0 16px 48px rgba(0,0,0,.16);

  /* --- transitions ------------------------------------------ */
  --ease-default: cubic-bezier(.4,0,.2,1);
  --duration:     0.25s;

  /* --- accent — Forge (Ember / terracota) --------------------- */
  --accent:         #D4663B;   /* Ember base — el naranja Forge */
  --accent-hover:   #E07848;   /* Ligeramente más claro + vibración Molten */
  --accent-active:  #B8532E;   /* Más oscuro para pressed */
  --accent-lighter: #F08C5A;   /* Ember light — highlights, textos sobre fondo oscuro */
  --accent-dark:    #943D22;   /* Ember dark — sombras, bordes activos */
  --accent-subtle:  rgba(212, 102, 59, .12);  /* Fondos de badges, tags, selecciones */
  --accent-muted:   #B06A47;   /* Burnt Clay — acentos discretos, iconos secundarios */
  --accent-intense: #E07040;   /* Molten — CTAs principales, alertas, badges urgentes */
  --accent-surface: rgba(212, 102, 59, .06);
  --brand-gradient: linear-gradient(135deg, #D4663B 0%, #F08C5A 100%);

  /* Copper accent para hovers secundarios */
  --copper:         #C2703E;
  --copper-subtle:  rgba(194, 112, 62, .10);
}


/* ============================================================
   2. LIGHT THEME
   ============================================================ */

[data-theme="light"] {
  /* Superficies */
  --bg-app:          #F5F3F1;
  --bg-surface:      #FFFFFF;
  --bg-surface-alt:  #F0EDEA;
  --bg-surface-hover:#EDE9E5;
  --bg-elevated:     #FFFFFF;
  --bg-sidebar:      #FDFCFB;
  --bg-topnav:       rgba(253, 252, 251, .88);
  --bg-input:        #FFFFFF;
  --bg-code:         #F5F3F1;
  --bg-overlay:      rgba(0, 0, 0, .3);

  /* Texto */
  --text-primary:    #1A1612;
  --text-secondary:  #4A4038;
  --text-tertiary:   #9C8E82;
  --text-disabled:   #D1C9C2;
  --text-inverse:    #FFFFFF;
  --text-link:       var(--accent);
  --text-on-brand:   #FFFFFF;
  --text-on-accent:  #FFFFFF;

  /* Bordes */
  --border-default:  #E0D8D0;
  --border-subtle:   #F0EDEA;
  --border-strong:   #C9BFB5;
  --border-focus:    var(--accent);
  --border-error:    #DC4A3A;

  /* Brand — mapped to accent */
  --brand:           var(--accent);
  --brand-hover:     var(--accent-hover);
  --brand-active:    var(--accent-active);

  /* Semantic */
  --success:         #2D8A56;
  --success-bg:      #E8F5EE;
  --success-border:  #A8D5BA;
  --warning:         #C08C20;
  --warning-bg:      #FDF6E3;
  --warning-border:  #E8D48A;
  --danger:          #C43D2E;
  --danger-bg:       #FCE8E6;
  --danger-border:   #E8A8A0;
  --info:            #3A6FA8;
  --info-bg:         #E6F0FA;
  --info-border:     #A0C4E0;

  /* Cards */
  --card-shadow:     0 1px 3px rgba(166, 130, 100, .08);
  --card-shadow-hover: 0 4px 16px rgba(166, 130, 100, .12);

  /* Sidebar */
  --sidebar-active-bg:    var(--accent-subtle);
  --sidebar-active-text:  var(--accent);
  --sidebar-active-border:var(--accent);

  /* AI Glow */
  --ai-glow: 0 0 20px rgba(212, 102, 59, .25), 0 0 40px rgba(212, 102, 59, .10);
}


/* ============================================================
   3. DARK THEME (DEFAULT)
   ============================================================ */

[data-theme="dark"] {
  /* Superficies — negro CÁLIDO, no frío */
  --bg-app:          #110E0B;
  --bg-surface:      rgba(255, 248, 240, .03);
  --bg-surface-alt:  rgba(255, 248, 240, .05);
  --bg-surface-hover:rgba(255, 248, 240, .07);
  --bg-elevated:     rgba(255, 248, 240, .06);
  --bg-sidebar:      rgba(14, 11, 8, .85);
  --bg-topnav:       rgba(14, 11, 8, .82);
  --bg-input:        rgba(255, 248, 240, .04);
  --bg-code:         rgba(255, 248, 240, .05);
  --bg-overlay:      rgba(0, 0, 0, .5);

  /* Texto — blanco cálido, NO blanco puro */
  --text-primary:    #F0E8E0;
  --text-secondary:  rgba(240, 232, 224, .60);
  --text-tertiary:   rgba(240, 232, 224, .32);
  --text-disabled:   rgba(240, 232, 224, .18);
  --text-inverse:    #110E0B;
  --text-link:       var(--accent-lighter);
  --text-on-brand:   #FFFFFF;
  --text-on-accent:  #FFFFFF;

  /* Bordes — influencia Burnt Clay */
  --border-default:  rgba(176, 106, 71, .15);
  --border-subtle:   rgba(255, 248, 240, .06);
  --border-strong:   rgba(176, 106, 71, .25);
  --border-focus:    var(--accent);
  --border-error:    #E05A4A;

  /* Brand */
  --brand:           var(--accent-lighter);
  --brand-hover:     #F5A070;
  --brand-active:    var(--accent);

  /* Semantic — cálidos para armonizar con terracota */
  --success:         #2FD08E;
  --success-bg:      rgba(47, 208, 142, .10);
  --success-border:  rgba(47, 208, 142, .25);
  --warning:         #F0A830;
  --warning-bg:      rgba(240, 168, 48, .10);
  --warning-border:  rgba(240, 168, 48, .25);
  --danger:          #EF5A4A;
  --danger-bg:       rgba(239, 90, 74, .10);
  --danger-border:   rgba(239, 90, 74, .25);
  --info:            #5A9AD8;
  --info-bg:         rgba(90, 154, 216, .10);
  --info-border:     rgba(90, 154, 216, .25);

  /* Cards */
  --card-shadow:     0 1px 3px rgba(0, 0, 0, .20);
  --card-shadow-hover: 0 4px 16px rgba(0, 0, 0, .30);

  /* Sidebar */
  --sidebar-active-bg:    var(--accent-subtle);
  --sidebar-active-text:  var(--accent-lighter);
  --sidebar-active-border:var(--accent);

  /* AI Glow — resplandor ember */
  --ai-glow: 0 0 20px rgba(212, 102, 59, .35), 0 0 40px rgba(240, 140, 90, .15);
}


/* ============================================================
   4. RESET & BASE
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  font-size: var(--fs-base);
  font-weight: var(--fw-regular);
  line-height: var(--lh-normal);
  color: var(--text-primary);
  background: var(--bg-app);
  min-height: 100vh;
  transition: background var(--duration) var(--ease-default),
              color var(--duration) var(--ease-default);
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-tight);
  color: var(--text-primary);
}

h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
h4 { font-size: var(--fs-md); }

a {
  color: var(--text-link);
  text-decoration: none;
  transition: color var(--duration) var(--ease-default);
}
a:hover { color: var(--accent-hover); }

code, pre {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
}

pre {
  background: var(--bg-code);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  overflow-x: auto;
}

::selection {
  background: var(--accent-subtle);
  color: var(--accent);
}

/* ============================================================
   5. LAYOUT — TOPBAR + SIDEBAR + CONTENT
   ============================================================ */

.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topnav-h) 1fr;
  grid-template-areas:
    "sidebar topnav"
    "sidebar content";
  min-height: 100vh;
}

.app-layout.sidebar-collapsed {
  grid-template-columns: var(--sidebar-w-collapsed) 1fr;
}

/* --- Topbar ------------------------------------------------- */
.topnav {
  grid-area: topnav;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--topnav-h);
  padding: 0 var(--space-6);
  background: var(--bg-topnav);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 100;
}

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

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

.topnav__toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: var(--fs-xl);
  cursor: pointer;
  padding: var(--space-1);
  border-radius: var(--radius-sm);
}
.topnav__toggle:hover { color: var(--text-primary); }

.topnav__breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--fs-sm);
  color: var(--text-tertiary);
}
.topnav__breadcrumb a { color: var(--text-secondary); }
.topnav__breadcrumb a:hover { color: var(--accent); }
.topnav__breadcrumb .sep { margin: 0 var(--space-1); }
.topnav__breadcrumb .current { color: var(--text-primary); font-weight: var(--fw-medium); }

/* Mode Toggle (Restaurante / Catering) */
.mode-toggle {
  display: flex;
  align-items: center;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  padding: 2px;
  gap: 0;
}
.mode-toggle__btn {
  padding: var(--space-1) var(--space-3);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  border: none;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--duration) var(--ease-default);
}
.mode-toggle__btn.active {
  background: var(--accent);
  color: var(--text-on-accent);
  box-shadow: 0 1px 4px rgba(212, 102, 59, .30);
}

/* Theme toggle */
.theme-toggle {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: var(--fs-lg);
  cursor: pointer;
  padding: var(--space-1);
  border-radius: var(--radius-sm);
  transition: color var(--duration) var(--ease-default);
}
.theme-toggle:hover { color: var(--accent); }

/* Notification bell */
.notif-btn {
  position: relative;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: var(--fs-lg);
  cursor: pointer;
  padding: var(--space-1);
  border-radius: var(--radius-sm);
}
.notif-btn:hover { color: var(--text-primary); }
.notif-btn .badge-dot {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 8px;
  height: 8px;
  background: var(--accent-intense);
  border-radius: var(--radius-full);
  border: 2px solid var(--bg-topnav);
}

/* Profile button */
.profile-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: var(--fs-sm);
  cursor: pointer;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-md);
}
.profile-btn:hover { background: var(--bg-surface-hover); }
.profile-btn .avatar {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-full);
  background: var(--accent-subtle);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
}

/* Enterprise switcher (superadmin) */
.empresa-switcher {
  padding: var(--space-1) var(--space-3);
  font-size: var(--fs-xs);
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  cursor: pointer;
}

/* --- Sidebar ------------------------------------------------ */
.sidebar {
  grid-area: sidebar;
  display: flex;
  flex-direction: column;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 200;
  transition: width var(--duration) var(--ease-default);
}

.sidebar__header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  height: var(--topnav-h);
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar__logo {
  width: 28px;
  height: 28px;
  background: var(--brand-gradient);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: var(--fw-bold);
  font-size: var(--fs-sm);
  flex-shrink: 0;
}

.sidebar__brand {
  font-family: var(--font-heading);
  font-weight: var(--fw-bold);
  font-size: var(--fs-md);
  color: var(--text-primary);
  letter-spacing: 0.5px;
}

.sidebar__nav {
  flex: 1;
  padding: var(--space-3) var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.sidebar__section-label {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: var(--space-4) var(--space-3) var(--space-1);
}

.sidebar__link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  transition: all var(--duration) var(--ease-default);
  text-decoration: none;
  border-left: 3px solid transparent;
}

.sidebar__link i {
  font-size: var(--fs-md);
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar__link:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

.sidebar__link.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  border-left-color: var(--sidebar-active-border);
  font-weight: var(--fw-semibold);
}

.sidebar__link .badge-count {
  margin-left: auto;
  background: var(--accent-subtle);
  color: var(--accent);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  padding: 1px 6px;
  border-radius: var(--radius-full);
}

/* Catering-only items */
.sidebar__link[data-mode="catering"] { display: none; }
body[data-app-mode="catering"] .sidebar__link[data-mode="catering"] { display: flex; }

.sidebar__footer {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border-subtle);
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
}

/* --- Content ------------------------------------------------ */
.content {
  grid-area: content;
  padding: var(--space-6);
  overflow-y: auto;
}

.content__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
}

.content__title {
  font-size: var(--fs-2xl);
  font-weight: var(--fw-bold);
}

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

/* ============================================================
   6. RESPONSIVE
   ============================================================ */

@media (max-width: 1024px) {
  .app-layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "topnav"
      "content";
  }

  .sidebar {
    position: fixed;
    left: -260px;
    width: var(--sidebar-w);
    transition: left var(--duration) var(--ease-default);
    box-shadow: var(--shadow-xl);
  }

  .sidebar.open { left: 0; }

  .topnav__toggle { display: flex; }
}

@media (max-width: 640px) {
  .content { padding: var(--space-4); }
  .topnav { padding: 0 var(--space-4); }
  .mode-toggle { display: none; }
}


/* ============================================================
   7. UTILITY CLASSES
   ============================================================ */

.text-primary { color: var(--text-primary) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-tertiary { color: var(--text-tertiary) !important; }
.text-accent { color: var(--accent) !important; }
.text-success { color: var(--success) !important; }
.text-warning { color: var(--warning) !important; }
.text-danger { color: var(--danger) !important; }

.bg-accent-subtle { background: var(--accent-subtle) !important; }
.bg-success-subtle { background: var(--success-bg) !important; }
.bg-warning-subtle { background: var(--warning-bg) !important; }
.bg-danger-subtle { background: var(--danger-bg) !important; }

.font-heading { font-family: var(--font-heading) !important; }
.font-mono { font-family: var(--font-mono) !important; }

.fw-regular { font-weight: var(--fw-regular) !important; }
.fw-medium { font-weight: var(--fw-medium) !important; }
.fw-semibold { font-weight: var(--fw-semibold) !important; }
.fw-bold { font-weight: var(--fw-bold) !important; }

.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }

.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }

.grid { display: grid; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

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

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================================
   8. ANIMATIONS
   ============================================================ */

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideRight {
  from { opacity: 0; transform: translateX(-8px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(.96); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: var(--ai-glow); }
  50% { box-shadow: 0 0 30px rgba(212, 102, 59, .45), 0 0 60px rgba(240, 140, 90, .20); }
}

.animate-fade-in { animation: fadeIn var(--duration) var(--ease-default); }
.animate-slide-up { animation: slideUp var(--duration) var(--ease-default); }

/* Staggered animations for lists */
.stagger > * { animation: slideUp var(--duration) var(--ease-default) both; }
.stagger > *:nth-child(1) { animation-delay: 0ms; }
.stagger > *:nth-child(2) { animation-delay: 40ms; }
.stagger > *:nth-child(3) { animation-delay: 80ms; }
.stagger > *:nth-child(4) { animation-delay: 120ms; }
.stagger > *:nth-child(5) { animation-delay: 160ms; }
.stagger > *:nth-child(6) { animation-delay: 200ms; }
.stagger > *:nth-child(7) { animation-delay: 240ms; }
.stagger > *:nth-child(8) { animation-delay: 280ms; }
