/* ====== SIDEBAR MENU STYLES ====== */

:root {
    --sidebar-width: 96px;
    --icon-color: #6b7280;
    --icon-hover-color: #0078d4;
    --icon-active-color: #0078d4;

    /* Fluent-ish tokens to match dashboard borders */
    --sidebar-item-bg: transparent;
    --sidebar-item-bg-hover: #ffffff;
    --sidebar-item-bg-active: #ffffff;
    --sidebar-item-border: rgba(208, 204, 203, 0.85); /* Teams/Fluent border */
    --sidebar-item-shadow: 0 1.6px 3.6px rgba(0,0,0,0.08), 0 0.3px 0.9px rgba(0,0,0,0.06);
    --sidebar-item-shadow-active: 0 3.2px 7.2px rgba(0,0,0,0.12), 0 0.6px 1.8px rgba(0,0,0,0.10);
    --sidebar-item-radius: 8px;
    --sidebar-focus-ring: 0 0 0 2px rgba(0, 120, 212, 0.35);

    /* Left gutter / submenu column */
    --gutter-width: 288px;
    --gutter-bg: #f3f2f1;
    --gutter-item-bg-hover: #ffffff;
    --gutter-item-bg-active: #ffffff;
    --gutter-item-border: #edebe9;
}

/* ====== SIDEBAR CONTAINER ====== */

.sidebar-menu {
    position: fixed;
    left: 0;
    top: 84px; /* sit below sticky header */
    width: 96px;
    height: calc(100vh - 84px);
    background: #f3f2f1;
    border: none;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 24px 0 24px 0;
    gap: 24px;
    z-index: 100;
    overflow: hidden;
}

/* ====== LEFT GUTTER (2ND COLUMN) ====== */

.sidebar-gutter {
    position: fixed;
    left: var(--sidebar-width);
    top: calc(60px + 96px); /* sit below sticky header + 1 inch */
    width: var(--gutter-width);
    height: calc(100vh - 60px - 96px);
    background: var(--gutter-bg);
    border: none;
    box-shadow: none;
    padding: 18px 14px;
    box-sizing: border-box;
    z-index: 110; /* above sidebar */
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow: hidden;
}

/* Reserve space for the top "row" (header) so the gutter doesn't jump vertically
   while server-rendered items are being resolved.
   This does NOT change spacing between the clickable rows (those are controlled
   by `.patient-submenu-items { gap: ... }`). */
.sidebar-gutter .patient-submenu-header {
    /* Keep header stable without creating extra blank space below */
    min-height: 0;
    padding-bottom: 12px; /* restore original intent */
}

.sidebar-gutter .patient-submenu-title {
    display: block;
    min-height: 0;
}

/* Hide any decorative/section icon above the gutter header title */
.sidebar-gutter .patient-submenu-header > i,
.sidebar-gutter .patient-submenu-header > .patient-submenu-icon,
.sidebar-gutter .patient-submenu-header .submenu-icon {
    display: none !important;
}

.sidebar-gutter .patient-submenu-header {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 10px 12px;
    border-bottom: 1px solid var(--gutter-item-border);
}

.sidebar-gutter .patient-submenu-header::after {
    content: "Choose a category";
    display: block;
    margin-top: 4px;
    font-size: 12px;
    font-weight: 500;
    color: #605e5c;
}

[data-theme="dark"] .sidebar-gutter .patient-submenu-header::after {
    color: #9ca3af;
}

/* If we add the helper text at the header level, don't also add it to the title (avoid duplicates). */
.sidebar-gutter .patient-submenu-title::after,
.sidebar-gutter .patient-submenu-header > h1::after,
.sidebar-gutter .patient-submenu-header > h2::after,
.sidebar-gutter .patient-submenu-header > h3::after,
.sidebar-gutter .patient-submenu-header > h4::after,
.sidebar-gutter .patient-submenu-header > h5::after,
.sidebar-gutter .patient-submenu-header > h6::after,
.sidebar-gutter .patient-submenu-header > .title::after,
.sidebar-gutter .patient-submenu-header > .header-title::after {
    content: none;
}

.sidebar-gutter .patient-submenu-title {
    font-size: 14px;
    font-weight: 700;
    color: #0f6cbd;
    line-height: 1.2;
}

/* Increase the font size of the gutter header title */
.patient-submenu-header span {
    font-size: calc(14px + 3px);
}

/* Prevent any clipping from line-height/overflow quirks */
.sidebar-gutter .patient-submenu-title,
.sidebar-gutter .patient-submenu-header > h1,
.sidebar-gutter .patient-submenu-header > h2,
.sidebar-gutter .patient-submenu-header > h3,
.sidebar-gutter .patient-submenu-header > h4,
.sidebar-gutter .patient-submenu-header > h5,
.sidebar-gutter .patient-submenu-header > h6,
.sidebar-gutter .patient-submenu-header > .title,
.sidebar-gutter .patient-submenu-header > .header-title {
    overflow: visible;
}

[data-theme="dark"] .sidebar-gutter .patient-submenu-title::after,
[data-theme="dark"] .sidebar-gutter .patient-submenu-header > h1::after,
[data-theme="dark"] .sidebar-gutter .patient-submenu-header > h2::after,
[data-theme="dark"] .sidebar-gutter .patient-submenu-header > h3::after,
[data-theme="dark"] .sidebar-gutter .patient-submenu-header > h4::after,
[data-theme="dark"] .sidebar-gutter .patient-submenu-header > h5::after,
[data-theme="dark"] .sidebar-gutter .patient-submenu-header > h6::after,
[data-theme="dark"] .sidebar-gutter .patient-submenu-header > .title::after,
[data-theme="dark"] .sidebar-gutter .patient-submenu-header > .header-title::after {
    color: #9ca3af;
}

.sidebar-gutter .patient-submenu-subtitle {
    font-size: 12px;
    color: #605e5c;
    line-height: 1.2;
}

.sidebar-gutter .patient-submenu-items {
    flex: 1;
    overflow: auto;
    padding: 10px 0 0;
    display: grid;
    grid-auto-rows: min-content;
    gap: 6px;
}

/* Prevent the first gutter row from popping in and shifting the list.
   We reserve the row height for only the first item; row spacing (gap) is unchanged. */
.sidebar-gutter .patient-submenu-items > :first-child {
    min-height: 42px;
}

.sidebar-gutter .patient-submenu-items::-webkit-scrollbar { width: 8px; }
.sidebar-gutter .patient-submenu-items::-webkit-scrollbar-track { background: transparent; }
.sidebar-gutter .patient-submenu-items::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.20); border-radius: 4px; }
.sidebar-gutter .patient-submenu-items::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.30); }

.sidebar-gutter a.patient-submenu-item {
    display: grid;
    grid-template-columns: 22px 1fr;
    align-items: center;

    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: transparent;

    text-decoration: none;
    color: #605e5f;

    transition: background-color 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease, color 0.12s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.sidebar-menu a.sidebar-item,
.sidebar-menu a.sidebar-item:link,
.sidebar-menu a.sidebar-item:visited,
.sidebar-menu a.sidebar-item:hover,
.sidebar-menu a.sidebar-item:active,
.sidebar-menu a.sidebar-item:focus,
.sidebar-menu a.sidebar-item:focus-visible {
    text-decoration: none;
}

.sidebar-menu a.sidebar-item .sidebar-item-icon,
.sidebar-menu a.sidebar-item .sidebar-item-label,
.sidebar-menu a.sidebar-item i {
    text-decoration: none;
}

.sidebar-gutter a.patient-submenu-item i {
    justify-self: center;
    color: #605e5c;
    font-size: 14px;
}

.sidebar-gutter a.patient-submenu-item span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
}

.sidebar-gutter a.patient-submenu-item:hover {
    background: var(--gutter-item-bg-hover);
    border-color: var(--gutter-item-border);
}

.sidebar-gutter a.patient-submenu-item:active {
    background: #e1dfdd;
}

.sidebar-gutter a.patient-submenu-item.active {
    background: var(--gutter-item-bg-active);
    border-color: var(--gutter-item-border);
    color: #0f6cbd;
    box-shadow: 0 3.2px 7.2px rgba(0, 0, 0, 0.10), 0 0.6px 1.8px rgba(0, 0, 0, 0.08);
}

.sidebar-gutter a.patient-submenu-item.active i,
.sidebar-gutter a.patient-submenu-item.active span {
    color: #0f6cbd;
}

.sidebar-gutter a.patient-submenu-item:focus { outline: none; }
.sidebar-gutter a.patient-submenu-item:focus-visible {
    box-shadow: var(--sidebar-focus-ring);
}

/* ====== DARK MODE SUPPORT (gutter) ====== */

[data-theme="dark"] .sidebar-gutter {
    background: #1f2937;
}

[data-theme="dark"] .sidebar-gutter .patient-submenu-header {
    border-bottom-color: rgba(55, 65, 81, 0.95);
}

[data-theme="dark"] .sidebar-gutter .patient-submenu-title {
    color: #60a5fa;
}

[data-theme="dark"] .sidebar-gutter .patient-submenu-subtitle {
    color: #9ca3af;
}

[data-theme="dark"] .sidebar-gutter a.patient-submenu-item {
    color: #9ca3af;
}

[data-theme="dark"] .sidebar-gutter a.patient-submenu-item i {
    color: #d1d5db;
}

[data-theme="dark"] .sidebar-gutter a.patient-submenu-item:hover {
    background: #111827;
    border-color: rgba(55, 65, 81, 0.95);
}

[data-theme="dark"] .sidebar-gutter a.patient-submenu-item.active {
    background: #111827;
    border-color: rgba(55, 65, 81, 0.95);
    color: #60a5fa;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.55), 0 2px 6px rgba(0, 0, 0, 0.45);
}

[data-theme="dark"] .sidebar-gutter a.patient-submenu-item.active i,
[data-theme="dark"] .sidebar-gutter a.patient-submenu-item.active span {
    color: #60a5fa;
}

/* ====== SIDEBAR MENU ITEM ====== */

.sidebar-item {
    width: 80px;
    height: auto;
    min-height: 64px;

    /* Fluent UI: card-ish surface + border */
    border-radius: var(--sidebar-item-radius);
    border: 1px solid transparent;
    background: var(--sidebar-item-bg);
    box-shadow: none;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease, color 0.15s ease;

    color: var(--icon-color);
    position: relative;
    flex-shrink: 0;
    text-decoration: none;
    padding: 8px 4px;
    gap: 4px;
}

.sidebar-item:focus {
    outline: none;
}

.sidebar-item:focus-visible {
    box-shadow: var(--sidebar-focus-ring);
}

.sidebar-item-icon {
    font-size: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    color: inherit;
}

.sidebar-item-label {
    font-size: 10px;
    font-weight: 500;
    color: inherit;
    text-align: center;
    line-height: 1.2;
    max-width: 80px;
    word-wrap: break-word;
    margin-top: 2px;
}

/* ====== SIDEBAR ITEM HOVER STATE ====== */

.sidebar-item:hover {
    background-color: var(--sidebar-item-bg-hover);
    border-color: var(--sidebar-item-border);
    box-shadow: var(--sidebar-item-shadow);
    transform: translateY(-1px);
}

.sidebar-item:hover .sidebar-item-icon {
    color: var(--icon-hover-color);
}

.sidebar-item:hover .sidebar-item-label {
    color: #6b7280;
}

/* ====== SIDEBAR ITEM ACTIVE STATE ====== */

.sidebar-item.active {
    background-color: var(--sidebar-item-bg-active);
    border-color: var(--sidebar-item-border);
    box-shadow: var(--sidebar-item-shadow-active);
    color: var(--icon-active-color);
}

/* Fallback: if the browser keeps focus on the clicked link, show it like active */
.sidebar-item:focus {
    background-color: var(--sidebar-item-bg-active);
    border-color: var(--sidebar-item-border);
    box-shadow: var(--sidebar-item-shadow-active);
    color: var(--icon-active-color);
}

/* ====== DARK MODE SUPPORT ====== */

[data-theme="dark"] .sidebar-menu {
    background: #1f2937;
}

[data-theme="dark"] .sidebar-item {
    --icon-color: #9ca3af;
    --icon-hover-color: #60a5fa;
    --icon-active-color: #60a5fa;

    --sidebar-item-bg-hover: #111827;
    --sidebar-item-bg-active: #111827;
    --sidebar-item-border: rgba(55, 65, 81, 0.95);
    --sidebar-item-shadow: 0 1.6px 3.6px rgba(0,0,0,0.35), 0 0.3px 0.9px rgba(0,0,0,0.30);
    --sidebar-item-shadow-active: 0 3.2px 7.2px rgba(0,0,0,0.45), 0 0.6px 1.8px rgba(0,0,0,0.35);
    --sidebar-focus-ring: 0 0 0 2px rgba(96, 165, 250, 0.35);
}

[data-theme="dark"] .sidebar-item:hover {
    background-color: var(--sidebar-item-bg-hover);
}

[data-theme="dark"] .sidebar-item.active {
    background-color: var(--sidebar-item-bg-active);
}
