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

:root {
    --bg-primary: #0f0f0f;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #282828;
    --text-primary: #ffffff;
    --text-secondary: #aaaaaa;
    --accent: #ff0000;
    --accent-hover: #cc0000;
}

body {
    font-family: 'Sarabun', 'Roboto', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
}

/* Header */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: linear-gradient(to bottom, rgba(0,0,0,0.9), transparent);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 100;
}

.logo {
    font-size: 16px;
    font-weight: bold;
    color: var(--text-primary);
}

.logo span {
    color: var(--accent);
}

.header-actions {
    display: flex;
    gap: 12px;
}

.btn-icon {
    background: rgba(255,255,255,0.1);
    border: none;
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.btn-icon:hover {
    background: rgba(255,255,255,0.2);
}

/* Video Container */
.video-container {
    height: 100vh;
    height: 100dvh;
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
    scrollbar-width: none;
}

.video-container::-webkit-scrollbar {
    display: none;
}

.video-slide {
    height: 100vh;
    height: 100dvh;
    scroll-snap-align: start;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    background: var(--bg-primary);
}

/* Video Player */
.video-wrapper {
    position: relative;
    width: 100%;
    max-width: 100%;
    height: 55vh; /* จำกัดความสูงไม่ให้ยาวเกินไป */
    max-height: 400px;
    background: #000;
    border-radius: 0;
}

@media (min-width: 768px) {
    .video-wrapper {
        max-width: 500px;
        border-radius: 12px;
    }
}

.video-wrapper iframe {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: inherit;
}

/* Swipe Overlay - ทับวีดีโอเพื่อให้ปัดได้ */
.swipe-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 100px; /* เว้นด้านล่างมากขึ้นสำหรับ iPhone */
    z-index: 5;
    cursor: pointer;
    touch-action: pan-y; /* อนุญาตให้ scroll แนวตั้ง */
}

/* Play button สำหรับกรณี autoplay ไม่ทำงาน */
.play-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 6;
    cursor: pointer;
}

.play-overlay.hidden {
    display: none;
}

.play-overlay-btn {
    width: 80px;
    height: 80px;
    background: var(--accent);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 36px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

.play-overlay-btn:hover {
    transform: scale(1.1);
}

/* Video Info */
.video-info {
    position: absolute;
    bottom: 30px;
    left: 16px;
    right: 70px;
    z-index: 10;
}

.video-title {
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

.video-channel {
    font-size: 12px;
    color: var(--text-secondary);
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

.video-category {
    display: inline-block;
    margin-top: 6px;
    padding: 3px 10px;
    background: rgba(0,0,0,0.5);
    border-radius: 20px;
    font-size: 11px;
}

/* Side Actions */
.side-actions {
    position: absolute;
    right: 12px;
    bottom: 30px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    z-index: 10;
}

.action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
}

.action-btn .icon {
    width: 40px;
    height: 40px;
    background: rgba(0,0,0,0.5);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.2s;
}

.action-btn:hover .icon {
    background: rgba(0,0,0,0.7);
    transform: scale(1.1);
}

.action-btn.liked .icon {
    color: var(--accent);
}

.action-btn .count {
    font-size: 10px;
    color: var(--text-secondary);
}

/* Bottom Navigation - REMOVED */
/*
.bottom-nav {
    display: none;
}
*/

/* Header Play Mode */
.header-play-mode {
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(255,255,255,0.1);
    border-radius: 20px;
    padding: 4px;
}

.header-play-mode .mode-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s;
}

.header-play-mode .mode-btn.active {
    background: var(--text-primary);
    color: var(--bg-primary);
}

.header-play-mode .mode-btn:hover:not(.active) {
    background: rgba(255,255,255,0.1);
}

/* Category Filter */
.category-filter {
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    padding: 10px 16px;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    background: linear-gradient(to bottom, rgba(0,0,0,0.8), transparent);
    z-index: 90;
}

.category-filter::-webkit-scrollbar {
    display: none;
}

.category-chip {
    padding: 6px 14px;
    background: var(--bg-tertiary);
    border: none;
    border-radius: 20px;
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.category-chip:hover {
    background: var(--bg-secondary);
}

.category-chip.active {
    background: var(--text-primary);
    color: var(--bg-primary);
}

/* Comment Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.8);
    z-index: 200;
    display: none;
    align-items: flex-end;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.comment-modal {
    background: var(--bg-secondary);
    width: 100%;
    max-width: 500px;
    max-height: 70vh;
    border-radius: 20px 20px 0 0;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 16px;
    border-bottom: 1px solid var(--bg-tertiary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 18px;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 24px;
    cursor: pointer;
}

.comment-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.comment-item {
    margin-bottom: 16px;
}

.comment-author {
    font-weight: bold;
    font-size: 14px;
    margin-bottom: 4px;
}

.comment-text {
    font-size: 14px;
    color: var(--text-secondary);
}

.comment-time {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.comment-form {
    padding: 16px;
    border-top: 1px solid var(--bg-tertiary);
}

.comment-form input,
.comment-form textarea {
    width: 100%;
    padding: 12px;
    background: var(--bg-tertiary);
    border: none;
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    margin-bottom: 8px;
}

.comment-form textarea {
    resize: none;
    height: 80px;
}

.comment-form button {
    width: 100%;
    padding: 12px;
    background: var(--accent);
    border: none;
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
}

.comment-form button:hover {
    background: var(--accent-hover);
}

/* Share Modal */
.share-modal {
    background: var(--bg-secondary);
    width: 100%;
    max-width: 400px;
    border-radius: 20px 20px 0 0;
    padding: 24px;
}

.share-options {
    display: flex;
    justify-content: space-around;
    margin-top: 20px;
}

.share-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
}

.share-btn .icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
}

.share-btn.line .icon { background: #00B900; }
.share-btn.facebook .icon { background: #1877F2; }
.share-btn.twitter .icon { background: #1DA1F2; }
.share-btn.copy .icon { background: var(--bg-tertiary); }

.share-btn .label {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-primary);
    color: var(--bg-primary);
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 300;
    opacity: 0;
    transition: opacity 0.3s;
}

.toast.show {
    opacity: 1;
}

/* Loading */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    gap: 16px;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--bg-tertiary);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    gap: 16px;
    color: var(--text-secondary);
}

.empty-state .icon {
    font-size: 64px;
}

/* Admin Styles */
.admin-container {
    padding: 20px;
    max-width: 800px;
    margin: 0 auto;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.admin-title {
    font-size: 24px;
    font-weight: bold;
}

.btn {
    padding: 10px 20px;
    background: var(--accent);
    border: none;
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
}

.btn:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: var(--bg-tertiary);
}

.btn-secondary:hover {
    background: var(--bg-secondary);
}

.card {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    color: var(--text-secondary);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px;
    background: var(--bg-tertiary);
    border: none;
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
}

.song-list-item {
    display: flex;
    gap: 16px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: 12px;
    margin-bottom: 12px;
    align-items: center;
}

.song-list-item img {
    width: 80px;
    height: 60px;
    object-fit: cover;
    border-radius: 8px;
}

.song-list-item .info {
    flex: 1;
}

.song-list-item .title {
    font-weight: bold;
    margin-bottom: 4px;
}

.song-list-item .channel {
    font-size: 14px;
    color: var(--text-secondary);
}

.song-list-item .actions {
    display: flex;
    gap: 8px;
}

.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
}

.tab {
    padding: 10px 20px;
    background: var(--bg-tertiary);
    border: none;
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
}

.tab.active {
    background: var(--accent);
    color: var(--text-primary);
}

/* Login */
.login-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    gap: 20px;
}

.login-form {
    background: var(--bg-secondary);
    padding: 32px;
    border-radius: 16px;
    width: 100%;
    max-width: 400px;
}

.login-form h2 {
    text-align: center;
    margin-bottom: 24px;
}

.login-form input {
    width: 100%;
    padding: 12px;
    background: var(--bg-tertiary);
    border: none;
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 16px;
    text-align: center;
    margin-bottom: 16px;
}

.login-form button {
    width: 100%;
    padding: 12px;
    background: var(--accent);
    border: none;
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 16px;
    cursor: pointer;
}

.error-msg {
    color: var(--accent);
    text-align: center;
    margin-bottom: 16px;
}
