/* ═══════════════════════════════════════════════════════════════
   MINIMAL STREAM CONTROL
   Clean, balanced dashboard
   ═══════════════════════════════════════════════════════════════ */

:root {
    /* Gruvbox Dark */
    --bg-hard: #1d2021;
    --bg: #282828;
    --bg-soft: #32302f;
    --bg1: #3c3836;
    --bg2: #504945;
    --bg3: #665c54;
    --bg4: #7c6f64;

    --fg: #ebdbb2;
    --fg1: #ebdbb2;
    --fg2: #d5c4a1;
    --fg3: #bdae93;
    --fg4: #a89984;

    --red: #fb4934;
    --red-dim: #cc241d;
    --green: #b8bb26;
    --green-dim: #98971a;
    --yellow: #fabd2f;
    --yellow-dim: #d79921;
    --blue: #83a598;
    --blue-dim: #458588;
    --purple: #d3869b;
    --purple-dim: #b16286;
    --aqua: #8ec07c;
    --aqua-dim: #689d6a;
    --orange: #fe8019;
    --orange-dim: #d65d0e;

    /* Spacing - unified */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;

    --radius: 6px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    font-family: 'JetBrains Mono', 'SF Mono', monospace;
    font-size: 13px;
    background: var(--bg-hard);
    color: var(--fg);
    line-height: 1.5;
    overflow-x: hidden;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--bg4); }

/* ═══════════════════════════════════════════════════════════════
   LAYOUT
   ═══════════════════════════════════════════════════════════════ */

.dashboard {
    max-width: 640px;
    margin: 0 auto;
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    min-height: 100vh;
}

.dashboard.single-column {
    max-width: 640px;
}

.main-grid {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

/* ═══════════════════════════════════════════════════════════════
   STATUS BAR
   ═══════════════════════════════════════════════════════════════ */

.status-bar {
    display: flex;
    gap: var(--space-md);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg);
    border-radius: var(--radius);
}

.status-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--bg4);
}

.status-dot.connected { background: var(--green); }
.status-dot.disconnected { background: var(--red); }
.status-dot.live {
    background: var(--red);
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.status-text {
    font-size: 11px;
    font-weight: 600;
    color: var(--fg4);
    letter-spacing: 0.05em;
}

/* ═══════════════════════════════════════════════════════════════
   CARDS - unified style
   ═══════════════════════════════════════════════════════════════ */

.card,
.ptz-section,
.service-card,
.console-section {
    background: var(--bg);
    border-radius: var(--radius);
    border: 1px solid var(--bg1);
}

.service-card.live { border-color: var(--red-dim); }
.service-card.active { border-color: var(--green-dim); }

/* Card Header */
.service-header,
.section-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md);
}

.section-header {
    padding-bottom: 0;
    margin-bottom: var(--space-md);
}

.section-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--fg4);
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.section-title i { color: var(--fg4); }

/* Service Icon */
.service-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    font-size: 14px;
    flex-shrink: 0;
}

.service-icon.youtube { background: var(--red-dim); color: var(--fg); }
.service-icon.digitalocean { background: var(--blue-dim); color: var(--fg); }
.service-icon.presets { background: var(--bg2); color: var(--fg3); }

/* Service Info */
.service-info {
    flex: 1;
    min-width: 0;
}

.service-name {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--fg);
}

.service-status {
    display: block;
    font-size: 11px;
    color: var(--fg4);
}

.service-card.live .service-status {
    color: var(--red);
    font-weight: 600;
}

/* Card Body */
.service-body {
    padding: 0 var(--space-md) var(--space-md);
}

/* ═══════════════════════════════════════════════════════════════
   PTZ CONTROLS
   ═══════════════════════════════════════════════════════════════ */

.ptz-section {
    padding: var(--space-md);
}

.ptz-grid {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: var(--space-lg);
    align-items: center;
}

/* D-Pad */
.dpad {
    display: grid;
    grid-template-columns: repeat(3, 36px);
    grid-template-rows: repeat(3, 36px);
    gap: 4px;
}

.dpad-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg1);
    border: 1px solid var(--bg2);
    border-radius: var(--radius);
    color: var(--fg3);
    font-size: 16px;
    cursor: pointer;
    transition: all 0.1s;
}

.dpad-btn:hover:not(:disabled) {
    background: var(--bg2);
    color: var(--fg);
}

.dpad-btn:active:not(:disabled) {
    background: var(--blue-dim);
    border-color: var(--blue);
    color: var(--fg);
}

.dpad-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.dpad-btn.up { grid-column: 2; grid-row: 1; }
.dpad-btn.left { grid-column: 1; grid-row: 2; }
.dpad-btn.center { grid-column: 2; grid-row: 2; background: var(--bg2); }
.dpad-btn.right { grid-column: 3; grid-row: 2; }
.dpad-btn.down { grid-column: 2; grid-row: 3; }

/* Sliders */
.sliders {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.slider-row {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.slider-label {
    width: 14px;
    font-size: 11px;
    font-weight: 600;
    color: var(--fg4);
    text-align: center;
}

.slider-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg1);
    border: 1px solid var(--bg2);
    border-radius: var(--radius);
    color: var(--fg3);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.1s;
}

.slider-btn:hover:not(:disabled) {
    background: var(--bg2);
    color: var(--fg);
}

.slider-btn:active:not(:disabled) {
    background: var(--aqua-dim);
    border-color: var(--aqua);
}

.slider-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.slider-track {
    flex: 1;
    height: 4px;
    background: var(--bg2);
    border-radius: 2px;
    overflow: hidden;
}

.slider-fill {
    height: 100%;
    background: var(--bg4);
    border-radius: 2px;
    transition: width 0.2s;
}

/* PTZ Options */
.ptz-options {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.speed-control,
.mode-control {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.option-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--fg4);
    letter-spacing: 0.05em;
    width: 28px;
}

.speed-dots {
    display: flex;
    gap: 6px;
}

.speed-dot {
    width: 10px;
    height: 10px;
    background: var(--bg2);
    border: 1px solid var(--bg3);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.15s;
}

.speed-dot:hover { background: var(--bg3); }
.speed-dot.active {
    background: var(--yellow);
    border-color: var(--yellow);
}

.mode-btn {
    padding: 4px 8px;
    background: var(--bg1);
    border: 1px solid var(--bg2);
    border-radius: var(--radius);
    color: var(--fg4);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: all 0.15s;
}

.mode-btn:hover {
    background: var(--bg2);
    color: var(--fg);
}

.mode-btn.active {
    background: var(--purple-dim);
    border-color: var(--purple-dim);
    color: var(--fg);
}

/* ═══════════════════════════════════════════════════════════════
   INPUTS & CONTROLS
   ═══════════════════════════════════════════════════════════════ */

.service-input {
    width: 100%;
    padding: var(--space-sm) 10px;
    background: var(--bg1);
    border: 1px solid var(--bg2);
    border-radius: var(--radius);
    color: var(--fg);
    font-family: inherit;
    font-size: 12px;
    transition: border-color 0.15s;
}

.service-input:focus {
    outline: none;
    border-color: var(--blue);
}

.service-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.service-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: var(--space-sm);
    font-size: 11px;
    color: var(--fg4);
}

.service-select {
    padding: 4px 8px;
    background: var(--bg1);
    border: 1px solid var(--bg2);
    border-radius: var(--radius);
    color: var(--fg3);
    font-family: inherit;
    font-size: 11px;
    cursor: pointer;
}

.service-select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Stats */
.service-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-sm);
}

.stat { text-align: center; }

.stat-label {
    display: block;
    font-size: 10px;
    color: var(--fg4);
    margin-bottom: 2px;
}

.stat-value {
    display: block;
    font-size: 12px;
    color: var(--fg);
    font-weight: 500;
}

/* Switch */
.switch {
    position: relative;
    width: 40px;
    height: 22px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.switch-slider {
    position: absolute;
    inset: 0;
    background: var(--bg2);
    border-radius: 11px;
    cursor: pointer;
    transition: background 0.2s;
}

.switch-slider::before {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    background: var(--fg3);
    border-radius: 50%;
    transition: transform 0.2s, background 0.2s;
}

.switch input:checked + .switch-slider {
    background: var(--green-dim);
}

.switch input:checked + .switch-slider::before {
    transform: translateX(18px);
    background: var(--fg);
}

.switch input:disabled + .switch-slider {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Presets */
.presets-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

.presets-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: var(--space-md);
    color: var(--fg4);
    font-size: 12px;
}

.preset-btn {
    padding: var(--space-sm) var(--space-xs);
    background: var(--bg1);
    border: 1px solid var(--bg2);
    border-radius: var(--radius);
    color: var(--fg3);
    font-size: 11px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}

.preset-btn:hover:not(:disabled) {
    background: var(--bg2);
    color: var(--fg);
}

.preset-btn:active:not(:disabled),
.preset-btn.active {
    background: var(--blue-dim);
    border-color: var(--blue);
    color: var(--fg);
}

/* Icon Button */
.icon-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius);
    color: var(--fg4);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
}

.icon-btn:hover:not(:disabled) {
    background: var(--bg2);
    color: var(--fg);
}

.icon-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* ═══════════════════════════════════════════════════════════════
   CONSOLE
   ═══════════════════════════════════════════════════════════════ */

.console-section {
    display: flex;
    flex-direction: column;
    height: 160px;
    flex-shrink: 0;
}

.console-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px solid var(--bg1);
}

.console-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--fg4);
    display: flex;
    align-items: center;
    gap: 6px;
}

.console-title i { color: var(--fg4); }

.console {
    flex: 1;
    padding: var(--space-sm) var(--space-md);
    overflow-y: auto;
    font-size: 11px;
    line-height: 1.6;
}

.console-line {
    display: flex;
    gap: var(--space-sm);
}

.console-time {
    color: var(--fg4);
    flex-shrink: 0;
}

.console-msg {
    color: var(--fg3);
    word-break: break-word;
}

.console-msg.info { color: var(--blue); }
.console-msg.success { color: var(--green); }
.console-msg.warning { color: var(--yellow); }
.console-msg.error { color: var(--red); }

/* ═══════════════════════════════════════════════════════════════
   PREVIEW (if used)
   ═══════════════════════════════════════════════════════════════ */

.preview-wrapper {
    display: flex;
    flex-direction: column;
    background: var(--bg);
    border-radius: var(--radius);
    border: 1px solid var(--bg1);
    overflow: hidden;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg1);
    border-bottom: 1px solid var(--bg2);
}

.preview-label {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.05em;
    color: var(--fg3);
}

.rec-dot {
    width: 8px;
    height: 8px;
    background: var(--red);
    border-radius: 50%;
    animation: pulse 1.5s ease-in-out infinite;
}

.preview-actions {
    display: flex;
    gap: 4px;
}

.preview-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    aspect-ratio: 16/9;
}

.preview-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 600px) {
    .dashboard {
        padding: var(--space-sm);
        gap: var(--space-sm);
    }

    .main-grid {
        gap: var(--space-sm);
    }

    .ptz-grid {
        grid-template-columns: 1fr;
        gap: var(--space-md);
    }

    .dpad {
        justify-self: center;
    }

    .ptz-options {
        flex-direction: row;
        justify-content: center;
        gap: var(--space-md);
    }
}

/* ═══════════════════════════════════════════════════════════════
   UTILITIES
   ═══════════════════════════════════════════════════════════════ */

.hidden { display: none !important; }

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.animate-spin {
    animation: spin 1s linear infinite;
}

/* Legacy compatibility */
.bg-green-500, .status-dot.bg-green-500 { background: var(--green) !important; }
.bg-red-500, .status-dot.bg-red-500 { background: var(--red) !important; }
.bg-blue-500, .status-dot.bg-blue-500 { background: var(--blue) !important; }
.bg-gray-500, .status-dot.bg-gray-500 { background: var(--fg4) !important; }

/* Panel compatibility */
.panel, .panel-main, .panel-side {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    min-height: 0;
    min-width: 0;
}

.services {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}
