/* ── Virtualobby — Mobile-First Styles ─────────────────────────────── */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #60a5fa;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg: #f8fafc;
    --bg-card: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 6px rgba(0, 0, 0, 0.1);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-full: 9999px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

/* Telegram Mini App adjustments */
body.telegram-webapp {
    padding-top: 0;
}

/* ── Header ─────────────────────────────────────────────────────── */

.header {
    background: var(--primary);
    color: white;
    padding: 16px 20px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-lg);
}

.header-content {
    max-width: 600px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.logo-icon {
    font-size: 28px;
}

.logo h1 {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    opacity: 0.9;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ── Main ────────────────────────────────────────────────────────── */

.main {
    flex: 1;
    padding: 20px;
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
}

/* ── Steps ───────────────────────────────────────────────────────── */

.step {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    animation: fadeIn 0.3s ease;
}

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

.step.hidden {
    display: none;
}

.step-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.step-number {
    width: 32px;
    height: 32px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
}

.step-header h2 {
    font-size: 20px;
    font-weight: 600;
}

.step-description {
    color: var(--text-muted);
    margin-bottom: 20px;
    font-size: 15px;
}

/* ── Business Grid ──────────────────────────────────────────────── */

.business-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.business-card {
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.business-card:hover,
.business-card:active {
    border-color: var(--primary);
    background: var(--primary-light);
    background: rgba(37, 99, 235, 0.05);
    transform: scale(1.02);
}

.business-card.selected {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.1);
}

.business-icon {
    font-size: 36px;
}

.business-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
}

/* ── Camera ──────────────────────────────────────────────────────── */

.camera-container {
    position: relative;
    width: 100%;
    aspect-ratio: 4/3;
    background: #000;
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-bottom: 16px;
}

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

.camera-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.scan-frame {
    width: 80%;
    height: 60%;
    border: 2px dashed rgba(255, 255, 255, 0.6);
    border-radius: 8px;
    position: relative;
}

.scan-frame::before {
    content: 'Position document here';
    position: absolute;
    bottom: -28px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-size: 12px;
    white-space: nowrap;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.camera-controls {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* ── OCR Result ──────────────────────────────────────────────────── */

.ocr-result {
    margin-top: 20px;
    animation: fadeIn 0.3s ease;
}

.result-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.result-icon {
    font-size: 24px;
}

.result-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--success);
}

.result-fields {
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-bottom: 16px;
}

.field-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.field-row:last-child {
    border-bottom: none;
}

.field-label {
    font-size: 13px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.field-value {
    font-weight: 500;
    text-align: right;
}

.result-actions {
    display: flex;
    gap: 12px;
}

/* ── Loading ─────────────────────────────────────────────────────── */

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

.loading.hidden {
    display: none;
}

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

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

.loading p {
    color: var(--text-muted);
    font-size: 14px;
}

/* ── Voice ────────────────────────────────────────────────────────── */

.voice-container {
    display: flex;
    flex-direction: column;
    height: 400px;
}

.transcript {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
}

.transcript-messages {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 15px;
    line-height: 1.4;
    animation: fadeIn 0.2s ease;
}

.message.agent {
    background: var(--primary);
    color: white;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.message.user {
    background: var(--bg-card);
    border: 1px solid var(--border);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.voice-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.btn-voice {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-voice:hover {
    transform: scale(1.05);
}

.btn-voice:active,
.btn-voice.recording {
    background: var(--danger);
    transform: scale(0.95);
}

.voice-icon {
    font-size: 28px;
}

.voice-text {
    font-size: 10px;
    font-weight: 500;
}

.voice-status {
    display: none;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 13px;
}

.voice-status.active {
    display: flex;
}

.voice-wave {
    width: 20px;
    height: 20px;
    background: var(--primary);
    border-radius: 50%;
    animation: wave 1.5s infinite;
}

@keyframes wave {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.7; }
}

/* ── Confirmation ────────────────────────────────────────────────── */

.confirm-card {
    text-align: center;
    padding: 40px 20px;
}

.confirm-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.confirm-card h3 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--success);
}

.confirm-message {
    color: var(--text-muted);
    margin-bottom: 20px;
}

.confirm-id {
    background: var(--bg);
    padding: 16px;
    border-radius: var(--radius-sm);
    font-family: monospace;
    font-size: 18px;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 24px;
}

/* ── Buttons ─────────────────────────────────────────────────────── */

.btn {
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
    font-family: inherit;
}

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

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

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

.btn-secondary:hover {
    background: var(--border);
}

.btn-block {
    width: 100%;
}

.btn-capture {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    padding: 0;
    font-size: 24px;
}

/* ── Footer ──────────────────────────────────────────────────────── */

.footer {
    text-align: center;
    padding: 16px;
    color: var(--text-muted);
    font-size: 12px;
}

.footer strong {
    color: var(--primary);
}

/* ── Responsive ──────────────────────────────────────────────────── */

@media (max-width: 480px) {
    .header {
        padding: 12px 16px;
    }
    
    .logo h1 {
        font-size: 18px;
    }
    
    .main {
        padding: 16px;
    }
    
    .step {
        padding: 20px;
    }
    
    .business-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    
    .business-card {
        padding: 16px 12px;
    }
    
    .business-icon {
        font-size: 28px;
    }
    
    .btn {
        padding: 10px 20px;
        font-size: 14px;
    }
}

@media (min-width: 768px) {
    .business-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ── Utilities ───────────────────────────────────────────────────── */

.hidden {
    display: none !important;
}
