:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --bg: #0f172a;
    --surface: #1e293b;
    --text: #f8fafc;
    --text-muted: #94a3b8;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 20px;
}

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

.header h1 {
    font-size: 2.5rem;
    font-weight: 600;
    background: linear-gradient(135deg, #818cf8, #c084fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 8px;
}

.header p {
    color: var(--text-muted);
    font-size: 1.1rem;
}

.main-container {
    background: var(--surface);
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    gap: 24px;
    max-width: 800px;
    width: 100%;
}

.camera-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 4/3;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
}

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

.overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60%;
    height: 70%;
    border: 2px dashed rgba(255, 255, 255, 0.4);
    border-radius: 50% 50% 40% 40%;
    pointer-events: none;
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

@media (min-width: 600px) {
    .controls {
        flex-direction: row;
        align-items: flex-end;
        justify-content: space-between;
    }
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    /* Allow inputs to grow but respect gap */
}

.input-group label {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 300;
}

input[type="text"] {
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    color: white;
    font-size: 1rem;
    outline: none;
    transition: all 0.3s;
}

input[type="text"]:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

button {
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 46px;
    /* Match input height */
}

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

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

.btn-capture:active {
    transform: translateY(0);
}

.btn-auto {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-auto:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn-auto.active {
    background: var(--danger);
    border-color: var(--danger);
    animation: pulse 2s infinite;
}

.stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    margin-top: 10px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

/* Flash effect when capturing */
.flash {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: white;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.1s ease-out;
    z-index: 10;
}

.flash.active {
    opacity: 0.8;
    transition: none;
}

/* Instructions Panel Styles */
.instructions-panel {
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 12px;
    padding: 16px 20px;
    margin-top: 10px;
}

.instructions-panel h3 {
    font-size: 1.1rem;
    color: var(--primary);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.instructions-panel ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.instructions-panel li {
    font-size: 0.95rem;
    color: var(--text);
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.phase-badge {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.phase-active {
    background: var(--primary);
    color: white;
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.5);
}

.max-input {
    width: 100px;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    background: var(--surface);
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    max-width: 400px;
    text-align: center;
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.modal-content h3 {
    font-size: 1.5rem;
    color: white;
    margin-bottom: 12px;
}

.modal-content p {
    color: var(--text-muted);
    margin-bottom: 24px;
    line-height: 1.5;
}

.modal-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    transition: background 0.2s;
}

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

.modal-btn:disabled {
    background: #6b7280;
    cursor: not-allowed;
}

/* Progress Bar Styles */
.progress-container {
    width: 100%;
    height: 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    margin-top: 20px;
    overflow: hidden;
    position: relative;
}

.progress-bar {
    height: 100%;
    background: var(--primary);
    width: 0%;
    transition: width 0.3s ease;
    position: relative;
}

/* 80% Marker */
.progress-marker {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 80%;
    width: 2px;
    background: #fbbf24;
    z-index: 10;
}

.progress-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: right;
    margin-top: 4px;
    font-weight: 600;
}

/* Gallery Styles */
.gallery-container {
    background: var(--surface);
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 800px;
    width: 100%;
    margin-top: 30px;
}

.gallery-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.gallery-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
}

.gallery-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

select {
    padding: 10px 16px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    color: white;
    font-size: 1rem;
    outline: none;
    cursor: pointer;
}

select option {
    background: var(--surface);
    color: white;
}

.btn-download {
    background: #10b981;
    color: white;
    padding: 10px 16px;
    height: auto;
    font-size: 0.9rem;
}

.btn-download:hover {
    background: #059669;
}

.btn-download:disabled {
    background: #6b7280;
    cursor: not-allowed;
    opacity: 0.7;
}

.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 10px;
}

/* Custom scrollbar for image grid */
.image-grid::-webkit-scrollbar {
    width: 8px;
}

.image-grid::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

.image-grid::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.image-grid::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.image-card {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    aspect-ratio: 1;
    background: #000;
}

.image-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

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

.btn-delete {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
    padding: 0;
}

.image-card:hover .btn-delete {
    opacity: 1;
}

.btn-delete:hover {
    transform: scale(1.1);
    background: var(--danger);
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 0;
    grid-column: 1 / -1;
}

/* Login Form Styles */
.login-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 300px;
    margin: 0 auto;
    align-items: center;
}

.login-container h3 {
    font-size: 1.2rem;
    color: var(--text-muted);
}

.login-container .input-group {
    width: 100%;
}

.hidden {
    display: none !important;
}