/*
  ADAPT Sidebar Rail Navigation
  Persistent left-hand nav across all tools.
  Always expanded: 230px (icon + label).
*/

.adapt-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 230px;
    background: #fff;
    border-right: 1px solid #e8ebe9;
    display: flex;
    flex-direction: column;
    z-index: 99999;
    overflow: hidden;
    font-family: 'DM Sans', 'Segoe UI', Arial, sans-serif;
    box-shadow: 1px 0 8px rgba(0, 0, 0, 0.04);
}

/* Push page content to the right */
body.has-sidebar {
    margin-left: 230px !important;
}

/* Fixed-position elements must also offset for sidebar */
body.has-sidebar .bottom-action-bar {
    left: 230px;
}

/* Brand mark at top */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 14px;
    text-decoration: none;
    border-bottom: 1px solid #e8ebe9;
    flex-shrink: 0;
    min-height: 60px;
    box-sizing: border-box;
}

.sidebar-brand-icon {
    width: 32px;
    height: 32px;
    min-width: 32px;
    background: linear-gradient(135deg, #1a7a6d, #2a9d8f);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-brand-icon svg {
    color: white;
    stroke: white;
}

.sidebar-brand-label {
    font-size: 18px;
    font-weight: 700;
    color: #1a7a6d;
    white-space: nowrap;
    letter-spacing: -0.5px;
}

/* Nav items */
.sidebar-nav-items {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 12px 8px;
    overflow-y: auto;
}

.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-radius: 8px;
    text-decoration: none;
    color: #555;
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
    min-height: 42px;
    box-sizing: border-box;
}

.sidebar-nav-item:hover {
    background: #f0faf8;
    color: #1a7a6d;
}

.sidebar-nav-item.active {
    background: #edf8f6;
    color: #1a7a6d;
}

.sidebar-nav-item.active::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 24px;
    background: #1a7a6d;
    border-radius: 0 3px 3px 0;
}

.sidebar-nav-icon {
    width: 22px;
    height: 22px;
    min-width: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-nav-icon svg {
    width: 20px;
    height: 20px;
}

.sidebar-nav-label {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
}

/* Sub-actions (e.g. Protocol Builder tools) */
.sidebar-sub-actions {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 4px 0 4px 34px;
}

.sidebar-sub-action {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 6px;
    border: none;
    background: none;
    color: #777;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    text-align: left;
}

.sidebar-sub-action:hover {
    background: #f0faf8;
    color: #1a7a6d;
}

.sidebar-sub-action svg {
    width: 15px;
    height: 15px;
    min-width: 15px;
}

.sidebar-sub-action.sub-action-primary {
    color: #1a7a6d;
    font-weight: 600;
}

.sidebar-sub-action.sub-action-primary:hover {
    background: #edf8f6;
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .adapt-sidebar {
        background: #1e1e1e;
        border-right-color: #333;
        box-shadow: 1px 0 8px rgba(0, 0, 0, 0.2);
    }
    :root:not([data-theme="light"]) .sidebar-brand {
        border-bottom-color: #333;
    }
    :root:not([data-theme="light"]) .sidebar-brand-label {
        color: #8CD9C0;
    }
    :root:not([data-theme="light"]) .sidebar-nav-item {
        color: #bbb;
    }
    :root:not([data-theme="light"]) .sidebar-nav-item:hover {
        background: #2a3530;
        color: #8CD9C0;
    }
    :root:not([data-theme="light"]) .sidebar-nav-item.active {
        background: #243028;
        color: #8CD9C0;
    }
    :root:not([data-theme="light"]) .sidebar-nav-item.active::before {
        background: #8CD9C0;
    }
    :root:not([data-theme="light"]) .sidebar-sub-action {
        color: #999;
    }
    :root:not([data-theme="light"]) .sidebar-sub-action:hover {
        background: #2a3530;
        color: #8CD9C0;
    }
    :root:not([data-theme="light"]) .sidebar-sub-action.sub-action-primary {
        color: #8CD9C0;
    }
}

:root[data-theme="dark"] .adapt-sidebar {
    background: #1e1e1e;
    border-right-color: #333;
    box-shadow: 1px 0 8px rgba(0, 0, 0, 0.2);
}
:root[data-theme="dark"] .sidebar-brand {
    border-bottom-color: #333;
}
:root[data-theme="dark"] .sidebar-brand-label {
    color: #8CD9C0;
}
:root[data-theme="dark"] .sidebar-nav-item {
    color: #bbb;
}
:root[data-theme="dark"] .sidebar-nav-item:hover {
    background: #2a3530;
    color: #8CD9C0;
}
:root[data-theme="dark"] .sidebar-nav-item.active {
    background: #243028;
    color: #8CD9C0;
}
:root[data-theme="dark"] .sidebar-nav-item.active::before {
    background: #8CD9C0;
}
:root[data-theme="dark"] .sidebar-sub-action {
    color: #999;
}
:root[data-theme="dark"] .sidebar-sub-action:hover {
    background: #2a3530;
    color: #8CD9C0;
}
:root[data-theme="dark"] .sidebar-sub-action.sub-action-primary {
    color: #8CD9C0;
}

/* Theme toggle at bottom */
.sidebar-theme-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border: none;
    border-top: 1px solid #e8ebe9;
    background: none;
    color: #777;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
    white-space: nowrap;
}

.sidebar-theme-toggle:hover {
    color: #1a7a6d;
    background: #f0faf8;
}

:root[data-theme="dark"] .sidebar-theme-toggle {
    border-top-color: #333;
    color: #999;
}

:root[data-theme="dark"] .sidebar-theme-toggle:hover {
    color: #8CD9C0;
    background: #2a3530;
}

/* Mobile: icon-only */
@media (max-width: 768px) {
    .adapt-sidebar {
        width: 48px;
    }
    body.has-sidebar {
        margin-left: 48px !important;
    }
    .sidebar-brand {
        padding: 12px 8px;
        min-height: 48px;
    }
    .sidebar-brand-icon {
        width: 28px;
        height: 28px;
        min-width: 28px;
        border-radius: 6px;
    }
    .sidebar-brand-icon svg {
        width: 16px;
        height: 16px;
    }
    .sidebar-brand-label,
    .sidebar-nav-label,
    .sidebar-sub-actions,
    .sidebar-theme-toggle span {
        display: none;
    }
    .sidebar-theme-toggle {
        justify-content: center;
        padding: 12px 8px;
    }
    .sidebar-nav-items {
        padding: 8px 4px;
    }
    .sidebar-nav-item {
        padding: 10px 8px;
        justify-content: center;
    }
    .sidebar-nav-item.active::before {
        left: -4px;
        height: 20px;
    }
}

/* Print: hide sidebar */
@media print {
    .adapt-sidebar { display: none !important; }
    body.has-sidebar { margin-left: 0 !important; }
}
