/* ==========================================================================
   EASY DELIVERY - CORPORATE DESIGN SYSTEM & PALETTE
   Brand: Easy Intelligence (Manual de Identidad Corporativa Oficial)
   Primary Colors:
     - #00a9ff (Easy Vibrant Tech Blue / Cyan)
     - #161766 (Easy Deep Navy Blue)
     - #151835 (Easy Dark Slate Surface)
     - #179726 (Easy Emerald Accent)
     - #d48b40 (Easy Gold / Amber Accent)
     - #d11714 (Easy Corporate Red)
   Typography: Montserrat (Light, Regular, SemiBold, Bold)
   ========================================================================== */

/* ==========================================================================
   EASY INTELLIGENCE OFFICIAL BRAND PALETTE & DUAL THEME TOKENS
   Manual de Identidad Corporativa:
   - Azul Marino Corporativo: #161766
   - Cian Easy: #00a9ff
   - Dark Slate: #151835
   - Verde: #179726
   - Ámbar: #d48b40
   - Rojo: #d11714
   ========================================================================== */

:root, [data-theme="dark"] {
  --theme-mode: 'dark';

  /* Brand Core */
  --easy-blue: #00a9ff;
  --easy-blue-hover: #38bdf8;
  --easy-blue-light: rgba(0, 169, 255, 0.18);
  --easy-blue-glow: rgba(0, 169, 255, 0.45);

  --easy-navy: #161766;
  --easy-navy-light: rgba(22, 23, 102, 0.4);

  --easy-green: #179726;
  --easy-green-hover: #22c55e;
  --easy-green-light: rgba(23, 151, 38, 0.2);

  --easy-amber: #d48b40;
  --easy-amber-light: rgba(212, 139, 64, 0.2);

  --easy-red: #d11714;
  --easy-red-light: rgba(209, 23, 20, 0.2);

  /* Semantic */
  --primary: var(--easy-blue);
  --primary-hover: var(--easy-blue-hover);
  --primary-light: var(--easy-blue-light);
  --primary-glow: var(--easy-blue-glow);

  --accent-orange: var(--easy-amber);
  --accent-emerald: var(--easy-green);
  --accent-rose: var(--easy-red);
  --accent-cyan: var(--easy-blue);

  /* Surfaces: Dark Slate / Deep Navy Base */
  --bg-main: #0b0d1e;
  --bg-surface: #151835;
  --bg-surface-elevated: #1a1e45;
  --bg-surface-card: rgba(26, 30, 69, 0.85);
  --bg-surface-glass: rgba(13, 15, 34, 0.92);

  /* Borders & Inputs */
  --border-subtle: rgba(0, 169, 255, 0.22);
  --border-focus: #00a9ff;
  --border-active: #00a9ff;
  --input-bg: rgba(11, 13, 30, 0.85);
  --input-border: rgba(0, 169, 255, 0.28);
  --input-text: #ffffff;

  /* Typography */
  --text-main: #ffffff;
  --text-muted: #cbd5e1;
  --text-subtle: #94a3b8;
  --text-inverse: #0b0d1e;

  /* Shadows */
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px -1px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 10px 25px -3px rgba(0, 0, 0, 0.6);
  --shadow-xl: 0 20px 35px -5px rgba(0, 0, 0, 0.7);
  --shadow-glow: 0 0 20px rgba(0, 169, 255, 0.45);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
  --transition-smooth: 0.4s ease;
}

[data-theme="light"] {
  --theme-mode: 'light';

  /* Brand Core */
  --easy-blue: #00a9ff;
  --easy-blue-hover: #0284c7;
  --easy-blue-light: rgba(0, 169, 255, 0.12);
  --easy-blue-glow: rgba(0, 169, 255, 0.25);

  --easy-navy: #161766;
  --easy-navy-light: rgba(22, 23, 102, 0.08);

  --easy-green: #179726;
  --easy-green-hover: #15803d;
  --easy-green-light: rgba(23, 151, 38, 0.12);

  --easy-amber: #d48b40;
  --easy-amber-light: rgba(212, 139, 64, 0.12);

  --easy-red: #d11714;
  --easy-red-light: rgba(209, 23, 20, 0.12);

  /* Semantic */
  --primary: #00a9ff;
  --primary-hover: #0284c7;
  --primary-light: rgba(0, 169, 255, 0.12);
  --primary-glow: rgba(0, 169, 255, 0.25);

  --accent-orange: var(--easy-amber);
  --accent-emerald: var(--easy-green);
  --accent-rose: var(--easy-red);
  --accent-cyan: var(--easy-blue);

  /* Surfaces: Crisp Corporate Light */
  --bg-main: #f4f6fa;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #f8fafc;
  --bg-surface-card: #ffffff;
  --bg-surface-glass: rgba(255, 255, 255, 0.95);

  /* Borders & Inputs */
  --border-subtle: rgba(22, 23, 102, 0.15);
  --border-focus: #00a9ff;
  --border-active: #00a9ff;
  --input-bg: #ffffff;
  --input-border: #cbd5e1;
  --input-text: #0f172a;

  /* Typography: High-Contrast Navy & Slate */
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-subtle: #64748b;
  --text-inverse: #ffffff;

  /* Shadows: Soft Depth */
  --shadow-sm: 0 1px 3px 0 rgba(22, 23, 102, 0.05);
  --shadow-md: 0 4px 12px -1px rgba(22, 23, 102, 0.08);
  --shadow-lg: 0 10px 24px -3px rgba(22, 23, 102, 0.1);
  --shadow-xl: 0 20px 30px -5px rgba(22, 23, 102, 0.12);
  --shadow-glow: 0 0 16px rgba(0, 169, 255, 0.2);
}

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

html, body {
  width: 100%;
  height: 100%;
  font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

#app-root {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ==========================================================================
   TOP BAR: EASY INTELLIGENCE CORPORATE BRANDING & ROLE SWITCHER
   ========================================================================== */
.top-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--bg-surface-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.35rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
}

.brand-logo-img {
  height: 32px;
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 0 10px rgba(0, 169, 255, 0.35));
}

.brand-text h1 {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.brand-text h1 span.highlight {
  color: var(--easy-blue);
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.7rem;
  font-weight: 600;
  background: var(--easy-blue-light);
  color: #38bdf8;
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius-full);
  border: 1px solid rgba(0, 169, 255, 0.3);
}

/* Grouped Navigation System: 4 Main Modules */
.module-tabs-container {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(0, 0, 0, 0.2);
  padding: 4px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
}

.module-tab-btn {
  background: transparent;
  border: 1px solid transparent;
  outline: none;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  transition: all var(--transition-fast);
}

.module-tab-btn:hover {
  color: var(--text-main);
  background: rgba(0, 169, 255, 0.08);
  border-color: rgba(0, 169, 255, 0.15);
}

.module-tab-btn.active {
  background: var(--bg-surface-elevated);
  color: var(--text-main);
  border-color: var(--easy-blue);
  box-shadow: 0 0 14px rgba(0, 169, 255, 0.25);
  font-weight: 700;
}

.module-pill {
  font-size: 0.68rem;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 9999px;
  background: var(--easy-blue-light);
  color: var(--easy-blue);
  border: 1px solid rgba(0, 169, 255, 0.25);
}

.module-tab-btn.active .module-pill {
  background: var(--easy-blue);
  color: white;
}

/* Secondary Sub-Header Navigation (Active Module Screens) */
.sub-header-nav {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.25rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  position: sticky;
  top: 48px;
  z-index: 990;
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-sm);
  transition: background var(--transition-normal);
}

.sub-nav-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.sub-nav-badge {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--easy-blue);
  background: var(--easy-blue-light);
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  border: 1px solid rgba(0, 169, 255, 0.25);
  text-transform: uppercase;
  white-space: nowrap;
}

.sub-nav-group {
  display: none;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.sub-nav-group.active {
  display: flex;
}

.sub-role-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.sub-role-btn:hover {
  color: var(--text-main);
  background: rgba(0, 169, 255, 0.08);
  border-color: rgba(0, 169, 255, 0.2);
}

.sub-role-btn.active {
  color: #ffffff !important;
  background: var(--easy-blue) !important;
  border-color: var(--easy-blue) !important;
  box-shadow: 0 2px 8px rgba(0, 169, 255, 0.35);
  font-weight: 700;
}

/* Quick Jump Dropdown Menu */
.quick-jump-wrapper {
  position: relative;
}

.quick-jump-btn {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  transition: all 0.2s;
  white-space: nowrap;
}

.quick-jump-btn:hover {
  border-color: var(--easy-blue);
  box-shadow: 0 0 10px rgba(0, 169, 255, 0.2);
}

.quick-jump-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 290px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  padding: 0.6rem;
  display: none;
  flex-direction: column;
  z-index: 1200;
  backdrop-filter: blur(20px);
  max-height: 480px;
  overflow-y: auto;
}

.quick-jump-menu.show {
  display: flex;
}

.quick-jump-section-title {
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--easy-blue);
  padding: 0.45rem 0.5rem 0.25rem 0.5rem;
  letter-spacing: 0.05em;
  border-top: 1px solid var(--border-subtle);
  margin-top: 0.35rem;
}

.quick-jump-section-title:first-child {
  border-top: none;
  margin-top: 0;
}

.quick-jump-menu a {
  color: var(--text-main);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.42rem 0.65rem;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.15s;
}

.quick-jump-menu a:hover {
  background: var(--easy-blue-light);
  color: var(--easy-blue);
  transform: translateX(4px);
}

/* Legacy Role Tabs Container compatibility */
.role-tabs-container {
  display: flex;
  background: rgba(12, 15, 36, 0.6);
  padding: 4px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
}

.role-tab-btn {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: all var(--transition-fast);
}

/* Header Fast Actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.demo-btn {
  background: linear-gradient(135deg, var(--easy-blue), #0077b6);
  color: white;
  border: none;
  outline: none;
  padding: 0.45rem 0.95rem;
  font-size: 0.82rem;
  font-weight: 700;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  box-shadow: 0 4px 14px rgba(0, 169, 255, 0.35);
  transition: all var(--transition-fast);
}

.demo-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(0, 169, 255, 0.5);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--easy-green);
  box-shadow: 0 0 10px var(--easy-green);
  animation: pulse-ring 2s infinite ease-out;
}

@keyframes pulse-ring {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

/* View Section transitions */
.view-section {
  display: none;
  flex: 1;
  animation: fadeInView 0.25s ease-in-out;
}

.view-section.active {
  display: flex;
  flex-direction: column;
}

/* Fluid Full-Width Page Container for high-density space usage */
.page-fluid-container {
  width: 100%;
  max-width: 100%;
  padding: 0.85rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-sizing: border-box;
  flex: 1;
}

.page-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.85rem;
}

.page-header-title {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.page-header-title h2 {
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.page-header-title p {
  font-size: 0.82rem;
  color: var(--text-muted);
}

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

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-pending {
  background: var(--easy-amber-light);
  color: #fbbf24;
  border: 1px solid rgba(212, 139, 64, 0.3);
}

.badge-preparing {
  background: var(--easy-blue-light);
  color: #38bdf8;
  border: 1px solid rgba(0, 169, 255, 0.3);
}

.badge-in_transit {
  background: rgba(0, 169, 255, 0.2);
  color: #7dd3fc;
  border: 1px solid rgba(0, 169, 255, 0.4);
}

.badge-delivered {
  background: var(--easy-green-light);
  color: #4ade80;
  border: 1px solid rgba(23, 151, 38, 0.3);
}

.badge-cancelled {
  background: var(--easy-red-light);
  color: #f87171;
  border: 1px solid rgba(209, 23, 20, 0.3);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-primary {
  background: var(--easy-blue);
  color: white;
}
.btn-primary:hover {
  background: var(--easy-blue-hover);
  box-shadow: var(--shadow-glow);
}

.btn-secondary {
  background: var(--bg-surface-elevated);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn-success {
  background: var(--easy-green);
  color: white;
}
.btn-success:hover {
  background: var(--easy-green-hover);
}

/* Toast Container */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  min-width: 280px;
  max-width: 420px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-left: 4px solid var(--easy-blue);
  border-radius: var(--radius-md);
  padding: 0.85rem 1.15rem;
  box-shadow: var(--shadow-xl);
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  animation: slideInToast 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  color: var(--text-main);
}

.toast.toast-success { border-left-color: var(--easy-green); }
.toast.toast-warning { border-left-color: var(--easy-amber); }
.toast.toast-error { border-left-color: var(--easy-red); }
.toast.toast-dispatch { border-left-color: var(--easy-blue); }
.toast.toast-gov { border-left-color: #06b6d4; }

@keyframes slideInToast {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(12, 15, 36, 0.85);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay.active {
  display: flex;
}

.modal-window {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: modalPop 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.modal-close-btn:hover {
  color: white;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}
