/* --- General Body & Layout --- */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    background-color: #f0f2f5;
    color: #1c1e21;
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    transition: background-color 0.3s ease;
    overflow-x: hidden; /* Prevents horizontal scrolling */
}

body.view-active {
    background-color: #000;
}

.container {
    max-width: 680px;
    width: 100%;
    padding: 16px;
    text-align: center;
    box-sizing: border-box; /* Ensures padding is included in the width, preventing overflow */
}

/* --- Google-style Title --- */
.google-title {
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}
.char-r { color: #4285F4; }
.char-k { color: #DB4437; }
.char-p { color: #0F9D58; }
.tagline {
    font-size: 1rem;
    color: #606770;
    margin-top: 0;
}

/* --- Options Grid --- */
.options-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-top: 2rem;
}

.option-card {
    background-color: #fff;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    cursor: pointer;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
    text-align: left;
}

.option-card:hover:not(.loading) {
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

.option-card.disabled-card {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* --- Loading State for Upload Button --- */
.option-card.loading {
    cursor: wait;
    opacity: 0.8;
}

#upload-status-text {
    font-size: 0.9rem;
    color: #606770;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 8px;
}

.loader {
    width: 1rem;
    height: 1rem;
    border: 2px solid #e0e0e0;
    border-top: 2px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    display: inline-block;
    margin-right: 8px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}


/* --- Composite Card for ID Scan --- */
.option-card-composite {
    background-color: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
}

.main-card-section {
    display: flex; 
    align-items: center; 
    padding: 20px;
    text-align: left;
}

.main-card-section i {
    font-size: 1.8rem; 
    color: #3b82f6;
    margin: 0 16px 0 0; 
}

.main-card-section h3 {
    margin: 0 0 4px 0; 
    font-size: 1.1rem;
    font-weight: 600;
}

.main-card-section p {
    margin: 0;
    font-size: 0.95rem;
    color: #606770;
}

.actions-section {
    display: flex;
    border-top: 1px solid #e9ebee;
}

.action-button {
    flex: 1;
    padding: 16px;
    text-align: center;
    cursor: pointer;
    transition: background-color 0.2s ease;
    color: #3b82f6;
    text-decoration: none;
    display: flex;
    justify-content: center;
    align-items: center;
}

.action-button:hover {
    background-color: #f7f8fa;
}

.action-button:first-child {
    border-right: 1px solid #e9ebee;
}

.action-button i {
    margin-right: 0; 
    font-size: 1.6rem; 
}

/* --- Scanner View --- */
#scanner-view {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-color: #000;
    display: flex; 
    justify-content: center;
    align-items: center;
    flex-direction: column;
    z-index: 100;
}

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

#scanner-guide {
    position: absolute;
    width: 90%;
    max-width: 420px;
    aspect-ratio: 85.6 / 54;
    border: 2px solid #fff;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.6);
    border-radius: 12px;
}

.scanner-controls {
    position: absolute;
    bottom: 2.5rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 2rem;
    align-items: center;
}

.scanner-btn {
    width: 5rem;
    height: 5rem;
    border-radius: 50%;
    border: 5px solid white;
    background-color: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2.5rem;
    color: #333;
    transition: transform 0.2s ease;
}
.scanner-btn:active { transform: scale(0.9); }

.close-btn {
    width: 3.5rem; height: 3.5rem;
    background: none;
    border: none;
    color: white;
    font-size: 2rem;
}

/* --- Preview & Crop View --- */
#preview-view {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-color: #111;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 200;
    padding: 1rem 0;
}

#crop-container {
    position: relative;
    width: 95%;
    height: 80%;
    display: flex;
    justify-content: center;
    align-items: center;
}

#captured-image-preview {
    max-width: 100%;
    max-height: 100%;
    display: block;
    box-shadow: 0 5px 20px rgba(0,0,0,0.5);
}

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

/* --- UPDATED: Touch-friendly Crop Handles --- */
.crop-handle {
    position: absolute;
    width: 32px;  /* Increased size */
    height: 32px; /* Increased size */
    background-color: rgba(59, 130, 246, 0.95);
    border: 3px solid white;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    cursor: grab;
    /* Larger invisible area for easier touch targeting */
    box-shadow: 0 0 0 15px rgba(255, 255, 255, 0);
}

.crop-handle:active {
    cursor: grabbing;
    background-color: rgba(37, 99, 235, 1);
}

/* --- Preview Controls --- */
.preview-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 1.5rem;
    box-sizing: border-box;
    background: linear-gradient(to top, rgba(0,0,0,0.7), transparent);
    display: flex;
    justify-content: space-between;
    gap: 1rem;
}

.preview-btn {
    padding: 0.8rem 1.2rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    background-color: rgba(255, 255, 255, 0.15);
    color: #fff;
    transition: background-color 0.2s ease;
    flex-grow: 1; /* Make buttons grow */
}

.preview-btn:hover { background-color: rgba(255, 255, 255, 0.25); }

.confirm-btn {
    background-color: #3b82f6;
    color: white;
}
.confirm-btn:hover { background-color: #2563eb; }

.back-link {
    display: inline-block;
    margin-top: 2rem;
    color: #3b82f6;
    text-decoration: none;
    font-weight: 500;
}
.back-link:hover { text-decoration: underline; }
