/* Badge Scanner - Mobile-First Dark Theme */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #089fff;
    --primary-hover: #00beff;
    --success-color: #10b981;
    --error-color: #ef4444;
    --text-primary: #e8f4ff;
    --text-secondary: #7eb3cc;
    --border-color: #1c3a52;
    --bg-gray: #12212e;
    --bg-dark: #0a1929;
    --card-bg: #12212e;
    --white: #ffffff;
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.4);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.6), 0 10px 10px -5px rgba(0, 0, 0, 0.5);
}

body {
    font-family: 'Source Sans 3', 'Source Sans Pro', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    background: #09131c;
    color: var(--text-primary);
    line-height: 1.6;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ============================================
   Screens - Full viewport containers
   ============================================ */

.screen {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

/* ============================================
   App Header
   ============================================ */

.app-header {
    padding: 16px 20px;
    background: rgba(9, 19, 28, 0.97);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 10;
}

.tamr-logo-wrapper {
    text-align: center;
    margin-bottom: 6px;
}

.tamr-logo {
    height: 24px;
    width: auto;
}

.app-title {
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: -0.01em;
}

.header-icon {
    width: 22px;
    height: 22px;
    opacity: 0.8;
}

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

.camera-screen {
    background: #000;
}

.viewfinder-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.viewfinder-container video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
}

/* Badge alignment guide */
.badge-guide {
    position: relative;
    width: 85%;
    max-width: 340px;
    aspect-ratio: 3.375 / 2.125;
    z-index: 5;
    pointer-events: none;
}

.guide-corner {
    position: absolute;
    width: 24px;
    height: 24px;
    border-color: rgba(59, 130, 246, 0.7);
    border-style: solid;
}

.guide-corner.top-left {
    top: 0; left: 0;
    border-width: 3px 0 0 3px;
    border-radius: 6px 0 0 0;
}

.guide-corner.top-right {
    top: 0; right: 0;
    border-width: 3px 3px 0 0;
    border-radius: 0 6px 0 0;
}

.guide-corner.bottom-left {
    bottom: 0; left: 0;
    border-width: 0 0 3px 3px;
    border-radius: 0 0 0 6px;
}

.guide-corner.bottom-right {
    bottom: 0; right: 0;
    border-width: 0 3px 3px 0;
    border-radius: 0 0 6px 0;
}

.viewfinder-hint {
    position: absolute;
    bottom: 12px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 13px;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.6);
    z-index: 5;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

/* Capture controls */
.capture-controls {
    padding: 24px 0 36px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    background: rgba(0, 0, 0, 0.9);
}

.manual-entry-link {
    color: var(--text-secondary);
    font-size: 14px;
    text-decoration: none;
    transition: color 0.2s ease;
}

.manual-entry-link:active,
.manual-entry-link:hover {
    color: var(--primary-color);
}

.capture-button {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--white);
    border: none;
    cursor: pointer;
    position: relative;
    transition: transform 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.capture-button:active {
    transform: scale(0.92);
}

.capture-ring {
    position: absolute;
    inset: -6px;
    border: 3px solid rgba(255, 255, 255, 0.4);
    border-radius: 50%;
}

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

.processing-screen {
    background: linear-gradient(135deg, #09131c 0%, #112236 50%, #09131c 100%);
    align-items: center;
    justify-content: center;
}

.processing-content {
    text-align: center;
    padding: 40px;
}

.processing-content h2 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}

.processing-subtitle {
    color: var(--text-secondary);
    font-size: 15px;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    margin: 0 auto 24px;
    animation: spin 0.8s linear infinite;
}

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

/* ============================================
   Results Screen
   ============================================ */

.results-screen {
    background: linear-gradient(135deg, #09131c 0%, #112236 50%, #09131c 100%);
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
}

.results-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-height: 0;
}

.results-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.field-group label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}

.field-group input {
    width: 100%;
    padding: 12px 14px;
    font-size: 16px;
    font-family: inherit;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    transition: border-color 0.2s ease;
    -webkit-appearance: none;
}

.field-group input:-webkit-autofill,
.field-group input:-webkit-autofill:hover,
.field-group input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 1000px var(--bg-dark) inset;
    -webkit-text-fill-color: var(--text-primary);
    caret-color: var(--text-primary);
}

.field-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(8, 159, 255, 0.2);
}

.field-group input::placeholder {
    color: #4b5563;
    font-style: italic;
}

.field-group select {
    width: 100%;
    padding: 12px 14px;
    font-size: 16px;
    font-family: inherit;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    transition: border-color 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.field-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(8, 159, 255, 0.2);
}

.field-group select option {
    background: var(--bg-dark);
    color: var(--text-primary);
}

.field-divider {
    height: 1px;
    background: var(--border-color);
    margin: 4px 0;
}

.input-clearable {
    position: relative;
    display: flex;
    align-items: center;
}

.input-clearable input {
    padding-right: 36px;
}

.clear-btn {
    position: absolute;
    right: 10px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 4px;
    -webkit-tap-highlight-color: transparent;
}

.clear-btn:active {
    color: var(--text-primary);
}

/* Action buttons */
.result-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-bottom: 20px;
}

a.btn {
    text-decoration: none;
}

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

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

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

.btn-primary:active {
    background: var(--primary-hover);
    transform: scale(0.98);
}

.btn-secondary {
    background: var(--bg-gray);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:active {
    background: var(--bg-dark);
    transform: scale(0.98);
}

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

/* ============================================
   Success Screen
   ============================================ */

.success-screen {
    background: linear-gradient(135deg, #09131c 0%, #112236 50%, #09131c 100%);
    align-items: center;
    justify-content: center;
}

.success-content {
    text-align: center;
    padding: 40px;
}

.success-checkmark {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--success-color);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
    animation: scaleIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.success-checkmark svg {
    width: 36px;
    height: 36px;
    color: var(--white);
}

.success-content h2 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}

.success-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    width: 100%;
    margin-top: 8px;
}

.success-actions .btn {
    width: 100%;
    max-width: 320px;
}

.success-subtitle {
    color: var(--text-secondary);
    font-size: 15px;
    margin-bottom: 32px;
}

@keyframes scaleIn {
    from {
        transform: scale(0);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

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

.error-screen {
    background: linear-gradient(135deg, #09131c 0%, #112236 50%, #09131c 100%);
    align-items: center;
    justify-content: center;
}

.error-content {
    text-align: center;
    padding: 40px;
}

.error-icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--error-color);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
}

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

.error-content h2 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 8px;
}

.error-message {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 32px;
    line-height: 1.5;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
}

/* ============================================
   Safe area insets for notched phones
   ============================================ */

.app-header {
    padding-top: max(16px, env(safe-area-inset-top));
}

.capture-controls {
    padding-bottom: max(36px, env(safe-area-inset-bottom));
}

.result-actions {
    padding-bottom: max(20px, env(safe-area-inset-bottom));
}

/* ============================================
   Desktop Layout
   ============================================ */

@media (min-width: 768px) {
    body {
        overflow: auto;
    }

    .results-screen {
        height: auto;
        max-height: none;
        overflow: auto;
        align-items: center;
    }

    .results-screen .app-header {
        width: 100%;
        max-width: 720px;
        margin: 0 auto;
        background: transparent;
        padding-top: 40px;
    }

    .results-body {
        width: 100%;
        max-width: 720px;
        margin: 0 auto;
        padding: 24px 0 40px;
    }

    .results-card {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 20px;
        padding: 32px;
    }

    .field-divider {
        grid-column: 1 / -1;
    }

    .field-group input,
    .field-group select {
        font-size: 14px;
        padding: 10px 12px;
    }

    .field-group select {
        padding-right: 36px;
    }

    .result-actions {
        flex-direction: row;
        justify-content: flex-end;
        padding-bottom: 20px;
    }

    .result-actions .btn {
        width: auto;
    }

    .success-screen,
    .error-screen,
    .processing-screen {
        align-items: center;
        justify-content: center;
    }
}
