/* ===== THEME BASICS (body + main background) ===== */
:root {
  --focus-contrast: #ffffff;
}
body.theme-light {
  --bg-color: #F5F5F5;
  background-color: var(--bg-color, #F5F5F5);
  color: #111827;
}
body.theme-light .w3-main {
  background-color: var(--bg-color, #F5F5F5);
  color: #111827;
}

body.theme-dark {
  --bg-color: #3f4e5a;
  background-color: var(--bg-color, #3f4e5a);
  color: #e5e7eb;
}
body.theme-dark .w3-main {
  background-color: var(--bg-color, #3f4e5a);
  color: #e5e7eb;
}

body.theme-grays {
  --bg-color: #f3f4f6;
  background-color: var(--bg-color, #f3f4f6);
  color: #111827;
}
body.theme-grays .w3-main {
  background-color: var(--bg-color, #f3f4f6);
  color: #111827;
}

/* ===== GLOBAL ACCENT HELPERS (driven by --focus-color) ===== */

/* Generic "panel/header" strip that uses the current focus color */
/* Generic "panel/header" strip that uses the current focus color */
.dr-panel-header {
  background: var(--focus-color);
  color: var(--focus-contrast, #fff);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}

/* Reusable accent background (also maps legacy .mycolor) */
.dr-accent-bg,
.mycolor {
  background: var(--focus-color);
  color: var(--focus-contrast, #fff);
}
.mycolor {
  color: var(--focus-contrast, #fff) !important;
}

/* Accent text only */
.dr-accent-text {
  color: var(--focus-color);
}

/* Accent border helper (for cards/buttons if you want) */
.dr-accent-border {
  border-color: var(--focus-color);
}


/* ===== SIDEBAR BASE ===== */

.side-nav {
  --side-width: 200px;
  --side-store-height: 40px;
  --side-footer-height: 40px;
  width: var(--side-width);
  padding: 0;
  z-index: 100;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  border-right: 2px solid var(--focus-color);
  background: rgba(255, 255, 255, 0.98);
  color: #0f172a;
  height: 100vh;
  overflow: hidden;
}

.side-store-bar {
  min-height: var(--side-store-height);
  height: var(--side-store-height);
  box-sizing: border-box;
  overflow: hidden;
}

body.theme-dark .side-nav {
  background: rgba(17, 24, 39, 0.98);
  border-right-color: var(--focus-color);
  color: #e5e7eb;
}

body.theme-grays .side-nav {
  background: rgba(243, 244, 246, 0.98);
  border-right-color: var(--focus-color);
}

/* store name bar */

.side-store-bar {
  padding: 2px;
  font-size: 11px;
  background: var(--focus-color);
  color: var(--focus-contrast, #fff);
}

.side-nav-links {
  position: fixed;
  top: var(--side-store-height);
  left: 0;
  width: calc(var(--side-width) - 2px);
  height: calc(100vh - var(--side-store-height) - var(--side-footer-height));
  display: block;
  overflow-y: auto !important;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
  scrollbar-gutter: auto;
  scrollbar-width: none;
  scrollbar-color: transparent transparent;
}

.side-nav-links:hover,
.side-nav-links:focus-within {
  scrollbar-width: thin;
  scrollbar-color: rgba(120, 133, 153, 0.55) transparent;
}

.side-nav-links::-webkit-scrollbar {
  width: 10px;
}

.side-nav-links::-webkit-scrollbar-track {
  background: transparent;
}

.side-nav-links::-webkit-scrollbar-thumb {
  background-color: transparent;
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: content-box;
  transition: background-color 0.18s ease;
}

.side-nav-links:hover::-webkit-scrollbar-thumb,
.side-nav-links:focus-within::-webkit-scrollbar-thumb {
  background-color: rgba(120, 133, 153, 0.55);
}

.side-nav-links:hover::-webkit-scrollbar-thumb:hover,
.side-nav-links:focus-within::-webkit-scrollbar-thumb:hover {
  background-color: rgba(120, 133, 153, 0.78);
}

/* links */

.side-link {
  padding: 6px 10px !important;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.side-link i.side-icon {
  width: 32px;          /* wider to comfortably fit 2xl icon */
  text-align: center;
  font-size: 1.75rem;   /* roughly 2x the old size */
  line-height: 1;
  flex-shrink: 0;
}

.side-link:hover {
  text-decoration: none;
}

body.theme-light .side-link:hover {
  background: rgba(23, 103, 167, 0.06);
}

body.theme-dark .side-link:hover {
  background: rgba(148, 163, 184, 0.15);
}

body.theme-grays .side-link:hover {
  background: rgba(107, 114, 128, 0.10);
}

/* active link */

.side-active {
  font-weight: 600;
  border-left: 4px solid var(--focus-color);
}

body.theme-light .side-active {
  background: color-mix(in srgb, var(--focus-color) 12%, #ffffff) !important;
  color: var(--focus-color) !important;
}

body.theme-dark .side-active {
    background: color-mix(in srgb, var(--focus-color) 28%, #0b1626) !important;
    color: var(--focus-color) !important;
    border-left-color: var(--focus-color);
  }

body.theme-grays .side-active {
  background: color-mix(in srgb, var(--focus-color) 12%, #f9fafb) !important;
  color: #111827 !important;
  border-left-color: var(--focus-color);
}

/* when we explicitly hide the sidebar */
#mySidebar.sidebar-hidden {
  display: none !important;
}

.side-hide-bottom {
  position: fixed;
  left: 0;
  bottom: 0;
  width: calc(var(--side-width) - 2px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: var(--side-footer-height);
  padding: 0 6px 1px;
  box-sizing: border-box;
  border-top: 1px solid rgba(15, 23, 42, 0.10);
  background: inherit;
  z-index: 1;
}

.side-hide-bottom .side-hide-btn {
  border: 0;
  background: transparent;
  padding: 0;
  width: 32px;
  height: 32px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.side-bottom-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  flex: 0 0 auto;
}

.side-icon-mode-btn[aria-pressed="true"] {
  background: color-mix(in srgb, var(--focus-color) 13%, transparent);
  border-radius: 999px;
}

body.sidenav-icon-mode .side-nav {
  --side-store-height: 0px;
}

body.sidenav-icon-mode .side-store-bar,
body.sidenav-icon-mode .side-station-label,
body.sidenav-icon-mode .side-link > span {
  display: none !important;
}

body.sidenav-icon-mode .side-link {
  justify-content: center;
  gap: 0;
  padding-left: 4px !important;
  padding-right: 4px !important;
}

body.sidenav-icon-mode .side-link i.side-icon {
  width: 100%;
}

body.sidenav-icon-mode .side-hide-bottom {
  justify-content: center;
  gap: 0;
  padding-left: 1px;
  padding-right: 1px;
}

body.sidenav-icon-mode .side-bottom-actions {
  gap: 0;
}

body.sidenav-icon-mode .side-hide-bottom .side-hide-btn {
  width: 29px;
}

body.sidenav-icon-mode .side-icon-mode-btn .side-hide-icon {
  font-size: 1.15rem;
}

@media (max-width: 992px) {
  .side-icon-mode-btn {
    display: none !important;
  }
}

.side-hide-bottom .side-hide-icon {
  font-size: 1.6rem; /* nice visible circle */
}

.side-station-label {
  font-size: 11px;
  color: rgba(0,0,0,0.6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}
body.theme-dark .side-station-label {
  color: rgba(255,255,255,0.75);
}

body.theme-dark .side-hide-bottom {
  border-top-color: rgba(255,255,255,0.14);
}

body.theme-grays .side-hide-bottom {
  border-top-color: rgba(15, 23, 42, 0.10);
}


/* floating actions for desktop when the sidebar is hidden */
#sideShowBtn,
#sideCollapsedLogoutBtn {
  position: fixed;
  top: 8px;
  z-index: 9999;
  display: none;
}

#sideShowBtn {
  left: 8px;
}

#sideCollapsedLogoutBtn {
  left: 60px;
}

/* === AI Assist Drawer === */
.ai-drawer-overlay{
  position:fixed; inset:0; background:rgba(0,0,0,0.35);
  z-index:11000; opacity:0; pointer-events:none;
  transition:opacity .15s ease;
}
.ai-drawer-overlay.show{ opacity:1; pointer-events:auto; }
.ai-drawer{
  position:fixed; top:0; right:-420px; width:360px; max-width:92vw; height:100vh;
  background: rgba(255,255,255,0.96);
  color:#0f172a;
  box-shadow:-6px 0 18px rgba(0,0,0,0.35);
  z-index:11001; display:flex; flex-direction:column;
  transition:right .18s ease;
}
body.theme-dark .ai-drawer{
  background: rgba(15,23,42,0.95);
  color:#e5e7eb;
}
.ai-drawer.open{ right:0; }
.ai-drawer.ai-drawer-pos-right{
  top:0;
  right:-420px;
  left:auto;
  bottom:auto;
  width:360px;
  max-width:92vw;
  height:100vh;
  max-height:none;
  box-shadow:-6px 0 18px rgba(0,0,0,0.35);
  transition:right .18s ease;
}
.ai-drawer.ai-drawer-pos-right.open{ right:0; }
.ai-drawer.ai-drawer-pos-bottom{
  top:auto;
  right:0;
  left:0;
  bottom:-62vh;
  width:100vw;
  max-width:100vw;
  height:42vh;
  max-height:560px;
  min-height:280px;
  box-shadow:0 -6px 18px rgba(0,0,0,0.35);
  transition:bottom .18s ease;
}
.ai-drawer.ai-drawer-pos-bottom.open{
  right:0;
  bottom:0;
}
.ai-drawer-header{
  display:flex; justify-content:space-between; align-items:center;
  padding:12px 14px; font-weight:700; border-bottom:1px solid rgba(0,0,0,0.08);
}
body.theme-dark .ai-drawer-header{ border-color:rgba(255,255,255,0.1); }
.ai-close-btn{
  background:transparent; border:0; font-size:22px; cursor:pointer; color:inherit;
}
.ai-chat-log{
  flex:1 1 auto; overflow:auto; padding:10px 14px; gap:6px; display:flex; flex-direction:column;
}
.ai-chat-note{ font-size:12px; opacity:0.7; }
.ai-msg{ padding:6px 8px; border-radius:8px; font-size:13px; line-height:1.35; }
.ai-msg.ai-user{ background: color-mix(in srgb, var(--focus-color,#1767a7) 14%, #fff); color:#0f172a; }
.ai-msg.ai-bot{ background: rgba(0,0,0,0.04); }
.ai-link-msg{ padding:0; background:transparent!important; }
.ai-help-link{
  display:block;
  padding:6px 8px;
  border-radius:8px;
  color:var(--focus-color,#1767a7);
  text-decoration:none;
  font-weight:600;
}
.ai-help-link:hover{
  background:rgba(0,0,0,0.05);
  text-decoration:underline;
}
body.theme-dark .ai-msg.ai-user{ background: color-mix(in srgb, var(--focus-color,#1767a7) 26%, #0b1626); color:#e5e7eb; }
body.theme-dark .ai-msg.ai-bot{ background: rgba(255,255,255,0.04); }
body.theme-dark .ai-help-link:hover{ background:rgba(255,255,255,0.06); }
.ai-input-wrap{
  padding:10px 14px; border-top:1px solid rgba(0,0,0,0.08);
  display:flex; flex-direction:column; gap:8px;
}
body.theme-dark .ai-input-wrap{ border-color:rgba(255,255,255,0.1); }
.ai-input-wrap textarea{
  width:100%; resize:vertical; min-height:60px;
  border:1px solid rgba(148,163,184,0.6);
  border-radius:8px; padding:8px; font-size:13px;
  background:inherit; color:inherit;
}
.ai-actions{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
}
.ai-pin-actions{
  display:flex;
  align-items:center;
  gap:6px;
}
.ai-main-actions{
  display:flex;
  align-items:center;
  gap:8px;
}
.ai-pin-btn{
  width:30px;
  height:30px;
  border-radius:8px;
  border:1px solid rgba(148,163,184,0.6);
  background:transparent;
  color:inherit;
  cursor:pointer;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  font-size:13px;
}
.ai-pin-btn:hover{
  border-color: var(--focus-color, #1767a7);
  color: var(--focus-color, #1767a7);
}
.ai-pin-btn.is-active{
  border-color: var(--focus-color, #1767a7);
  background: color-mix(in srgb, var(--focus-color, #1767a7) 18%, transparent);
  color: var(--focus-color, #1767a7);
}
.ai-btn{
  padding:6px 12px; border-radius:8px; border:1px solid var(--focus-color,#1767a7);
  background: var(--focus-color,#1767a7); color: var(--focus-contrast, #fff); cursor:pointer;
}
.ai-btn-ghost{
  background: transparent; color: inherit; border-color: rgba(148,163,184,0.6);
}
/* ===== PAGEBAR THEME VARIANTS ===== */

/*
 * Pagebars are navigation surfaces, not full theme-shade panels. Keep their
 * base surface readable and use the focus color as a restrained tint. This
 * prevents saturated store shades (especially navy in dark mode) from
 * overpowering every toolbar while retaining the selected theme identity.
 */
/* Light (default) – bright surface with a subtle focus tint */
body.theme-light .pagebar {
  background: rgba(255, 255, 255, 0.92);
  background: color-mix(in srgb, rgba(255, 255, 255, 0.94) 96%, var(--focus-color, #1767a7));
  border-color: color-mix(in srgb, var(--focus-color, #1767a7) 14%, rgba(15, 23, 42, 0.12));
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.10);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* Dark – neutral slate surface; never use the saturated store shade directly */
body.theme-dark .pagebar {
  background: rgba(15, 23, 42, 0.92);
  background: color-mix(in srgb, rgba(15, 23, 42, 0.94) 92%, var(--focus-color, #1767a7));
  border-color: color-mix(in srgb, var(--focus-color, #1767a7) 22%, rgba(148, 163, 184, 0.36));
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.48);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}


/* Grays – neutral soft-gray surface with restrained focus tint */
body.theme-grays .pagebar {
  background: rgba(249, 250, 251, 0.92);
  background: color-mix(in srgb, rgba(249, 250, 251, 0.94) 97%, var(--focus-color, #64748b));
  border-color: color-mix(in srgb, var(--focus-color, #64748b) 12%, #d1d5db);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
/* Default accent background (light + grays) */
.dr-accent-bg {
  background-color: var(--focus-color, #1767a7);
  color: #fff;
}

/* In dark theme, use the lighter panel color instead of full accent */
body.theme-dark .dr-accent-bg {
  background-color: #3f4e5a;         /* same “lighter back color” you’re using in dark panels */
  color: #f9fafb;
  border: 1px solid rgba(148,163,184,0.6);
}
