/* ═══════════════════════════════════════════════════
   SIDEBAR — dark navy theme
   ═══════════════════════════════════════════════════ */

:root {
    --sb-bg:               #1e295b;
    --sb-bg-hover:         rgba(255,255,255,0.07);
    --sb-active-pill:      #ffffff;
    --sb-active-text:      #1e295b;
    --sb-text:             rgba(255,255,255,0.65);
    --sb-text-hover:       rgba(255,255,255,0.90);
    --sb-label:            rgba(255,255,255,0.35);
    --sb-border:           rgba(255,255,255,0.10);
    --sb-soon:             rgba(255,255,255,0.28);
    --sb-badge-bg:         #e74c3c;
    --sb-badge-warn:       #f39c12;
    --sb-soon-tag-bg:      rgba(255,255,255,0.12);
    --sb-width:            264px;
    --sb-width-collapsed:  64px;
}

/* ── Sidebar shell ── */
#sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sb-width);
    height: 100vh;
    background: var(--sb-bg);
    z-index: 200;
    display: flex;
    flex-direction: column;
    transition: width 0.25s ease;
    overflow: hidden;
}

/* ── Collapsed state (toggled by JS on <body>) ── */
body.sidebar-collapsed #sidebar          { width: var(--sb-width-collapsed); }
body.sidebar-collapsed #topbar           { margin-left: var(--sb-width-collapsed); }
body.sidebar-collapsed .main             { margin-left: var(--sb-width-collapsed); }

body.sidebar-collapsed .sidebar-brand-name,
body.sidebar-collapsed .sidebar-section-label,
body.sidebar-collapsed .sidebar-nav-list > li > a > span,
body.sidebar-collapsed .sidebar-nav-list > li > span > span:not(.sidebar-badge):not(.sidebar-soon-tag),
body.sidebar-collapsed .sidebar-group-toggle > span:not(.sidebar-chevron),
body.sidebar-collapsed .sidebar-badge,
body.sidebar-collapsed .sidebar-soon-tag,
body.sidebar-collapsed .sidebar-sublist,
body.sidebar-collapsed .user-info        { display: none; }

body.sidebar-collapsed .sidebar-group-toggle { justify-content: center; padding: 0; }
body.sidebar-collapsed .sidebar-chevron      { display: none; }
body.sidebar-collapsed .sidebar-nav-list > li > a { justify-content: center; padding: 0; }
body.sidebar-collapsed .sidebar-nav-list > li > span { justify-content: center; padding: 0; }
body.sidebar-collapsed #sidebar-user-footer  { justify-content: center; padding: 12px 0; gap: 0; }
body.sidebar-collapsed .settings-gear-btn   { margin: 0; }

/* Collapsed sidebar header: the toggle button now lives in the topbar, so
   the header just centers the brand logo when there's no room for the
   text label. */
body.sidebar-collapsed #sidebar-header { padding: 0; justify-content: center; }
body.sidebar-collapsed .sidebar-brand  { gap: 0; }

#sidebar-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

/* ── Sidebar header ── */
#sidebar-header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    height: 56px;
    border-bottom: 1px solid var(--sb-border);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    overflow: hidden;
}

/* Logo shown as a white "app icon" badge — works on any dark background */
.sidebar-brand-logo-wrap {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: white;
    padding: 3px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-brand-logo {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.sidebar-brand-name {
    font-size: 15px;
    font-weight: 700;
    color: white;
    white-space: nowrap;
    letter-spacing: 0.01em;
}

/* ── Scrollable nav ── */
#sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px 0 16px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.15) transparent;
}

#sidebar-nav::-webkit-scrollbar { width: 4px; }
#sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15);
    border-radius: 4px;
}

/* ── Section labels ── */
.sidebar-section-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--sb-label);
    padding: 16px 20px 6px;
}

/* ── Nav list ── */
.sidebar-nav-list {
    list-style: none;
    margin: 0;
    padding: 0 10px;
}

.sidebar-nav-list li {
    margin-bottom: 2px;
}

/* Regular nav items */
.sidebar-nav-list > li > a,
.sidebar-nav-list > li > span {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 10px;
    height: 38px;
    border-radius: 8px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--sb-text);
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-nav-list > li > a svg,
.sidebar-nav-list > li > span svg {
    flex-shrink: 0;
    opacity: 0.7;
}

.sidebar-nav-list > li > a:hover {
    background: var(--sb-bg-hover);
    color: var(--sb-text-hover);
}

.sidebar-nav-list > li > a:hover svg {
    opacity: 1;
}

/* Active pill */
.sidebar-nav-list > li.is-active > a {
    background: var(--sb-active-pill);
    color: var(--sb-active-text);
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0,0,0,0.18);
}

.sidebar-nav-list > li.is-active > a svg {
    opacity: 1;
}

/* Coming-soon items */
.sidebar-nav-list > li.is-soon > span {
    cursor: default;
    color: var(--sb-soon);
}

.sidebar-nav-list > li.is-soon > span svg {
    opacity: 0.4;
}

/* ── Badge (validations count, IIA warnings) ── */
.sidebar-badge {
    margin-left: auto;
    flex-shrink: 0;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    font-size: 10px;
    font-weight: 700;
    background: var(--sb-badge-bg);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.sidebar-badge--warn {
    background: var(--sb-badge-warn);
    color: #1e295b;
}

/* ── Soon tag ── */
.sidebar-soon-tag {
    margin-left: auto;
    flex-shrink: 0;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--sb-soon-tag-bg);
    color: rgba(255,255,255,0.45);
    border-radius: 4px;
    padding: 2px 5px;
}

/* ══════════════════════════════════════════
   Expandable groups (Outgoing / Incoming)
   ══════════════════════════════════════════ */

.sidebar-group {
    margin-bottom: 2px;
}

.sidebar-group-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    height: 38px;
    padding: 0 10px;
    border: none;
    background: transparent;
    border-radius: 8px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--sb-text);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    text-align: left;
}

.sidebar-group-toggle svg:first-child {
    flex-shrink: 0;
    opacity: 0.7;
}

.sidebar-group-toggle span:not(.sidebar-chevron) {
    flex: 1;
}

.sidebar-chevron {
    flex-shrink: 0;
    opacity: 0.5;
    transition: transform 0.2s ease;
    display: flex;
    align-items: center;
}

.sidebar-group.is-open .sidebar-chevron {
    transform: rotate(-180deg);
}

.sidebar-group-toggle:hover {
    background: var(--sb-bg-hover);
    color: var(--sb-text-hover);
}

.sidebar-group.is-open > .sidebar-group-toggle {
    color: var(--sb-text-hover);
}

/* Sublist */
.sidebar-sublist {
    list-style: none;
    margin: 2px 0 4px 0;
    padding: 0 0 0 18px;
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: max-height 0.25s ease, opacity 0.2s ease;
}

.sidebar-group.is-open > .sidebar-sublist {
    max-height: 300px;
    opacity: 1;
}

.sidebar-sublist li {
    margin-bottom: 1px;
}

.sidebar-sublist li > a,
.sidebar-sublist li > span {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 10px;
    height: 34px;
    border-radius: 7px;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--sb-text);
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-sublist li > a svg,
.sidebar-sublist li > span svg {
    flex-shrink: 0;
    opacity: 0.6;
}

.sidebar-sublist li > a:hover {
    background: var(--sb-bg-hover);
    color: var(--sb-text-hover);
}

.sidebar-sublist li.is-active > a {
    background: var(--sb-active-pill);
    color: var(--sb-active-text);
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0,0,0,0.18);
}

.sidebar-sublist li.is-active > a svg {
    opacity: 1;
}

.sidebar-sublist li.is-soon > span {
    cursor: default;
    color: var(--sb-soon);
}

.sidebar-sublist li.is-soon > span svg {
    opacity: 0.4;
}

/* ══════════════════════════════════════════
   Help & Feedback button
   ══════════════════════════════════════════ */

#sidebar-feedback {
    flex-shrink: 0;
    padding: 6px 10px 8px;
    border-top: 1px solid var(--sb-border);
}

.sidebar-feedback-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 10px;
    height: 38px;
    border-radius: 8px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--sb-text);
    text-decoration: none;
    opacity: 0.6;
    white-space: nowrap;
    overflow: hidden;
    transition: background 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}

.sidebar-feedback-link svg {
    flex-shrink: 0;
}

.sidebar-feedback-link:hover {
    background: var(--sb-bg-hover);
    color: var(--sb-text-hover);
    opacity: 1;
}

/* Collapsed state — icon only */
body.sidebar-collapsed .sidebar-feedback-link > span { display: none; }
body.sidebar-collapsed .sidebar-feedback-link        { justify-content: center; padding: 0; }
body.sidebar-collapsed #sidebar-feedback             { padding: 6px 0 8px; }

/* ══════════════════════════════════════════
   User footer (fixed at bottom)
   ══════════════════════════════════════════ */

#sidebar-user-footer {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-top: 1px solid var(--sb-border);
    background: var(--sb-bg);
}

.user-avatar {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    color: white;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    letter-spacing: 0.5px;
    border: 1.5px solid rgba(255,255,255,0.2);
}

.user-info {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-size: 12px;
    font-weight: 600;
    color: rgba(255,255,255,0.90);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-title {
    font-size: 10px;
    color: var(--sb-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 1px;
}

.settings-gear-btn {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: 7px;
    color: rgba(255,255,255,0.45);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease;
    text-decoration: none;
}

.settings-gear-btn:hover,
.settings-gear-btn.active {
    background: rgba(255,255,255,0.10);
    color: rgba(255,255,255,0.90);
}

/* ══════════════════════════════════════════
   Topbar
   ══════════════════════════════════════════ */

#topbar {
    position: sticky;
    top: 0;
    margin-left: var(--sb-width);
    transition: margin-left 0.25s ease;
    height: 52px;
    background: white;
    border-bottom: 1px solid #eef0f6;
    box-shadow: 0 1px 8px rgba(19, 3, 66, 0.06);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
}

/* Topbar sidebar-toggle (replaces the in-sidebar collapse button). */
.topbar-sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: 8px;
    color: var(--sb-bg);
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.topbar-sidebar-toggle:hover {
    background: rgba(30, 41, 91, 0.08);
    color: var(--sb-bg);
}

body.sidebar-collapsed .topbar-sidebar-toggle { transform: rotate(180deg); }

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

.topbar-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: 8px;
    color: #606489;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
    text-decoration: none;
}

.topbar-btn:hover {
    background: #f0eeff;
    color: #6c5ce7;
}

.topbar-btn--logout { color: #606489; margin-left: 8px; }
.topbar-btn--logout:hover { background: #fff0f0; color: #e74c3c; }

.topbar-btn--soon {
    opacity: 0.45;
    cursor: not-allowed;
}

.coming-soon-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 8px;
    font-weight: 700;
    background: #6c5ce7;
    color: white;
    border-radius: 4px;
    padding: 0 3px;
    line-height: 13px;
}

/* ══════════════════════════════════════════
   Legacy — kept for backward compatibility
   ══════════════════════════════════════════ */
hr {
    border-top: 1px solid rgba(255,255,255,0.1) !important;
    opacity: 1 !important;
}
