/*
 * Unified shell: service tabs (unified platform R3, R28; task 1.7).
 * Desktop: tabs in a row at the top. Phones (<= 768px): fixed bottom bar, five equal
 * columns, icon above label, 44px+ touch targets, no horizontal scrolling.
 * Service names are lowercase in the markup; never add text-transform here (R2.4).
 * Colors use the existing brand blue (#4472C4 / #4a90d9 in desktop.css and mobile.css).
 */

/* Keep the line breaks a teacher types in question and poll texts. pre-line keeps
   new lines but still merges runs of spaces and wraps long lines. */
.question-text,
.question-item-text,
.question-result-text,
.poll-active-text,
.poll-question,
.poll-item-text,
.present-poll-question,
.keep-lines {
    white-space: pre-line;
}

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.shell-tabs {
    display: flex;
    gap: 4px;
    justify-content: center;
    padding: 8px 12px 0;
    background: #fff;
    border-bottom: 1px solid #dde3ec;
    position: sticky;
    top: 0;
    z-index: 50;
}

.shell-tab {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    min-width: 44px;
    padding: 8px 16px;
    border: 0;
    border-bottom: 3px solid transparent;
    background: transparent;
    color: #4a5568;
    font: inherit;
    font-size: 16px;
    cursor: pointer;
    text-transform: none;
}

.shell-tab:hover {
    color: #1f3b73;
    background: #f3f6fb;
}

.shell-tab:focus-visible {
    outline: 3px solid #1f3b73;
    outline-offset: 2px;
}

/* Active state: underline + bold + color, so it never relies on color alone (R3.2) */
.shell-tab--active,
.shell-tab[aria-selected="true"] {
    color: #1f3b73;
    font-weight: 700;
    border-bottom-color: #4472C4;
}

.shell-tab-icon {
    flex: none;
}

.shell-badge {
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: #A31F34;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    line-height: 20px;
    text-align: center;
}

.shell-badge--dot {
    min-width: 10px;
    width: 10px;
    height: 10px;
    padding: 0;
    position: absolute;
    top: 8px;
    right: 8px;
}

.shell-panel {
    padding: 16px;
}

.shell-panel[hidden],
#main-content[hidden] {
    display: none !important;
}

.shell-placeholder {
    max-width: 640px;
    margin: 24px auto;
    text-align: center;
}

.shell-placeholder-title {
    text-transform: none;
}

/* Teacher tools next to the tabs (presentation controls, task 1.8) */
.shell-tools {
    display: flex;
    justify-content: center;
    padding: 6px 12px;
    background: #fff;
    border-bottom: 1px solid #dde3ec;
}

.shell-presentation-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.shell-follow {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    cursor: pointer;
}

.shell-follow input {
    width: 20px;
    height: 20px;
}

.shell-presentation-blocked {
    flex-basis: 100%;
    margin: 4px 0 0;
    color: #7a2e00;
}

/* Lecturer lesson bar above all five tab panels, same width as #main-content */
#lesson-bar {
    box-sizing: border-box;
    width: calc(100% - 48px);
    max-width: 1352px;
    margin: 16px auto 0;
}

.lesson-bar-left,
.lesson-bar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.lesson-bar-right {
    justify-content: flex-end;
}

.lesson-bar-right .overview-button {
    min-height: 38px;
}

/* The bar's network icon replaces the "Connected" pill. */
body.has-lesson-bar .connection-status {
    display: none !important;
}

/* The teacher tools row now only holds the (hidden until opened) overview panel. */
body.shell-role-lecturer .shell-tools {
    padding: 0;
    border-bottom: 0;
    background: transparent;
}

/* Connection icon next to the logo: green when connected, red when not. */
.lesson-bar-net {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: default;
}

.lesson-bar-net--ok {
    color: #2e7d32;
}

.lesson-bar-net--fail {
    color: #c62828;
}

.lesson-bar-net:focus-visible {
    outline: 3px solid #1f3b73;
    outline-offset: 2px;
}

.lesson-bar-net-tip {
    position: absolute;
    left: calc(100% + 8px);
    top: 50%;
    transform: translateY(-50%);
    padding: 6px 10px;
    border-radius: 6px;
    background: #1f2937;
    color: #fff;
    font-size: 13px;
    line-height: 1.3;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.12s ease;
    z-index: 60;
}

.lesson-bar-net:hover .lesson-bar-net-tip,
.lesson-bar-net:focus-visible .lesson-bar-net-tip {
    opacity: 1;
    visibility: visible;
}

/* Questions tab in a lesson: desktop.css widens #main-content to 1600px / 1800px on
   wide screens. Keep it at 1400px (1352px content) like the lesson bar and the other
   four tabs, so all panels stop growing at the same width. */
@media screen and (min-width: 769px) {
    body.has-lesson-bar #main-content {
        max-width: 1400px;
        padding-left: 24px;
        padding-right: 24px;
    }
}

/* Preparation mode (lesson not started): a note at the top of each tab. */
.prepare-notice {
    box-sizing: border-box;
    max-width: 1352px;
    margin: 8px auto 4px;
    padding: 12px 16px;
    border: 1px solid #f0c36d;
    border-left: 6px solid #b45309;
    border-radius: 10px;
    background: #fff8e6;
    color: #5b3a00; /* 8.9:1 on the background */
    font-weight: 600;
    line-height: 1.45;
}

.poll-prepared-note {
    margin: 0;
    font-weight: 600;
}

/* Teacher service tabs (poll, pulse, vibe, ask): same width, panels and headings as the
   questions tab, so the panels line up under the lesson bar on every tab. */
.shell-role-lecturer .shell-panel {
    padding: 16px 24px;
}

.shell-role-lecturer .shell-panel > .poll-teacher,
.shell-role-lecturer .shell-panel > .pulse-teacher,
.shell-role-lecturer .shell-panel > .vibe-teacher,
.shell-role-lecturer .shell-panel > .ask-teacher {
    box-sizing: border-box;
    max-width: 1352px;
    margin: 0 auto;
    padding: 8px 0 24px;
}

.shell-panel .ngager-left-panel > .panel-title:first-child,
.shell-panel .ngager-left-panel > div:first-child > .panel-title:first-child,
.shell-panel .ngager-right-panel > .panel-title:first-child {
    margin-top: 0;
}

/* Phones: desktop.css (which styles the panels) is not loaded; give the panels the
   same card look, stacked. */
@media screen and (max-width: 768px) {
    .shell-role-lecturer .shell-panel {
        padding-left: 12px;
        padding-right: 12px;
    }

    .shell-panel .ngager-left-panel,
    .shell-panel .ngager-right-panel {
        background: #fff;
        border-radius: 12px;
        padding: 16px;
        margin-bottom: 16px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    }

    .shell-panel .panel-title {
        font-size: 18px;
        font-weight: 600;
        color: #444;
        margin: 0 0 16px;
        padding-bottom: 12px;
        border-bottom: 2px solid #e8e8e8;
    }
}

/* Desktop lecturer: tabs sit in the logo bar (logo + icon | tabs | overview + end) */
@media screen and (min-width: 769px) {
    .end-lesson-bar--with-tabs {
        display: grid;
        grid-template-columns: 1fr auto 1fr;
        align-items: center;
        column-gap: 16px;
    }

    .shell-tabs--in-bar {
        position: static;
        padding: 0;
        background: transparent;
        border-bottom: 0;
    }
}

/* Phones: bottom tab bar */
@media screen and (max-width: 768px) {
    body.has-shell {
        padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    }

    /* Same top space as #main-content in mobile.css, which leaves room for the fixed
       connection status bar. */
    .shell-panel {
        padding-top: 60px;
    }

    .shell-tabs {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        gap: 0;
        padding: 0 0 env(safe-area-inset-bottom, 0px);
        border-top: 1px solid #dde3ec;
        border-bottom: 0;
        box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);
    }

    .shell-tab {
        flex: 1 1 0;
        min-width: 0;
        flex-direction: column;
        justify-content: center;
        gap: 2px;
        min-height: 56px;
        padding: 6px 2px;
        font-size: 13px;
        border-bottom: 0;
        border-top: 3px solid transparent;
    }

    .shell-tab--active,
    .shell-tab[aria-selected="true"] {
        border-top-color: #4472C4;
    }

    .shell-badge {
        position: absolute;
        top: 4px;
        left: calc(50% + 6px);
        min-width: 18px;
        height: 18px;
        line-height: 18px;
        font-size: 11px;
    }

    .shell-badge--dot {
        left: calc(50% + 8px);
        top: 6px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .shell-tab {
        transition: none;
    }
}

/* Cross-tab alert and notification switches (task 5.3, R23.6, R26.4). */
.shell-alert {
    position: fixed;
    top: 70px;
    right: 16px;
    z-index: 300;
    max-width: 320px;
    padding: 10px 14px;
    border-left: 5px solid #1f3b73;
    border-radius: 8px;
    background: #ffffff;
    color: #1f2937;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
    font-weight: 600;
}
.shell-alert[hidden] {
    display: none !important;
}
.shell-notify {
    margin: 20px 0 0;
    padding: 10px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}
.shell-notify legend {
    font-weight: 700;
    padding: 0 4px;
}
.shell-notify-row {
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 32px;
}
.shell-notify-row input {
    width: 18px;
    height: 18px;
}

/* Lesson overview (task 6.1, R25). */
.overview-button {
    min-height: 32px;
    padding: 0 12px;
    border: 1px solid #1f3b73;
    border-radius: 6px;
    background: #ffffff;
    color: #1f3b73;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.overview-button[aria-expanded="true"] {
    background: #1f3b73;
    color: #ffffff;
}
.overview-button:focus-visible,
.overview-close:focus-visible {
    outline: 3px solid #1f3b73;
    outline-offset: 2px;
}
/* Pop-up: dimmed backdrop over the whole page with a centered dialog. */
.overview-panel {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(17, 24, 39, 0.55);
}
.overview-panel[hidden] {
    display: none !important;
}
body.overview-open {
    overflow: hidden;
}
.overview-dialog {
    display: flex;
    flex-direction: column;
    width: min(960px, 100%);
    max-height: calc(100vh - 48px);
    border-radius: 14px;
    background: #f5f7fa;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}
.overview-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 24px;
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
}
.overview-heading {
    margin: 0;
    font-size: 1.25em;
    color: #1f2937;
}
.overview-scroll {
    overflow-y: auto;
    padding: 20px 24px 24px;
}
.overview-close {
    min-height: 32px;
    padding: 0 12px;
    border: 1px solid #6b7280;
    border-radius: 6px;
    background: #ffffff;
    font: inherit;
    cursor: pointer;
}
/* Cards: Students, questions, poll on the first row; pulse (two columns wide, two rows
   tall) with vibe and ask stacked next to it. DOM order is unchanged. */
.overview-body {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-auto-flow: row dense;
    gap: 16px;
    align-items: start;
}
.overview-section {
    padding: 14px 16px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
.overview-section[data-service="pulse"] {
    grid-column: span 2;
    grid-row: span 2;
}
.overview-title {
    margin: 0 0 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #eef0f3;
    font-size: 1em;
    color: #1f2937;
}
.overview-list {
    margin: 0;
}
.overview-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: baseline;
    gap: 12px;
    padding: 5px 0;
}
.overview-row dt {
    color: #4b5563;
}
.overview-row dd {
    margin: 0;
    font-weight: 700;
    color: #1f2937;
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
/* Long values (the text of the last question or poll) wrap under their label. */
.overview-section[data-service="questions"] .overview-row:first-child,
.overview-section[data-service="poll"] .overview-row:first-child {
    grid-template-columns: 1fr;
    gap: 2px;
}
.overview-section[data-service="questions"] .overview-row:first-child dd,
.overview-section[data-service="poll"] .overview-row:first-child dd {
    text-align: left;
    white-space: normal;
    font-weight: 600;
    overflow-wrap: anywhere;
}
/* pulse rows: label | bar | value */
.overview-row--bar {
    grid-template-columns: minmax(170px, 1.3fr) minmax(60px, 1fr) minmax(110px, auto);
    align-items: center;
}
.overview-swatch {
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-right: 8px;
    border-radius: 50%;
    border: 1px solid #1f2937;
    vertical-align: -1px;
}
.overview-bar {
    display: block;
    height: 10px;
    border-radius: 5px;
    background: #eef2f7;
    overflow: hidden;
}
.overview-bar-fill {
    display: block;
    height: 100%;
    border-radius: 5px;
    background: #4472C4;
}
.overview-extras {
    margin-top: 16px;
    padding: 12px 16px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    background: #ffffff;
}
.overview-extras > details + details {
    border-top: 1px solid #eef0f3;
    padding-top: 10px;
}
@media screen and (max-width: 900px) {
    .overview-body {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .overview-section[data-service="pulse"] {
        grid-column: 1 / -1;
        grid-row: auto;
    }
}
@media screen and (max-width: 560px) {
    .overview-panel {
        padding: 8px;
    }
    .overview-body {
        grid-template-columns: 1fr;
    }
    .overview-row--bar {
        grid-template-columns: minmax(0, 1fr) auto;
    }
    .overview-row--bar .overview-bar {
        display: none;
    }
}
.overview-note {
    grid-column: 1 / -1;
    margin: 4px 0 0;
    color: #4b5563;
    font-size: 0.9em;
}
.overview-notify {
    margin-top: 10px;
}
.overview-notify summary,
.overview-delete summary {
    cursor: pointer;
    font-weight: 600;
}
.overview-delete {
    margin-top: 10px;
}
.overview-delete-item {
    margin: 8px 0;
}
.overview-delete-confirm {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}
.overview-delete-confirm[hidden],
.overview-delete-start[hidden] {
    display: none;
}
.overview-delete-confirm p {
    flex-basis: 100%;
    margin: 0;
}
.overview-delete-status {
    margin: 4px 0 0;
    color: #1f2937;
}
