/* Global Styles & Variables */
:root {
    --primary-color: #ff7eb9;
    --secondary-color: #7eb6ff;
    --accent-color: #a18cd1;
    --bg-gradient: linear-gradient(135deg, #fdfbfb 0%, #ebedee 100%);
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: 1px solid rgba(255, 255, 255, 0.5);
    --shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
    --text-color: #555;
    --font-heading: 'Fredoka One', cursive;
    --font-body: 'Varela Round', sans-serif;
    --border-radius: 24px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-body);
    background: linear-gradient(120deg, #e0c3fc 0%, #8ec5fc 100%);
    min-height: 100vh;
    color: var(--text-color);
    overflow-x: hidden;
    padding: 20px;
}

/* Background Decorations */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(255, 255, 255, 0.4) 0%, transparent 20%),
        radial-gradient(circle at 90% 80%, rgba(255, 255, 255, 0.4) 0%, transparent 20%);
    pointer-events: none;
    z-index: -1;
}

/* Layout Structure */
.booth-machine {
    max-width: 1400px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 30px;
    border: var(--glass-border);
    box-shadow: var(--shadow);
    padding: 30px;
    min-height: 90vh;
    display: flex;
    flex-direction: column;
}

.booth-header {
    text-align: center;
    margin-bottom: 30px;
}

.booth-title {
    font-family: var(--font-heading);
    font-size: 3rem;
    background: linear-gradient(45deg, #ff9a9e 0%, #fad0c4 99%, #fad0c4 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 5px;
}

.booth-main {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr; /* Camera larger than controls */
    gap: 30px;
    flex: 1;
}

/* Left Column: Camera */
.booth-left {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.camera-wrapper {
    position: relative;
    width: 100%;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
    background: #000;
    border: 8px solid white;
}

.camera-container {
    width: 100%;
    aspect-ratio: 4/3;
    position: relative;
    overflow: hidden;
}

#camera {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1); /* Mirror effect */
}

/* Camera Overlays */
.camera-frame {
    position: absolute;
    inset: 0;
    border: 2px solid rgba(255,255,255,0.3);
    pointer-events: none;
}

.countdown {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 8rem;
    font-weight: bold;
    color: white;
    text-shadow: 0 0 20px rgba(255,105,180,0.8);
    opacity: 0;
    pointer-events: none;
}

.countdown.active {
    animation: countAnim 1s ease-in-out infinite;
    opacity: 1;
}

@keyframes countAnim {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
    50% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 0; }
}

.flash {
    position: absolute;
    inset: 0;
    background: white;
    opacity: 0;
    pointer-events: none;
}

.flash.active {
    animation: flashAnim 0.3s ease-out;
}

@keyframes flashAnim {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

/* Right Column: Controls */
.booth-right {
    display: flex;
    flex-direction: column;
}

.controls-panel {
    background: var(--glass-bg);
    border-radius: var(--border-radius);
    padding: 25px;
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 20px;
    box-shadow: inset 0 0 20px rgba(255,255,255,0.5);
    border: var(--glass-border);
}

.panel-header h2 {
    font-family: var(--font-heading);
    color: var(--accent-color);
    font-size: 1.5rem;
    margin-bottom: 0;
}

.panel-header {
    border-bottom: 2px dashed rgba(0,0,0,0.1);
    padding-bottom: 10px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.social-link {
    font-size: 0.9rem;
    color: var(--primary-color);
    text-decoration: none;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.2s;
    background: rgba(255, 126, 185, 0.1);
    padding: 5px 10px;
    border-radius: 15px;
}

.social-link:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
}

.group-title {
    font-weight: bold;
    color: #666;
    margin-bottom: 10px;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Mode Options */
.mode-options {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.mode-option {
    cursor: pointer;
    position: relative;
}

.mode-option input {
    display: none;
}

.mode-option div {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    background: white;
    border-radius: 15px;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.mode-icon {
    font-size: 1.5rem;
    margin-bottom: 5px;
}

.mode-option span {
    font-size: 0.8rem;
    font-weight: bold;
}

.mode-option input:checked + div {
    background: #fff0f5;
    border-color: var(--primary-color);
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(255, 126, 185, 0.3);
}

/* Main Actions */
.main-actions {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
}

.btn-xl {
    width: 100%;
    padding: 15px;
    border-radius: 50px;
    background: linear-gradient(45deg, #ff9a9e 0%, #fecfef 99%, #fecfef 100%);
    border: none;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 10px 20px rgba(255, 105, 180, 0.3);
}

.btn-xl:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 25px rgba(255, 105, 180, 0.4);
}

.btn-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: white;
    font-family: var(--font-heading);
    font-size: 1.5rem;
}

.secondary-actions {
    display: flex;
    gap: 10px;
    width: 100%;
}

.secondary-actions .btn {
    flex: 1;
    padding: 12px;
    border-radius: 15px;
    border: none;
    cursor: pointer;
    font-weight: bold;
    color: white;
    transition: all 0.2s;
}

.btn-danger { background: #ff6b6b; }
.btn-success { background: #4ecdc4; }
.btn-secondary { background: #a8a8a8; }

/* Scrollable Controls (Filters & Stickers) */
.scrollable-controls {
    flex: 1;
    overflow-y: auto;
    padding-right: 5px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Custom Scrollbar */
.scrollable-controls::-webkit-scrollbar {
    width: 6px;
}
.scrollable-controls::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.05);
    border-radius: 10px;
}
.scrollable-controls::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.1);
    border-radius: 10px;
}

/* Filters */
.filters-scroll {
    display: flex;
    gap: 15px;
    overflow-x: auto;
    padding-bottom: 10px;
}

.filter-btn {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    gap: 5px;
}

.filter-preview {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #eee;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid white;
    transition: all 0.3s;
    font-size: 1.2rem;
    color: #888;
}

.filter-btn.active .filter-preview {
    border-color: var(--primary-color);
    background: var(--primary-color);
    color: white;
    transform: scale(1.1);
}

/* Stickers */
.stickers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 10px;
}

.sticker-btn {
    aspect-ratio: 1;
    background: white;
    border-radius: 12px;
    padding: 5px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sticker-btn:hover {
    border-color: var(--secondary-color);
    transform: scale(1.05);
}

.sticker-btn img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Gallery Section */
.gallery {
    margin: 40px auto;
    background: rgba(255,255,255,0.5);
    border-radius: 20px;
    padding: 20px;
    max-width: 1400px; /* Căn chỉnh theo khung máy booth */
}

.photos-container {
    display: flex; /* Chuyển sang Flexbox để dễ kiểm soát kích thước */
    flex-wrap: wrap;
    gap: 20px;
    justify-content: flex-start;
}

.photo-item {
    position: relative;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    transition: transform 0.3s;
    width: 250px; /* Kích thước cố định cho ảnh thumbnail */
    flex-shrink: 0;
}

.photo-item:hover {
    transform: translateY(-5px);
}

.photo-item img {
    width: 100%;
    height: auto;
    display: block;
    padding: 0;
}

.photo-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 10px;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: space-around;
    opacity: 0;
    transition: opacity 0.3s;
}

.photo-item:hover .photo-overlay {
    opacity: 1;
}

/* Collage Preview */
.collage-preview {
    background: white;
    padding: 15px;
    border-radius: 15px;
    margin-bottom: 20px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.collage-container {
    display: grid;
    gap: 5px;
    margin-bottom: 10px;
    background: #eee;
    padding: 5px;
}

.collage-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Responsive Design */
@media (max-width: 900px) {
    .booth-main {
        grid-template-columns: 1fr;
    }
    
    .booth-right {
        order: 2;
    }
}

@media (max-width: 768px) {
    body {
        padding: 15px;
        /* Giữ lại background gradient mặc định thay vì màu trắng */
    }

    .booth-machine {
        border-radius: 24px;
        padding: 20px;
        border: var(--glass-border);
        background: rgba(255, 255, 255, 0.9); /* Nền rõ hơn một chút trên mobile */
        box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    }

    .booth-header h1 {
        font-size: 2rem;
    }

    .camera-container {
        aspect-ratio: 9/16; /* Portrait for mobile */
        border-radius: 20px;
    }

    .controls-panel {
        padding: 15px;
        background: white;
        box-shadow: 0 5px 20px rgba(0,0,0,0.05);
        border-radius: 20px;
        position: relative;
        z-index: 10;
    }

    .mode-options {
        grid-template-columns: repeat(4, 1fr);
    }

    .mode-icon {
        font-size: 1.2rem;
        width: 30px;
        height: 30px;
    }

    .btn-xl {
        padding: 12px;
    }

    .btn-content {
        font-size: 1.2rem;
    }
    
    .photo-overlay {
        opacity: 1;
        background: linear-gradient(to top, rgba(0,0,0,0.7), transparent);
    }

    /* Fix overflow issues */
    .booth-main, .booth-left, .booth-right {
        width: 100%;
        min-width: 0; /* Prevent grid blowout */
    }

    .camera-wrapper {
        border-width: 4px; /* Reduce border size on mobile */
        max-width: 100%;
        margin: 0 auto;
    }
    
    .camera-container {
        width: 100%;
        border-radius: 16px; /* Match inner radius */
    }}

/* Filter classes for video */
.filter-normal { filter: none; }
.filter-grayscale { filter: grayscale(100%); }
.filter-sepia { filter: sepia(100%); }
.filter-invert { filter: invert(80%); }
.filter-vintage { filter: sepia(30%) saturate(140%) brightness(0.9) contrast(1.2); }
.filter-pastel { filter: brightness(1.1) saturate(1.3) contrast(0.9); }
.filter-cute { filter: brightness(1.1) saturate(1.5) contrast(0.85) hue-rotate(10deg); }

/* Flip Button */
#flip-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.8);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    transition: transform 0.2s;
}

#flip-btn:hover {
    transform: rotate(180deg);
    background: white;
}

#flip-btn i {
    color: var(--primary-color);
    font-size: 1.2rem;
}

/* Collage Preview Improvements */
.collage-item {
    background: #fff;
    border: 2px dashed #ddd;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 4/3;
    overflow: hidden;
    border-radius: 8px;
}

.collage-item.empty span {
    font-size: 2rem;
    color: #ddd;
    font-weight: bold;
}

/* Floating Icons Decoration */
.top-left-decor {
    position: fixed;
    top: 30px;
    left: 30px;
    display: flex;
    gap: 15px;
    z-index: 100;
}

.floating-icon {
    font-size: 2rem;
    color: rgba(255, 255, 255, 0.8);
    filter: drop-shadow(0 0 10px rgba(0,0,0,0.2));
    animation: float 3s ease-in-out infinite;
}

.floating-icon:nth-child(2) {
    animation-delay: 0.5s;
    color: #ff9a9e;
}

.floating-icon:nth-child(3) {
    animation-delay: 1s;
    color: #fad0c4;
}

@keyframes float {
    0% { transform: translateY(0); }
    50% { transform: translateY(-10px) rotate(10deg); }
    100% { transform: translateY(0); }
}

@media (max-width: 768px) {
    .top-left-decor {
        top: 15px;
        left: 15px;
    }
    .floating-icon {
        font-size: 1.5rem;
    }
}