/* --- Global Styles & Variables --- */
:root {
    --bg-dark: #1a1c23;
    --bg-light: #252831;
    --bg-lighter: #2f323b;
    --border-color: #424651;
    --text-light: #f1f2f6;
    --text-muted: #a0a6b5;
    --primary-color: #6c5ce7;
    --primary-hover: #5a4cdb;
    --danger-color: #e74c3c;
    --danger-hover: #c0392b;
    --success-color: #2ecc71;
    --success-hover: #27ae60;
    --font-family: 'Poppins', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-dark);
    color: var(--text-light);
    font-size: 16px;
    line-height: 1.6;
}

.page-container {
    max-width: 1200px;
    margin: 30px auto;
    padding: 20px;
}

.card {
    background-color: var(--bg-light);
    border-radius: 12px;
    padding: 25px 30px;
    margin-bottom: 30px;
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

h1, h2 {
    font-weight: 600;
}

h1 { font-size: 1.8rem; }
h2 { font-size: 1.4rem; margin-bottom: 20px; border-bottom: 1px solid var(--border-color); padding-bottom: 15px; }

i {
    margin-right: 8px;
}

/* --- Header --- */
.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

/* --- Buttons --- */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-family: var(--font-family);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn-logout { background-color: var(--bg-lighter); color: var(--text-light); }
.btn-logout:hover { background-color: var(--danger-color); }
.btn-upload {
    background: linear-gradient(45deg, var(--primary-color), #a29bfe);
    color: white;
    width: 100%;
    margin-top: 20px;
    font-size: 1.1rem;
    box-shadow: 0 4px 15px rgba(108, 92, 231, 0.3);
}
.btn-upload:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(108, 92, 231, 0.4); }
.btn-upload:disabled { background: var(--bg-lighter); cursor: not-allowed; box-shadow: none; }

/* --- Upload Section --- */
.drop-zone { border: 2px dashed var(--border-color); border-radius: 12px; padding: 40px; text-align: center; cursor: pointer; transition: background-color 0.2s ease, border-color 0.2s ease; }
.drop-zone:hover, .drop-zone.drag-over { background-color: var(--bg-lighter); border-color: var(--primary-color); }
.drop-zone-icon { font-size: 3rem; color: var(--primary-color); margin-bottom: 15px; }
.drop-zone-text { color: var(--text-muted); }

/* --- Progress Bar --- */
.progress-container { width: 100%; background-color: var(--bg-dark); border-radius: 8px; margin-top: 20px; position: relative; height: 35px; display: flex; align-items: center; justify-content: center; border: 1px solid var(--border-color); }
.progress-bar { position: absolute; top: 0; left: 0; width: 0%; height: 100%; background: linear-gradient(45deg, var(--success-color), #7bed9f); border-radius: 8px; transition: width 0.3s ease; }
#progress-text { position: relative; z-index: 1; font-weight: 600; color: var(--text-light); }

/* --- Playlist Section --- */
.playlist-header { display: flex; justify-content: space-between; align-items: center; }
.video-count { background-color: var(--bg-dark); color: var(--text-muted); padding: 5px 12px; border-radius: 20px; font-size: 0.9rem; font-weight: 500; }
.table-container { overflow-x: auto; }
.video-table { width: 100%; border-collapse: collapse; margin-top: 20px; }
.video-table th, .video-table td { padding: 15px; text-align: left; vertical-align: middle; }
.video-table thead { background-color: var(--bg-lighter); }
.video-table th { font-weight: 600; color: var(--text-muted); text-transform: uppercase; font-size: 0.8rem; letter-spacing: 0.5px; }
.video-table tbody tr { border-bottom: 1px solid var(--border-color); transition: background-color 0.2s ease; }
.video-table tbody tr:last-child { border-bottom: none; }
.video-table tbody tr:hover { background-color: var(--bg-lighter); }
.admin-thumbnail { width: 100px; height: 56px; object-fit: cover; border-radius: 6px; }
.id-tag { background-color: var(--bg-dark); padding: 4px 8px; border-radius: 4px; font-family: monospace; font-size: 0.9rem; }
.action-buttons { display: flex; gap: 10px; }
.btn-action { width: 40px; height: 40px; padding: 0; font-size: 1rem; }
.btn-action i { margin: 0; }
.btn-view { background-color: var(--primary-color); color: white; }
.btn-view:hover { background-color: var(--primary-hover); }
.btn-copy { background-color: var(--success-color); color: white; }
.btn-copy:hover { background-color: var(--success-hover); }
.btn-delete { background-color: var(--danger-color); color: white; }
.btn-delete:hover { background-color: var(--danger-hover); }
.no-videos { text-align: center; padding: 40px; color: var(--text-muted); }

/* --- Flash Message --- */
.flash-message { padding: 15px; border-radius: 8px; color: white; text-align: center; margin-top: 20px; }
.flash-login-error { background-color: var(--danger-color); }
.admin-flash { background-color: var(--primary-color); margin-top: 0; margin-bottom: 20px; }

/*
========================================
LOGIN & WATCH PAGE STYLES
========================================
*/
.login-page-container, .watch-page-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.login-card, .watch-card {
    width: 100%;
    max-width: 450px;
    background-color: var(--bg-light);
    padding: 40px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    text-align: center;
}

.login-card h1, .watch-card h1 {
    margin-bottom: 10px;
}

.login-subtitle {
    color: var(--text-muted);
    margin-bottom: 30px;
}

.input-group {
    position: relative;
    margin-bottom: 20px;
}

.input-group i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.login-form input {
    display: block;
    width: 100%;
    padding: 15px 15px 15px 45px; /* Add padding for icon */
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-dark);
    color: var(--text-light);
    font-size: 1rem;
    font-family: var(--font-family);
    transition: border-color 0.2s ease;
}

.login-form input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.btn-login {
    width: 100%;
    padding: 15px;
    font-size: 1.1rem;
    background: linear-gradient(45deg, var(--primary-color), #a29bfe);
    box-shadow: 0 4px 15px rgba(108, 92, 231, 0.3);
    color: white;
}
.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(108, 92, 231, 0.4);
}

.watch-card video {
    width: 100%;
    border-radius: 8px;
    margin: 20px 0;
}

.watch-card .link-container input {
    background-color: var(--bg-dark);
    border: 1px solid var(--border-color);
    color: var(--text-light);
    font-family: var(--font-family);
}

.watch-card .link-container button {
    background-color: var(--primary-color);
    color: white;
    border: none;
}
.watch-card .link-container button:hover {
    background-color: var(--primary-hover);
}

.watch-card .back-link {
    display: inline-block;
    margin-top: 20px;
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}
.watch-card .back-link:hover {
    text-decoration: underline;
}

/* Fallback for old/simple .container on watch page */
.container {
    max-width: 600px;
    margin: 20px auto;
}
.video-container {
    position: relative; /* สำคัญมาก! ทำให้ watermark-logo อ้างอิงตำแหน่งจากกรอบนี้ */
    width: 100%;
    line-height: 0; /* แก้ปัญหาช่องว่างปริศนาใต้วิดีโอ */
}

/* 2. จัดการกับตัววิดีโอให้เต็มกรอบ */
.video-container video {
    width: 100%;
    height: auto;
}

/* 3. จัดสไตล์และตำแหน่งของโลโก้ลายน้ำ */
.watermark-logo {
    position: absolute;   /* ทำให้ลอยทับองค์ประกอบอื่นได้ */
    top: 15px;            /* ระยะห่างจากขอบบน */
    right: 15px;          /* ระยะห่างจากขอบขวา */
    width: 120px;         /* กำหนดขนาดโลโก้ตามความเหมาะสม */
    height: auto;
    opacity: 0.6;         /* ทำให้จางลง (0.0 คือโปร่งใส, 1.0 คือทึบ) */
    pointer-events: none; /* ทำให้คลิกทะลุโลโก้ไปโดนปุ่มควบคุมวิดีโอได้ */
    z-index: 10;          /* ทำให้แสดงอยู่ชั้นบนสุดเสมอ */
}