:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --secondary: #64748b;
    --success: #22c55e;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-color: #1e293b;
    --border-radius: 16px;
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    min-height: 100vh;
    overflow-x: hidden;
}

.app-container {
    width: 100%;
    max-width: 600px;
    /* Simulate mobile view on desktop */
    background: white;
    min-height: 100vh;
    position: relative;
    display: flex;
    flex-direction: column;
}

header {
    background: var(--primary);
    color: white;
    padding: 1rem;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

header h1 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
}

/* Views */
.view {
    display: none;
    flex: 1;
    flex-direction: column;
    animation: fadeIn 0.3s ease;
}

.view.active {
    display: flex;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Home View */
#view-home {
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

.action-card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 2rem;
    text-align: center;
    width: 100%;
}

.icon-circle {
    width: 80px;
    height: 80px;
    background: #e0e7ff;
    color: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    margin: 0 auto 1.5rem;
}

h2 {
    margin-top: 0;
    color: var(--text-color);
}

p {
    color: var(--secondary);
    margin-bottom: 2rem;
}

.or-divider {
    margin: 1.5rem 0;
    color: var(--secondary);
    font-size: 0.9rem;
    position: relative;
}

.or-divider::before,
.or-divider::after {
    content: "";
    position: absolute;
    top: 50%;
    width: 40%;
    height: 1px;
    background: #e2e8f0;
}

.or-divider::before {
    left: 0;
}

.or-divider::after {
    right: 0;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 1rem;
    border-radius: 12px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    transition: transform 0.1s, opacity 0.2s;
    text-decoration: none;
    gap: 0.5rem;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.3);
}

.btn-secondary {
    background: white;
    border: 2px solid #e2e8f0;
    color: var(--text-color);
}

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

/* Camera View */
.camera-container {
    flex: 1;
    position: relative;
    background: black;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#video-stream {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

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

#camera-feed {
    width: 100%;
    height: 100%;
    object-fit: contain;
    /* Ensure proper aspect ratio */
}

/* Removed separate video-stream and overlay-canvas styles */

.camera-controls {
    position: absolute;
    top: 0;
    /* Moved to TOP */
    left: 0;
    width: 100%;
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    /* Space out Close and Capture */
    align-items: flex-start;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.8), transparent);
    /* Gradient downwards */
    pointer-events: none;
    /* Let clicks pass through empty space */
}

/* Enable pointer events on buttons inside container */
.camera-controls button {
    pointer-events: auto;
}

.btn-capture-ring {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    border: 4px solid white;
    background: rgba(255, 255, 255, 0.2);
    cursor: pointer;
    transition: all 0.2s;
    margin: 0 auto;
    /* Center the capture button absolutely if needed, or flex */
    /* To strictly center the capture button while keeping close button on right: */
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: 1.5rem;
}

.btn-capture-ring:active {
    background: white;
    transform: translateX(-50%) scale(0.9);
}

#btn-close-camera {
    /* Position relative to the container now, or keep absolute right */
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
    cursor: pointer;
    z-index: 20;
}

.scan-status {
    position: absolute;
    bottom: 2rem;
    /* Moved to BOTTOM */
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    pointer-events: none;
}

/* Review View */
.review-container {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.image-preview-wrapper {
    background: #e2e8f0;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

#img-preview {
    width: 100%;
    height: auto;
    display: block;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--secondary);
}

.form-group input {
    padding: 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

.form-group input:focus {
    border-color: var(--primary);
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: auto;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: #1e293b;
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 50px;
    font-size: 0.9rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    z-index: 100;
    opacity: 1;
    transition: opacity 0.3s;
}

.toast.hidden {
    opacity: 0;
    pointer-events: none;
}