/**
 * EduFlow chrome that is not in the shared design package:
 * waffle module switcher, named user menu, sidebar header + collapse.
 * Tokens, buttons, cards, tables, 56px header — from styles/ds/.
 */

/* Header is a sibling of .app-shell, not nested — keep row layout */
.app-shell {
    flex-direction: row;
}

/* -- Module switcher (waffle) -- */
.header-module-switcher {
    position: relative;
    flex-shrink: 0;
}
.header-icon-btn .badge-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ff5630;
    border: 2px solid var(--header-bg);
}

.module-switcher-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    width: 320px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-raised);
    padding: 16px;
    z-index: var(--z-dropdown);
}
.module-switcher-dropdown.hidden { display: none; }
.module-switcher-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 12px;
}
.module-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
}
.module-grid-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 8px;
    border-radius: var(--radius);
    color: var(--text);
    cursor: pointer;
    transition: background-color 0.15s;
    text-decoration: none;
    border: none;
    background: none;
    font-family: inherit;
}
.module-grid-item:hover { background: var(--surface-hover); text-decoration: none; color: var(--text); }
.module-grid-item.active { background: var(--primary-soft); }
.module-grid-item i { font-size: 24px; color: var(--primary); }
.module-grid-item.active i { color: var(--primary-hover); }
.module-grid-item span { font-size: 12px; font-weight: 500; }

.header-logo-icon { font-size: 16px; }

.header-nav-item.active {
    box-shadow: inset 0 -2px 0 0 #fff;
    border-radius: 0;
}

/* -- User menu in header -- */
.header-user-menu-wrap { position: relative; }
.header-user-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px 4px 4px;
    background: transparent;
    border: none;
    border-radius: 9999px;
    cursor: pointer;
    font-family: inherit;
    color: var(--header-text);
    transition: background-color 0.15s;
}
.header-user-btn:hover,
.header-user-btn[aria-expanded="true"] { background: var(--header-hover); }
.header-user-name {
    font-size: 13px;
    font-weight: 500;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    width: 260px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-raised);
    padding: 6px;
    z-index: 120;
}
.user-dropdown.hidden { display: none; }
.user-dropdown-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 10px 12px;
}
.user-dropdown-header-text { min-width: 0; flex: 1; }
.user-dropdown-header-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-strong);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.user-dropdown-header-email {
    font-size: 12px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.user-dropdown-divider { height: 1px; background: var(--border-subtle); margin: 4px 2px; }
.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text);
    transition: background-color 0.15s, color 0.15s;
    text-decoration: none;
}
.user-dropdown-item:hover { background: var(--surface-hover); color: var(--text-strong); text-decoration: none; }
.user-dropdown-item i { width: 16px; text-align: center; color: var(--text-faint); font-size: 13px; }
.user-dropdown-item:hover i { color: var(--text-muted); }
.user-dropdown-item-danger { color: var(--danger); }
.user-dropdown-item-danger:hover { background: var(--danger-soft); color: var(--danger-hover); }
.user-dropdown-item-danger i,
.user-dropdown-item-danger:hover i { color: currentColor; }

/* Sidebar header + collapse sit inside the panel (not the floating DS control) */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--sidebar-border);
    flex-shrink: 0;
    min-height: 44px;
}
.sidebar-header-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
}
.app-sidebar.collapsed .sidebar-header-title { display: none; }

.app-sidebar .sidebar-collapse-btn {
    position: static;
    width: 24px;
    height: 24px;
    right: auto;
    top: auto;
    border: none;
    box-shadow: none;
    background: transparent;
    border-radius: var(--radius-sm);
    font-size: 12px;
}
.app-sidebar .sidebar-collapse-btn:hover { background: var(--sidebar-bg-hover); color: var(--text); }
.app-sidebar.collapsed .sidebar-collapse-btn i { transform: rotate(180deg); }

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}
.app-sidebar.collapsed .sidebar-section-title { display: none; }
.app-sidebar.collapsed .sidebar-item {
    justify-content: center;
    padding: 10px 0;
}
.app-sidebar.collapsed .sidebar-item span { display: none; }
.app-sidebar.collapsed .sidebar-item i { width: auto; font-size: 16px; }

.sidebar-tree { padding-left: 0; }
.sidebar-tree-item {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px 8px 5px 12px;
    margin: 1px 0;
    border-radius: var(--radius);
    color: var(--sidebar-text);
    font-size: 13px;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
}
.sidebar-tree-item:hover { background: var(--sidebar-bg-hover); text-decoration: none; color: var(--sidebar-text); }
.sidebar-tree-item.active { background: var(--sidebar-active-bg); color: var(--sidebar-active-text); font-weight: 500; }
.sidebar-tree-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border: none;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
    font-size: 10px;
    flex-shrink: 0;
}
.sidebar-tree-toggle.expanded { transform: rotate(90deg); }
.sidebar-tree-children { padding-left: 16px; }
.sidebar-tree-children.hidden { display: none; }

.sidebar-footer {
    margin-top: auto;
    padding: 8px;
    border-top: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}

/* Templates use .form-input on select/textarea */
select.form-input { cursor: pointer; }
textarea.form-input { resize: vertical; min-height: 96px; }
.form-actions { display: flex; gap: 8px; align-items: center; margin-top: 12px; }

.demo-account-list { display: flex; flex-direction: column; gap: 8px; }
.demo-account-btn {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    transition: background-color 0.15s, border-color 0.15s;
}
.demo-account-btn:hover {
    background: var(--primary-soft);
    border-color: rgba(7, 71, 166, 0.18);
}
.demo-account-role { font-size: 14px; font-weight: 600; color: var(--text-strong); }
.demo-account-email { font-size: 12px; color: var(--text-muted); }

/* Shared schedule calendar */
.cal-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding: 12px 16px;
}
.cal-toolbar-views,
.cal-toolbar-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
.cal-toolbar-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-strong);
}
.cal-wrap {
    overflow-x: auto;
}
.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(110px, 1fr));
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--surface);
    min-width: 770px;
}
.cal-head {
    background: var(--surface-raised, #f4f5f7);
    font-size: 12px;
    font-weight: 600;
    padding: 8px 6px;
    text-align: center;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border-subtle, #ebecf0);
}
.cal-head:nth-child(7n) { border-right: 0; }
.cal-cell {
    min-height: 104px;
    border-right: 1px solid var(--border-subtle, #ebecf0);
    border-bottom: 1px solid var(--border-subtle, #ebecf0);
    padding: 6px;
    vertical-align: top;
}
.cal-cell:nth-child(7n) { border-right: 0; }
.cal-grid-week .cal-cell { min-height: 220px; }
.cal-cell-out {
    background: #f7f8f9;
    color: var(--text-muted);
}
.cal-cell-weekend { background: #fafbfc; }
.cal-cell-out.cal-cell-weekend { background: #f4f5f7; }
.cal-cell-today {
    box-shadow: inset 0 0 0 2px var(--primary, #0052cc);
}
.cal-cell-num {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-strong);
    margin-bottom: 4px;
}
.cal-cell-num a { color: inherit; text-decoration: none; }
.cal-cell-num a:hover { text-decoration: underline; }
.cal-cell-out .cal-cell-num { color: var(--text-muted); }
.cal-more a { color: inherit; text-decoration: none; }
.cal-more a:hover { color: var(--primary, #0052cc); }
.cal-event {
    display: flex;
    gap: 4px;
    align-items: baseline;
    font-size: 11px;
    line-height: 1.35;
    padding: 3px 6px;
    border-radius: 4px;
    margin-top: 3px;
    text-decoration: none;
    overflow: hidden;
}
.cal-event-time {
    font-weight: 600;
    flex-shrink: 0;
}
.cal-event-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cal-event-group { background: #deebff; color: #0747a6; }
.cal-event-individual { background: #e3fcef; color: #006644; }
.cal-event-cancelled { background: #ffebe6; color: #bf2600; text-decoration: line-through; }
.cal-event:hover { filter: brightness(0.97); }
.cal-more {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
    padding: 0 4px;
}
.cal-day-list { padding: 8px; }
.cal-event-row {
    font-size: 14px;
    padding: 10px 12px;
    margin-top: 0;
    margin-bottom: 6px;
    border-radius: var(--radius);
}
.cal-event-row .cal-event-title { white-space: normal; }
