/* css/style.css */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    background: #0a0a0a;
    color: #e0e0e0;
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 16px;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    border-radius: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

header h1 {
    font-size: 24px;
    font-weight: 600;
    color: #fff;
    letter-spacing: 1px;
}

.search-box {
    position: relative;
    flex: 1;
    max-width: 400px;
    min-width: 200px;
}

.search-box input {
    width: 100%;
    padding: 10px 16px;
    border: none;
    border-radius: 25px;
    background: rgba(255,255,255,0.1);
    color: #fff;
    font-size: 14px;
    outline: none;
    transition: all 0.3s;
}

.search-box input:focus {
    background: rgba(255,255,255,0.2);
    box-shadow: 0 0 20px rgba(0, 150, 255, 0.2);
}

.search-box input::placeholder {
    color: #888;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #1a1a2e;
    border-radius: 12px;
    margin-top: 8px;
    max-height: 400px;
    overflow-y: auto;
    display: none;
    z-index: 1000;
    box-shadow: 0 20px 60px rgba(0,0,0,0.8);
    border: 1px solid rgba(255,255,255,0.05);
}

.search-result-item {
    display: flex;
    flex-direction: column;
    padding: 10px 16px;
    color: #ccc;
    text-decoration: none;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    transition: background 0.2s;
}

.search-result-item:hover {
    background: rgba(255,255,255,0.05);
}

.result-camera {
    font-weight: bold;
    color: #4CAF50;
    font-size: 13px;
}

.result-date {
    color: #888;
    font-size: 12px;
}

.result-file {
    color: #aaa;
    font-size: 13px;
}

.no-results {
    padding: 20px;
    text-align: center;
    color: #666;
}

/* Browser Layout */
.browser {
    display: flex;
    gap: 20px;
}

.sidebar {
    width: 220px;
    flex-shrink: 0;
}

.section {
    background: rgba(255,255,255,0.03);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
    border: 1px solid rgba(255,255,255,0.05);
}

.section h3 {
    font-size: 14px;
    color: #888;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.section ul {
    list-style: none;
}

.section ul li {
    margin-bottom: 4px;
}

.section ul li a {
    display: block;
    padding: 8px 12px;
    color: #aaa;
    text-decoration: none;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s;
}

.section ul li a:hover {
    background: rgba(255,255,255,0.05);
    color: #fff;
}

.section ul li a.active {
    background: rgba(0, 150, 255, 0.2);
    color: #4CAF50;
    font-weight: 500;
}

/* Main Content */
.main-content {
    flex: 1;
    min-width: 0;
}

/* Video Player Wrapper */
.video-player-wrapper {
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 16px;
    position: relative;
}

.video-container {
    position: relative;
    width: 100%;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

#cctvPlayer {
    width: 100%;
    max-height: 70vh;
    background: #000;
    display: block;
    transition: transform 0.1s ease;
}

#cctvPlayer.zoomed {
    cursor: grab;
}

#cctvPlayer.zoomed:active {
    cursor: grabbing;
}

/* ปุ่มควบคุมลอยบนวิดีโอ */
.video-controls-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.4) 60%, transparent 100%);
    padding: 40px 20px 16px 20px;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.video-container:hover .video-controls-overlay,
.video-container.show-controls .video-controls-overlay {
    opacity: 1;
    pointer-events: all;
}

.controls-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding: 0 10px;
}

.video-title {
    font-size: 14px;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 2px 8px rgba(0,0,0,0.8);
}

.video-info {
    font-size: 12px;
    color: #aaa;
    text-shadow: 0 2px 8px rgba(0,0,0,0.8);
}

.controls-center {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.ctrl-btn {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.1);
    color: #fff;
    padding: 8px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    min-width: 40px;
    min-height: 40px;
    backdrop-filter: blur(4px);
    text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

.ctrl-btn:hover {
    background: rgba(255,255,255,0.3);
    transform: scale(1.05);
}

.ctrl-btn:active {
    transform: scale(0.95);
}

.ctrl-btn.small {
    padding: 4px 8px;
    font-size: 13px;
    min-width: 32px;
    min-height: 32px;
}

.ctrl-btn.active {
    background: rgba(76, 175, 80, 0.4);
    border-color: rgba(76, 175, 80, 0.4);
}

.play-btn {
    background: rgba(76, 175, 80, 0.3);
    border-color: rgba(76, 175, 80, 0.3);
    font-size: 20px;
    padding: 8px 24px;
    min-width: 56px;
}

.play-btn:hover {
    background: rgba(76, 175, 80, 0.5);
}

.controls-bottom {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 10px;
}

.control-group-left,
.control-group-right {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.speed-display {
    color: #4CAF50;
    font-weight: bold;
    font-size: 14px;
    min-width: 42px;
    text-align: center;
    text-shadow: 0 2px 8px rgba(0,0,0,0.8);
}

.progress-container {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.time-display {
    color: #aaa;
    font-size: 12px;
    font-family: monospace;
    text-shadow: 0 2px 8px rgba(0,0,0,0.8);
    min-width: 42px;
}

.progress-bar {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    border-radius: 2px;
    background: rgba(255,255,255,0.2);
    outline: none;
    min-width: 50px;
}

.progress-bar::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #4CAF50;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.5);
}

.progress-bar::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #4CAF50;
    cursor: pointer;
    border: none;
}

/* ซ่อน native controls */
#cctvPlayer::-webkit-media-controls {
    display: none !important;
}
#cctvPlayer::-webkit-media-controls-enclosure {
    display: none !important;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    background: rgba(255,255,255,0.02);
    border-radius: 12px;
    border: 2px dashed rgba(255,255,255,0.05);
}

.empty-state h2 {
    font-size: 28px;
    color: #555;
    margin-bottom: 8px;
}

.empty-state p {
    color: #666;
}

/* Video List */
.video-list {
    background: rgba(255,255,255,0.03);
    border-radius: 12px;
    padding: 16px;
    border: 1px solid rgba(255,255,255,0.05);
}

.video-list h3 {
    font-size: 16px;
    color: #aaa;
    margin-bottom: 12px;
}

.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px;
}

.video-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: rgba(255,255,255,0.03);
    border-radius: 8px;
    text-decoration: none;
    color: #aaa;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.video-item:hover {
    background: rgba(255,255,255,0.06);
    color: #fff;
}

.video-item.active {
    background: rgba(0, 150, 255, 0.15);
    border-color: rgba(0, 150, 255, 0.3);
    color: #4CAF50;
}

.video-item .video-icon {
    font-size: 12px;
    color: #4CAF50;
}

.video-item .video-name {
    flex: 1;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.video-item .video-size {
    font-size: 11px;
    color: #666;
}

/* Responsive */
@media (max-width: 768px) {
    .browser {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        display: flex;
        gap: 12px;
        overflow-x: auto;
        padding-bottom: 8px;
    }

    .sidebar .section {
        min-width: 150px;
        flex: 1;
    }

    .section ul {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
    }

    .section ul li {
        display: inline-block;
    }

    .section ul li a {
        padding: 6px 12px;
        font-size: 13px;
    }

    header h1 {
        font-size: 18px;
    }

    .search-box {
        max-width: 100%;
        min-width: auto;
        width: 100%;
    }

    .video-grid {
        grid-template-columns: 1fr;
    }

    #cctvPlayer {
        max-height: 50vh;
    }

    .video-controls-overlay {
        padding: 30px 10px 10px 10px;
    }

    .controls-center {
        gap: 4px;
    }

    .ctrl-btn {
        padding: 4px 8px;
        font-size: 11px;
        min-width: 30px;
        min-height: 30px;
    }

    .play-btn {
        padding: 4px 14px;
        min-width: 44px;
        font-size: 16px;
    }

    .ctrl-btn.small {
        padding: 3px 6px;
        font-size: 11px;
        min-width: 26px;
        min-height: 26px;
    }

    .controls-bottom {
        flex-wrap: wrap;
        gap: 4px;
    }

    .video-title {
        font-size: 11px;
    }

    .video-info {
        font-size: 10px;
    }

    .time-display {
        font-size: 10px;
        min-width: 35px;
    }

    .speed-display {
        font-size: 12px;
        min-width: 35px;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.03);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.25);
}
