/* Customer portal, signed-in layout (views/themes/…/template_parts/sidebar.php): sidebar + top bar like the staff
   panel. Light and dark follow <html data-theme>. Only applies while the sidebar is on the page. */
:root {
  --cp-side-w: 256px;
  --cp-top-h: 64px;
  --cp-bg: #f4f6fb;
  --cp-surface: #ffffff;
  --cp-text: #0f172a;
  --cp-muted: #64748b;
  --cp-line: #e5e8ef;
  --cp-hover: #f1f4f9;
  --cp-accent: #4f46e5;
  --cp-accent-soft: rgba(79, 70, 229, .1);
}
html[data-theme="dark"] {
  --cp-bg: #0b1120;
  --cp-surface: #111827;
  --cp-text: #e5e7eb;
  --cp-muted: #94a3b8;
  --cp-line: #1f2a3a;
  --cp-hover: #1a2333;
  --cp-accent: #818cf8;
  --cp-accent-soft: rgba(129, 140, 248, .14);
}

body.customers:has(.cp-sidebar) { background: var(--cp-bg) !important; padding-top: 0 !important; }

/* sidebar */
.cp-sidebar { position: fixed; top: 0; left: 0; bottom: 0; width: var(--cp-side-w); z-index: 1040; display: flex; flex-direction: column;
  background: var(--cp-surface); border-right: 1px solid var(--cp-line); transition: transform .25s ease; }
.cp-brand { height: var(--cp-top-h); display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 18px; border-bottom: 1px solid var(--cp-line); flex: none; }
.cp-brand a { display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--cp-text) !important; font-weight: 700; font-size: 16px; text-decoration: none !important; }
.cp-brand img { max-height: 36px; max-width: 180px; object-fit: contain; }
.cp-close { display: none; border: 0; background: none; color: var(--cp-muted); font-size: 18px; width: 36px; height: 36px; border-radius: 8px; }
.cp-close:hover { background: var(--cp-hover); }
.cp-scroll { flex: 1; overflow-y: auto; padding: 8px 12px 16px; scrollbar-width: thin; }
.cp-nav { list-style: none; margin: 0; padding: 0; }
.cp-nav > li.cp-label { padding: 16px 10px 6px; font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--cp-muted); }
.cp-nav > li:not(.cp-label) > a { display: flex; align-items: center; gap: 12px; padding: 9px 10px; margin: 1px 0; border-radius: 10px; color: var(--cp-text) !important;
  font-size: 14px; font-weight: 500; text-decoration: none !important; line-height: 1.3; transition: background .15s, color .15s; }
.cp-nav > li:not(.cp-label) > a:hover { background: var(--cp-hover); }
.cp-nav > li > a i, .cp-nav > li > a .cp-ic { width: 20px; text-align: center; font-size: 15px; color: var(--cp-muted); flex: none; }
.cp-nav > li.active > a { background: var(--cp-accent-soft); color: var(--cp-accent) !important; font-weight: 600; }
.cp-nav > li.active > a i { color: var(--cp-accent); }
/* the old dark-mode switch item is in the top bar now */
.cp-sidebar .crm-theme-toggle { display: none !important; }
/* "Account" title only when something was added under it */
.cp-nav > li.cp-label-hook:last-child, .cp-nav > li.cp-label-hook:has(+ li.cp-label) { display: none; }

.cp-me { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--cp-line); flex: none; }
.cp-me-img { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; flex: none; background: var(--cp-hover); }
.cp-me-txt { flex: 1; min-width: 0; line-height: 1.25; }
.cp-me-txt b, .cp-me-txt span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cp-me-txt b { font-size: 13.5px; color: var(--cp-text); }
.cp-me-txt span { font-size: 12px; color: var(--cp-muted); }
.cp-me-out { width: 34px; height: 34px; border-radius: 8px; display: flex; align-items: center; justify-content: center; color: var(--cp-muted) !important; flex: none; }
.cp-me-out:hover { background: rgba(220, 38, 38, .1); color: #dc2626 !important; }

/* top bar */
.cp-topbar { position: sticky; top: 0; z-index: 1030; height: var(--cp-top-h); margin-left: var(--cp-side-w); display: flex; align-items: center; gap: 12px; padding: 0 24px;
  background: color-mix(in srgb, var(--cp-surface) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--cp-line); }
.cp-burger { display: none; border: 0; background: none; width: 40px; height: 40px; border-radius: 10px; color: var(--cp-text); font-size: 18px; flex: none; }
.cp-burger:hover { background: var(--cp-hover); }
.cp-title { flex: 1; min-width: 0; font-weight: 600; font-size: 17px; color: var(--cp-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cp-actions { list-style: none; margin: 0; padding: 0; display: flex; align-items: center; gap: 6px; }
.cp-actions > li { position: relative; }
.cp-act { position: relative; width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; color: var(--cp-muted) !important; font-size: 16px; text-decoration: none !important; }
.cp-act:hover { background: var(--cp-hover); color: var(--cp-text) !important; }
.cp-act .crm-sun { display: none; }
html[data-theme="dark"] .cp-act .crm-sun { display: inline; color: #fbbf24; }
html[data-theme="dark"] .cp-act .crm-moon { display: none; }
.cp-dot { position: absolute; top: 4px; right: 4px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 999px; background: #ef4444; color: #fff; font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.cp-profile { display: flex !important; align-items: center; gap: 8px; padding: 4px 10px 4px 4px !important; border-radius: 999px; border: 1px solid var(--cp-line); color: var(--cp-text) !important; text-decoration: none !important; }
.cp-profile:hover { background: var(--cp-hover); }
.cp-profile img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; margin: 0 !important; }
.cp-profile-name { font-size: 13.5px; font-weight: 600; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cp-profile .fa-chevron-down { font-size: 10px; color: var(--cp-muted); }
.cp-actions .dropdown-menu { min-width: 240px; padding: 6px; border-radius: 12px; border: 1px solid var(--cp-line); background: var(--cp-surface); box-shadow: 0 12px 32px rgba(15, 23, 42, .14); margin-top: 8px; }
.cp-actions .dropdown-menu > li > a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--cp-text) !important; font-size: 13.5px; }
.cp-actions .dropdown-menu > li > a i { width: 16px; text-align: center; color: var(--cp-muted); }
.cp-actions .dropdown-menu > li > a:hover { background: var(--cp-hover) !important; }
.cp-actions .dropdown-menu > li > a .badge { margin-left: auto; }
.cp-actions .dropdown-menu .divider { margin: 6px 4px; background: var(--cp-line); }
.cp-dd-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--cp-line); margin-bottom: 6px; line-height: 1.3; }
.cp-dd-head b { display: block; color: var(--cp-text); font-size: 14px; }
.cp-dd-head span { display: block; color: var(--cp-muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; }
.cp-dd-label { padding: 6px 10px 4px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--cp-muted); }
.cp-lang-list { max-height: 168px; overflow-y: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 2px; padding: 0 4px; }
.cp-lang-list a { padding: 6px 8px; border-radius: 6px; font-size: 13px; color: var(--cp-text) !important; text-decoration: none !important; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cp-lang-list a:hover { background: var(--cp-hover); }
.cp-lang-list a.active { background: var(--cp-accent-soft); color: var(--cp-accent) !important; font-weight: 600; }

/* page area next to the sidebar */
body.customers:has(.cp-sidebar) #wrapper { margin-left: var(--cp-side-w); }
/* the footer is full width by itself: it keeps clear of the sidebar with padding instead of a margin */
body.customers:has(.cp-sidebar) .footer { margin-left: 0; padding-left: var(--cp-side-w); box-sizing: border-box; width: 100%; }
body.customers:has(.cp-sidebar) .footer .container { width: auto; max-width: 100%; }
body.customers:has(.cp-sidebar) #wrapper { min-height: calc(100vh - var(--cp-top-h) - 60px); padding-top: 8px; }
body.customers:has(.cp-sidebar) #content > .container { width: auto; max-width: 1280px; padding-left: 28px; padding-right: 28px; }
body.customers:has(.cp-sidebar) .footer { background: transparent; border-top: 1px solid var(--cp-line); color: var(--cp-muted); }

.cp-overlay { display: none; }

/* tablets and phones: the sidebar slides in over the page */
@media (max-width: 991px) {
  .cp-sidebar { transform: translateX(-100%); box-shadow: none; width: min(300px, 86vw); }
  body.cp-open .cp-sidebar { transform: none; box-shadow: 16px 0 48px rgba(0, 0, 0, .25); }
  body.cp-open .cp-overlay { display: block; position: fixed; inset: 0; z-index: 1035; background: rgba(15, 23, 42, .5); }
  body.cp-open { overflow: hidden; }
  .cp-close { display: flex; align-items: center; justify-content: center; }
  .cp-topbar { margin-left: 0; padding: 0 12px; gap: 8px; }
  .cp-burger { display: flex; align-items: center; justify-content: center; }
  body.customers:has(.cp-sidebar) #wrapper { margin-left: 0; }
  body.customers:has(.cp-sidebar) .footer { padding-left: 0; }
  body.customers:has(.cp-sidebar) #content > .container { padding-left: 16px; padding-right: 16px; }
}
@media (max-width: 480px) {
  .cp-profile-name, .cp-profile .fa-chevron-down { display: none; }
  .cp-profile { padding: 3px !important; }
  .cp-title { font-size: 15px; }
  .cp-actions { gap: 2px; }
  .cp-actions .dropdown-menu { position: fixed; top: calc(var(--cp-top-h) - 4px); right: 8px; left: 8px; min-width: 0; }
}
