/* =====================================================
   PHOTOBOOTH CSS
   Styles principaux pour l'interface photobooth
   ===================================================== */

:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #10b981;
    --danger-color: #ef4444;
    --dark-color: #1e293b;
    --light-color: #f8fafc;
    --text-color: #334155;
    --text-light: #94a3b8;
    
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
    
    --border-radius: 16px;
    --border-radius-lg: 24px;
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: #000;
    color: #fff;
    cursor: default;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

/* ===== SCREENS ===== */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.screen.active {
    display: flex;
    opacity: 1;
}

/* ===== LOADING SCREEN ===== */
#loading-screen {
    background: linear-gradient(135deg, var(--dark-color), #0f172a);
    z-index: 1000;
}

.loading-content {
    text-align: center;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255,255,255,0.1);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== IDLE SCREEN ===== */
#idle-screen {
    background: #000;
}

#background-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

#background-container img,
#background-container video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.idle-content {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 40px;
}

#app-title {
    font-size: 4rem;
    font-weight: 700;
    text-shadow: 0 4px 20px rgba(0,0,0,0.5);
    margin-bottom: 40px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.start-button {
    padding: 30px 80px;
    font-size: 2rem;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    border: none;
    border-radius: var(--border-radius-lg);
    cursor: pointer;
    box-shadow: 0 10px 40px rgba(99, 102, 241, 0.4);
    transition: all var(--transition-normal);
    animation: pulse 2s ease-in-out infinite;
}

.start-button:hover,
.start-button:active {
    transform: scale(1.05);
    box-shadow: 0 15px 50px rgba(99, 102, 241, 0.5);
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 10px 40px rgba(99, 102, 241, 0.4); }
    50% { box-shadow: 0 10px 60px rgba(99, 102, 241, 0.6); }
}

/* ===== TEMPLATE SCREEN ===== */
#template-screen {
    background: linear-gradient(180deg, var(--dark-color), #0f172a);
    padding: 40px;
}

.screen-header {
    margin-bottom: 40px;
}

.screen-header h2 {
    font-size: 2.5rem;
    font-weight: 600;
}

.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 30px;
    max-width: 1200px;
    width: 100%;
    padding: 20px;
    overflow-y: auto;
    max-height: 60vh;
}

.template-card {
    background: rgba(255,255,255,0.05);
    border-radius: var(--border-radius);
    overflow: hidden;
    cursor: pointer;
    transition: all var(--transition-normal);
    border: 3px solid transparent;
}

.template-card:hover,
.template-card.selected {
    transform: translateY(-5px);
    border-color: var(--primary-color);
    box-shadow: 0 10px 30px rgba(99, 102, 241, 0.3);
}

.template-card img {
    width: 100%;
    aspect-ratio: 2/3;
    object-fit: contain;
    background: #1e293b;
}

.template-card .template-info {
    padding: 15px;
    text-align: center;
}

.template-card .template-name {
    font-weight: 600;
    font-size: 1.1rem;
}

.template-card .template-meta {
    font-size: 0.9rem;
    color: var(--text-light);
    margin-top: 5px;
}

.back-button {
    position: absolute;
    bottom: 40px;
    left: 40px;
    padding: 15px 30px;
    font-size: 1.2rem;
    background: rgba(255,255,255,0.1);
    border: none;
    border-radius: var(--border-radius);
    color: #fff;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.back-button:hover {
    background: rgba(255,255,255,0.2);
}

/* ===== CAPTURE SCREEN ===== */
#capture-screen {
    background: #000;
}

.camera-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

#camera-preview {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transform: scaleX(-1); /* Mirror effect */
}

#camera-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Countdown */
.countdown {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
}

.countdown.hidden {
    display: none;
}

#countdown-number {
    font-size: 15rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 0 50px rgba(255,255,255,0.5);
    animation: countdownPop 1s ease-out;
}

@keyframes countdownPop {
    0% { transform: scale(0.5); opacity: 0; }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}

/* Capture indicator */
.capture-indicator {
    position: absolute;
    top: 40px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.7);
    padding: 15px 30px;
    border-radius: var(--border-radius);
    font-size: 1.5rem;
    font-weight: 600;
}

.capture-indicator.hidden {
    display: none;
}

/* Flash effect */
.flash-effect {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #fff;
    opacity: 0;
    pointer-events: none;
    z-index: 100;
}

.flash-effect.active {
    animation: flash 0.3s ease-out;
}

@keyframes flash {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

/* Quick preview */
.quick-preview {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 200px;
    height: auto;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    z-index: 50;
}

.quick-preview.hidden {
    display: none;
}

.quick-preview img {
    width: 100%;
    height: auto;
}

/* ===== RESULT SCREEN ===== */
#result-screen {
    background: linear-gradient(180deg, var(--dark-color), #0f172a);
    padding: 40px;
}

.result-container {
    text-align: center;
    max-width: 900px;
    width: 100%;
}

.result-container h2 {
    font-size: 2.5rem;
    margin-bottom: 30px;
}

#result-preview {
    margin-bottom: 30px;
}

#result-canvas {
    max-width: 100%;
    max-height: 50vh;
    border-radius: var(--border-radius);
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.result-actions {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 30px;
}

.action-button {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 40px;
    font-size: 1.3rem;
    font-weight: 600;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.action-button .icon {
    font-size: 1.5rem;
}

.action-button.primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: #fff;
}

.action-button.primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(99, 102, 241, 0.4);
}

.action-button.secondary {
    background: linear-gradient(135deg, var(--secondary-color), #059669);
    color: #fff;
}

.action-button.secondary:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(16, 185, 129, 0.4);
}

.action-button.outline {
    background: transparent;
    color: #fff;
    border: 2px solid rgba(255,255,255,0.3);
}

.action-button.outline:hover {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.5);
}

/* Email form */
.email-form {
    display: flex;
    gap: 15px;
    justify-content: center;
    align-items: center;
    margin-top: 20px;
}

.email-form.hidden {
    display: none;
}

.email-form input[type="email"] {
    padding: 15px 25px;
    font-size: 1.2rem;
    border: none;
    border-radius: var(--border-radius);
    width: 350px;
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.email-form input::placeholder {
    color: var(--text-light);
}

/* Auto return timer */
.auto-return-timer {
    margin-top: 30px;
    font-size: 1rem;
    color: var(--text-light);
}

/* ===== TOAST NOTIFICATIONS ===== */
#toast-container {
    position: fixed;
    top: 40px;
    right: 40px;
    z-index: 2000;
}

.toast {
    background: rgba(0,0,0,0.9);
    padding: 20px 30px;
    border-radius: var(--border-radius);
    margin-bottom: 15px;
    font-size: 1.1rem;
    animation: slideIn 0.3s ease-out;
}

.toast.success {
    border-left: 4px solid var(--secondary-color);
}

.toast.error {
    border-left: 4px solid var(--danger-color);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    #app-title {
        font-size: 2.5rem;
    }
    
    .start-button {
        padding: 20px 50px;
        font-size: 1.5rem;
    }
    
    .template-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    .result-actions {
        flex-direction: column;
    }
    
    .action-button {
        width: 100%;
        justify-content: center;
    }
    
    .email-form {
        flex-direction: column;
    }
    
    .email-form input[type="email"] {
        width: 100%;
    }
}

/* ===== ANIMATIONS UTILITIES ===== */
.fade-in {
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.scale-in {
    animation: scaleIn 0.3s ease-out;
}

@keyframes scaleIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}
