/**
 * Vinco Stream Monitor Styles
 * Version: 2.10.4
 * 
 * Styles for [jw_stream_monitor] shortcode
 * Compact UI design for at-a-glance monitoring
 * Status colors: Live=red, Scheduled=green, Other=blue
 */

/* =============================================================================
   DASHBOARD CONTAINER
   ============================================================================= */

.jw-monitor-dashboard {
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    max-width: 100%;
    margin: 0 auto;
    padding: 16px;
    background: #1a1a2e;
    border-radius: 10px;
    color: #fff;
    box-sizing: border-box;
}

.jw-monitor-dashboard *,
.jw-monitor-dashboard *::before,
.jw-monitor-dashboard *::after {
    box-sizing: border-box;
}

/* =============================================================================
   ENVIRONMENT BADGES
   ============================================================================= */

.vinco-env-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-left: 8px;
    vertical-align: middle;
}

.vinco-env-badge.staging {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fcd34d;
}

.vinco-env-badge.dev {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #93c5fd;
}

/* =============================================================================
   HEADER
   ============================================================================= */

.jw-monitor-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.jw-monitor-title {
    margin: 0 !important;
    padding: 0 !important;
    font-size: 18px !important;
    font-weight: 700 !important;
    color: #fff !important;
    line-height: 1.2 !important;
    border: none !important;
    background: none !important;
    flex-shrink: 0;
}

.jw-monitor-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

/* Neutralize WordPress wpautop paragraph and br tags */
.jw-monitor-controls p {
    display: contents;
    margin: 0;
    padding: 0;
}

.jw-monitor-controls p:empty {
    display: none;
}

/* Hide ALL br tags throughout the controls */
.jw-monitor-controls br,
.jw-monitor-count br,
.jw-monitor-filters br,
.jw-filter-toggle br,
.jw-btn br {
    display: none;
}

/* Ensure consistent height and alignment for all control elements */
.jw-monitor-controls > *,
.jw-monitor-controls p > * {
    vertical-align: middle;
    margin: 0;
}

.jw-monitor-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 10px;
    height: 30px;
    border-radius: 5px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    margin: 0;
    line-height: 1;
}

.jw-monitor-count .count-number {
    font-weight: 700;
    color: #fff;
    margin-right: 3px;
}

/* =============================================================================
   FILTER TOGGLES - High visibility
   ============================================================================= */

.jw-monitor-filters {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 30px;
}

.jw-filter-toggle {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
    height: 30px;
    margin: 0;
    position: relative;
}

.jw-filter-toggle input {
    /* Hide visually but keep clickable */
    position: absolute;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 1;
    margin: 0;
    top: 0;
    left: 0;
}

.jw-filter-toggle .toggle-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 0 10px;
    height: 30px;
    border-radius: 5px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.2s ease;
}

/* Checkmark icon - hidden by default */
.jw-filter-toggle .toggle-check {
    display: none;
    font-size: 11px;
    font-weight: 700;
}

/* Show checkmark when checked */
.jw-filter-toggle input:checked ~ .toggle-label .toggle-check {
    display: inline;
}

/* Unchecked state - dimmed but visible */
.jw-filter-toggle .toggle-label.live {
    background: transparent;
    color: rgba(255, 255, 255, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.jw-filter-toggle .toggle-label.scheduled {
    background: transparent;
    color: rgba(255, 255, 255, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.jw-filter-toggle .toggle-label.offline {
    background: transparent;
    color: rgba(255, 255, 255, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Checked state - bright and prominent (use ~ not + for WordPress br compatibility) */
/* Live = Red (active/urgent), Scheduled = Green (ready), Other = Blue (info) */
.jw-filter-toggle input:checked ~ .toggle-label.live {
    background: #ef4444;
    color: #fff;
    border-color: #ef4444;
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.4);
}

.jw-filter-toggle input:checked ~ .toggle-label.scheduled {
    background: #22c55e;
    color: #fff;
    border-color: #22c55e;
    box-shadow: 0 0 12px rgba(34, 197, 94, 0.4);
}

.jw-filter-toggle input:checked ~ .toggle-label.offline {
    background: #3b82f6;
    color: #fff;
    border-color: #3b82f6;
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.4);
}

/* =============================================================================
   COLUMN SELECT & BUTTONS - Consistent height alignment
   ============================================================================= */

.jw-select {
    display: inline-flex;
    align-items: center;
    padding: 0 10px;
    height: 30px;
    border-radius: 5px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 11px;
    cursor: pointer;
    vertical-align: middle;
    margin: 0;
    line-height: 1;
}

.jw-select:focus {
    outline: none;
    border-color: #3b82f6;
}

.jw-select option {
    background: #1a1a2e;
    color: #fff;
}

.jw-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 0 12px;
    height: 30px;
    border-radius: 5px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    vertical-align: middle;
    margin: 0;
    line-height: 1;
}

.jw-btn-primary {
    background: #3b82f6;
    color: #fff;
}

.jw-btn-primary:hover {
    background: #2563eb;
}

.jw-btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.jw-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

.jw-refresh-icon {
    transition: transform 0.3s ease;
}

.jw-btn:active .jw-refresh-icon {
    transform: rotate(180deg);
}

/* =============================================================================
   STREAM TOGGLES (Quick access buttons)
   ============================================================================= */

.jw-stream-toggles {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 14px;
}

.jw-stream-toggle {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 5px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
}

.jw-stream-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.jw-stream-toggle.is-active {
    background: #3b82f6;
    border-color: #3b82f6;
    color: #fff;
}

.jw-stream-toggle .status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #9ca3af;
}

/* Status dot colors - class is on the dot itself */
/* Live = Red (urgent/active), Scheduled = Green (ready/upcoming), Other = Blue (info) */
.jw-stream-toggle .status-dot.live {
    background: #ef4444;
}

.jw-stream-toggle .status-dot.scheduled {
    background: #22c55e;
}

.jw-stream-toggle .status-dot.offline {
    background: #3b82f6;
}

.jw-stream-toggle.hidden {
    display: none;
}

/* =============================================================================
   LOADING, ERROR, EMPTY STATES
   ============================================================================= */

.jw-monitor-loading,
.jw-monitor-error,
.jw-monitor-empty {
    text-align: center;
    padding: 40px 16px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
}

.jw-spinner {
    width: 32px;
    height: 32px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-top-color: #3b82f6;
    border-radius: 50%;
    margin: 0 auto 12px;
    animation: spin 1s linear infinite;
}

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

.jw-monitor-error {
    color: #f87171;
}

.jw-monitor-error .error-message {
    margin-bottom: 16px;
}

/* =============================================================================
   STREAM GRID
   ============================================================================= */

.jw-monitor-grid {
    display: grid;
    gap: 14px;
}

.jw-monitor-grid[data-columns="1"] {
    grid-template-columns: 1fr;
}

.jw-monitor-grid[data-columns="2"] {
    grid-template-columns: repeat(2, 1fr);
}

.jw-monitor-grid[data-columns="3"] {
    grid-template-columns: repeat(3, 1fr);
}

.jw-monitor-grid[data-columns="4"] {
    grid-template-columns: repeat(4, 1fr);
}

/* Responsive grid */
@media (max-width: 1200px) {
    .jw-monitor-grid[data-columns="4"] {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 900px) {
    .jw-monitor-grid[data-columns="3"],
    .jw-monitor-grid[data-columns="4"] {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .jw-monitor-grid[data-columns="2"],
    .jw-monitor-grid[data-columns="3"],
    .jw-monitor-grid[data-columns="4"] {
        grid-template-columns: 1fr;
    }
}

/* =============================================================================
   STREAM CARD
   ============================================================================= */

.jw-stream-card {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

.jw-stream-card:hover {
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
}

.jw-stream-card.hidden {
    display: none;
}

/* Card Header */
.jw-stream-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.jw-stream-title {
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    margin-right: 10px;
}

.jw-stream-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.jw-stream-status.status-live,
.jw-stream-status.status-streaming {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.jw-stream-status.status-live .status-dot,
.jw-stream-status.status-streaming .status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #ef4444;
    animation: pulse 2s ease-in-out infinite;
}

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

.jw-stream-status.status-preview {
    background: rgba(251, 191, 36, 0.2);
    color: #f59e0b;
}

.jw-stream-status.status-scheduled,
.jw-stream-status.status-starting {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
}

.jw-stream-status.status-idle,
.jw-stream-status.status-offline {
    background: rgba(59, 130, 246, 0.2);
    color: #3b82f6;
}

/* Card Video Container */
.jw-stream-video {
    position: relative;
    aspect-ratio: 16 / 9;
    background: #000;
}

.jw-stream-video .jwplayer {
    position: absolute !important;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
}

.jw-stream-poster {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.jw-stream-no-video {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: rgba(255, 255, 255, 0.3);
    font-size: 14px;
}

/* AV Meters */
.jw-stream-meters {
    position: absolute;
    bottom: 10px;
    right: 10px;
    display: flex;
    gap: 4px;
    padding: 6px 8px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 6px;
}

.jw-meter {
    width: 4px;
    height: 30px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

.jw-meter-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: linear-gradient(to top, #22c55e, #fbbf24, #ef4444);
    transition: height 0.1s ease;
}

/* Card Footer */
.jw-stream-card-footer {
    padding: 8px 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.6);
}

.jw-stream-info {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.jw-stream-info .dashicons {
    font-size: 12px;
    width: 12px;
    height: 12px;
}

.jw-stream-time {
    margin-left: auto;
}

/* =============================================================================
   FOOTER
   ============================================================================= */

.jw-monitor-footer {
    display: flex;
    justify-content: flex-end;
    padding-top: 12px;
    margin-top: 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.jw-last-updated {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.5);
}

/* =============================================================================
   RESPONSIVE
   ============================================================================= */

@media (max-width: 600px) {
    .jw-monitor-dashboard {
        padding: 12px;
    }
    
    .jw-monitor-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .jw-monitor-controls {
        width: 100%;
        justify-content: space-between;
    }
    
    .jw-monitor-filters {
        width: 100%;
        order: 10;
        margin-top: 8px;
    }
    
    .jw-stream-toggles {
        display: none;
    }
}

/* =============================================================================
   PRINT STYLES
   ============================================================================= */

@media print {
    .jw-monitor-dashboard {
        background: #fff;
        color: #000;
    }
    
    .jw-monitor-controls,
    .jw-stream-toggles,
    .jw-stream-meters {
        display: none !important;
    }
    
    .jw-stream-card {
        break-inside: avoid;
        border: 1px solid #ddd;
    }
}
