/* Shared by the Django and Jinja headers. Keep labels in flow so neither
   hover nor a recording/call state can move the surrounding navigation. */
.audio-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    pointer-events: auto;
}

.audio-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 76px;
    min-height: 52px;
    padding: 5px 4px;
    border: 1px solid transparent;
    border-radius: 12px;
    background: transparent;
    color: #9ca3af;
    font-family: inherit;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: color 150ms ease, background-color 150ms ease, border-color 150ms ease;
}

.audio-action-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 24px;
}

.audio-action-icon svg { width: 22px; height: 22px; }
.audio-action-label { font-size: 11px; line-height: 14px; white-space: nowrap; text-transform: lowercase; }
.audio-action:focus-visible { outline: 2px solid #7dd3fc; outline-offset: 3px; }
.audio-action:active:not(:disabled) { background: #ffffff12; }
.audio-action:disabled { opacity: .4; cursor: default; }

@media (hover: hover) {
    .audio-action[data-state="idle"]:hover:not(:disabled) { color: #f9fafb; background: #ffffff08; }
}

.audio-action-call[data-state="active"] {
    color: #fda4af;
    background: #fb718515;
    border-color: #fb718530;
}

/* Recording is meant to be unmissable: the neighbors step aside and the
   whole cluster becomes one solid rose pill — mode links and cancel on the
   left, live bars + elapsed time in the middle, and the End segment
   (#record) on the right. The control panel docks inside the pill (see
   showRecordControlPanel). */
.audio-actions-recording .audio-action-dictate,
.audio-actions-recording .audio-action-call { display: none; }
.audio-actions.audio-actions-recording {
    gap: 4px;
    padding: 6px 7px;
    border: 1px solid #ffffff1f;
    border-radius: 16px;
    background: #111827f2;
    box-shadow: 0 10px 28px #00000066;
    position: relative;
    z-index: 5;
}

/* Call Grug's level indicator: the same bar cluster, sitting in the call's
   own modal beside its End call button (the ring around the header button
   is gone). */
/* Compound selector: the base .record-level sizing is declared later in
   this file and would otherwise win the tie and shrink these. */
.record-level.live-audio-level { height: 24px; gap: 3px; color: #fb7185; align-self: center; }
.record-level.live-audio-level span { width: 3.5px; height: 22px; border-radius: 2px; }

/* Call Grug modal controls in the meeting bar's language: quiet gray
   control + solid red end segment. JS only swaps state classes; all
   styling lives here. */
.live-audio-speaker-toggle {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 40px;
    padding: 0 13px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: #9ca3af;
    font-family: inherit;
    font-size: 14px;
    line-height: 1;
    text-transform: lowercase;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: color 150ms ease, background-color 150ms ease;
    flex-shrink: 0;
}
.live-audio-speaker-toggle svg { width: 17px; height: 17px; flex-shrink: 0; }
.live-audio-speaker-muted { color: #fbbf24; background: #f59e0b1a; }
.live-audio-status-exit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    height: 44px;
    padding: 0 20px 0 17px;
    border: none;
    border-radius: 11px;
    background: #e11d48;
    color: #ffffff;
    font-family: inherit;
    font-size: 16px;
    line-height: 1;
    text-transform: lowercase;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
    animation: record-attention 2s ease-out infinite;
}
.live-audio-status-exit svg { width: 14px; height: 14px; flex-shrink: 0; }
.live-audio-speaker-toggle:focus-visible, .live-audio-status-exit:focus-visible { outline: 2px solid #7dd3fc; outline-offset: -2px; }
@media (hover: hover) {
    .live-audio-speaker-toggle:hover { color: #f9fafb; background: #ffffff14; }
    .live-audio-speaker-muted:hover { color: #fcd34d; background: #f59e0b26; }
    .live-audio-status-exit:hover { background: #be123c; }
}

/* While recording, the bar leaves the header row and floats just below it,
   overlaying the content edge — the header keeps its height and search/date
   keep their width, and the page itself never shifts. Roomier spacing at
   desktop sizes, extra air after the timer. */
@media (min-width: 768px) {
    /* #audio stays in the header grid (its idle width is reserved inline by
       setRecording) so date/search never move; only the bar itself floats,
       anchored to #main_nav — its own .relative wrapper is neutralized so
       the anchor is the header row, not a collapsed box. */
    #top_nav:has(.audio-actions-recording) #main_nav { position: relative; }
    /* The wrapper is a flex item, so its z-10 applies even while static and
       traps the bar under the search's z-50 context — raise the whole
       context while recording so the bar is the header's top layer. */
    #top_nav:has(.audio-actions-recording) #audio > .relative { position: static; z-index: 70; }
    #top_nav:has(.audio-actions-recording) #audio { z-index: 70; }
    .audio-actions.audio-actions-recording {
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        right: 0;
        z-index: 60;
    }
    .audio-actions.audio-actions-recording { gap: 8px; padding: 6px 8px; }
    .audio-actions-recording .record-hud-status::before { margin: 0 14px 0 10px; }
    .audio-actions-recording .record-level { margin-right: 12px; }
    .audio-actions-recording .record-mode-button { padding: 0 14px; }
    #record[data-state="recording"] { margin-left: 10px; }
}
#record[data-state="recording"] {
    flex-direction: row;
    justify-content: center;
    gap: 9px;
    width: auto;
    min-height: 0;
    height: 44px;
    padding: 0 20px 0 17px;
    border-radius: 11px;
    border-color: transparent;
    background: #e11d48;
    color: #ffffff;
    animation: record-attention 2s ease-out infinite;
}
#record[data-state="recording"] .audio-action-label { font-size: 16px; }
@media (hover: hover) {
    #record[data-state="recording"]:hover:not(:disabled) { color: #ffffff; background: #be123c; }
}
@keyframes record-attention {
    0% { box-shadow: 0 0 0 0 #f43f5e73; }
    70% { box-shadow: 0 0 0 12px #f43f5e00; }
    100% { box-shadow: 0 0 0 0 #f43f5e00; }
}

/* Docked control segments: quiet on the dark pill; only End is red. */
.audio-actions-recording #record-control-panel { min-width: 0; }
.audio-actions-recording .record-control-surface {
    height: auto;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 999px;
    background: transparent;
    box-shadow: none;
}
.audio-actions-recording .record-mode-button,
.audio-actions-recording .record-control-cancel {
    height: 40px;
    padding: 0 13px;
    border-radius: 10px;
    font-size: 14px;
    color: #9ca3af;
}
.audio-actions-recording .record-mode-button svg { width: 17px; height: 17px; }
.audio-actions-recording .record-control-cancel svg { width: 15px; height: 15px; }
.audio-actions-recording .record-mode-button { gap: 7px; }
.audio-actions-recording .record-mode-button[aria-pressed="true"] {
    color: #f9fafb;
    background: #ffffff14;
}
.audio-actions-recording .record-control-modes::before {
    content: '';
    width: 1px;
    height: 18px;
    margin: 0 7px 0 3px;
    background: #ffffff1f;
    flex-shrink: 0;
}
.audio-actions-recording .record-hud-status {
    color: #f9fafb;
    font-size: 18px;
}
.audio-actions-recording .record-hud-status::before {
    content: '';
    width: 1px;
    height: 18px;
    margin: 0 12px 0 8px;
    background: #ffffff1f;
    flex-shrink: 0;
}
.audio-actions-recording .record-hud-status .timer-display { font-variant-numeric: tabular-nums; }
.audio-actions-recording .record-hud-status .target-text { display: none; }
.audio-actions-recording .record-level { height: 24px; gap: 3px; margin-right: 11px; color: #fb7185; }
.audio-actions-recording .record-level span { width: 3.5px; height: 22px; border-radius: 2px; }
@media (hover: hover) {
    .audio-actions-recording .record-mode-button:not([aria-pressed="true"]):hover { color: #f9fafb; }
    .audio-actions-recording .record-control-cancel:hover { color: #fda4af; background: #fb718514; }
}

.audio-action-call[data-state="connecting"] { color: #7dd3fc; background: #38bdf810; }
#grug-dictation-launch[aria-expanded="true"] { color: #fdba74; background: #fb923c15; border-color: #fb923c30; }
.audio-action-call[data-state="active"] svg { transform: rotate(135deg); }
.audio-action-call[data-state="connecting"] .audio-action-icon { animation: audio-calling 1.2s ease-in-out infinite; }
@keyframes audio-calling { 50% { opacity: .4; } }

/* Recording strip: one slim capsule under the audio actions, in the
   header's pill idiom (date chip, document pill). The record button itself
   carries the recording state and elapsed time, like Call Grug; the capsule
   holds only routing, the mode links, and cancel. */
.record-control-surface {
    display: flex;
    align-items: center;
    width: fit-content;
    max-width: 100%;
    min-width: 0;
    height: 40px;
    margin-left: auto;
    padding: 0 8px 0 16px;
    border: 1px solid #ffffff14;
    border-radius: 999px;
    background: #111827f2;
    box-shadow: 0 8px 24px #00000059;
}
[data-record-hud-status] { display: flex; min-width: 0; overflow: hidden; }
.record-hud-status { display: flex; align-items: center; min-width: 0; }
.record-hud-status .target-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #9ca3af;
    font-size: 13px;
}
.record-control-modes { display: flex; align-items: center; flex-shrink: 0; }
.record-mode-button, .record-control-cancel {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 32px;
    padding: 0 10px;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: #9ca3af;
    font-family: inherit;
    font-size: 13px;
    line-height: 1;
    text-transform: lowercase;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: color 150ms ease;
    flex-shrink: 0;
}
.record-mode-button[aria-pressed="true"] { color: #7dd3fc; }
.record-control-cancel svg { width: 12px; height: 12px; flex-shrink: 0; }
.record-mode-button:focus-visible, .record-control-cancel:focus-visible { outline: 2px solid #7dd3fc; outline-offset: -2px; }
@media (hover: hover) {
    .record-mode-button:not([aria-pressed="true"]):hover { color: #f9fafb; }
    .record-control-cancel:hover { color: #fda4af; }
}

/* The live level indicator (was a ring around the header mic): tiny bars in
   the timer row, scaled by grug_audio.js from the analyser. currentColor
   picks up the surrounding text color (white inside the rose pill). */
.record-level { display: flex; align-items: center; gap: 2px; height: 12px; flex-shrink: 0; }
.record-level span {
    width: 2px;
    height: 11px;
    border-radius: 1px;
    background: currentColor;
    transform: scaleY(.25);
    will-change: transform;
}

@media (min-width: 768px) {
    /* The menu occupies the upper-right corner outside the header's row. */
    #top_nav.audio-header { padding-right: 128px; }
}

@media (min-width: 768px) and (max-width: 1199px) {
    #top_nav.audio-header { padding-left: 16px; }
    .audio-header #main_nav { gap: 8px; padding-left: 0; padding-right: 0; grid-template-columns: minmax(0, 1fr) minmax(100px, 180px) auto; }
    .audio-header #mobile-header-user { min-width: 0; max-width: 100px; overflow: hidden; }
    .audio-header #mobile-header-user h2 { overflow: hidden; text-overflow: ellipsis; }
    .audio-header #date-picker { margin-left: 0; margin-right: 0; }
    .audio-header #date-title > div > div { padding-left: 0; padding-right: 0; gap: 0; }
    .audio-header .audio-header-search { flex: 1 1 100px; min-width: 0; padding-right: 0; }
    .audio-header .audio-header-search-field { width: 100%; min-width: 0; }
    .audio-header #search_ask_input { min-width: 0; width: 100%; }
    .audio-action { width: 68px; }
    .audio-actions { gap: 4px; }
}

@media (min-width: 768px) and (max-width: 959px) {
    .audio-header #mobile-header-user { max-width: 80px; }
    .audio-action { width: 60px; }
}

@media (max-width: 767px) {
    #audio.audio-nav { top: 156px; right: 12px; width: auto; height: auto; }
    .audio-actions { gap: 4px; padding: 3px; border: 1px solid #ffffff0d; border-radius: 16px; background: #111827f2; }
    .audio-action { width: 68px; }
    /* While recording, the bar floats where the cluster was; keep it inside
       the viewport, icons-only so everything fits. */
    .audio-actions.audio-actions-recording { max-width: calc(100vw - 24px); }
    .audio-actions-recording .record-control-cancel span { display: none; }
    .audio-actions-recording .record-mode-button span { display: none; }
    .audio-actions-recording .record-mode-button { padding: 0 11px; }
}

/* Very narrow phones (320-419px): compact every segment so the strip's
   non-shrinking controls fit inside the viewport cap instead of the timer
   overlapping End. */
@media (max-width: 419px) {
    .audio-actions.audio-actions-recording { gap: 2px; padding: 5px; }
    .audio-actions-recording .record-mode-button,
    .audio-actions-recording .record-control-cancel { padding: 0 8px; }
    .audio-actions-recording .record-hud-status { font-size: 15px; }
    .audio-actions-recording .record-hud-status::before { margin: 0 7px 0 4px; }
    .audio-actions-recording .record-level { margin-right: 7px; gap: 2px; }
    .audio-actions-recording .record-level span { width: 3px; }
    #record[data-state="recording"] { padding: 0 13px 0 11px; gap: 6px; }
    #record[data-state="recording"] .audio-action-label { font-size: 14px; }
}

@media (prefers-reduced-motion: reduce) {
    .audio-action, .record-mode-button, .record-control-cancel { transition: none; }
    .audio-action-call[data-state="connecting"] .audio-action-icon { animation: none; }
    /* The red End segment + running timer already signal recording. */
    .record-level { display: none; }
    #record[data-state="recording"] { animation: none; }
    .live-audio-status-exit { animation: none; }
}

@media (prefers-reduced-transparency: reduce) {
    .record-control-surface { background: #111827; }
}
