/* ==========================================
   OWLDIO PLAYER - 全域設計系統與 CSS 變數
   ========================================== */
:root {
    --bg-main: #09090b;          /* 極致暗黑背景 */
    --bg-card: #18181b;          /* 卡片與區塊背景 */
    --bg-card-hover: #27272a;    /* 卡片懸停背景 */
    --accent: #f59e0b;           /* 質感金黃色 (Owldio 貓頭鷹眼亮色) */
    --accent-hover: #d97706;     /* 亮色懸停 */
    --text-primary: #f4f4f5;     /* 主要文字 (亮灰白) */
    --text-secondary: #a1a1aa;   /* 次要文字 (中灰) */
    --text-muted: #71717a;       /* 隱藏文字 (暗灰) */
    --border-color: rgba(255, 255, 255, 0.08); /* 細緻邊框 */
    --glow-color: rgba(245, 158, 11, 0.25);    /* 金色微光 */
    --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --transition-smooth: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* 基本重設 */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
}

/* 捲軸美化 (Webkit) */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
    background: var(--bg-card-hover);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

/* ==========================================
   1. 密碼驗證遮罩層 (Password Overlay)
   ========================================== */
.password-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at center, #18181b 0%, #09090b 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s ease, visibility 0.5s ease;
    padding: 20px;
}

/* 驗證卡片 - 玻璃擬態質感 */
.password-card {
    background: rgba(24, 24, 27, 0.65);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 40px;
    border-radius: 20px;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5), 0 0 40px rgba(245, 158, 11, 0.03);
    text-align: center;
    transform: translateY(0);
    transition: var(--transition-smooth);
}

.password-overlay.fade-out {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.brand-logo {
    margin-bottom: 30px;
}

.owl-icon {
    width: 64px;
    height: 64px;
    color: var(--accent);
    margin-bottom: 16px;
    filter: drop-shadow(0 0 10px var(--glow-color));
    animation: pulseGlow 3s infinite ease-in-out;
}

@keyframes pulseGlow {
    0%, 100% { filter: drop-shadow(0 0 8px rgba(245, 158, 11, 0.2)); }
    50% { filter: drop-shadow(0 0 20px rgba(245, 158, 11, 0.5)); }
}

.brand-logo h2 {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: 2px;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #fff 0%, var(--text-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

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

/* 密碼輸入框 */
.input-group {
    position: relative;
    margin-bottom: 20px;
}

.input-group input {
    width: 100%;
    padding: 14px 16px;
    background: rgba(9, 9, 11, 0.8);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: #fff;
    font-size: 16px;
    outline: none;
    transition: var(--transition-smooth);
    text-align: center;
    letter-spacing: 4px;
}

.input-group input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 10px var(--glow-color);
}

.btn-submit {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
    border: none;
    border-radius: 10px;
    color: #000;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.2);
}

.btn-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.4);
}

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

.error-msg {
    color: #ef4444;
    font-size: 13px;
    margin-top: 12px;
    min-height: 20px;
    font-weight: 500;
}

/* ==========================================
   2. 主介面 (Main Content)
   ========================================== */
.main-content {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    opacity: 1;
    transition: opacity 0.5s ease;
}

.main-content.hidden {
    display: none;
    opacity: 0;
}

/* 頂部導覽列 */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 40px;
    background-color: rgba(9, 9, 11, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-logo {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 1px;
}

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

.nav-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}

.badge-dot {
    width: 6px;
    height: 6px;
    background-color: var(--accent);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--accent);
}

/* ==========================================
   3. 響應式佈局 (Layout)
   ========================================== */
.app-container {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr; /* 行動版預設為單欄 */
    gap: 32px;
    max-width: 1720px;
    width: 100%;
    margin: 0 auto;
    padding: 24px;
}

/* 桌面版（大螢幕）: 左 70% (7fr) , 右 30% (3fr) */
@media (min-width: 1024px) {
    .app-container {
        grid-template-columns: 7fr 3fr;
        padding: 40px;
    }
}

/* 3-1. 播放器區塊 */
.player-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.player-wrapper {
    background-color: #000;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    /* 保持 16:9 比例 */
    aspect-ratio: 16 / 9;
}

/* Plyr 客製化樣式調整 */
.plyr {
    --plyr-color-main: var(--accent);
    --plyr-video-background: #000;
    height: 100%;
    width: 100%;
}

.video-info {
    padding: 10px 4px;
}

.video-title {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 12px;
    color: #fff;
    letter-spacing: 0.5px;
}

.video-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.meta-tag {
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 6px;
    letter-spacing: 0.5px;
}

.meta-tag.resolution {
    background-color: rgba(245, 158, 11, 0.1);
    color: var(--accent);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.meta-tag.codec {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.meta-tag.access {
    background-color: rgba(239, 68, 68, 0.1);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.playback-notice {
    background: rgba(255, 255, 255, 0.03);
    border-left: 3px solid var(--accent);
    padding: 12px 16px;
    border-radius: 0 8px 8px 0;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* 3-2. 右側/下方影片清單區區塊 */
.playlist-section {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    height: fit-content;
    max-height: 780px; /* 大螢幕限制高度以維持滾動 */
    overflow: hidden;
}

.playlist-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.playlist-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.playlist-count {
    font-size: 13px;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 10px;
    border-radius: 12px;
}

.playlist-items {
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* 影片卡片 (List Card) */
.playlist-card {
    display: flex;
    gap: 14px;
    padding: 10px;
    border-radius: 10px;
    background-color: rgba(255, 255, 255, 0.02);
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.playlist-card:hover {
    background-color: var(--bg-card-hover);
    border-color: rgba(255, 255, 255, 0.05);
    transform: translateX(4px);
}

/* 高亮目前播放的卡片 */
.playlist-card.active {
    background-color: rgba(245, 158, 11, 0.08);
    border-color: rgba(245, 158, 11, 0.3);
}

.playlist-card.active .card-title {
    color: var(--accent);
}

.card-thumb-wrapper {
    position: relative;
    width: 120px;
    aspect-ratio: 16 / 9;
    border-radius: 6px;
    overflow: hidden;
    background-color: #000;
    flex-shrink: 0;
}

.card-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition-smooth);
}

.playlist-card:hover .card-thumb {
    transform: scale(1.05);
}

/* 播放狀態 Overlay */
.card-play-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: var(--transition-smooth);
}

.playlist-card:hover .card-play-overlay,
.playlist-card.active .card-play-overlay {
    opacity: 1;
}

.play-icon-mini {
    width: 24px;
    height: 24px;
    color: #fff;
}

.playlist-card.active .play-icon-mini {
    color: var(--accent);
}

.card-duration {
    position: absolute;
    bottom: 6px;
    right: 6px;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    font-size: 10px;
    font-weight: 500;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}

.card-info {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 2px 0;
}

.card-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: var(--transition-smooth);
}

.card-tag {
    font-size: 11px;
    color: var(--text-muted);
}

/* 行動版特定樣式調整 */
@media (max-width: 1023px) {
    .playlist-section {
        max-height: none; /* 行動版不需要限制高度，直接流動排版 */
    }
}

/* ==========================================
   4. 底部頁尾 (Footer)
   ========================================== */
.footer {
    text-align: center;
    padding: 30px 20px;
    border-top: 1px solid var(--border-color);
    margin-top: auto;
}

.footer p {
    font-size: 12px;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

/* ==========================================
   5. 管理後台專用樣式 (Admin Portal CSS)
   ========================================== */
.nav-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.btn-admin-portal {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: var(--transition-smooth);
}

.btn-admin-portal:hover {
    background: var(--accent);
    color: #000;
    border-color: var(--accent);
    box-shadow: 0 0 12px var(--glow-color);
}

.btn-admin-portal.hidden {
    display: none;
}

/* Modal 容器 */
.admin-portal-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    transition: opacity 0.3s ease;
}

.admin-portal-modal.hidden {
    display: none;
    opacity: 0;
    pointer-events: none;
}

.admin-card {
    background: #121214;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    width: 100%;
    max-width: 1100px;
    height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 30px 60px rgba(0,0,0,0.6);
}

.admin-header {
    padding: 20px 30px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.admin-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: #fff;
}

.btn-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 32px;
    cursor: pointer;
    line-height: 1;
    transition: var(--transition-smooth);
}

.btn-close:hover {
    color: #fff;
}

.admin-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* 頁籤 */
.admin-tabs {
    display: flex;
    background: #18181b;
    border-bottom: 1px solid var(--border-color);
    padding: 0 20px;
}

.tab-btn {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    padding: 16px 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition-smooth);
}

.tab-btn:hover {
    color: #fff;
}

.tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.tab-content {
    display: none;
    flex: 1;
    overflow: hidden;
    padding: 30px;
}

.tab-content.active {
    display: flex;
    flex-direction: column;
}

/* 左右分欄 */
.admin-split {
    display: grid;
    grid-template-columns: 4fr 6fr;
    gap: 30px;
    height: 100%;
    overflow: hidden;
}

.form-section {
    background: #18181b;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    overflow-y: auto;
}

.list-section {
    background: #18181b;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.form-section h4, .list-section h4, .export-section h4 {
    margin-bottom: 20px;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    border-left: 3px solid var(--accent);
    padding-left: 10px;
}

/* 表單控制項 */
.form-group {
    margin-bottom: 16px;
}

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

.form-group input, .form-group select {
    width: 100%;
    padding: 10px 12px;
    background: #09090b;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: #fff;
    font-size: 14px;
    outline: none;
    transition: var(--transition-smooth);
}

.form-group input:focus, .form-group select:focus {
    border-color: var(--accent);
}

.btn-primary {
    background: var(--accent);
    color: #000;
    border: none;
    padding: 12px 20px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    transition: var(--transition-smooth);
}

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

/* 表格樣式 */
.table-wrapper {
    flex: 1;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 13px;
}

.admin-table th, .admin-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}

.admin-table th {
    background: #09090b;
    color: var(--text-secondary);
    font-weight: 500;
    position: sticky;
    top: 0;
    z-index: 10;
}

.admin-table tbody tr:hover {
    background: rgba(255,255,255,0.02);
}

.btn-danger {
    background: #ef4444;
    color: #fff;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: var(--transition-smooth);
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-danger-outline {
    background: none;
    border: 1px solid #ef4444;
    color: #ef4444;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: var(--transition-smooth);
}

.btn-danger-outline:hover {
    background: #ef4444;
    color: #fff;
}

/* 複選框授權列表 */
.auth-checkbox-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 120px;
    overflow-y: auto;
    background: #09090b;
    padding: 8px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.auth-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
}

.auth-item input {
    cursor: pointer;
    accent-color: var(--accent);
}

/* 匯出頁籤 */
.export-section {
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow: hidden;
}

.export-notice {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
    background: rgba(245, 158, 11, 0.05);
    border-left: 3px solid var(--accent);
    padding: 16px;
    border-radius: 0 8px 8px 0;
}

.btn-copy {
    width: auto;
    align-self: flex-start;
}

.code-output {
    flex: 1;
    background: #09090b;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    overflow: auto;
    font-family: monospace;
    font-size: 12px;
    color: #a78bfa; /* 紫色代碼高亮風格 */
    white-space: pre;
}

/* 頁尾 */
.admin-footer {
    padding: 20px 30px;
    border-top: 1px solid var(--border-color);
    background: #18181b;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--text-muted);
}

