/* ========================================
   Photo AI Booth - Styles
   Modern dark theme with indigo/purple accents
   ======================================== */

/* CSS Variables */
:root {
    --color-primary: #6366f1;
    --color-primary-hover: #4f46e5;
    --color-secondary: #8b5cf6;
    --color-background: #0f172a;
    --color-surface: #1e293b;
    --color-surface-light: #334155;
    --color-text: #f8fafc;
    --color-text-muted: #94a3b8;
    --color-accent: #22d3ee;
    --color-success: #22c55e;
    --color-error: #ef4444;
    --color-warning: #f59e0b;

    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
    --border-radius: 12px;
    --border-radius-lg: 20px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -4px rgba(0, 0, 0, 0.4);

    --transition: 0.2s ease;
    --transition-slow: 0.3s ease;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-family);
    background-color: var(--color-background);
    color: var(--color-text);
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* App Container */
#app {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    position: relative;
    overflow: hidden;
}

/* Screen Base */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    opacity: 0;
    transition: opacity var(--transition-slow);
}

.screen.active {
    display: flex;
    opacity: 1;
}

.screen-content {
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    min-height: 100%;
    overflow-y: auto;
}

.screen-content.centered {
    justify-content: center;
    align-items: center;
    text-align: center;
}

/* ========================================
   Welcome Screen
   ======================================== */

#screen-welcome {
    background: linear-gradient(180deg, var(--color-background) 0%, #1a1f3a 100%);
}

#screen-welcome .screen-content {
    justify-content: center;
    align-items: center;
    gap: 32px;
}

.logo-container {
    text-align: center;
}

.logo-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    border-radius: var(--border-radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    box-shadow: var(--shadow-lg);
}

.logo-icon svg {
    width: 48px;
    height: 48px;
    color: white;
}

.app-title {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--color-text), var(--color-accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.app-subtitle {
    color: var(--color-text-muted);
    font-size: 1rem;
    text-align: center;
    max-width: 280px;
}

.welcome-buttons {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    max-width: 320px;
}

.instructions {
    color: var(--color-text-muted);
    font-size: 0.875rem;
    text-align: center;
}

/* ========================================
   Buttons
   ======================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 24px;
    border: none;
    border-radius: var(--border-radius);
    font-family: var(--font-family);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    color: white;
    box-shadow: var(--shadow);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--color-surface-light);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--color-surface-light);
}

.btn-ghost {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    backdrop-filter: blur(10px);
}

.btn-ghost:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.2);
}

.btn-large {
    padding: 18px 32px;
    font-size: 1.125rem;
    width: 100%;
}

.btn-icon-only {
    width: 48px;
    height: 48px;
    padding: 0;
    border-radius: 50%;
}

.btn-icon-only svg {
    width: 24px;
    height: 24px;
}

/* ========================================
   Filter Selection Screen (New - Before Capture)
   ======================================== */

#screen-filter-selection {
    background: var(--color-background);
}

#screen-filter-selection .screen-content {
    justify-content: center;
    gap: 32px;
    padding-top: 40px;
    padding-bottom: 40px;
}

.filter-selection-header {
    text-align: center;
}

.filter-subtitle {
    color: var(--color-text-muted);
    font-size: 0.9rem;
    margin-top: 8px;
}

/* Carousel Wrapper with Fade Effects */
.filter-carousel-wrapper {
    position: relative;
    width: 100%;
    margin: 0;
}

.filter-carousel-fade {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 80px;
    pointer-events: none;
    z-index: 10;
}

.filter-carousel-fade-left {
    left: 0;
    background: linear-gradient(to right, var(--color-background) 0%, transparent 100%);
}

.filter-carousel-fade-right {
    right: 0;
    background: linear-gradient(to left, var(--color-background) 0%, transparent 100%);
}

/* Carousel Container */
.filter-carousel-container {
    width: 100%;
    overflow: hidden;
    padding: 0;
}

.filter-carousel {
    display: flex;
    gap: 24px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 40px 20px;
    align-items: center;
    min-height: 360px;
}

.filter-carousel::-webkit-scrollbar {
    display: none;
}

/* Filter Cards in Carousel */
.filter-carousel .filter-card {
    position: relative;
    flex-shrink: 0;
    width: 200px;
    height: 280px;
    border-radius: var(--border-radius-lg);
    border: 3px solid transparent;
    cursor: pointer;
    overflow: hidden;
    scroll-snap-align: center;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0.4;
    transform: scale(0.85);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Center/Active Card */
.filter-carousel .filter-card.center {
    opacity: 1;
    transform: scale(1);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

/* Selected Card */
.filter-carousel .filter-card.selected {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.3),
                0 20px 40px rgba(99, 102, 241, 0.2);
}

.filter-carousel .filter-card.selected .filter-name-overlay {
    background: linear-gradient(to top, var(--color-primary) 0%, transparent 100%);
}

/* Filter Image */
.filter-carousel .filter-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.filter-carousel .filter-card.center .filter-image {
    transform: scale(1.05);
}

/* Filter Name Overlay on Cards */
.filter-carousel .filter-name-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 16px 12px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9) 0%, transparent 100%);
    color: white;
    font-size: 0.95rem;
    font-weight: 600;
    text-align: center;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* Current Filter Name Display */
.filter-name-display {
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-text);
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.filter-selection-actions {
    display: flex;
    justify-content: center;
    width: 100%;
    max-width: 320px;
    margin: 0 auto;
}

/* ========================================
   Capture Choice Screen (New)
   ======================================== */

#screen-capture-choice {
    background: var(--color-background);
}

.selected-filter-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid var(--color-primary);
    border-radius: 24px;
    color: var(--color-primary);
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 24px;
}

.badge-icon {
    font-size: 1.2rem;
}

.capture-choice-buttons {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    max-width: 320px;
    margin-bottom: 24px;
}

/* ========================================
   Camera Screen
   ======================================== */

#screen-camera {
    background: black;
}

.camera-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

#camera-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.camera-controls-top {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    background: linear-gradient(180deg, rgba(0,0,0,0.5) 0%, transparent 100%);
}

.camera-controls-bottom {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 32px 20px 48px;
    display: flex;
    justify-content: center;
    background: linear-gradient(0deg, rgba(0,0,0,0.5) 0%, transparent 100%);
}

/* Capture Button */
.btn-capture {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: transparent;
    border: 4px solid white;
    padding: 4px;
    cursor: pointer;
    position: relative;
    transition: transform var(--transition);
    -webkit-tap-highlight-color: transparent;
}

.btn-capture:hover {
    transform: scale(1.05);
}

.btn-capture:active {
    transform: scale(0.95);
}

.capture-ring {
    position: absolute;
    inset: 4px;
    border-radius: 50%;
    border: 2px solid white;
}

.capture-center {
    position: absolute;
    inset: 8px;
    border-radius: 50%;
    background: white;
    transition: all var(--transition);
}

.btn-capture:active .capture-center {
    background: var(--color-primary);
}

/* Countdown Overlay */
.countdown-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.countdown-overlay.hidden {
    display: none;
}

#countdown-number {
    font-size: 8rem;
    font-weight: 700;
    color: white;
    animation: countdownPulse 1s ease-in-out;
}

@keyframes countdownPulse {
    0% { transform: scale(0.5); opacity: 0; }
    50% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

/* ========================================
   Filter Selection Screen (Old - Hidden from normal flow)
   ======================================== */

#screen-filters {
    background: var(--color-background);
    display: none !important;
}

#screen-filters .screen-content {
    padding-top: 16px;
    gap: 20px;
}

.preview-container {
    width: 100%;
    aspect-ratio: 1;
    max-height: 280px;
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    background: var(--color-surface);
    display: flex;
    align-items: center;
    justify-content: center;
}

#photo-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.section-title {
    font-size: 1.25rem;
    font-weight: 600;
    text-align: center;
}

/* Horizontal scroll container */
.filters-scroll-container {
    width: 100%;
    overflow: hidden;
    margin: 0 -24px;
    padding: 0 24px;
}

.filters-grid {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 8px 0;
}

.filters-grid::-webkit-scrollbar {
    display: none;
}

/* Image-based filter cards */
.filter-card {
    position: relative;
    flex-shrink: 0;
    width: 140px;
    height: 180px;
    border-radius: var(--border-radius);
    border: 3px solid transparent;
    cursor: pointer;
    overflow: hidden;
    scroll-snap-align: start;
    transition: all var(--transition);
}

.filter-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition);
}

.filter-name-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px 8px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
    color: white;
    font-size: 0.875rem;
    font-weight: 600;
    text-align: center;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* Hover effects */
.filter-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.filter-card:hover .filter-image {
    transform: scale(1.05);
}

/* Selected state */
.filter-card.selected {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.3);
}

.filter-card.selected .filter-name-overlay {
    background: linear-gradient(to top, var(--color-primary), transparent);
}

/* Touch interaction */
.filter-card:active {
    transform: scale(0.97);
}

.filter-actions {
    display: flex;
    gap: 12px;
    margin-top: auto;
    padding-top: 16px;
}

.filter-actions .btn {
    flex: 1;
}

/* ========================================
   Processing Screen
   ======================================== */

#screen-processing {
    background: var(--color-background);
}

.processing-animation {
    position: relative;
    width: 120px;
    height: 120px;
    margin-bottom: 32px;
}

.spinner {
    position: absolute;
    inset: 0;
    border: 4px solid var(--color-surface);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.processing-rings {
    position: absolute;
    inset: 0;
}

.ring {
    position: absolute;
    border-radius: 50%;
    border: 2px solid var(--color-primary);
    opacity: 0;
    animation: ripple 2s ease-out infinite;
}

.ring-1 { inset: 20px; animation-delay: 0s; }
.ring-2 { inset: 10px; animation-delay: 0.5s; }
.ring-3 { inset: 0; animation-delay: 1s; }

@keyframes ripple {
    0% { transform: scale(0.8); opacity: 1; }
    100% { transform: scale(1.5); opacity: 0; }
}

.processing-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.processing-subtitle {
    color: var(--color-text-muted);
    font-size: 1rem;
}

/* ========================================
   Result Screen
   ======================================== */

#screen-result {
    background: linear-gradient(180deg, var(--color-background) 0%, #1a1f3a 100%);
}

#screen-result .screen-content {
    justify-content: center;
    align-items: center;
    gap: 24px;
}

.result-header {
    text-align: center;
}

.result-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--color-success);
}

.result-header p {
    color: var(--color-text-muted);
}

.result-images-container {
    display: flex;
    gap: 24px;
    justify-content: center;
    align-items: flex-start;
    flex-wrap: wrap;
}

.preview-image-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 50%;
    margin: auto;
}

#preview-image {
    width: 200px;
    height: 200px;
    object-fit: cover;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
}

.qr-container {
    background: white;
    padding: 16px;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 50%;
    margin: auto;
}

#qr-code {
    width: 200px;
    height: 200px;
    display: block;
}

.image-label {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    font-weight: 500;
    margin: 0;
}

.expiry-timer {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--color-warning);
    font-size: 0.9rem;
    font-weight: 500;
}

.timer-icon {
    width: 18px;
    height: 18px;
}

.result-preview {
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

#filter-applied {
    color: var(--color-accent);
    font-weight: 600;
    text-transform: capitalize;
}

.result-buttons button {
    background-color: grey;
    color: white;
    border: none;
    padding: 10px 20px;
    margin: 5px;
    cursor: pointer;
    border-radius: 5px;
    font-size: 16px;
}

.result-buttons button.selected {
    background-color: purple;
    color: white;
}

/* ========================================
   Error Screen
   ======================================== */

#screen-error {
    background: var(--color-background);
}

.error-icon {
    width: 80px;
    height: 80px;
    background: rgba(239, 68, 68, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
}

.error-icon svg {
    width: 48px;
    height: 48px;
    color: var(--color-error);
}

.error-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.error-message {
    color: var(--color-text-muted);
    margin-bottom: 32px;
    max-width: 280px;
}

/* ========================================
   Responsive Adjustments
   ======================================== */

@media (min-width: 768px) {
    .screen-content {
        padding: 32px;
    }

    .logo-icon {
        width: 100px;
        height: 100px;
    }

    .logo-icon svg {
        width: 60px;
        height: 60px;
    }

    .app-title {
        font-size: 2.5rem;
    }

    .filter-card {
        width: 160px;
        height: 200px;
    }

    .preview-container {
        max-height: 320px;
    }

    #qr-code {
        width: 250px;
        height: 250px;
    }

    .filter-carousel {
        padding: 40px 60px;
    }

    .filter-carousel .filter-card {
        width: 240px;
        height: 320px;
    }
}

@media (max-height: 600px) {
    .logo-icon {
        width: 60px;
        height: 60px;
    }

    .logo-icon svg {
        width: 36px;
        height: 36px;
    }

    .app-title {
        font-size: 1.5rem;
    }

    #screen-welcome .screen-content {
        gap: 20px;
    }

    .preview-container {
        max-height: 180px;
    }

    .filter-card {
        width: 120px;
        height: 160px;
    }

    .filter-carousel {
        padding: 20px 40px;
    }

    .filter-carousel .filter-card {
        width: 160px;
        height: 240px;
    }
}

/* ========================================
   Utility Classes
   ======================================== */

.hidden {
    display: none !important;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* Focus states for accessibility */
.btn:focus-visible,
.filter-card:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

/* Smooth scrolling */
@media (prefers-reduced-motion: no-preference) {
    html {
        scroll-behavior: smooth;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --color-surface: #1a1a2e;
        --color-surface-light: #2a2a4e;
    }

    .btn-primary {
        background: var(--color-primary);
    }

    .filter-card.selected {
        border-width: 3px;
    }
}

/* Center the preview and QR code properly */
.preview-image-container, .qr-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
}
