* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Tahoma, sans-serif;
    margin: 0;
    padding: 0;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    position: relative;
    /* Fallback gradient ถ้าไม่มีรูปพื้นหลัง */
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* Background container สำหรับระบบสไลด์ */
#background-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.background-slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    transition: opacity 1.5s ease-in-out;
}

/* Background overlay สำหรับความเข้มข้น */
#background-container::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    z-index: 1;
    pointer-events: none;
}

/* Logo Container */
.logo-container {
    position: fixed;
    top: 30px;
    left: 30px;
    z-index: 1000;
    max-width: 200px;
    max-height: 80px;
    transition: all 0.3s ease;
}

.logo-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.3));
    transition: all 0.3s ease;
}

.logo-container:hover img {
    transform: scale(1.05);
    filter: drop-shadow(3px 3px 6px rgba(0, 0, 0, 0.4));
}

/* Logo placeholder เมื่อไม่มีรูป */
.logo-placeholder {
    display: none;
    background: rgba(255, 255, 255, 0.9);
    padding: 15px 20px;
    border-radius: 10px;
    color: #666;
    font-size: 14px;
    text-align: center;
    backdrop-filter: blur(10px);
    border: 2px dashed #ccc;
    cursor: pointer;
    transition: all 0.3s ease;
}

.logo-placeholder:hover {
    background: rgba(255, 255, 255, 0.95);
    border-color: #dc3545;
    color: #dc3545;
    transform: scale(1.02);
}

/* ซ่อน placeholder เมื่อมี logo */
.logo-container.has-logo .logo-placeholder {
    display: none;
}

/* แสดง placeholder เมื่อไม่มี logo (สำหรับแอดมิน) */
.logo-container.no-logo .logo-placeholder {
    display: block;
}

.logo-container.no-logo img {
    display: none;
}

.login-container {
    position: absolute;
    right: 80px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 0px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    padding: 40px;
    width: 450px;
    z-index: 2;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h1 {
    color: #333;
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 10px;
}

.login-header p {
    color: #666;
    font-size: 14px;
}

.form-group {
    margin-bottom: 25px;
    position: relative;
}

.form-group label {
    display: block;
    color: #555;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
}

.form-group input {
    width: 100%;
    padding: 15px 20px;
    border: 2px solid #e1e5e9;
    border-radius: 0px;
    font-size: 16px;
    background: rgba(255, 255, 255, 0.9);
    transition: all 0.3s ease;
    outline: none;
}

.form-group input:focus {
    border-color: #dc3545;
    background: white;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1);
}

.form-group input:valid {
    border-color: #28a745;
}

.btn {
    width: 100%;
    padding: 15px;
    border: none;
    border-radius: 0px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: #dc3545;
    color: white;
}

.btn-primary:hover {
    background: #c82333;
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(220, 53, 69, 0.3);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

.btn-success {
    background: #dc3545;
    color: white;
}

.btn-success:hover {
    background: #c82333;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(220, 53, 69, 0.3);
}

.user-info {
    background: #f8f9fa;
    border-radius: 0px;
    padding: 20px;
    margin-bottom: 25px;
    border-left: 4px solid #dc3545;
}

.user-info h3 {
    color: #333;
    font-size: 18px;
    margin-bottom: 10px;
}

.user-info p {
    color: #666;
    font-size: 14px;
    margin-bottom: 5px;
}

.back-btn {
    text-align: center;
    margin-top: 20px;
}

.back-btn button {
    background: transparent;
    border: 2px solid #dc3545;
    color: #dc3545;
    padding: 10px 20px;
    border-radius: 0px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
}

.back-btn button:hover {
    background: #dc3545;
    color: white;
}

.register-link {
    text-align: center;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e1e5e9;
}

.register-link a {
    color: #dc3545;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease;
}

.register-link a:hover {
    color: #c82333;
}

.alert {
    padding: 12px 20px;
    border-radius: 0px;
    margin-bottom: 20px;
    font-size: 14px;
    font-weight: 500;
}

.alert-danger {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.form-row {
    display: flex;
    gap: 15px;
}

.form-row .form-group {
    flex: 1;
}

.form-group select {
    width: 100%;
    padding: 15px 20px;
    border: 2px solid #e1e5e9;
    border-radius: 0px;
    font-size: 16px;
    background: rgba(255, 255, 255, 0.9);
    transition: all 0.3s ease;
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 12px center;
    background-repeat: no-repeat;
    background-size: 16px;
}

.form-group select:focus {
    border-color: #dc3545;
    background: white;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1);
}

/* Animation */
.login-container {
    animation: slideInRight 0.6s ease-out;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(50px) translateY(-50%);
    }
    to {
        opacity: 1;
        transform: translateX(0) translateY(-50%);
    }
}

/* ตัวบ่งชี้การสไลด์พื้นหลัง */
.slideshow-indicators {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    z-index: 100;
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

.slideshow-indicators:hover {
    opacity: 1;
}

.indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.8);
    cursor: pointer;
    transition: all 0.3s ease;
}

.indicator.active {
    background: rgba(255, 255, 255, 0.9);
    transform: scale(1.2);
}

.indicator:hover {
    background: rgba(255, 255, 255, 0.8);
    transform: scale(1.1);
}

/* ปุ่มควบคุมการสไลด์ - ซ่อนไว้ */
.slideshow-controls {
    display: none;
}

.control-btn {
    display: none;
}

.prev-btn {
    display: none;
}

.next-btn {
    display: none;
}

/* ข้อมูลรูปภาพ - ซ่อนไว้ */
.image-info {
    display: none;
}

/* ปุ่มจัดการพื้นหลัง (เฉพาะแอดมิน) */
.background-manager {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100;
    opacity: 0;
    transition: opacity 0.3s ease;
}

body:hover .background-manager {
    opacity: 0.8;
}

.bg-manager-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    margin-left: 5px;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.bg-manager-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Modal สำหรับจัดการพื้นหลัง */
.bg-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.bg-modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 15px;
    padding: 30px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.bg-modal h2 {
    margin-top: 0;
    color: #333;
    text-align: center;
}

.upload-area {
    border: 2px dashed #ccc;
    border-radius: 10px;
    padding: 40px;
    text-align: center;
    margin: 20px 0;
    transition: border-color 0.3s ease;
    cursor: pointer;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.1);
}

.bg-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    margin: 20px 0;
}

.bg-item {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    aspect-ratio: 16/9;
    background: #f0f0f0;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.bg-item:hover {
    transform: scale(1.05);
}

.bg-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.bg-item .delete-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(220, 53, 69, 0.8);
    color: white;
    border: none;
    border-radius: 50%;
    width: 25px;
    height: 25px;
    font-size: 12px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.bg-item:hover .delete-btn {
    opacity: 1;
}

/* Responsive */
@media (max-width: 768px) {
    .login-container {
        right: 20px;
        left: 20px;
        width: auto;
        transform: translateY(-50%);
    }
    
    body {
        background-attachment: scroll;
    }
}

@media (max-width: 480px) {
    .login-container {
        padding: 30px 20px;
    }
    
    .login-header h1 {
        font-size: 24px;
    }
    
    .form-row {
        flex-direction: column;
        gap: 0;
    }
}