/* CSS Variables for theming */
:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #64748b;
    --secondary-hover: #475569;
    --danger-color: #ef4444;
    --danger-hover: #dc2626;
    --success-color: #22c55e;
    --background: #0f172a;
    --surface: #1e293b;
    --surface-light: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border-color: #475569;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
    --radius: 12px;
    --radius-sm: 8px;
}

/* Reset and base styles */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

/* App Container */
.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    text-align: center;
    padding: 2rem 1rem;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.camera-icon {
    font-size: 2rem;
}

.tagline {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-top: 0.5rem;
}

/* Main content */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Camera Section */
.camera-section {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-lg);
}

.video-container {
    position: relative;
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
    background: #000;
    border-radius: var(--radius-sm);
    overflow: hidden;
    aspect-ratio: 4/3;
}

#video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
}

#overlay-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Countdown Display */
.countdown-display {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 8rem;
    font-weight: 700;
    color: white;
    text-shadow: 0 0 20px rgba(0, 0, 0, 0.8);
    z-index: 10;
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -50%) scale(1.1); }
}

/* Flash Effect */
.flash {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    opacity: 0;
    pointer-events: none;
    z-index: 20;
}

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

@keyframes flash {
    0% { opacity: 0.8; }
    100% { opacity: 0; }
}

/* Camera Controls */
.camera-controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow);
}

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

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

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

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

.btn-secondary:hover:not(:disabled) {
    background: var(--secondary-hover);
    transform: translateY(-2px);
}

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

.btn-danger:hover:not(:disabled) {
    background: var(--danger-hover);
    transform: translateY(-2px);
}

.btn-capture {
    background: linear-gradient(135deg, var(--danger-color), #f97316);
    color: white;
    padding: 1rem 2rem;
    font-size: 1.1rem;
}

.btn-capture:hover:not(:disabled) {
    transform: translateY(-2px) scale(1.05);
}

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

/* Settings Panel */
.settings-panel {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.setting-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

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

/* Timer Options */
.timer-options {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.timer-btn {
    padding: 0.5rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.timer-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.timer-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

/* Filter Options */
.filter-options {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 0.75rem;
}

.filter-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: transparent;
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-btn:hover {
    border-color: var(--primary-color);
}

.filter-btn.active {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.1);
}

.filter-preview {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    background: linear-gradient(135deg, #ff6b6b, #feca57, #48dbfb, #ff9ff3);
}

.filter-preview.grayscale {
    filter: grayscale(100%);
}

.filter-preview.sepia {
    filter: sepia(100%);
}

.filter-preview.vintage {
    filter: sepia(50%) contrast(90%) brightness(90%);
}

.filter-preview.warm {
    filter: sepia(30%) saturate(140%);
}

.filter-preview.cool {
    filter: saturate(80%) hue-rotate(180deg);
}

.filter-preview.bright {
    filter: brightness(130%);
}

.filter-preview.contrast {
    filter: contrast(150%);
}

.filter-name {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.filter-btn.active .filter-name {
    color: var(--primary-color);
}

/* Strip Options */
.strip-options {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.strip-btn {
    padding: 0.5rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.strip-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.strip-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.strip-info {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* Gallery Section */
.gallery-section {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-lg);
}

.gallery-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.gallery-header h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.5rem;
}

.gallery-icon {
    font-size: 1.5rem;
}

.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
}

.gallery-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

.gallery-item {
    position: relative;
    aspect-ratio: 4/3;
    border-radius: var(--radius-sm);
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s ease;
    box-shadow: var(--shadow);
}

.gallery-item:hover {
    transform: scale(1.05);
}

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

.gallery-item.strip {
    aspect-ratio: 1/3;
}

.gallery-item-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0.5rem;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    opacity: 0;
    transition: opacity 0.2s ease;
}

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

.gallery-item-time {
    font-size: 0.75rem;
    color: white;
}

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

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1rem;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    position: relative;
}

.modal-close {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 40px;
    height: 40px;
    border: none;
    background: var(--surface-light);
    color: var(--text-primary);
    font-size: 1.5rem;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s ease;
    z-index: 10;
}

.modal-close:hover {
    background: var(--danger-color);
}

#modal-image {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    border-radius: var(--radius-sm);
}

.modal-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem 1rem;
    margin-top: auto;
    border-top: 1px solid var(--border-color);
}

footer a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s ease;
}

footer a:hover {
    color: var(--primary-color);
}

/* Hidden utility class */
.hidden {
    display: none !important;
}

/* Filter classes for video */
.filter-none { filter: none; }
.filter-grayscale { filter: grayscale(100%); }
.filter-sepia { filter: sepia(100%); }
.filter-vintage { filter: sepia(50%) contrast(90%) brightness(90%); }
.filter-warm { filter: sepia(30%) saturate(140%); }
.filter-cool { filter: saturate(80%) hue-rotate(180deg); }
.filter-bright { filter: brightness(130%); }
.filter-contrast { filter: contrast(150%); }

/* Responsive Design */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.75rem;
    }

    .camera-icon {
        font-size: 1.5rem;
    }

    .tagline {
        font-size: 1rem;
    }

    .video-container {
        max-width: 100%;
    }

    .btn {
        padding: 0.625rem 1rem;
        font-size: 0.9rem;
    }

    .btn-capture {
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
    }

    .btn-text {
        display: none;
    }

    .countdown-display {
        font-size: 5rem;
    }

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

    .gallery {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
}

@media (max-width: 480px) {
    .app-container {
        padding: 0.5rem;
    }

    header {
        padding: 1rem 0.5rem;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .camera-section,
    .settings-panel,
    .gallery-section {
        padding: 1rem;
    }

    .timer-options,
    .strip-options {
        justify-content: center;
    }

    .filter-options {
        grid-template-columns: repeat(4, 1fr);
        gap: 0.5rem;
    }

    .filter-preview {
        width: 32px;
        height: 32px;
    }

    .filter-name {
        font-size: 0.65rem;
    }

    .gallery-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .gallery {
        grid-template-columns: repeat(2, 1fr);
    }

    .countdown-display {
        font-size: 4rem;
    }
}

/* Print styles */
@media print {
    .camera-section,
    .settings-panel,
    .camera-controls,
    .gallery-header button,
    footer {
        display: none;
    }

    .gallery {
        display: block;
    }

    .gallery-item {
        break-inside: avoid;
        margin-bottom: 1rem;
    }
}
