:root {
    --bg-main: #080c14;
    --card-bg: #111827;
    --accent-red: #ff2a5f;
    --accent-cyan: #00f0ff;
    --border-glow: rgba(0, 240, 255, 0.25);
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* ป้องกันการคลุมดำเลือกข้อความและการ drag รูปภาพ */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-user-drag: none;
}

/* อนุญาตให้พิมพ์ในช่องค้นหาได้ตามปกติ */
input, textarea {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

/* ซ่อนการแสดงผลเมื่อสั่งพิมพ์หน้าเว็บ (Print / Save to PDF) */
@media print {
    body {
        display: none !important;
    }
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: var(--font-family);
    padding: 20px 0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 28px;
    background: rgba(17, 24, 39, 0.85);
    backdrop-filter: blur(16px);
    border-radius: 12px;
    margin-bottom: 25px;
    border: 1px solid var(--border-glow);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    position: relative;
    flex-wrap: wrap;
    gap: 20px;
}

.header::before {
    content: '';
    position: absolute;
    top: -1px; left: 20px; right: 20px;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent-cyan), transparent);
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 16px;
}

.detective-logo {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, rgba(0, 240, 255, 0.1), rgba(255, 42, 95, 0.2));
    border: 1px solid var(--accent-cyan);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 12px rgba(0, 240, 255, 0.2);
}

.detective-logo svg {
    width: 24px;
    height: 24px;
    fill: var(--accent-cyan);
}

.brand-titles {
    display: flex;
    flex-direction: column;
}

.brand-main {
    font-size: 22px;
    font-weight: 900;
    letter-spacing: 2px;
    color: #ffffff;
    text-transform: uppercase;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
}

.brand-sub {
    font-size: 11px;
    color: var(--accent-red);
    letter-spacing: 4px;
    font-weight: 700;
    text-transform: uppercase;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-container {
    position: relative;
    display: flex;
    align-items: center;
    background: rgba(8, 12, 20, 0.95);
    border: 1px solid rgba(0, 240, 255, 0.3);
    border-radius: 8px;
    padding: 4px 12px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    width: 280px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
}

.search-container:focus-within {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.35), inset 0 0 8px rgba(0, 240, 255, 0.1);
    width: 340px;
}

.search-icon {
    width: 18px;
    height: 18px;
    fill: var(--text-muted);
    margin-right: 8px;
    transition: fill 0.3s ease;
}

.search-container:focus-within .search-icon {
    fill: var(--accent-cyan);
}

.search-input {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 13px;
    width: 100%;
    padding: 6px 0;
    outline: none;
}

.search-input::placeholder {
    color: #4b5563;
}

.search-clear {
    display: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 14px;
    padding: 0 4px;
}
.search-clear:hover { color: var(--accent-red); }

.search-results-panel {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 380px;
    background: rgba(17, 24, 39, 0.98);
    backdrop-filter: blur(20px);
    border: 1px solid var(--accent-cyan);
    border-radius: 10px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.8), 0 0 15px rgba(0, 240, 255, 0.2);
    z-index: 100;
    display: none;
    overflow: hidden;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.results-header {
    padding: 10px 14px;
    background: rgba(8, 12, 20, 0.8);
    font-size: 11px;
    color: var(--accent-cyan);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 700;
    letter-spacing: 1px;
}

.results-list {
    max-height: 280px;
    overflow-y: auto;
}

.results-list::-webkit-scrollbar { width: 5px; }
.results-list::-webkit-scrollbar-thumb { background: var(--accent-cyan); border-radius: 4px; }

.result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.2s ease;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.result-item:hover {
    background: rgba(0, 240, 255, 0.08);
}

.result-item img {
    width: 50px;
    height: 32px;
    object-fit: cover;
    border-radius: 4px;
}

.result-item-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.result-item-title {
    font-size: 13px;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.result-item-tag {
    font-size: 10px;
    color: var(--accent-red);
}

.no-results {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

.player-wrapper {
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
    margin-bottom: 20px;
    border: 1px solid #1f293d;
}

.video-container {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
}

.video-container iframe {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    border: 0;
}

.control-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--card-bg);
    padding: 16px 20px;
    border-radius: 10px;
    margin-bottom: 25px;
    border: 1px solid #1f293d;
    flex-wrap: wrap;
    gap: 15px;
}

.current-ep-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--accent-cyan);
}

.server-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.server-label {
    font-size: 12px;
    color: var(--text-muted);
}

.server-btn {
    padding: 7px 16px;
    background: #162032;
    border: 1px solid #2a3a5c;
    color: var(--text-main);
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
}

.server-btn:hover, .server-btn.active {
    background: var(--accent-red);
    border-color: var(--accent-red);
    font-weight: bold;
    box-shadow: 0 0 10px rgba(255, 42, 95, 0.4);
}

.section-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.slider-controls {
    display: flex;
    gap: 8px;
}

.nav-btn {
    background: var(--card-bg);
    border: 1px solid #2a3a5c;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: 0.2s;
}

.nav-btn:hover {
    background: var(--accent-cyan);
    color: #000;
    border-color: var(--accent-cyan);
}

.slider-container {
    display: flex;
    gap: 15px;
    overflow-x: auto;
    scroll-behavior: smooth;
    padding-bottom: 15px;
    margin-bottom: 25px;
}

.slider-container::-webkit-scrollbar { height: 6px; }
.slider-container::-webkit-scrollbar-thumb { background: #2a3a5c; border-radius: 10px; }

.ep-card {
    flex: 0 0 220px;
    background: var(--card-bg);
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease;
    border: 1px solid #1f293d;
    position: relative;
}

.ep-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent-cyan);
}

.ep-card.active {
    border-color: var(--accent-red);
    box-shadow: 0 0 12px rgba(255, 42, 95, 0.3);
}

/* Overlay โปร่งใสคลุมรูปเพื่อป้องกันการคลิกขวาบันทึกภาพโดยตรง */
.img-wrapper {
    position: relative;
    width: 100%;
    height: 124px;
}

.img-wrapper::after {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: transparent;
}

.ep-card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.ep-card-info { padding: 10px; }

.ep-badge {
    display: inline-block;
    background: rgba(0, 240, 255, 0.1);
    color: var(--accent-cyan);
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: bold;
    margin-bottom: 4px;
}

.ep-card-title {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.info-card {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 10px;
    border: 1px solid #1f293d;
    line-height: 1.6;
}

.info-card h1 {
    font-size: 20px;
    color: var(--accent-red);
    margin-bottom: 8px;
}

.info-card p {
    color: var(--text-muted);
    font-size: 14px;
}

@media (max-width: 768px) {
    .header { justify-content: center; padding: 15px; }
    .header-actions { width: 100%; justify-content: center; }
    .search-container { width: 100%; }
    .search-container:focus-within { width: 100%; }
    .search-results-panel { width: 100%; right: 0; left: 0; }
    .ep-card { flex: 0 0 170px; }
    .img-wrapper { height: 96px; }
}