:root {
  --bg-main: #0c1317;
  --bg-surface: #111b21;
  --bg-bubble: #202c33;
  --border-color: #222e35;
  --text-main: #e9edef;
  --text-muted: #8696a0;
  --primary: #9d4edd;
  --primary-hover: #b76eeb;
  --card-bg: rgba(17, 27, 33, 0.85);
  --dock-bg: rgba(20, 27, 33, 0.85);
  --dock-border: rgba(157, 78, 221, 0.3);
  --badge-bg: rgba(157, 78, 221, 0.2);
  --badge-text: #c77dff;
  --shadow: 0 12px 36px rgba(0, 0, 0, 0.5);
}

[data-theme="light"] {
  --bg-main: #eae6df;
  --bg-surface: #ffffff;
  --bg-bubble: #f0f2f5;
  --border-color: #d1d7db;
  --text-main: #111b21;
  --text-muted: #667781;
  --primary: #8338ec;
  --primary-hover: #7209b7;
  --card-bg: rgba(255, 255, 255, 0.9);
  --dock-bg: rgba(255, 255, 255, 0.88);
  --dock-border: rgba(131, 56, 236, 0.25);
  --badge-bg: #f3e8ff;
  --badge-text: #6b21a8;
  --shadow: 0 8px 24px rgba(11, 20, 26, 0.08);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
}

/* BLINDAJE DE SVG */
svg {
  max-width: 24px;
  max-height: 24px;
  box-sizing: content-box;
}

/* ESTRUCTURA DASHBOARD */
.dashboard-wrapper {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

aside {
  width: 260px;
  min-width: 260px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 24px 18px;
  flex-shrink: 0;
  height: 100vh;
  position: sticky;
  top: 0;
}

aside .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  text-decoration: none;
  color: var(--text-main);
  font-size: 1.15rem;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
}

aside .desktop-nav {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-grow: 1;
}

aside .desktop-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text-muted);
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.2s ease;
}

aside .desktop-nav a svg,
aside .desktop-nav svg.sidebar-icon {
  width: 18px !important;
  height: 18px !important;
  stroke: var(--primary);
  stroke-width: 2.2;
  fill: none;
  flex-shrink: 0;
}

aside .desktop-nav a.active, 
aside .desktop-nav a:hover {
  background: var(--bg-bubble);
  color: var(--text-main);
}

.dashboard-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow-y: auto;
  min-width: 0;
}

/* HEADER */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 28px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 30;
}

header .brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  text-decoration: none;
  color: var(--text-main);
  font-size: 1.25rem;
}

header .brand-icon {
  color: var(--primary);
}

.brand-side {
  display: flex;
  align-items: center;
  gap: 40px;
}

.desktop-nav-links {
  display: flex;
  align-items: center;
  gap: 24px;
}

.desktop-nav-links a {
  text-decoration: none;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 700;
  transition: color 0.2s ease;
}

.desktop-nav-links a:hover {
  color: var(--text-main);
}

.desktop-nav-links a svg.nav-icon {
  width: 18px !important;
  height: 18px !important;
  stroke: currentColor;
  stroke-width: 2.2;
  fill: none;
}

/* DROPDOWN DESKTOP EN HEADER */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-content {
  position: absolute;
  top: calc(100% + 15px);
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  box-shadow: var(--shadow);
  min-width: 160px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 100;
}

.dropdown:hover .dropdown-content {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  color: var(--text-muted) !important;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 10px;
  transition: background 0.2s, color 0.2s;
}

.dropdown-item:hover {
  background: var(--bg-bubble);
  color: var(--primary) !important;
}

.dropdown-item svg {
  width: 16px !important;
  height: 16px !important;
  stroke: currentColor;
  stroke-width: 2.2;
  fill: none;
}

.badge-pill {
  background: var(--badge-bg);
  color: var(--badge-text);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 700;
  text-decoration: none;
}

.theme-toggle-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--bg-bubble);
  border: 1px solid var(--border-color);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
}

.theme-toggle-btn svg {
  position: absolute;
  width: 20px !important;
  height: 20px !important;
  fill: none;
  stroke: var(--text-main);
  stroke-width: 2;
  transition: opacity 0.2s, transform 0.3s;
}

.theme-toggle-btn .icon-sun { opacity: 1; transform: rotate(0deg); }
.theme-toggle-btn .icon-moon { opacity: 0; transform: rotate(-90deg); }

[data-theme="light"] .theme-toggle-btn .icon-sun { opacity: 0; transform: rotate(90deg); }
[data-theme="light"] .theme-toggle-btn .icon-moon { opacity: 1; transform: rotate(0deg); }

/* CONTENEDOR CENTRAL OPTIMIZADO */
.single-column-layout {
  display: flex !important;
  flex-direction: column !important;
  gap: 20px !important;
  width: 100% !important;
  max-width: 100% !important;
  margin: 18px 0 90px 0 !important;
  padding: 0 28px !important;
  box-sizing: border-box !important;
}

.card {
  background: var(--card-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow);
  width: 100%;
  box-sizing: border-box;
}

/* FORMULARIOS */
.field {
  margin-bottom: 18px;
  width: 100%;
}

.field label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.field input, .field textarea, select {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  background: var(--bg-bubble);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-size: 0.95rem;
  outline: none;
  box-sizing: border-box;
}

.field input:focus, .field textarea:focus, select:focus {
  border-color: var(--primary);
}

.btn-submit {
  width: 100%;
  padding: 14px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(157, 78, 221, 0.35);
  transition: background-color 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-submit:hover {
  background: var(--primary-hover);
}

/* TABS FLASH, AVANZADO, MASIVO */
.order-mode-tabs {
  display: flex;
  background: var(--bg-bubble);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 4px;
  gap: 6px;
  margin-bottom: 22px;
}

.tab-btn {
  flex: 1;
  padding: 10px 14px;
  border-radius: 12px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.25s ease;
}

.tab-btn.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(157, 78, 221, 0.35);
}

.tab-btn svg {
  width: 16px !important;
  height: 16px !important;
  stroke: currentColor;
  stroke-width: 2.2;
  fill: none;
  flex-shrink: 0;
}

.order-mode-view {
  display: none;
}

.order-mode-view.active {
  display: block;
}

/* BUSCADOR TIPO GOOGLE */
.search-wrapper-relative {
  position: relative;
  width: 100%;
}

.search-input-box {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
}

.search-input-box svg {
  position: absolute;
  left: 16px;
  width: 18px !important;
  height: 18px !important;
  stroke: var(--primary);
  stroke-width: 2.2;
  fill: none;
  pointer-events: none;
  flex-shrink: 0;
}

.search-input-box input {
  width: 100%;
  padding: 14px 16px 14px 46px !important;
  border-radius: 14px !important;
  background: var(--bg-bubble) !important;
  border: 1px solid var(--border-color) !important;
  color: var(--text-main) !important;
  font-size: 0.92rem !important;
  outline: none;
}

.search-input-box input:focus {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 3px rgba(157, 78, 221, 0.18);
}

.search-results-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 100%;
  max-height: 280px;
  overflow-y: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.45);
  z-index: 120;
  display: none;
  padding: 6px;
  box-sizing: border-box;
}

.search-results-dropdown.show {
  display: block;
}

.search-result-item {
  padding: 10px 14px;
  border-radius: 10px;
  color: var(--text-main);
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.search-result-item:hover {
  background: var(--bg-bubble);
  color: var(--primary);
}

.search-result-item .search-item-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

.search-result-item .search-item-title {
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-item .search-item-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* CUSTOM DROPDOWNS */
.custom-select-wrap {
  position: relative;
  width: 100%;
}

.custom-select-trigger {
  width: 100%;
  padding: 13px 16px;
  border-radius: 12px;
  background: var(--bg-bubble);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-size: 0.92rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  box-sizing: border-box;
}

.custom-select-trigger .trigger-content {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-select-options {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 100%;
  max-height: 260px;
  overflow-y: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  box-shadow: var(--shadow);
  z-index: 100;
  display: none;
  padding: 6px;
  box-sizing: border-box;
}

.custom-select-options.show {
  display: block;
}

.custom-option {
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text-main);
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: background 0.15s;
}

.custom-option:hover, .custom-option.selected {
  background: var(--bg-bubble);
  color: var(--primary);
}

.media-badge-icon {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: rgba(157, 78, 221, 0.15);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.72rem;
  flex-shrink: 0;
}

.media-badge-icon svg {
  width: 14px !important;
  height: 14px !important;
  stroke: currentColor;
  stroke-width: 2.2;
  fill: none;
}

/* TOAST ALERTAS */
.toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  min-width: 320px;
  max-width: 400px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.08);
  transform: translateX(120%);
  opacity: 0;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s ease;
}

.toast.show { transform: translateX(0); opacity: 1; }
.toast.hide { transform: translateX(120%); opacity: 0; }

.toast-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px; 
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.toast-icon svg {
  width: 22px !important;
  height: 22px !important;
  stroke-width: 2.5 !important;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.toast-content { flex: 1; }

.toast-title { 
  font-size: 1.05rem;
  font-weight: 800; 
  color: var(--text-main); 
  margin-bottom: 4px; 
  letter-spacing: -0.3px;
}

.toast-message { 
  font-size: 0.9rem; 
  color: var(--text-muted); 
  font-weight: 500;
  line-height: 1.3; 
}

.toast-success { border-color: rgba(34, 197, 94, 0.3); }
.toast-success .toast-icon { background: #eaf8f0; }
.toast-success .toast-icon svg { stroke: #22c55e; }
[data-theme="dark"] .toast-success .toast-icon { background: rgba(34, 197, 94, 0.15); }

.toast-error { border-color: rgba(239, 68, 68, 0.3); }
.toast-error .toast-icon { background: #fee2e2; }
.toast-error .toast-icon svg { stroke: #ef4444; }
[data-theme="dark"] .toast-error .toast-icon { background: rgba(239, 68, 68, 0.15); }

.toast-info { border-color: rgba(157, 78, 221, 0.3); }
.toast-info .toast-icon { background: #f3e8ff; }
.toast-info .toast-icon svg { stroke: var(--primary); }
[data-theme="dark"] .toast-info .toast-icon { background: rgba(157, 78, 221, 0.15); }

/* BOTTOM SHEET & DOCK MÓVIL */
.floating-dock-container { display: none; }

.bottom-sheet {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  z-index: 100;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.sheet-content {
  background: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  border-top-left-radius: 28px;
  border-top-right-radius: 28px;
  padding: 20px 18px 24px;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.32, 1, 0.23, 1);
  max-height: 80vh;
  overflow-y: auto;
}

.sheet-handle {
  width: 40px; height: 4px;
  background: var(--text-muted);
  opacity: 0.4;
  border-radius: 10px;
  margin: 0 auto 16px;
}

.sheet-close-bg { flex: 1; text-decoration: none; }
.bottom-sheet:target { visibility: visible; opacity: 1; }
.bottom-sheet:target .sheet-content { transform: translateY(0); }

.sheet-compact-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-bubble);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  text-decoration: none;
  color: var(--text-main);
  font-size: 0.95rem;
  font-weight: 700;
  height: 50px;
  margin-bottom: 8px;
}

.sheet-compact-item svg {
  width: 19px !important;
  height: 19px !important;
  stroke: var(--primary);
  stroke-width: 2.2;
  fill: none;
  flex-shrink: 0;
}

.sheet-compact-item span { flex: 1; }
.sheet-compact-item.item-danger { color: #f87171; border-color: rgba(248, 113, 113, 0.2); }
.sheet-compact-item.item-danger svg { stroke: #f87171; }

.sheet-btn-close {
  text-decoration: none;
  color: var(--text-muted);
  background: var(--bg-bubble);
  border: 1px solid var(--border-color);
  padding: 12px;
  border-radius: 14px;
  font-size: 0.9rem;
  font-weight: 700;
  text-align: center;
  margin-top: 6px;
  display: block;
}

/* =========================================
   ESTILOS PARA LOGIN, REGISTRO Y RECUPERAR
   ========================================= */

.app-viewport {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.landing-main {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 60px;
  flex: 1; 
  padding: 40px 28px;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

.landing-main > section:first-child {
  flex: 1;
  min-width: 300px;
  opacity: 0; 
  animation: fadeInUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.hero-title {
  font-size: 3rem;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 16px;
  color: var(--text-main);
}

.hero-title span {
  color: var(--primary);
}

.hero-desc {
  font-size: 1.1rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.login-box {
  flex: 1;
  min-width: 320px;
  max-width: 420px;
  background: var(--card-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 32px;
  box-shadow: var(--shadow);
  opacity: 0; 
  animation: fadeInUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.2s forwards;
}

/* =========================================
   NUEVAS ANIMACIONES (FADE, SHAKE, SPINNER)
   ========================================= */

@keyframes fadeInUp {
  0% {
    opacity: 0;
    transform: translateY(30px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

.login-box.error-shake {
  animation: shake 0.4s ease-in-out;
  border-color: rgba(239, 68, 68, 0.5); 
}

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #fff;
  animation: spin 1s ease-in-out infinite;
  margin-right: 8px;
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* =========================================
   ADAPTACIÓN RESPONSIVE (MÓVILES)
   ========================================= */
@media (max-width: 850px) {
  aside { display: none !important; }
  .desktop-nav-links { display: none !important; }
  header { padding: 14px 20px; }
  .dashboard-wrapper { flex-direction: column; }
  .dashboard-main { height: auto; }
  
  .single-column-layout { 
    margin: 8px 0 140px 0 !important;
    padding: 0 14px !important;
    width: 100% !important;
  }

  .toast-container { top: 14px; right: 14px; left: 14px; }
  .toast { min-width: unset; width: 100%; transform: translateY(-50px); }
  .toast.show { transform: translateY(0); }
  .toast.hide { transform: translateY(-50px); }

  .landing-main {
    flex-direction: column;
    gap: 30px;
    padding: 24px 16px;
    text-align: center;
    margin-bottom: 40px;
  }

  .hero-title {
    font-size: 2.2rem;
  }

  .login-box {
    width: 100%;
    max-width: 100%;
    padding: 24px 20px;
    text-align: left;
  }

  .floating-dock-container {
    position: fixed;
    bottom: 20px;
    left: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 50;
    pointer-events: none;
    padding: 0 16px;
  }

  .floating-dock {
    pointer-events: auto;
    background: var(--dock-bg);
    backdrop-filter: blur(24px);
    border: 1px solid var(--dock-border);
    border-radius: 36px;
    padding: 8px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.45);
  }

  .dock-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.68rem;
    font-weight: 700;
    padding: 6px 10px;
    border-radius: 18px;
  }

  .dock-link svg {
    width: 18px !important;
    height: 18px !important;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    margin-bottom: 2px;
  }

  .dock-link.active, .dock-link:hover { color: var(--primary); }

  .dock-footer {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 8px;
    text-align: center;
    user-select: none;
  }
}