/**
 * Live Stream Viewer - Estilos
 */

.live-stream-wrapper {
    position: relative;
    width: 100%;
    background: var(--bg-darker, #0a0d12);
    border-radius: 12px;
    overflow: hidden;
    aspect-ratio: 16 / 9;
}

.live-stream-wrapper:fullscreen {
    border-radius: 0;
}

.live-stream-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.3s ease;
}

/* Loader */
.live-stream-loader {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10;
}

/* Overlay com badge AO VIVO */
.live-stream-overlay {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 5;
}

.live-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    backdrop-filter: blur(4px);
}

.live-dot {
    width: 8px;
    height: 8px;
    background: white;
    border-radius: 50%;
    animation: pulse-live 1.5s ease-in-out infinite;
}

@keyframes pulse-live {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(0.8);
    }
}

/* Controles */
.live-stream-controls {
    position: absolute;
    bottom: 12px;
    right: 12px;
    display: flex;
    gap: 8px;
    z-index: 5;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.live-stream-wrapper:hover .live-stream-controls {
    opacity: 1;
}

.live-stream-controls .btn {
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    backdrop-filter: blur(4px);
    transition: all 0.2s ease;
}

.live-stream-controls .btn:hover {
    background: rgba(59, 130, 246, 0.8);
    border-color: rgba(59, 130, 246, 0.5);
    transform: scale(1.05);
}

.live-stream-controls .btn.active {
    background: rgba(59, 130, 246, 0.9);
    border-color: rgba(59, 130, 246, 0.7);
}

.live-stream-controls .btn-live.active {
    background: rgba(239, 68, 68, 0.9);
    border-color: rgba(239, 68, 68, 0.7);
}

/* Erro */
.live-stream-error {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.8);
    color: #f87171;
    z-index: 15;
}

.live-stream-error i {
    font-size: 48px;
    margin-bottom: 12px;
}

.live-stream-error span {
    font-size: 14px;
    color: #cbd5e1;
}

/* Card de câmera com stream */
.camera-card-live {
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    background: var(--bg-card, #111827);
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    transition: all 0.3s ease;
}

.camera-card-live:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
    border-color: var(--accent-blue, #3b82f6);
}

.camera-card-live .card-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 12px;
    background: linear-gradient(to bottom, rgba(0,0,0,0.7) 0%, transparent 100%);
    z-index: 5;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.camera-card-live .card-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px;
    background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, transparent 100%);
    z-index: 5;
}

.camera-card-live .camera-id {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    font-family: monospace;
}

.camera-card-live .camera-station {
    font-size: 14px;
    font-weight: 600;
    color: white;
}

.camera-card-live .camera-count {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 20px;
    font-weight: 700;
    color: white;
}

.camera-card-live .camera-count i {
    font-size: 16px;
    color: var(--accent-blue, #3b82f6);
}

/* Status badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.status-badge.online {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.status-badge.offline {
    background: rgba(107, 114, 128, 0.2);
    color: #9ca3af;
    border: 1px solid rgba(107, 114, 128, 0.3);
}

.status-badge.erro {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Grid de câmeras */
.cameras-grid {
    display: grid;
    gap: 20px;
}

.cameras-grid.grid-2x2 {
    grid-template-columns: repeat(2, 1fr);
}

.cameras-grid.grid-3x3 {
    grid-template-columns: repeat(3, 1fr);
}

.cameras-grid.grid-4x4 {
    grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 1200px) {
    .cameras-grid.grid-4x4 {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 992px) {
    .cameras-grid.grid-3x3,
    .cameras-grid.grid-4x4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 576px) {
    .cameras-grid {
        grid-template-columns: 1fr !important;
    }
}

/* Toggle de visualização */
.view-toggle {
    display: inline-flex;
    background: var(--bg-card, #111827);
    border-radius: 8px;
    padding: 4px;
    gap: 4px;
}

.view-toggle .btn {
    padding: 6px 12px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--text-muted, #9ca3af);
    transition: all 0.2s ease;
}

.view-toggle .btn.active {
    background: var(--accent-blue, #3b82f6);
    color: white;
}

.view-toggle .btn:hover:not(.active) {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

/* Modal de stream */
#liveStreamModal .modal-content {
    border: 1px solid rgba(255, 255, 255, 0.1);
}

#liveStreamModal .modal-header {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

#liveStreamModal .live-stream-wrapper {
    border-radius: 0;
    min-height: 400px;
}

/* Sparkline mini chart */
.sparkline-container {
    height: 30px;
    width: 80px;
}

/* Timeago */
.timeago {
    font-size: 11px;
    color: var(--text-muted, #9ca3af);
}

.timeago.recent {
    color: #22c55e;
}

.timeago.stale {
    color: #f59e0b;
}

.timeago.old {
    color: #ef4444;
}

/* Quick action buttons on camera cards */
.camera-quick-actions {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 10;
}

.camera-card-live:hover .camera-quick-actions {
    opacity: 1;
}

.camera-quick-actions .btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(59, 130, 246, 0.9);
    border: 2px solid white;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s ease;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.camera-quick-actions .btn:hover {
    transform: scale(1.1);
    background: rgba(37, 99, 235, 1);
}

/* Camera card improvements */
.camera-card-live .camera-snapshot-view,
.camera-card-live .camera-live-view {
    position: relative;
    height: 180px;
    overflow: hidden;
}

.camera-card-live .camera-snapshot-view img {
    transition: transform 0.3s ease;
    height: 100%;
    width: 100%;
    object-fit: cover;
}

.camera-card-live:hover .camera-snapshot-view img {
    transform: scale(1.05);
}

.camera-card-live .live-stream-wrapper {
    height: 100%;
    aspect-ratio: auto;
}
