/* ─── Модуль «Аудио на ТВ» ─── */

.audio-tv-page-header {
    margin-bottom: 22px;
}

.audio-tv-page-intro {
    max-width: 820px;
    margin: 0 0 14px;
    line-height: 1.55;
    color: var(--muted);
    font-size: 14px;
}

.audio-tv-page-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.audio-tv-page-hint {
    margin: 0;
    font-size: 13px;
}

.audio-tv-section-title {
    margin: 28px 0 16px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(148, 163, 184, 0.9);
}

.audio-tv-section-title:first-of-type {
    margin-top: 8px;
}

.audio-tv-page .screens-list,
.audio-tv-screens-layout {
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 22px;
}

/* Карточки в стиле device-card */
.audio-tv-card.device-card {
    padding: 0;
}

.device-card--audio .device-card__accent {
    background: #3b82f6;
}

.device-card--youtube .device-card__accent {
    background: #1e40af;
}

.device-card--audio .device-card__icon {
    background: rgba(59, 130, 246, 0.14);
    color: var(--brand-text-soft, var(--blue));
    border-color: rgba(59, 130, 246, 0.2);
}

.device-card--youtube .device-card__icon {
    background: rgba(30, 64, 175, 0.12);
    color: var(--brand-text, var(--blue));
    border-color: rgba(30, 64, 175, 0.2);
}

.device-card--unassigned-audio .device-card__accent {
    background: #64748b;
}

.device-card--unassigned-audio .device-card__icon {
    background: rgba(148, 163, 184, 0.12);
    color: #94a3b8;
    border-color: rgba(148, 163, 184, 0.2);
}

.device-status--sync {
    background: var(--brand-bg-soft, rgba(59, 130, 246, 0.12));
    color: var(--brand-text, var(--blue));
    border: 1px solid var(--brand-border, rgba(59, 130, 246, 0.25));
}

.audio-tv-card__body {
    padding: 0 20px 4px;
}

.audio-tv-meta-strip {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(148, 163, 184, 0.08);
    border: 1px solid var(--border);
}

.audio-tv-meta-strip__kind {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}

.audio-tv-meta-strip__code {
    font-family: ui-monospace, 'Cascadia Code', monospace;
    font-size: 13px;
    font-weight: 600;
    color: var(--blue);
    padding: 3px 8px;
    border-radius: 6px;
    background: rgba(59, 130, 246, 0.1);
}

.device-status--sync .device-status__dot {
    background: var(--brand-blue, #3b82f6);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
    animation: device-pulse 2s ease-in-out infinite;
}

.device-card--youtube .audio-tv-meta-strip__code {
    color: var(--brand-text-soft, var(--blue));
    background: rgba(59, 130, 246, 0.1);
}

.audio-tv-meta-strip__group {
    margin-left: auto;
    font-size: 12px;
    color: var(--muted);
}

.audio-tv-meta-strip__group strong {
    color: var(--text-heading);
}

.audio-tv-mode-badge {
    display: inline-flex;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    background: var(--brand-bg-soft, rgba(59, 130, 246, 0.12));
    color: var(--brand-pill-text, var(--blue));
    border: 1px solid var(--brand-border, rgba(59, 130, 246, 0.2));
}

.audio-tv-card__hint {
    margin: 0 0 14px;
    font-size: 13px;
    line-height: 1.45;
    color: var(--muted);
    text-align: center;
}

.audio-tv-player-wrap {
    margin-bottom: 14px;
    padding: 12px;
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.04);
    border: 1px solid var(--border);
}

[data-theme="dark"] .audio-tv-player-wrap {
    background: rgba(0, 0, 0, 0.22);
}

.audio-tv-native {
    width: 100%;
    height: 40px;
    border-radius: 8px;
}

.audio-tv-preview {
    margin-bottom: 14px;
    aspect-ratio: 16 / 9;
    max-height: 220px;
    border-radius: 12px;
    overflow: hidden;
    background: #0f172a;
    border: 1px solid var(--border);
}

.audio-tv-preview iframe {
    width: 100%;
    height: 100%;
    border: 0;
}

.audio-tv-preview--audio-only {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
}

.audio-tv-open-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--blue);
    text-decoration: none;
}

.audio-tv-open-link:hover {
    text-decoration: underline;
}

.audio-tv-tv-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 4px;
}

.audio-tv-tv-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(148, 163, 184, 0.06);
    border: 1px solid transparent;
}

.audio-tv-tv-item__name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-heading);
}

.audio-tv-add-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: stretch;
}

.audio-tv-add-row .form-input {
    flex: 1 1 180px;
    min-width: 0;
}

.audio-tv-add-row .device-btn {
    flex: 0 0 auto;
}

.audio-tv-sync-muted {
    width: 100%;
    margin: 0;
    font-size: 13px;
    color: var(--muted);
}

/* Мастер */
.audio-tv-wizard-launch {
    margin-bottom: 8px;
}

.audio-tv-wizard {
    margin-bottom: 24px;
    padding: 0;
    border-radius: 16px;
    overflow: hidden;
    background: var(--card);
    border: 1px solid var(--border);
    box-shadow: 0 4px 20px rgba(15, 23, 42, 0.06);
}

[data-theme="dark"] .audio-tv-wizard {
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

.audio-tv-wizard__accent {
    height: 4px;
    background: #3b82f6;
}

.audio-tv-wizard-top {
    padding: 20px 22px 0;
}

.audio-tv-wizard-title {
    margin: 0 0 16px;
    font-size: 20px;
    font-weight: 700;
    color: var(--text-heading);
}

.audio-tv-wsteps {
    list-style: none;
    margin: 0;
    padding: 0 0 18px;
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
}

.audio-tv-wsteps .audio-tv-wstep {
    flex: 1;
    position: relative;
    display: flex;
    justify-content: center;
    padding-bottom: 4px;
}

.audio-tv-wsteps .audio-tv-wstep:not(:last-child)::after {
    content: '';
    position: absolute;
    top: 14px;
    left: calc(50% + 18px);
    right: calc(-50% + 18px);
    height: 2px;
    background: var(--border);
    z-index: 0;
}

.audio-tv-wsteps .audio-tv-wstep.done:not(:last-child)::after {
    background: var(--blue);
}

.audio-tv-wstep-num {
    position: relative;
    z-index: 1;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    background: var(--border);
    color: var(--muted);
}

.audio-tv-wstep.active .audio-tv-wstep-num {
    background: var(--blue);
    color: #fff;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2);
}

.audio-tv-wstep.done .audio-tv-wstep-num {
    background: #3b82f6;
    color: #fff;
}

.audio-tv-wizard-body {
    padding: 22px;
}

.audio-tv-wizard-h {
    margin: 0 0 8px;
    font-size: 17px;
    font-weight: 700;
    color: var(--text-heading);
}

.audio-tv-wizard-p {
    margin: 0 0 16px;
    max-width: 560px;
    line-height: 1.5;
}

.audio-tv-kind-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    margin: 18px 0 22px;
}

.audio-tv-kind-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 18px;
    border-radius: 14px;
    border: 2px solid var(--border);
    background: rgba(148, 163, 184, 0.04);
    cursor: pointer;
    text-align: left;
    transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.audio-tv-kind-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

.audio-tv-kind-card--audio:hover {
    border-color: rgba(139, 92, 246, 0.45);
}

.audio-tv-kind-card--youtube:hover {
    border-color: rgba(239, 68, 68, 0.45);
}

.audio-tv-kind-card__icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.audio-tv-kind-card--audio .audio-tv-kind-card__icon {
    background: rgba(59, 130, 246, 0.14);
    color: var(--brand-text-soft, var(--blue));
}

.audio-tv-kind-card--youtube .audio-tv-kind-card__icon {
    background: rgba(30, 64, 175, 0.12);
    color: var(--brand-text, var(--blue));
}

.audio-tv-kind-card__icon svg {
    width: 22px;
    height: 22px;
}

.audio-tv-kind-card__title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-heading);
}

.audio-tv-kind-card__text {
    font-size: 12px;
    line-height: 1.45;
    color: var(--muted);
}

.audio-tv-yt-mode-row {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 16px 0;
    padding: 14px;
    border-radius: 12px;
    background: rgba(148, 163, 184, 0.06);
    border: 1px solid var(--border);
}

.audio-tv-yt-mode-row__label {
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.audio-tv-yt-mode-options {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.audio-tv-yt-mode-options label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text);
}

.audio-tv-wizard-pick-audio {
    margin: 0 0 8px;
    font-size: 14px;
}

.audio-tv-wizard-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px dashed var(--border);
}

.audio-tv-wizard-tv-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 280px;
    overflow-y: auto;
    padding: 4px 2px;
}

.audio-tv-wizard-tv {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(148, 163, 184, 0.04);
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.audio-tv-wizard-tv:hover {
    border-color: rgba(59, 130, 246, 0.35);
    background: rgba(59, 130, 246, 0.06);
}

.audio-tv-wizard-tv input {
    margin-top: 3px;
    flex-shrink: 0;
}

.audio-tv-wizard-tv-note {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: var(--muted);
    font-weight: 400;
}

/* Device-first dashboard */
.audio-tv-stats {
    margin-bottom: 20px;
}

.audio-tv-control-panel {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 14px;
    align-items: center;
    margin-bottom: 22px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--card);
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.06);
}

.audio-tv-bulk-selection,
.audio-tv-select-all,
.audio-tv-bulk-controls,
.audio-tv-panel-actions {
    display: flex;
    align-items: center;
}

.audio-tv-bulk-selection {
    grid-column: 1;
    grid-row: 1;
    gap: 12px;
    white-space: nowrap;
}

.audio-tv-select-all {
    gap: 8px;
    font-size: 13px;
    font-weight: 650;
    color: var(--text);
    cursor: pointer;
}

.audio-tv-select-all input,
.audio-tv-wizard-select-all input {
    width: 17px;
    height: 17px;
    accent-color: var(--blue);
}

.audio-tv-selected-count {
    padding: 5px 9px;
    border-radius: 999px;
    background: rgba(59, 130, 246, 0.1);
    color: var(--blue);
    font-size: 12px;
    font-weight: 700;
}

.audio-tv-bulk-controls {
    grid-column: 1 / -1;
    grid-row: 2;
    gap: 8px;
    min-width: 0;
}

.audio-tv-bulk-controls .form-input {
    min-width: 190px;
    flex: 1 1 240px;
}

.audio-tv-bulk-controls .btn,
.audio-tv-panel-actions .btn {
    justify-content: center;
    white-space: nowrap;
}

.audio-tv-panel-actions {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    gap: 8px;
}

.audio-tv-wizard {
    margin-bottom: 22px;
}

.audio-tv-wizard-select-all {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    margin: 8px 0 12px;
    font-size: 13px;
    font-weight: 650;
    color: var(--text);
    cursor: pointer;
}

.audio-tv-device-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin: 4px 0 14px;
}

.audio-tv-device-heading h2 {
    margin: 0;
    font-size: 18px;
    color: var(--text-heading);
}

.audio-tv-device-heading p {
    margin: 5px 0 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
}

.audio-tv-page .audio-tv-device-grid {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 18px;
}

.audio-tv-device-card .screen-card__body {
    height: 100%;
}

.audio-tv-device-current {
    display: flex;
    align-items: center;
    gap: 11px;
    margin-top: 12px;
    padding: 11px 12px;
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 11px;
    background: rgba(59, 130, 246, 0.07);
}

.audio-tv-device-current--none {
    border-color: var(--border);
    background: rgba(148, 163, 184, 0.06);
}

.audio-tv-device-current--youtube {
    border-color: rgba(37, 99, 235, 0.24);
    background: rgba(37, 99, 235, 0.08);
}

.audio-tv-device-current__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    border-radius: 10px;
    background: rgba(59, 130, 246, 0.12);
    color: var(--blue);
}

.audio-tv-device-current__icon svg {
    width: 21px;
    height: 21px;
}

.audio-tv-device-current__copy {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.audio-tv-device-current__copy small {
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.audio-tv-device-current__copy strong {
    overflow: hidden;
    color: var(--text-heading);
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.audio-tv-device-current__copy > span {
    color: var(--muted);
    font-size: 11px;
}

.audio-tv-device-actions {
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.audio-tv-device-assign-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

.audio-tv-device-assign-row .btn {
    width: 100%;
    justify-content: center;
}

.audio-tv-device-assign-row .form-input {
    min-width: 0;
}

.audio-tv-device-sync-actions,
.audio-tv-device-sync-actions .device-actions-primary {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.audio-tv-device-sync-actions .btn {
    flex: 1 1 130px;
    justify-content: center;
}

.audio-tv-device-card .btn:disabled,
.audio-tv-control-panel .btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

@media (max-width: 720px) {
    .audio-tv-page .screens-list,
    .audio-tv-screens-layout {
        grid-template-columns: 1fr;
    }

    .audio-tv-kind-grid {
        grid-template-columns: 1fr;
    }

    .audio-tv-control-panel {
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .audio-tv-bulk-selection,
    .audio-tv-bulk-controls,
    .audio-tv-panel-actions {
        flex-wrap: wrap;
    }

    .audio-tv-bulk-controls .form-input,
    .audio-tv-bulk-controls .btn,
    .audio-tv-panel-actions .btn {
        width: 100%;
        flex: 1 1 100%;
    }

    .audio-tv-device-assign-row {
        grid-template-columns: 1fr;
    }
}
