/* ═══════════════════════════════════════════════════════════════════
   StreamersForge — Control Panel (Stream Deck)
   Mobile-first responsive layout for triggering overlay animations
   ═══════════════════════════════════════════════════════════════════ */

/* ─── Container ──────────────────────────────────────────────────── */
.control-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: var(--space-4);
    gap: var(--space-4);
    width: 100%;
    max-width: 960px;
    margin: 0;
}

/* ─── Master Overlay URL Box ─────────────────────────────────────── */
.cp-url-box {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    flex-shrink: 0;
}

.cp-url-label {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    flex-shrink: 0;
}

.cp-url-label svg {
    width: 16px;
    height: 16px;
}

.cp-url-field {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
    gap: var(--space-2);
}

.cp-url-input {
    flex: 1;
    min-width: 0;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-xs);
    color: var(--text-muted);
    font-family: 'SF Mono', 'Cascadia Code', monospace;
    outline: none;
    cursor: text;
}

.cp-url-input:focus {
    border-color: var(--accent);
}

.cp-url-copy {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--accent-muted);
    border: none;
    border-radius: var(--radius-md);
    color: var(--accent-light);
    cursor: pointer;
    flex-shrink: 0;
    transition: all var(--transition-base);
}

.cp-url-copy:hover {
    background: var(--accent);
    color: #fff;
}

.cp-url-copy svg {
    width: 14px;
    height: 14px;
}

/* ─── Scene Tabs ─────────────────────────────────────────────────── */
.cp-tabs {
    display: flex;
    gap: var(--space-2);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: var(--space-1);
    flex-shrink: 0;
}

.cp-tabs::-webkit-scrollbar {
    display: none;
}

.cp-tab {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    min-height: 44px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    color: var(--text-secondary);
    font-size: var(--text-sm);
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    scroll-snap-align: start;
    transition: all var(--transition-base);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.cp-tab:hover {
    background: var(--bg-elevated);
    border-color: var(--border-default);
    color: var(--text-primary);
}

.cp-tab.active {
    background: var(--accent-muted);
    border-color: var(--border-accent);
    color: var(--text-primary);
}

.cp-tab-live {
    background: rgba(34, 197, 94, 0.1);
    border-color: rgba(34, 197, 94, 0.3);
}

.cp-tab-live.active {
    background: rgba(34, 197, 94, 0.18);
    border-color: rgba(34, 197, 94, 0.45);
}

/* ─── Tab Drag & Drop ────────────────────────────────────────── */
.cp-tab-dragging {
    opacity: 0.35;
}

.cp-tab-dropzone {
    width: 4px;
    min-height: 36px;
    flex-shrink: 0;
    padding: 0 30px;
    background: transparent;
    position: relative;
    align-self: stretch;
    box-sizing: content-box;
}

.cp-tab-dropzone::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    border-radius: var(--radius-md);
    background: transparent;
    transition: all 0.15s ease;
}

.cp-tab-dropzone-active::before {
    width: 150px;
    background: var(--accent-muted);
    border: 2px dashed var(--accent);
    box-shadow: 0 0 12px rgba(124, 58, 237, 0.4);
}

/* ─── Activate Scene Button ──────────────────────────────────────── */
.cp-status-bar {
    flex-shrink: 0;
}

.cp-activate-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    width: 100%;
    padding: var(--space-3) var(--space-4);
    min-height: 44px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-lg);
    font-size: var(--text-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    -webkit-tap-highlight-color: transparent;
}

.cp-activate-btn:hover {
    background: var(--accent-light);
    box-shadow: var(--shadow-glow);
}

.cp-activate-btn svg {
    width: 16px;
    height: 16px;
}

.cp-activate-bar.active {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
    border-radius: var(--radius-lg);
    color: var(--success);
    font-size: var(--text-sm);
    font-weight: 600;
}

.cp-activate-bar.active svg {
    width: 16px;
    height: 16px;
}

/* ─── Animation Cards Grid (4 columns desktop, 1 mobile) ────────── */
.cp-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-2);
    overflow-y: auto;
    flex: 1;
    padding-bottom: var(--space-4);
    align-content: start;
}

/* ─── Animation Card (compact 2-line design) ─────────────────────── */
.cp-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) var(--space-4);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    gap: var(--space-3);
    transition: all var(--transition-base);
}

.cp-card:hover {
    border-color: var(--border-default);
    box-shadow: var(--shadow-md);
}

.cp-card.disabled {
    opacity: 0.35;
}

.cp-card-left {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.cp-card-name {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cp-card-meta {
    font-size: var(--text-xs);
    color: var(--text-muted);
}

.cp-card-right {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-shrink: 0;
}

/* ─── Toggle Switch ──────────────────────────────────────────────── */
.cp-toggle {
    position: relative;
    width: 36px;
    height: 20px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
}

.cp-toggle input {
    display: none;
}

.cp-toggle-track {
    position: absolute;
    inset: 0;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-full);
    transition: all var(--transition-base);
}

.cp-toggle input:checked+.cp-toggle-track {
    background: var(--success);
    border-color: var(--success);
}

.cp-toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 50%;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition-spring);
}

.cp-toggle input:checked~.cp-toggle-thumb {
    transform: translateX(16px);
}

/* ─── Play Button ────────────────────────────────────────────────── */
.cp-play-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--accent), #9333ea);
    color: #fff;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
}

.cp-play-btn:hover {
    box-shadow: var(--shadow-glow);
    transform: translateY(-1px);
}

.cp-play-btn:active {
    transform: translateY(0) scale(0.95);
}

.cp-play-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.cp-play-btn svg {
    width: 16px;
    height: 16px;
}

.cp-play-btn.cooldown {
    background: var(--bg-elevated);
    pointer-events: none;
}

/* ─── Overlay Group Headers ──────────────────────────────────────── */
.cp-group-header {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--border-subtle);
    margin-top: var(--space-2);
}

.cp-group-header:first-child {
    margin-top: 0;
}

.cp-group-name {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* ─── Empty State ────────────────────────────────────────────────── */
.cp-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    padding: var(--space-12) var(--space-4);
    text-align: center;
    color: var(--text-muted);
    flex: 1;
}

.cp-empty svg {
    width: 48px;
    height: 48px;
    opacity: 0.3;
}

.cp-empty p {
    font-size: var(--text-sm);
    max-width: 280px;
}

/* ─── Responsive ─────────────────────────────────────────────────── */

/* Mobile: 1 column */
@media (max-width: 768px) {
    .control-panel {
        padding: var(--space-3);
        gap: var(--space-3);
    }

    .cp-cards {
        grid-template-columns: 1fr;
    }

    .cp-url-box {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-2);
    }

    .cp-status-bar {
        flex-direction: column;
        gap: var(--space-2);
        align-items: stretch;
    }

    .cp-status-info {
        justify-content: center;
    }

    .cp-golive-btn {
        width: 100%;
        justify-content: center;
    }
}

/* Tablet: 2 columns */
@media (min-width: 769px) and (max-width: 1024px) {
    .cp-cards {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ─── Control Panel fullscreen override ──────────────────────────── */
.dashboard-layout.cp-active .sidebar,
.dashboard-layout.cp-active .properties-wrapper {
    display: none !important;
}

.dashboard-layout.cp-active .editor-main {
    margin-left: 0 !important;
    margin-right: 0 !important;
}

/* ─── Scene Overlay/Animation Toggle List ────────────────────────── */
.cp-scene-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    overflow-y: auto;
    padding-bottom: var(--space-4);
}

.cp-scene-overlay-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 8px;
    border-radius: 6px;
    margin-top: 6px;
}

.cp-scene-overlay-row:first-child {
    margin-top: 0;
}

.cp-scene-overlay-name {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    margin-right: 8px;
}

.cp-scene-anim-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 8px 5px 20px;
    border-radius: 6px;
    transition: background 0.15s ease;
}

.cp-scene-anim-row:hover {
    background: var(--bg-tertiary);
}

.cp-scene-anim-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    margin-right: 8px;
}

/* Disabled state when parent overlay is off */
.cp-scene-anim-row.disabled .cp-scene-anim-name {
    color: var(--text-muted);
    opacity: 0.45;
    text-decoration: line-through;
}

.cp-scene-anim-row.disabled .cp-scene-toggle {
    opacity: 0.3;
    pointer-events: none;
    cursor: default;
}

/* Compact toggle for scene list (reuse cmd-toggle style) */
.cp-scene-toggle {
    position: relative;
    width: 36px;
    height: 20px;
    border-radius: 999px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-default);
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.cp-scene-toggle::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: all 0.2s ease;
}

.cp-scene-toggle.active {
    background: var(--accent);
    border-color: var(--accent);
}

.cp-scene-toggle.active::after {
    left: 18px;
    background: white;
}