/* Dashboards V2 — uses Portal V2 theme tokens. All colors derived from CSS variables so light/dark work automatically. */

/* Toolbar panel wraps with overflow:hidden; allow dropdowns to escape */
.dashboards-toolbar.portal-panel,
.dashboards-toolbar .portal-panel-body {
    overflow: visible !important;
}

/* Ensure toolbar stacks above the card grid so dropdowns aren't covered */
.dashboards-toolbar {
    position: relative;
    z-index: 1030;
}

.dashboards-toolbar .dropdown-menu {
    z-index: 1055;
}

.dashboards-toolbar .dashboards-switcher .dropdown-menu {
    min-width: 260px;
    max-height: 400px;
    overflow-y: auto;
}

.dashboards-toolbar .vr {
    opacity: 0.4;
}

/* Feed grid */
.feed-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 16px;
    align-items: stretch;
}

.feed-card {
    display: flex;
    flex-direction: column;
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.feed-card.sortable-ghost {
    opacity: 0.4;
}

.feed-card.sortable-chosen {
    box-shadow: 0 0 0 2px var(--cui-primary);
}

/* Active Vox feed — amber/yellow gradient mirrored from calls playlists .tg-card-active, pulsing */
@keyframes dashboards-scan-pulse {
    0%, 100% {
        box-shadow:
            0 22px 46px rgba(25, 21, 4, 0.55),
            0 0 0 2px rgba(255, 224, 122, 0.55),
            0 0 32px rgba(255, 220, 105, 0.28);
    }
    50% {
        box-shadow:
            0 24px 52px rgba(25, 21, 4, 0.6),
            0 0 0 3px rgba(255, 224, 122, 0.85),
            0 0 48px rgba(255, 220, 105, 0.45);
    }
}

.feed-card.scan-active {
    border-color: rgba(255, 224, 122, 0.9) !important;
    background:
        radial-gradient(320px 160px at 12% 0%, rgba(255, 224, 122, 0.26), transparent 72%),
        linear-gradient(180deg, rgba(112, 96, 28, 0.98), rgba(55, 45, 14, 0.99)) !important;
    transform: translateY(-1px);
    transition: background 0.2s ease, transform 0.2s ease;
    animation: dashboards-scan-pulse 1.8s ease-in-out infinite;
    position: relative;
    z-index: 2;
}

.feed-card.scan-active .card-header {
    border-bottom-color: rgba(255, 224, 122, 0.6) !important;
    background:
        radial-gradient(300px 110px at 10% 0%, rgba(255, 226, 128, 0.26), transparent 70%),
        linear-gradient(135deg, rgba(148, 128, 36, 0.98), rgba(75, 62, 16, 0.98)) !important;
}

.feed-card.scan-active .feed-title {
    color: #fff5d0 !important;
    text-shadow: 0 0 10px rgba(255, 224, 122, 0.35);
}

.feed-card.scan-active .feed-position {
    background-color: rgba(255, 224, 122, 0.9) !important;
    color: #2a1f05 !important;
}

.feed-card.scan-muted {
    opacity: 0.55;
    filter: saturate(0.6);
    transition: opacity 0.2s ease, filter 0.2s ease;
}

/* Orphan slot — dashboard row points to a feed that no longer exists in
   audio_feed. Greyed out, only the Remove button is interactive. */
.feed-card-orphan {
    opacity: 0.7;
    filter: saturate(0.5);
}

.feed-card-orphan .card-header {
    background: var(--cui-tertiary-bg, rgba(0, 0, 0, 0.04)) !important;
}

.feed-card-orphan .card-body {
    padding: 0.75rem 1rem;
}

[data-coreui-theme="dark"] .feed-card-orphan {
    opacity: 0.6;
}

/* Visually-disabled-but-hoverable: keeps tooltips firing (the `disabled` attribute
 * blocks mouseover events, which kills Bootstrap/CoreUI tooltips). */
.scan-locked {
    opacity: 0.45;
    cursor: not-allowed !important;
    pointer-events: auto; /* keep hover so tooltip fires */
    filter: grayscale(0.4);
}

.scan-locked:hover {
    opacity: 0.55;
}

.scan-locked:active {
    transform: none !important;
}

.dashboards-safari-alert {
    margin-bottom: 12px;
}

.feed-card .card-header {
    padding: 0.5rem 0.75rem;
    font-size: 0.95rem;
}

.feed-position {
    font-size: 0.7rem;
    font-weight: 600;
}

.feed-title {
    font-weight: 600;
    font-size: 0.95rem;
}

.feed-title[contenteditable="true"] {
    outline: 2px solid var(--cui-primary);
    background: var(--cui-body-bg);
    border-radius: 3px;
    padding: 0 4px;
}

.feed-rename {
    color: var(--cui-body-color);
    opacity: 0.5;
}

.feed-rename:hover {
    opacity: 1;
}

/* Status dot */
.feed-status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #6c757d;
    margin-right: 6px;
    vertical-align: middle;
}

.feed-status-dot[data-status="1"] {
    background: #28a745;
    box-shadow: 0 0 6px rgba(40, 167, 69, 0.5);
}

.feed-status-dot[data-status="0"] {
    background: #dc3545;
}

/* VU meter */
.vu-meter-wrap {
    background: var(--cui-tertiary-bg, rgba(0, 0, 0, 0.04));
    border-radius: 4px;
    padding: 4px;
    margin-bottom: 0.5rem;
    position: relative;
}

.vu-meter {
    display: block;
    width: 100%;
    height: 22px;
    margin-bottom: 2px;
    image-rendering: crisp-edges;
}
.vu-meter:last-child {
    margin-bottom: 0;
}

/* Per-card vox readout (visible only while scan mode is on) */
.vox-readout {
    margin-top: -0.25rem;
    margin-bottom: 0.5rem;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}
.vox-readout-sep {
    opacity: 0.5;
}
.vox-tune-btn {
    line-height: 1;
}

/* Auto-tune-all button in the toolbar (shown only when scan is on) */
.dashboards-autotune-all {
    font-size: 0.7rem;
    text-decoration: none;
    margin-top: 0.25rem;
}
.dashboards-autotune-all:hover {
    text-decoration: underline;
}

.vu-channel-label {
    position: absolute;
    left: 6px;
    font-size: 0.6rem;
    color: rgba(255, 255, 255, 0.6);
    font-weight: 600;
    pointer-events: none;
    letter-spacing: 0.05em;
}
.vu-meter-wrap { position: relative; }

/* Sliders */
.feed-sliders .slider-row {
    display: grid;
    grid-template-columns: 40px 1fr;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.feed-sliders .slider-row label {
    margin: 0;
    text-align: right;
    padding-right: 6px;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.04em;
}

.feed-sliders .form-range {
    margin: 0;
}

/* ID3 */
.feed-id3 .id3-title {
    font-style: italic;
}

/* Connecting / reconnecting / buffering status bar — matches listen pattern */
.feed-status-bar {
    font-size: 0.78rem;
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 3px;
    margin-bottom: 6px;
    text-align: center;
    letter-spacing: 0.02em;
}

.feed-status-info {
    background: rgba(13, 110, 253, 0.18);
    color: #6ea8fe;
    border: 1px solid rgba(110, 168, 254, 0.3);
}

.feed-status-success {
    background: rgba(25, 135, 84, 0.18);
    color: #75d99e;
    border: 1px solid rgba(117, 217, 158, 0.3);
}

.feed-status-warn {
    background: rgba(255, 193, 7, 0.18);
    color: #ffd86b;
    border: 1px solid rgba(255, 216, 107, 0.35);
}

.feed-status-error {
    background: rgba(220, 53, 69, 0.2);
    color: #ff8a96;
    border: 1px solid rgba(255, 138, 150, 0.35);
}

[data-coreui-theme="light"] .feed-status-info { color: #084298; background: #cfe2ff; border-color: #b6d4fe; }
[data-coreui-theme="light"] .feed-status-success { color: #0f5132; background: #d1e7dd; border-color: #badbcc; }
[data-coreui-theme="light"] .feed-status-warn { color: #664d03; background: #fff3cd; border-color: #ffecb5; }
[data-coreui-theme="light"] .feed-status-error { color: #842029; background: #f8d7da; border-color: #f5c2c7; }

.feed-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
}

.feed-meta-right {
    margin-left: auto;
    text-align: right;
    white-space: nowrap;
}

.feed-meta .feed-vol,
.feed-meta .feed-pan-status {
    font-variant-numeric: tabular-nums;
}

/* Scan-mode state on toolbar */
.dashboards-scan .form-check-input:checked {
    background-color: #28a745;
    border-color: #28a745;
}

/* Play/stop icon state */
.feed-play.is-playing {
    color: #fff;
    background-color: var(--cui-danger);
    border-color: var(--cui-danger);
}

.feed-play.is-playing i::before {
    content: "\f04d"; /* fa-stop */
}

/* Mute state */
.feed-mute.is-muted {
    color: var(--cui-warning);
}

/* Solo state */
.feed-solo.is-solo {
    background-color: var(--cui-primary);
    color: #fff;
    border-color: var(--cui-primary);
}

/* Read-only hint */
.feed-grid[data-read-only="1"] .feed-sliders {
    opacity: 0.85;
}

/* Dark-mode card theming — deeper contrast than CoreUI default */
[data-coreui-theme="dark"] .feed-card {
    background-color: #141821;
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

[data-coreui-theme="dark"] .feed-card .card-header {
    background-color: #0f131a;
    border-bottom-color: rgba(255, 255, 255, 0.06);
}

[data-coreui-theme="dark"] .feed-card .card-body {
    background-color: #141821;
}

[data-coreui-theme="dark"] .vu-meter-wrap {
    background: #0a0d13;
    border: 1px solid rgba(255, 255, 255, 0.04);
}

[data-coreui-theme="dark"] .feed-position {
    background-color: rgba(255, 255, 255, 0.08) !important;
    color: rgba(255, 255, 255, 0.7);
}

[data-coreui-theme="dark"] .feed-card:hover {
    border-color: rgba(255, 255, 255, 0.15);
}

/* Empty state */
.dashboards-empty {
    text-align: center;
    padding: 2rem;
    color: var(--cui-secondary-color);
}

/* Now-active (scan) indicator */
.now-active-banner {
    position: sticky;
    top: 0;
    background: #28a745;
    color: #fff;
    padding: 6px 12px;
    border-radius: 4px;
    margin-bottom: 8px;
    font-size: 0.9rem;
    display: none;
}

.now-active-banner.visible {
    display: block;
    background: linear-gradient(90deg, rgba(112, 96, 28, 0.98), rgba(75, 62, 16, 0.98));
    color: #fff5d0;
    border: 1px solid rgba(255, 224, 122, 0.5);
}

/* Keyboard shortcuts help modal (lightweight, no Bootstrap dep) */
.shortcuts-help {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2000;
    background: var(--cui-body-bg, #1a1f2b);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    padding: 16px 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    min-width: 280px;
}

.shortcuts-help-inner table { width: 100%; }
.shortcuts-help-inner td { padding: 3px 8px; }
.shortcuts-help-inner kbd {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 3px;
    padding: 2px 6px;
    font-size: 0.75rem;
    font-family: monospace;
}
.shortcuts-help-inner .btn-close {
    position: absolute;
    top: 8px;
    right: 8px;
}
