/* =========================================================
   Live CCTV — Simple, Clean & Modern UI Stylesheet
   Theme: PT Bakauheni Terbanggi Besar Toll
   ========================================================= */

/* Prevent text/element selection on sensitive stream area */
.cctv-section {
    background-color: var(--secondary-cream, #faf8f5);
    min-height: 60vh;
    padding: 36px 0 80px;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
}

/* ---------------------------------------------------------
   Toolbar: Full-Width Search Bar
   --------------------------------------------------------- */
.cctv-toolbar {
    display: block;
    width: 100%;
    margin-bottom: 28px;
}

.cctv-search-wrap {
    position: relative;
    width: 100%;
    max-width: 100%;
}

.cctv-search-icon {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    color: #888888;
    font-size: 1rem;
    pointer-events: none;
}

.cctv-search-input {
    width: 100%;
    padding: 13px 48px 13px 52px;
    background: var(--white, #ffffff);
    border: 1.5px solid #e0e0e0;
    border-radius: var(--radius-lg, 12px);
    font-size: 0.95rem;
    font-family: var(--font-primary);
    color: var(--charcoal, #333333);
    outline: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
    transition: all 0.2s ease;
}

.cctv-search-input:focus {
    border-color: var(--primary-maroon, #bd0808);
    box-shadow: 0 0 0 4px rgba(189, 8, 8, 0.08);
}

.cctv-search-clear {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    background: #e4e4e4;
    color: #555555;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.cctv-search-clear:hover {
    background: #cccccc;
    color: #222222;
}

/* ---------------------------------------------------------
   CCTV Cards Grid
   --------------------------------------------------------- */
.cctv-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
}

.cctv-card {
    background: var(--white, #ffffff);
    border: 1px solid #e8e8e8;
    border-radius: var(--radius-lg, 12px);
    overflow: hidden;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.04);
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
    display: flex;
    flex-direction: column;
}

.cctv-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.08);
    border-color: #d8d8d8;
}

/* ---------------------------------------------------------
   Video Player Box & Overlays
   --------------------------------------------------------- */
.cctv-player-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #0f1115;
    overflow: hidden;
}

.cctv-video-container {
    position: relative;
    width: 100%;
    height: 100%;
}

.cctv-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    background: #0f1115;
}

/* Remove default browser download/fullscreen buttons from native controls */
.cctv-video::-webkit-media-controls-download-button,
.cctv-video::-webkit-media-controls-timeline,
.cctv-video::-webkit-media-controls-fullscreen-button {
    display: none !important;
}

/* Center Watermark Logo Overlay */
.cctv-player-watermark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 3;
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
    opacity: 0.15; /* Transparansi hampir 85% */
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40%;
    max-width: 140px;
    transition: opacity 0.3s ease;
}

.cctv-player-watermark img {
    width: 100%;
    height: auto;
    object-fit: contain;
    display: block;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.5));
}

.cctv-modal-watermark {
    width: 30%;
    max-width: 220px;
}

/* ---------------------------------------------------------
   Running Warning Text Ticker (Marquee)
   --------------------------------------------------------- */
.cctv-running-ticker {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    overflow: hidden;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.42) 0%, rgba(0, 0, 0, 0.18) 75%, transparent 100%);
    padding: 5px 0 4px;
    z-index: 4;
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
}

.cctv-ticker-track {
    display: inline-flex;
    white-space: nowrap;
    width: max-content;
    will-change: transform;
    animation: cctvTickerScroll 22s linear infinite;
}

.cctv-ticker-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding-right: 48px;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    color: rgba(255, 255, 255, 0.92);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85);
}

.cctv-ticker-item i {
    color: #f59e0b;
    font-size: 0.62rem;
}

@keyframes cctvTickerScroll {
    0% {
        transform: translateX(0);
    }
    100% {
        transform: translateX(-50%);
    }
}

.cctv-modal-running-ticker {
    padding: 8px 0 6px;
}

.cctv-modal-running-ticker .cctv-ticker-item {
    font-size: 0.78rem;
    padding-right: 64px;
}

.cctv-modal-running-ticker .cctv-ticker-item i {
    font-size: 0.72rem;
}

/* Top Action Overlay (Top Right Controls) */
.cctv-top-overlay {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    z-index: 10;
    pointer-events: none;
}

.cctv-overlay-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    pointer-events: auto;
}

.cctv-action-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(15, 17, 21, 0.7);
    color: var(--white, #ffffff);
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(4px);
}

.cctv-action-btn:hover {
    background: var(--primary-maroon, #bd0808);
    border-color: var(--primary-maroon, #bd0808);
    transform: scale(1.08);
}

/* ---------------------------------------------------------
   Loading & Error Overlays
   --------------------------------------------------------- */
.cctv-loading-overlay {
    position: absolute;
    inset: 0;
    background: #0f1115;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: #e0e0e0;
    font-size: 0.82rem;
    z-index: 5;
    transition: opacity 0.3s ease;
}

.cctv-loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.cctv-spinner {
    width: 34px;
    height: 34px;
    border: 3px solid rgba(255, 255, 255, 0.15);
    border-top-color: var(--primary-maroon, #bd0808);
    border-radius: 50%;
    animation: cctvSpin 0.8s linear infinite;
}

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

.cctv-error-overlay {
    position: absolute;
    inset: 0;
    background: #0f1115;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px;
    text-align: center;
    color: #e0e0e0;
    z-index: 6;
}

.cctv-error-icon {
    font-size: 1.5rem;
    color: #ef4444;
}

.cctv-error-text {
    font-size: 0.8rem;
    color: #bbbbbb;
    max-width: 180px;
    line-height: 1.4;
}

.cctv-btn-retry {
    margin-top: 4px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 20px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: all 0.2s ease;
}

.cctv-btn-retry:hover {
    background: var(--primary-maroon, #bd0808);
    border-color: var(--primary-maroon, #bd0808);
}

/* Offline Placeholder */
.cctv-offline-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 16px;
    text-align: center;
    background: #14171d;
    color: #8c92a4;
}

.cctv-offline-icon {
    font-size: 1.8rem;
    color: #64748b;
    margin-bottom: 2px;
}

.cctv-offline-maintenance .cctv-offline-icon {
    color: #f59e0b;
}

.cctv-offline-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: #e2e8f0;
}

.cctv-offline-sub {
    font-size: 0.72rem;
    color: #8c92a4;
}

/* ---------------------------------------------------------
   Card Body & Metadata
   --------------------------------------------------------- */
.cctv-card-body {
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    justify-content: center;
}

.cctv-card-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.cctv-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--charcoal, #333333);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cctv-location-meta {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.8rem;
    color: #666666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cctv-location-meta i {
    color: var(--primary-maroon, #bd0808);
    font-size: 0.78rem;
    flex-shrink: 0;
}

/* Status Badges & Live Pill */
.cctv-live-badge {
    background: #dc2626;
    color: var(--white, #ffffff);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    padding: 3px 9px;
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    box-shadow: 0 2px 6px rgba(220, 38, 38, 0.35);
    flex-shrink: 0;
    white-space: nowrap;
}

.live-dot {
    width: 6px;
    height: 6px;
    background: #ffffff;
    border-radius: 50%;
    animation: livePulse 1.2s ease-in-out infinite;
    display: inline-block;
}

@keyframes livePulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.3; transform: scale(0.75); }
}

.cctv-status-pill {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
    flex-shrink: 0;
}

.cctv-status-inactive {
    background: #f1f3f5;
    color: #6c757d;
    border: 1px solid #e2e6ea;
}

.cctv-status-maintenance {
    background: #fff8e6;
    color: #b45309;
    border: 1px solid #fed7aa;
}

/* ---------------------------------------------------------
   Empty / No Results State
   --------------------------------------------------------- */
.cctv-no-results,
.cctv-state-card {
    text-align: center;
    background: var(--white, #ffffff);
    border: 1px solid #e8e8e8;
    border-radius: var(--radius-lg, 12px);
    padding: 50px 20px;
    max-width: 500px;
    margin: 30px auto;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.03);
}

.no-results-icon,
.state-icon-box {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: #fdf2f2;
    color: var(--primary-maroon, #bd0808);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    margin: 0 auto 16px;
}

.cctv-no-results h3,
.cctv-state-card h2 {
    font-size: 1.25rem;
    color: var(--charcoal, #333333);
    margin-bottom: 8px;
    font-weight: 700;
}

.cctv-no-results p,
.cctv-state-card p {
    color: #666666;
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 18px;
}

.btn-cctv-reset,
.btn-cctv-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--primary-maroon, #bd0808);
    color: var(--white, #ffffff);
    border: none;
    padding: 9px 20px;
    border-radius: 30px;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: var(--font-primary);
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s ease, transform 0.2s ease;
}

.btn-cctv-reset:hover,
.btn-cctv-primary:hover {
    background: var(--primary-maroon-light, #d41010);
    transform: translateY(-2px);
    color: var(--white, #ffffff);
}

/* ---------------------------------------------------------
   CCTV Modal / Theater Viewer
   --------------------------------------------------------- */
.cctv-modal {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.cctv-modal.is-open {
    display: flex;
}

.cctv-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.82);
    backdrop-filter: blur(8px);
    animation: fadeIn 0.25s ease;
}

.cctv-modal-dialog {
    position: relative;
    width: 100%;
    max-width: 920px;
    z-index: 10;
    animation: modalScaleUp 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modalScaleUp {
    from { opacity: 0; transform: scale(0.92) translateY(12px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.cctv-modal-content {
    background: #0f1115;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-xl, 16px);
    overflow: hidden;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}

.cctv-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: #14171e;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.cctv-modal-title-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.cctv-modal-badge {
    background: #dc2626;
    color: #ffffff;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    padding: 4px 10px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.cctv-modal-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #ffffff;
    margin: 0;
}

.cctv-modal-location {
    font-size: 0.8rem;
    color: #94a3b8;
    margin: 2px 0 0;
}

.cctv-modal-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cctv-modal-btn,
.cctv-modal-close {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #ffffff;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.cctv-modal-btn:hover,
.cctv-modal-close:hover {
    background: var(--primary-maroon, #bd0808);
    border-color: var(--primary-maroon, #bd0808);
}

.cctv-modal-player-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000000;
}

.cctv-modal-video-container {
    position: relative;
    width: 100%;
    height: 100%;
}

.cctv-modal-video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000000;
}

.cctv-modal-footer {
    padding: 12px 20px;
    background: #14171e;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.cctv-modal-security-note {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.78rem;
    color: #64748b;
}

.cctv-modal-security-note i {
    color: #94a3b8;
}

/* ---------------------------------------------------------
   Responsive Breakpoints
   --------------------------------------------------------- */
@media (max-width: 1024px) {
    .cctv-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 18px;
    }
}

@media (max-width: 768px) {
    .cctv-section {
        padding: 20px 0 50px;
    }

    .cctv-toolbar {
        margin-bottom: 18px;
    }

    .cctv-search-input {
        padding: 11px 40px 11px 44px;
        font-size: 0.88rem;
    }

    .cctv-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .cctv-card-body {
        padding: 10px 12px;
        gap: 4px;
    }

    .cctv-name {
        font-size: 0.85rem;
    }

    .cctv-location-meta {
        font-size: 0.75rem;
    }

    .cctv-live-badge {
        font-size: 0.62rem;
        padding: 2px 7px;
    }

    .cctv-status-pill {
        font-size: 0.62rem;
        padding: 2px 7px;
    }

    .cctv-modal-title {
        font-size: 0.95rem;
    }

    .cctv-modal-location {
        font-size: 0.75rem;
    }
}

@media (max-width: 480px) {
    .cctv-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .cctv-card-body {
        padding: 8px 10px;
        gap: 3px;
    }

    .cctv-name {
        font-size: 0.8rem;
    }

    .cctv-location-meta {
        font-size: 0.7rem;
    }

    .cctv-live-badge {
        font-size: 0.58rem;
        padding: 2px 6px;
        gap: 4px;
    }

    .live-dot {
        width: 5px;
        height: 5px;
    }

    .cctv-status-pill {
        font-size: 0.58rem;
        padding: 2px 6px;
    }

    .cctv-top-overlay {
        top: 6px;
        left: 6px;
        right: 6px;
    }

    .cctv-action-btn {
        width: 24px;
        height: 24px;
        font-size: 0.68rem;
    }
}
