/*
 * ngager pulse, student side (unified platform R12, R13, R28; task 3.3).
 * Level colors are set from shared/pulseLevels.js in JavaScript; do not repeat them here.
 * Service names stay lowercase: no text-transform.
 */

.pulse-student {
    max-width: 560px;
    margin: 0 auto;
}

.pulse-title {
    margin: 0 0 8px;
    text-transform: none;
}

.pulse-prompt {
    font-size: 1.2em;
    font-weight: 600;
    margin: 0 0 12px;
}

.pulse-choices {
    display: grid;
    gap: 10px;
}

.pulse-choice {
    position: relative;
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 56px;
    padding: 8px 16px;
    border: 2px solid #c7d2e3;
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
    font-size: 1.05em;
}

.pulse-choice-input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
}

.pulse-dot {
    flex: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid #1f2937;
}

.pulse-choice-label {
    flex: 1;
}

.pulse-check {
    visibility: hidden;
    font-weight: 700;
    font-size: 1.2em;
}

.pulse-choice--chosen {
    border-color: #1f3b73;
    background: #eaf0fb;
    font-weight: 700;
}

.pulse-choice--chosen .pulse-check {
    visibility: visible;
}

.pulse-choice:focus-within {
    outline: 3px solid #1f3b73;
    outline-offset: 2px;
}

.pulse-status {
    min-height: 1.4em;
    margin: 12px 0 4px;
}

.pulse-status[data-state="pending"],
.pulse-status[data-state="failed"] {
    color: #8a3b00;
    font-weight: 600;
}

.pulse-status--small {
    font-size: 0.9em;
    margin: 8px 0;
}

.pulse-note {
    color: #4b5563;
    margin: 4px 0 12px;
}

.pulse-shortcut-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
}

.pulse-shortcut-toggle input {
    width: 20px;
    height: 20px;
}

/* Quick pulse button */
.pulse-shortcut {
    position: fixed;
    right: 20px;
    bottom: 24px;
    z-index: 60;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

.pulse-shortcut[hidden],
.pulse-shortcut-panel[hidden] {
    display: none !important;
}

.pulse-fab {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 3px solid #1f2937;
    background: #fff;
    color: #1f2937;
    font-size: 1.3em;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    cursor: pointer;
}

.pulse-fab:focus-visible {
    outline: 3px solid #1f3b73;
    outline-offset: 3px;
}

.pulse-fab--unset {
    border-style: dashed;
}

.pulse-fab--pending {
    border-color: #8a3b00;
    border-style: dotted;
}

.pulse-shortcut-panel {
    width: min(340px, calc(100vw - 32px));
    max-height: calc(100vh - 180px);
    overflow-y: auto;
    padding: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.pulse-shortcut-prompt {
    margin: 0 0 8px;
    font-weight: 600;
}

.pulse-choices--compact .pulse-choice {
    min-height: 44px;
    padding: 4px 10px;
    font-size: 0.95em;
}

.pulse-choices--compact .pulse-dot {
    width: 22px;
    height: 22px;
}

.pulse-shortcut-actions {
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

/* Room under the content for the floating button */
body.has-pulse-shortcut {
    padding-bottom: 96px;
}

@media screen and (max-width: 768px) {
    body.has-shell.has-pulse-shortcut {
        padding-bottom: calc(140px + env(safe-area-inset-bottom, 0px));
    }

    /* Above the bottom tab bar */
    .pulse-shortcut {
        right: 12px;
        bottom: calc(76px + env(safe-area-inset-bottom, 0px));
    }
}

/* ---------- teacher view (task 3.5) ---------- */

.pulse-teacher {
    max-width: 1352px;
    margin: 0 auto;
}

/* Two panels like the questions tab: summary on the left, live view on the right. */
.pulse-teacher .pulse-title {
    margin: 0 0 12px;
}

.pulse-teacher-note {
    color: #4b5563;
    margin: 0 0 16px;
    padding: 10px 12px;
    background: #f3f6fb;
    border-radius: 8px;
    font-size: 0.92em;
    line-height: 1.45;
}

.pulse-donut-box {
    padding: 8px 0 4px;
}

.pulse-teacher-side .pulse-stats-title {
    margin: 20px 0 8px;
    padding-top: 16px;
    border-top: 1px solid #e8e8e8;
    color: #444;
}

.pulse-teacher-side .pulse-stats-list dt {
    font-size: 0.9em;
    color: #4b5563;
}

.pulse-teacher-side .pulse-stats-list dd {
    margin: 2px 0 12px;
    font-size: 1.05em;
    color: #1f2937;
}

.pulse-teacher-controls {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #e8e8e8;
}

.pulse-teacher-main .pulse-canvas {
    flex: 1;
}

.pulse-teacher-main .pulse-table-wrap {
    overflow-x: auto;
}

.pulse-away-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 44px;
}

.pulse-away-toggle input {
    width: 20px;
    height: 20px;
}

.pulse-teacher-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 16px;
    align-items: start;
}

.pulse-canvas {
    position: relative;
    background: #f8fafc;
    border: 1px solid #dde3ec;
    border-radius: 10px;
    min-height: 320px;
}

.pulse-canvas[hidden],
.pulse-canvas-empty[hidden],
.pulse-popover[hidden] {
    display: none !important;
}

.pulse-canvas-svg {
    display: block;
    width: 100%;
    height: auto;
}

.pulse-canvas-svg:focus-within {
    outline: none;
}

.pulse-circle {
    stroke: #1f2937;
    stroke-width: 1.5;
    cursor: pointer;
    transition: fill 300ms ease;
}

.pulse-circle:focus {
    outline: none;
    stroke: #000;
    stroke-width: 4;
}

.pulse-circle--off {
    stroke-dasharray: 2 2;
}

.pulse-circle--away {
    opacity: 0.4;
    stroke-dasharray: 4 3;
}

.pulse-canvas-empty {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    color: #4b5563;
}

.pulse-popover {
    position: absolute;
    z-index: 5;
    display: grid;
    gap: 2px;
    width: 210px;
    padding: 8px 10px;
    background: #fff;
    border: 1px solid #c7d2e3;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    pointer-events: none;
}

.pulse-pop-time,
.pulse-pop-status {
    color: #4b5563;
    font-size: 0.9em;
}

.pulse-donut {
    margin: 0;
}

.pulse-donut-graphic {
    display: flex;
    justify-content: center;
}

.pulse-donut-seg {
    transition: stroke-dasharray 300ms ease, stroke-dashoffset 300ms ease;
}

.pulse-donut-number {
    font-size: 36px;
    font-weight: 700;
    fill: #1f2937;
}

.pulse-donut-label {
    font-size: 14px;
    fill: #4b5563;
}

.pulse-legend {
    list-style: none;
    padding: 0;
    margin: 8px 0;
    display: grid;
    gap: 4px;
}

.pulse-legend li {
    display: grid;
    grid-template-columns: 16px 1fr auto;
    gap: 8px;
    align-items: center;
}

.pulse-legend-swatch {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 1px solid #1f2937;
}

.pulse-legend-value {
    font-variant-numeric: tabular-nums;
}

.pulse-donut-caption {
    color: #4b5563;
    font-size: 0.9em;
}

.pulse-stats-title {
    margin: 16px 0 4px;
    font-size: 1em;
}

.pulse-stats-list {
    margin: 0;
}

.pulse-stats-list dt {
    color: #374151;
}

.pulse-stats-list dd {
    margin: 0 0 8px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.pulse-stats-away {
    color: #4b5563;
    font-size: 0.9em;
}

.pulse-table {
    border-collapse: collapse;
    width: 100%;
    margin-top: 12px;
}

.pulse-table caption {
    text-align: left;
    font-weight: 600;
    margin-bottom: 6px;
}

.pulse-table th,
.pulse-table td {
    border: 1px solid #dde3ec;
    padding: 6px 10px;
    text-align: left;
}


@media (prefers-reduced-motion: reduce) {
    .pulse-choice,
    .pulse-fab,
    .pulse-circle,
    .pulse-donut-seg {
        transition: none;
    }
}
