:root {
  --dash-sidebar: #191424;
  --dash-sidebar-soft: #241d32;
  --dash-accent: #8057ff;
  --dash-accent-strong: #6940e8;
  --dash-pink: #d9468f;
  --dash-ink: #211a2e;
  --dash-muted: #797181;
  --dash-border: #e8e3ee;
  --dash-canvas: #f7f5fa;
  --dash-surface: #ffffff;
  --menu-width: 274px;
  --menu-width-collapsed: 78px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  overflow: hidden;
  color: var(--dash-ink);
  background: var(--dash-canvas);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

#container {
  display: flex;
  width: 100%;
  min-height: 100vh;
  background: var(--dash-canvas);
}

#sidebar {
  position: relative;
  z-index: 30;
  display: flex;
  flex: 0 0 var(--menu-width);
  width: var(--menu-width);
  min-width: var(--menu-width);
  max-width: var(--menu-width);
  height: 100vh;
  padding: 18px 14px 16px;
  overflow: hidden;
  color: #f8f5ff;
  border: 0;
  border-radius: 0;
  background:
    radial-gradient(circle at 30% 0, rgba(128, 87, 255, 0.24), transparent 18rem),
    linear-gradient(180deg, #1d172a 0%, var(--dash-sidebar) 100%);
  box-shadow: 16px 0 50px rgba(31, 20, 48, 0.09);
  transition: flex-basis 0.24s ease, width 0.24s ease, min-width 0.24s ease;
}

#sidebar.collapsed {
  flex-basis: var(--menu-width-collapsed) !important;
  width: var(--menu-width-collapsed) !important;
  min-width: var(--menu-width-collapsed) !important;
  max-width: var(--menu-width-collapsed) !important;
  padding: 18px 10px 16px;
}

.sidebar-inner {
  display: flex;
  width: 100%;
  min-width: 0;
  flex-direction: column;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 0 5px;
  gap: 11px;
}

.brand-mark {
  display: grid;
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 14px;
  color: #fff;
  background: linear-gradient(135deg, var(--dash-accent), var(--dash-pink));
  box-shadow: 0 12px 26px rgba(103, 59, 217, 0.32);
  font-size: 1.08rem;
  font-weight: 900;
}

.brand-copy {
  min-width: 0;
  flex: 1;
}

.brand-copy strong,
.brand-copy small {
  display: block;
  white-space: nowrap;
}

.brand-copy strong {
  color: #fff;
  font-size: 0.92rem;
  letter-spacing: -0.01em;
}

.brand-copy small {
  margin-top: 1px;
  color: #a79daf;
  font-size: 0.66rem;
}

#toggle-sidebar {
  display: grid;
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  margin: 0;
  padding: 0;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 9px;
  color: #b9afc1;
  background: rgba(255, 255, 255, 0.05);
}

#toggle-sidebar:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

#toggle-sidebar svg {
  width: 15px;
  height: 15px;
}

.assistant-card {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 62px;
  margin: 24px 3px 18px;
  padding: 10px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.045);
}

.assistant-avatar {
  position: relative;
  display: grid;
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 12px;
  color: #d8cbff;
  background: rgba(128, 87, 255, 0.16);
  font-size: 0.76rem;
  font-weight: 850;
}

.assistant-avatar::after {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 9px;
  height: 9px;
  border: 2px solid var(--dash-sidebar);
  border-radius: 50%;
  background: #39d49d;
  content: "";
}

.assistant-copy {
  min-width: 0;
}

#NombreAs {
  display: block;
  max-width: 160px;
  margin: 0;
  overflow: hidden;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 780;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.assistant-copy small {
  display: block;
  margin-top: 2px;
  color: #9e94a8;
  font-size: 0.65rem;
}

.balance-card {
  margin: 0 3px 20px;
  padding: 13px 14px;
  border: 1px solid rgba(128, 87, 255, 0.2);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(128, 87, 255, 0.13), rgba(217, 70, 143, 0.08));
}

.balance-label {
  color: #a9a0b1;
  font-size: 0.65rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.balance-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 5px;
}

#balanceValue {
  color: #fff;
  font-size: 1.15rem;
  font-weight: 850;
  letter-spacing: -0.03em;
}

.balance-link {
  color: #d8cbff;
  font-size: 0.68rem;
  font-weight: 750;
  text-decoration: none;
}

.sidebar-navigation {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
}

.sidebar-section-title {
  margin: 9px 12px 7px;
  color: #716879;
  font-size: 0.61rem;
  font-weight: 850;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 44px;
  margin: 2px 0;
  padding: 0 12px;
  gap: 12px;
  overflow: hidden;
  border: 0;
  border-radius: 13px;
  color: #b8afc0;
  background: transparent;
  font-size: 0.78rem;
  font-weight: 650;
  text-align: left;
  text-decoration: none;
  white-space: nowrap;
}

.nav-link svg {
  flex: 0 0 19px;
  width: 19px;
  height: 19px;
  margin: 0;
}

.nav-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.055);
}

.nav-link.active {
  color: #fff;
  background: linear-gradient(90deg, rgba(128, 87, 255, 0.25), rgba(128, 87, 255, 0.09));
  box-shadow: inset 3px 0 0 #9b7bff;
}

.nav-link.active svg {
  color: #bdaaff;
}

.nav-link.is-danger {
  color: #d69aa8;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

#sidebar.collapsed .brand-copy,
#sidebar.collapsed .assistant-copy,
#sidebar.collapsed .balance-card,
#sidebar.collapsed .sidebar-section-title,
#sidebar.collapsed .menu-label {
  display: none;
}

#sidebar.collapsed .sidebar-brand {
  justify-content: center;
  flex-wrap: wrap;
}

#sidebar.collapsed #toggle-sidebar {
  order: 2;
}

#sidebar.collapsed .assistant-card {
  justify-content: center;
  margin-top: 18px;
  padding: 8px;
}

#sidebar.collapsed .nav-link {
  justify-content: center;
  padding: 0;
}

#main-content {
  display: flex;
  min-width: 0;
  min-height: 100vh;
  height: 100vh;
  flex: 1;
  overflow: hidden;
  border-radius: 0;
  background: var(--dash-canvas);
}

.dashboard-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 76px;
  padding: 13px 26px;
  border-bottom: 1px solid rgba(226, 219, 234, 0.86);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(16px);
}

.topbar-copy {
  min-width: 0;
}

.topbar-copy small,
.topbar-copy strong {
  display: block;
}

.topbar-copy small {
  margin-bottom: 2px;
  color: var(--dash-muted);
  font-size: 0.66rem;
  font-weight: 720;
}

#dashboardPageTitle {
  margin: 0;
  color: var(--dash-ink);
  font-size: 1.08rem;
  font-weight: 820;
  letter-spacing: -0.02em;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.service-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid #dcefe8;
  border-radius: 999px;
  color: #167255;
  background: #f2fbf7;
  font-size: 0.7rem;
  font-weight: 750;
}

.service-status::before {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #27b57f;
  box-shadow: 0 0 0 4px rgba(39, 181, 127, 0.11);
  content: "";
}

#dashboardPreviewButton {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  margin: 0;
  padding: 0 16px;
  gap: 8px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, var(--dash-accent), var(--dash-accent-strong));
  box-shadow: 0 10px 24px rgba(105, 64, 232, 0.22);
  font-size: 0.76rem;
  font-weight: 780;
}

#dashboardPreviewButton svg {
  width: 16px;
  height: 16px;
}

.dashboard-frame {
  min-height: 0;
  flex: 1;
  padding: 0;
  overflow: hidden;
  background: var(--dash-canvas);
}

#content-frame {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  border-radius: 0;
  background: var(--dash-canvas);
  box-shadow: none;
}

#mobile-toggle-sidebar {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 50;
  display: none;
  width: 42px;
  height: 42px;
  margin: 0;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 13px;
  color: #fff;
  background: var(--dash-sidebar);
  box-shadow: 0 12px 30px rgba(27, 18, 41, 0.25);
}

#mobile-toggle-sidebar svg {
  width: 19px;
  height: 19px;
}

/* El chat se abre desde la cabecera del panel. */
#chat-button {
  display: none !important;
}

#chat-overlay {
  background: rgba(24, 17, 35, 0.38);
  backdrop-filter: blur(7px);
}

#chat-widget {
  right: 24px;
  bottom: 24px;
  width: min(410px, calc(100vw - 32px));
  height: min(650px, calc(100vh - 48px));
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 30px 90px rgba(30, 19, 48, 0.28);
}

#widget-header {
  min-height: 68px;
  padding: 0 18px;
  color: #fff;
  background:
    radial-gradient(circle at 85% 20%, rgba(217, 70, 143, 0.36), transparent 11rem),
    linear-gradient(135deg, #271d38, #5631b6);
}

#widget-header h2 {
  font-size: 0.95rem;
  font-weight: 780;
}

.widget-btn {
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
}

#input-row {
  padding: 12px;
  border-top: 1px solid var(--dash-border);
  background: #fff;
}

#chat-user-input {
  min-height: 45px;
  border: 1px solid var(--dash-border);
  border-radius: 13px;
  background: #faf9fc;
}

#send-btn {
  min-height: 45px;
  border-radius: 13px;
  background: var(--dash-accent);
}

@media (max-width: 920px) {
  #mobile-toggle-sidebar {
    display: grid;
  }

  #sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(286px, calc(100vw - 56px));
    min-width: min(286px, calc(100vw - 56px));
    max-width: min(286px, calc(100vw - 56px));
    transform: translateX(0);
    transition: transform 0.24s ease;
  }

  #sidebar.collapsed {
    width: min(286px, calc(100vw - 56px)) !important;
    min-width: min(286px, calc(100vw - 56px)) !important;
    max-width: min(286px, calc(100vw - 56px)) !important;
    padding: 18px 14px 16px;
    transform: translateX(-105%);
  }

  #sidebar.collapsed .brand-copy,
  #sidebar.collapsed .assistant-copy,
  #sidebar.collapsed .balance-card,
  #sidebar.collapsed .sidebar-section-title,
  #sidebar.collapsed .menu-label {
    display: block;
  }

  #sidebar.collapsed .sidebar-brand,
  #sidebar.collapsed .assistant-card,
  #sidebar.collapsed .nav-link {
    justify-content: flex-start;
  }

  #sidebar.collapsed .nav-link {
    padding: 0 12px;
  }

  .dashboard-topbar {
    min-height: 70px;
    padding: 10px 14px 10px 68px;
  }
}

@media (max-width: 620px) {
  .service-status,
  #dashboardPreviewButton span {
    display: none;
  }

  #dashboardPreviewButton {
    width: 40px;
    padding: 0;
    justify-content: center;
  }

  #chat-widget {
    right: 10px;
    bottom: 10px;
    width: calc(100vw - 20px);
    height: calc(100vh - 20px);
    border-radius: 20px;
  }
}

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