/* ==========================================
   MeowBoard - control panel
   ========================================== */

body {
    height: 100vh;
    overflow: hidden;
}

.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.mt {
    margin-top: 10px;
}

/* === Top bar === */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 24px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.account-name {
    color: var(--text-muted);
    font-weight: 600;
}

.account-name:not(:empty)::before {
    content: '·';
    margin-right: 10px;
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

@media (max-width: 600px) {
    .top-bar {
        padding: 10px 14px;
    }

    .clock {
        display: none;
    }

    .workspace {
        padding: 14px;
    }

    .toolbar,
    .call-row {
        padding-left: 12px;
        padding-right: 12px;
    }

    .call-row {
        grid-template-columns: 22px 64px 1fr;
    }

    .call-actions {
        grid-column: 1 / -1;
        justify-content: flex-end;
    }
}

.connection {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}

.connection .dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--secondary);
}

.connection.online .dot {
    background: var(--success);
}

.connection.offline {
    color: var(--text-danger);
}

.connection.offline .dot {
    background: var(--danger);
}

.clock {
    min-width: 46px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
}

/* === Layout === */
.workspace {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 20px;
    padding: 20px;
}

.command-column {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-height: 0;
    overflow-y: auto;
    padding-right: 4px;
}

.command-column .card {
    flex-shrink: 0;
}

@media (max-width: 1000px) {
    body {
        overflow: auto;
        height: auto;
    }

    .app {
        height: auto;
    }

    .workspace {
        grid-template-columns: 1fr;
    }

    .command-column {
        overflow: visible;
    }

    .calls-card {
        min-height: 70vh;
    }
}

.count {
    display: inline-block;
    min-width: 26px;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--secondary);
    font-size: 13px;
    font-weight: 700;
    text-align: center;
}

/* === New call === */
.segmented {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    padding: 4px;
    margin-bottom: 16px;
    border-radius: 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
}

.segmented button {
    padding: 9px;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: var(--text-muted);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.segmented button[aria-checked='true'][data-mode='judge'] {
    background: var(--primary);
    color: #fff;
}

.segmented button[aria-checked='true'][data-mode='ring'] {
    background: var(--ring);
    color: #fff;
}

.numbers-input {
    font-size: 26px !important;
    font-weight: 800;
    text-align: center;
    padding: 12px !important;
    letter-spacing: 0.02em;
}

.preview {
    margin: -4px 0 14px;
    padding: 8px 12px;
    border-radius: 8px;
    background: rgb(59 130 246 / 0.12);
    color: var(--text-info);
    font-size: 14px;
    font-weight: 600;
}

/* "Verrà annunciato: «...»" under the call buttons */
.phrase-preview {
    margin: -4px 0 14px;
    font-size: 14px;
    color: var(--text-muted);
}

.phrase-preview q {
    display: block;
    margin-top: 2px;
    color: var(--text-main);
    font-weight: 600;
    font-style: italic;
}

.preview.warn {
    background: rgb(245 158 11 / 0.15);
    color: var(--text-warning);
}

.field-note {
    margin: -6px 0 14px;
    font-size: 13px;
    color: var(--text-warning);
}

.call-buttons {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
}

.btn-urgent {
    background: transparent;
    border: 2px solid var(--danger);
    color: var(--text-danger);
    padding-left: 14px;
    padding-right: 14px;
    font-size: 15px;
}

.btn-urgent:hover:not(:disabled) {
    background: var(--danger);
    color: #fff;
}

.ring-mode #callBtn {
    background: var(--ring);
}

.ring-mode #callBtn:hover:not(:disabled) {
    background: #7c3aed;
}

/* === Judges === */
.inline-form {
    display: flex;
    gap: 8px;
}

.inline-form input {
    flex: 1;
    min-width: 0;
}

.judges-list {
    list-style: none;
    margin: 12px 0 0;
    padding: 0;
    max-height: 220px;
    overflow-y: auto;
}

.judges-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 4px 6px 10px;
    border-bottom: 1px solid var(--border);
}

.judges-list li:last-child {
    border-bottom: none;
}

.judges-list .empty {
    color: var(--text-muted);
    justify-content: center;
    border: none;
    padding: 10px;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
}

.icon-btn svg {
    width: 16px;
    height: 16px;
}

.icon-btn:hover {
    color: var(--danger);
    border-color: rgb(239 68 68 / 0.5);
    background: rgb(239 68 68 / 0.1);
}

/* === Active calls === */
.calls-card {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.toolbar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 18px;
    border-bottom: 1px solid var(--border);
}

.toolbar input[type='search'] {
    flex: 1;
}

.select-all {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    white-space: nowrap;
}

.bulk-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 10px 18px;
    background: rgb(59 130 246 / 0.12);
    border-bottom: 1px solid var(--border);
    font-weight: 700;
}

.bulk-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.calls-list {
    flex: 1;
    overflow-y: auto;
}

.call-row {
    display: grid;
    grid-template-columns: 22px 84px 1fr auto;
    align-items: center;
    gap: 14px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--border);
    border-left: 4px solid transparent;
}

.call-row:hover {
    background: var(--bg-hover);
}

.call-row.selected {
    background: rgb(59 130 246 / 0.1);
}

.call-row.urgent {
    border-left-color: var(--danger);
}

.call-row.recalled {
    border-left-color: var(--warning);
}

.call-row.cancelling {
    border-left-color: var(--danger);
    opacity: 0.75;
}

.call-number {
    padding: 4px 0;
    border-radius: 8px;
    background: var(--bg-subtle);
    font-size: 26px;
    font-weight: 900;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.call-info {
    min-width: 0;
}

.call-target {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.kind-tag {
    flex-shrink: 0;
    padding: 1px 7px;
    border-radius: 5px;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: rgb(59 130 246 / 0.2);
    color: var(--text-judge);
}

.kind-tag.ring {
    background: rgb(139 92 246 / 0.2);
    color: var(--text-ring);
}

.call-status {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 3px;
    font-size: 13px;
    color: var(--text-muted);
}

.call-status .tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 700;
}

.call-status .tag svg {
    width: 13px;
    height: 13px;
}

.tag.urgent {
    color: var(--text-danger);
}

.tag.recalled {
    color: var(--text-recall);
}

.tag.cancelling {
    color: var(--text-danger);
}

.tag.used-up {
    color: var(--text-danger);
}

/* Last recall done: the disqualify button is the one to press */
.action-btn.highlight {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

.action-btn.highlight:hover:not(:disabled) {
    background: var(--danger-hover);
    color: #fff;
}

.call-actions {
    display: flex;
    gap: 6px;
}

.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--bg-input);
    color: var(--text-muted);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.action-btn svg {
    width: 15px;
    height: 15px;
}

.action-btn:hover:not(:disabled) {
    color: var(--text-main);
    border-color: var(--secondary);
}

.action-btn.recall:hover:not(:disabled) {
    color: var(--warning);
    border-color: var(--warning);
}

.action-btn.urgent:hover:not(:disabled),
.action-btn.disqualify:hover:not(:disabled),
.action-btn.remove:hover:not(:disabled) {
    color: var(--danger);
    border-color: var(--danger);
}

.action-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* "Richiama" is the action used most: the only one framed and always with its label */
.action-btn.primary {
    padding: 7px 14px;
    border-color: var(--text-muted);
    color: var(--text-main);
}

/* The others are quieter until the pointer is on them */
.action-btn.quiet {
    background: transparent;
    border-color: transparent;
}

/* Labels hidden on narrower screens: icons + tooltips remain (not on "Richiama") */
@media (max-width: 1350px) {
    .action-btn:not(.primary):not(.highlight) .label {
        display: none;
    }
}

.list-empty {
    padding: 48px 20px;
    text-align: center;
    color: var(--text-muted);
}

.list-empty svg {
    width: 36px;
    height: 36px;
    opacity: 0.6;
}

/* === Settings dialog === */
.settings-dialog {
    width: min(560px, calc(100vw - 32px));
}

.settings-section {
    padding: 16px 0;
    border-top: 1px solid var(--border);
}

.settings-section:first-of-type {
    border-top: none;
    padding-top: 6px;
}

.settings-section h4 {
    margin: 0 0 8px;
    font-size: 15px;
}

.settings-section .inline-form {
    margin: 10px 0;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 10px 0;
    cursor: pointer;
}

.languages-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 12px;
}

.languages-grid label.field {
    margin-bottom: 0;
}

.announce-lang {
    margin: 10px 0 0;
}

input[type='range'] {
    width: 100%;
    accent-color: var(--primary);
}

/* === Translations: hidden until the texts are loaded (no flash of Italian) === */
.i18n-loading body {
    visibility: hidden;
}

/* === Top bar extras === */
.status-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: transparent;
    color: var(--text-muted);
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
}

.status-chip.static {
    cursor: default;
}

.status-chip::before {
    content: '';
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--secondary);
}

.status-chip.ok {
    color: var(--text-success);
}

.status-chip.ok::before {
    background: var(--success);
}

.status-chip.warn {
    color: var(--text-warning);
    border-color: var(--warning);
}

.status-chip.warn::before {
    background: var(--warning);
}

.status-chip.bad {
    color: var(--text-danger);
    border-color: var(--danger);
}

.status-chip.bad::before {
    background: var(--danger);
}

.operator-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-main);
}

.link-btn {
    padding: 0;
    border: none;
    background: none;
    color: var(--primary);
    font: inherit;
    font-weight: 600;
    text-decoration: underline;
    cursor: pointer;
}

/* === Banners under the top bar === */
.banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 600;
}

.banner-warning {
    background: rgb(245 158 11 / 0.15);
    color: var(--text-warning);
    border-bottom: 1px solid var(--warning);
}

.banner-demo {
    background: rgb(220 38 38 / 0.15);
    color: var(--text-danger);
    border-bottom: 1px solid var(--danger);
}

/* === Demo accounts === */
.demo-badge {
    padding: 2px 10px;
    border-radius: 6px;
    background: #dc2626;
    color: #fff;
    font-size: 13px;
    font-weight: 900;
    letter-spacing: 0.08em;
}

.demo-watermark {
    position: fixed;
    inset: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    font-size: 26vw;
    font-weight: 900;
    letter-spacing: 0.1em;
    color: rgb(220 38 38 / 0.07);
    transform: rotate(-18deg);
}

.is-demo .demo-hide,
.is-demo #judgeEditor {
    display: none !important;
}

.demo-only {
    display: none;
}

.is-demo .demo-only {
    display: block;
}

.is-demo #demoJudgesNote {
    display: block !important;
}

/* === "?" help === */
.label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

.label-row label,
.label-row h4 {
    margin: 0;
}

.field > .label-row label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}

.help-btn {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    font: inherit;
    font-size: 12px;
    font-weight: 800;
    line-height: 1;
    cursor: pointer;
}

.help-btn:hover {
    color: var(--primary);
    border-color: var(--primary);
}

.help-pop {
    position: fixed;
    z-index: 2000;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-card);
    color: var(--text-main);
    box-shadow: var(--shadow);
    font-size: 14px;
    line-height: 1.45;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.shortcuts-hint {
    margin: 10px 0 0;
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
}

/* === Toast with "Annulla" === */
.toast {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.toast-action {
    flex-shrink: 0;
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    background: var(--primary);
    color: #fff;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
}

/* === Settings extras === */
.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

.audio-check {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 6px;
}

.operators-list {
    margin: 0 0 12px;
}

.operators-list em {
    color: var(--text-muted);
    font-style: normal;
    font-size: 13px;
}

.pin-input {
    max-width: 150px;
}

.pin-input.big {
    max-width: none;
    font-size: 22px;
    letter-spacing: 0.3em;
    text-align: center;
}

.operator-choices {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 14px 0;
}

.operator-choice {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
}

.operator-choice:has(input:checked) {
    border-color: var(--primary);
    background: rgb(59 130 246 / 0.12);
}

dialog textarea {
    margin-top: 6px;
}

/* === Wizard === */
.wizard-dialog {
    width: min(620px, calc(100vw - 32px));
}

.wizard-step {
    margin: 0 0 6px !important;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--primary) !important;
}

.wizard-page {
    min-height: 260px;
}

.wizard-page .inline-form {
    margin: 14px 0;
}

.wizard-actions .spacer {
    flex: 1;
}

.wizard-actions {
    justify-content: flex-start;
}

.status-line {
    margin-top: 14px !important;
    font-weight: 700;
}

.status-line.ok {
    color: var(--text-success) !important;
}

.status-line.warn {
    color: var(--text-warning) !important;
}

.shortcut-list {
    list-style: none;
    margin: 12px 0 18px;
    padding: 0;
}

.shortcut-list li {
    margin-bottom: 6px;
}

kbd {
    display: inline-block;
    min-width: 120px;
    margin-right: 10px;
    padding: 2px 8px;
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: 6px;
    background: var(--bg-input);
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    text-align: center;
}

/* Field blocks that contain a "?" next to their label */
div.field {
    margin-bottom: 14px;
}

/* === "In annuncio sul display" === */
.now-playing {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 24px;
    background: rgb(59 130 246 / 0.15);
    border-bottom: 1px solid var(--primary);
    color: var(--text-info);
    font-size: 15px;
}

.now-playing strong {
    color: var(--text-main);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.now-playing-icon {
    display: flex;
    color: var(--primary);
    animation: now-playing 1s ease-in-out infinite alternate;
}

.now-playing-icon svg {
    width: 20px;
    height: 20px;
}

.now-playing-queue {
    margin-left: auto;
    flex-shrink: 0;
    font-weight: 600;
}

@keyframes now-playing {
    to {
        opacity: 0.35;
    }
}

/* === World Show / Jubilee rings switches (under the ring list) === */
.ring-groups {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: -4px 0 14px;
    font-size: 13px;
    color: var(--text-muted);
}

.toggle-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text-main);
    font-weight: 600;
    cursor: pointer;
}

.toggle-chip:has(input:checked) {
    border-color: var(--primary);
    background: rgb(59 130 246 / 0.15);
}

.toggle-chip input {
    width: 16px;
    height: 16px;
}

/* === Chime on/off (top bar) === */
.chime-btn {
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: transparent;
    color: var(--text-main);
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
}

.chime-btn.off {
    color: var(--text-muted);
    border-style: dashed;
}

.chime-btn:hover {
    border-color: var(--primary);
}

/* The label on its own line, the two switches side by side under it */
.ring-groups > span:first-child {
    flex-basis: 100%;
}

/* === Judges' phones (judges card) === */
.judge-name {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.judge-dot {
    flex-shrink: 0;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--border);
}

.judge-dot.on {
    background: var(--success);
    box-shadow: 0 0 0 3px rgb(34 197 94 / 0.2);
}

.judge-tools {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.pin-chip {
    padding: 3px 8px;
    border: 1px dashed var(--border);
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    font: inherit;
    font-size: 12px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.05em;
    cursor: pointer;
}

.pin-chip:hover {
    border-color: var(--primary);
    color: var(--text-main);
}

.judge-qr-box {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.judge-qr-box .hint {
    margin: 0 0 8px;
}

.judge-qr-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
