/* Reset และ Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

/* หน้าล็อกอิน */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: 15px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-box h1 {
    color: #667eea;
    margin-bottom: 30px;
    font-size: 24px;
    font-weight: 600;
}

.input-group {
    margin-bottom: 20px;
    text-align: left;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #555;
}

.input-group input,
.input-group textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s ease;
}

.input-group input:focus,
.input-group textarea:focus {
    outline: none;
    border-color: #667eea;
}

.input-group small {
    color: #666;
    font-size: 12px;
    margin-top: 5px;
    display: block;
}

button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    width: 100%;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

button:active {
    transform: translateY(0);
}

.error-message {
    color: #e74c3c;
    background: #fdf2f2;
    padding: 10px;
    border-radius: 8px;
    margin-top: 15px;
    border: 1px solid #e74c3c;
}

/* แดชบอร์ด */
.dashboard-container {
    min-height: 100vh;
    background: #f8f9fa;
}

.dashboard-header {
    background: white;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.dashboard-header h1 {
    color: #667eea;
    font-size: 24px;
    font-weight: 600;
}

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

.settings-btn {
    background: #28a745;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
    width: auto;
}

.settings-btn:hover {
    background: #218838;
    transform: translateY(-1px);
}

.logout-btn {
    background: #e74c3c;
    padding: 8px 20px;
    font-size: 14px;
    width: auto;
}

.logout-btn:hover {
    background: #c0392b;
    transform: translateY(-1px);
}

.dashboard-main {
    padding: 30px 20px;
    max-width: 1200px;
    margin: 0 auto;
}

/* ส่วนอัปโหลด */
.upload-section {
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
    margin-bottom: 40px;
}

.upload-section h2 {
    color: #333;
    margin-bottom: 25px;
    font-size: 20px;
    font-weight: 600;
}

.upload-form {
    display: grid;
    gap: 20px;
}

.upload-progress {
    margin-top: 20px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
}

.progress-bar {
    width: 100%;
    height: 10px;
    background: #e1e5e9;
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    width: 0%;
    transition: width 0.3s ease;
}

/* ส่วนวิดีโอ */
.video-section {
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
}

.video-section h2 {
    color: #333;
    margin-bottom: 25px;
    font-size: 20px;
    font-weight: 600;
}

.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 25px;
}

.video-card {
    background: #f8f9fa;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.video-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

.video-thumbnail {
    width: 100%;
    height: 180px;
    background: #ddd;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    color: #999;
    cursor: pointer;
    position: relative;
}

.video-thumbnail::after {
    content: '▶';
    position: absolute;
    color: white;
    font-size: 24px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    background: rgba(0, 0, 0, 0.5);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.video-info {
    padding: 20px;
}

.video-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

.video-description {
    color: #666;
    font-size: 14px;
    margin-bottom: 15px;
    line-height: 1.4;
}

.video-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn-play, .btn-link, .btn-embed {
    flex: 1;
    min-width: 80px;
    padding: 8px 15px;
    font-size: 14px;
    border-radius: 6px;
}

.btn-play {
    background: #28a745;
}

.btn-play:hover {
    background: #218838;
}

.btn-link {
    background: #6c757d;
}

.btn-link:hover {
    background: #5a6268;
}

.btn-embed {
    background: #17a2b8;
}

.btn-embed:hover {
    background: #138496;
}

/* ปุ่มจัดการวิดีโอ */
.video-management {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #eee;
}

.btn-edit, .btn-delete {
    flex: 1;
    min-width: 80px;
    padding: 8px 15px;
    font-size: 14px;
    border-radius: 6px;
}

.btn-edit {
    background: #ffc107;
    color: #212529;
}

.btn-edit:hover {
    background: #e0a800;
    color: white;
}

.btn-delete {
    background: #dc3545;
}

.btn-delete:hover {
    background: #c82333;
}

/* ปุ่มในฟอร์ม */
.btn-save {
    background: #28a745;
    width: auto;
    padding: 10px 20px;
    margin-right: 10px;
}

.btn-save:hover {
    background: #218838;
}

.btn-cancel {
    background: #6c757d;
    width: auto;
    padding: 10px 20px;
}

.btn-cancel:hover {
    background: #5a6268;
}

/* Actions ในฟอร์ม */
.edit-actions, .delete-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    justify-content: flex-end;
}

.no-videos {
    text-align: center;
    color: #666;
    font-size: 18px;
    padding: 40px;
}

/* Modal */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-content {
    background: white;
    border-radius: 15px;
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.modal-header {
    padding: 20px 20px 10px;
    border-bottom: 1px solid #eee;
}

.modal-header h3 {
    color: #333;
    font-size: 18px;
    font-weight: 600;
}

.modal-body {
    padding: 20px;
}

.modal-body video {
    width: 100%;
    border-radius: 8px;
    margin-bottom: 15px;
}

.close {
    position: absolute;
    right: 20px;
    top: 15px;
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.close:hover {
    color: #333;
}

.embed-code {
    width: 100%;
    height: 120px;
    padding: 15px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    resize: vertical;
    margin-bottom: 15px;
}

.copy-btn {
    background: #28a745;
    width: auto;
    padding: 10px 20px;
}

.copy-btn:hover {
    background: #218838;
}

.copy-success {
    color: #28a745;
    background: #d4edda;
    padding: 10px;
    border-radius: 5px;
    margin-top: 10px;
    border: 1px solid #c3e6cb;
}

/* Responsive Design */
@media (max-width: 768px) {
    .dashboard-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .dashboard-header h1 {
        font-size: 20px;
    }
    
    .dashboard-main {
        padding: 20px 15px;
    }
    
    .upload-section,
    .video-section {
        padding: 20px;
    }
    
    .video-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .video-actions {
        flex-direction: column;
    }
    
    .btn-play, .btn-link, .btn-embed, .btn-edit, .btn-delete {
        flex: none;
    }
    
    .video-management {
        flex-direction: column;
    }
    
    .modal-content {
        margin: 10px;
        max-width: calc(100% - 20px);
    }
    
    .login-box {
        padding: 30px 20px;
    }
    
    .login-box h1 {
        font-size: 20px;
    }
}

@media (max-width: 480px) {
    .upload-section,
    .video-section {
        padding: 15px;
    }
    
    .video-info {
        padding: 15px;
    }
    
    .modal-body {
        padding: 15px;
    }
    
    .login-box {
        padding: 25px 15px;
    }
}

/* Loading Animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}