:root {
    --bg-dark: #0f172a;
    --bg-darker: #020617;
    --bg-card: rgba(30, 41, 59, 0.7);
    --bg-card-hover: rgba(51, 65, 85, 0.8);
    --border-card: rgba(51, 65, 85, 0.5);
    --accent-primary: #3b82f6;
    --accent-glow: rgba(59, 130, 246, 0.5);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --live-color: #ef4444;
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: linear-gradient(135deg, var(--bg-dark), var(--bg-darker));
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

/* App Header */
.app-header {
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-card);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.pulse-indicator {
    width: 10px;
    height: 10px;
    background-color: var(--accent-primary);
    border-radius: 50%;
    box-shadow: 0 0 12px var(--accent-glow);
    animation: pulse 2s infinite;
}

.pulse-indicator-small {
    width: 8px;
    height: 8px;
    background-color: var(--live-color);
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.8);
    animation: pulse-red 2s infinite;
    display: inline-block;
}

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 var(--accent-glow); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(59, 130, 246, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); }
}

@keyframes pulse-red {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 5px rgba(239, 68, 68, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.brand h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    background: linear-gradient(to right, #60a5fa, #3b82f6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.datetime-display {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Main Content */
.main-content {
    flex: 1;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    padding: 2rem 1.5rem;
}

.page-title {
    margin-bottom: 2rem;
    text-align: center;
}

.page-title h2 {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
}

.page-title p {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* CCTV Grid */
.cctv-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.cctv-card-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

/* CCTV Card */
.cctv-card {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: 1rem;
    overflow: hidden;
    backdrop-filter: blur(8px);
    transition: transform 0.3s ease, box-shadow 0.3s ease, background-color 0.3s ease, border-color 0.3s ease;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.cctv-card-link:hover .cctv-card {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.4);
    border-color: rgba(59, 130, 246, 0.4);
    background: var(--bg-card-hover);
}

/* Video Thumbnail Placeholder */
.video-thumbnail {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: linear-gradient(to bottom right, #1e293b, #0f172a);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    border-bottom: 1px solid var(--border-card);
}

.cctv-placeholder-icon {
    color: rgba(255, 255, 255, 0.2);
    transition: color 0.3s ease;
}

.cctv-card-link:hover .cctv-placeholder-icon {
    color: rgba(59, 130, 246, 0.4);
}

.play-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    opacity: 0;
    background: rgba(0, 0, 0, 0.3);
    transition: opacity 0.3s ease;
}

.cctv-card-link:hover .play-overlay {
    opacity: 1;
}

.play-icon {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 3.5rem;
    height: 3.5rem;
    background: rgba(59, 130, 246, 0.9);
    color: white;
    border-radius: 50%;
    font-size: 1.25rem;
    padding-left: 0.25rem; 
    box-shadow: 0 4px 12px var(--accent-glow);
    transform: scale(0.8);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.cctv-card-link:hover .play-icon {
    transform: scale(1);
}

/* CCTV Info */
.cctv-info {
    padding: 1.25rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex: 1;
}

.cctv-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 10px;
}

.cctv-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}

.status-dot {
    width: 6px;
    height: 6px;
    background-color: #10b981;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
}

/* Single Player View */
.single-player-container {
    max-width: 900px;
    margin: 0 auto;
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.player-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-card);
    background: rgba(15, 23, 42, 0.6);
}

.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.2s;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.5rem 1rem;
    border-radius: 2rem;
    border: 1px solid transparent;
}

.back-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.1);
}

.player-title {
    font-size: 1.15rem;
    font-weight: 600;
    text-align: center;
    flex: 1;
    margin: 0 1rem;
}

.live-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
    padding: 0.35rem 0.75rem;
    border-radius: 2rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.video-container.main-player {
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
}

.video-container.main-player video {
    width: 100%;
    height: 100%;
    outline: none;
}

.player-info {
    padding: 1.5rem;
    background: rgba(15, 23, 42, 0.4);
}

.player-info h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-card);
    padding-bottom: 0.5rem;
}

.player-info p {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.player-info strong {
    color: var(--text-primary);
    font-weight: 500;
    display: inline-block;
    width: 100px;
}

/* Empty State */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem 2rem;
    background: var(--bg-card);
    border-radius: 1rem;
    border: 1px dashed var(--border-card);
    color: var(--text-secondary);
}

/* Footer */
.app-footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--text-secondary);
    font-size: 0.8rem;
    border-top: 1px solid var(--border-card);
    background: rgba(15, 23, 42, 0.5);
    margin-top: auto;
}

/* Share Button */
.share-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--accent-primary);
    color: white;
    border: none;
    padding: 0.45rem 1rem;
    border-radius: 2rem;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
    box-shadow: 0 4px 12px var(--accent-glow);
}

.share-btn:hover {
    background: #2563eb;
    transform: translateY(-2px);
}

.share-btn:active {
    transform: translateY(0);
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 0.75rem;
        padding: 1rem;
    }
    
    .main-content {
        padding: 0.75rem;
    }

    .page-title {
        margin-bottom: 1.25rem;
    }

    .page-title h2 {
        font-size: 1.35rem;
    }

    .page-title p {
        font-size: 0.85rem;
    }
    
    .cctv-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    /* Simplify List View for Mobile */
    .cctv-card {
        flex-direction: row;
        align-items: center;
        border-radius: 0.75rem;
    }

    .video-thumbnail {
        width: 100px;
        min-height: 70px;
        aspect-ratio: auto;
        border-bottom: none;
        border-right: 1px solid var(--border-card);
    }

    .cctv-placeholder-icon svg {
        width: 24px;
        height: 24px;
    }

    .play-icon {
        width: 2.25rem;
        height: 2.25rem;
        font-size: 1rem;
    }

    .cctv-info {
        padding: 0.75rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.35rem;
    }

    .cctv-name {
        font-size: 0.85rem;
        white-space: normal;
        overflow: visible;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        padding-right: 0;
    }
    
    .player-header {
        flex-wrap: wrap;
        gap: 1rem;
    }
    
    .player-title {
        order: 3;
        width: 100%;
        margin: 0;
        text-align: left;
        margin-top: 0.5rem;
    }
    
    .share-btn {
        padding: 0.4rem 0.75rem;
        font-size: 0.8rem;
    }
}


/* Tabs Container */
.tabs-container {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.tab-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    color: var(--text-secondary);
    padding: 0.75rem 2rem;
    border-radius: 2rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tab-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.tab-btn.active {
    background: var(--accent-primary);
    color: white;
    box-shadow: 0 4px 12px var(--accent-glow);
    border-color: var(--accent-primary);
}

.offline-card {
    cursor: not-allowed;
    opacity: 0.7;
}

.offline-card .cctv-card:hover {
    transform: none;
    box-shadow: none;
    background: var(--bg-card);
    border-color: var(--border-card);
}

.offline-thumbnail {
    background: repeating-linear-gradient(45deg, #1e293b, #1e293b 10px, #0f172a 10px, #0f172a 20px);
}

