/* VotoLibre App - Mobile-first PWA */
/* Colors: Gold #FECE1A on Dark #0d0d0d */

:root {
    --vl: #FECE1A;
    --vl-hover: #e5b916;
    --vl-dim: rgba(254,206,26,0.15);
    --vl-dim2: rgba(254,206,26,0.08);
    --bg: #0d0d0d;
    --bg2: #1a1a1a;
    --bg3: #242424;
    --bg4: #2e2e2e;
    --text: #ffffff;
    --text2: #a0a4a8;
    --text3: #6b7075;
    --border: #2d2d2d;
    --success: #22c55e;
    --success-dim: rgba(34,197,94,0.15);
    --error: #ef4444;
    --error-dim: rgba(239,68,68,0.15);
    --warn: #f59e0b;
    --warn-dim: rgba(245,158,11,0.15);
    --r: 12px;
    --r2: 16px;
    --nav-h: 64px;
    --top-h: 52px;
    --safe-b: env(safe-area-inset-bottom, 0px);
    --safe-t: env(safe-area-inset-top, 0px);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-tap-highlight-color: transparent; }
body { font-family: 'Inter', -apple-system, sans-serif; background: var(--bg); color: var(--text); min-height: 100dvh; overflow-x: hidden; -webkit-font-smoothing: antialiased; }

/* Desktop blocker */
#desktop-block { display: none; position: fixed; inset: 0; z-index: 99999; background: var(--bg); align-items: center; justify-content: center; }
@media (min-width: 768px) and (pointer: fine) { #desktop-block { display: flex !important; } #app { display: none !important; } }
.db-content { text-align: center; padding: 2rem; max-width: 440px; }
.db-logo { height: 64px; margin-bottom: 1rem; }
.db-title { font-size: 2rem; font-weight: 800; color: var(--vl); margin-bottom: 0.25rem; }
.db-subtitle { font-size: 0.9rem; color: var(--text2); margin-bottom: 2rem; }
.db-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--r2); padding: 2rem; }
.db-card h2 { font-size: 1.1rem; font-weight: 700; margin-bottom: 0.5rem; }
.db-card p { font-size: 0.8rem; color: var(--text2); margin-bottom: 1.5rem; }
.db-phone { width: 50px; height: 80px; margin: 0 auto 1rem; animation: db-bounce 2s ease-in-out infinite; }
.db-phone svg { width: 100%; height: 100%; }
#desktop-qr { margin: 0 auto; width: 160px; height: 160px; background: #fff; border-radius: 8px; padding: 8px; }
#desktop-qr canvas, #desktop-qr img { width: 100% !important; height: 100% !important; }
.db-url { font-family: monospace; font-size: 0.7rem; color: var(--text3); margin-top: 0.75rem; word-break: break-all; }
@keyframes db-bounce { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

/* Landscape blocker */
#landscape-block { display: none; position: fixed; inset: 0; z-index: 99998; background: var(--bg); align-items: center; justify-content: center; }
@media screen and (orientation: landscape) and (max-height: 500px) { #landscape-block { display: flex !important; } body.doc-capture-active #landscape-block { display: none !important; } }
.lb-content { text-align: center; padding: 2rem; }
.lb-phone { width: 50px; height: 80px; margin: 0 auto 1rem; animation: lb-rot 2.5s ease-in-out infinite; }
.lb-phone svg { width: 100%; height: 100%; }
.lb-title { font-size: 1.1rem; font-weight: 700; color: var(--text); margin-bottom: 0.25rem; }
.lb-sub { font-size: 0.8rem; color: var(--text3); }
@keyframes lb-rot { 0%,15% { transform: rotate(90deg); } 40%,60% { transform: rotate(0); } 85%,100% { transform: rotate(90deg); } }

/* Top bar */
#topbar { position: fixed; top: 0; left: 0; right: 0; height: calc(var(--top-h) + var(--safe-t)); padding: var(--safe-t) 16px 0; background: var(--bg); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; z-index: 100; box-sizing: border-box; }
.topbar-logo { height: 28px; }
.topbar-title { font-size: 1rem; font-weight: 700; color: var(--vl); }

/* Screens */
#screens { padding: calc(var(--top-h) + var(--safe-t) + 12px) 16px calc(var(--nav-h) + var(--safe-b) + 12px); min-height: 100dvh; }

/* Bottom nav */
#bottomnav { position: fixed; bottom: 0; left: 0; right: 0; height: calc(var(--nav-h) + var(--safe-b)); padding: 6px 0 calc(var(--safe-b) + 4px); background: var(--bg2); border-top: 1px solid var(--border); display: flex; align-items: flex-start; justify-content: space-around; z-index: 100; box-sizing: border-box; }
.nav-btn { display: flex; flex-direction: column; align-items: center; gap: 3px; background: none; border: none; color: var(--text3); font-size: 0.6rem; font-weight: 600; padding: 8px 12px; cursor: pointer; transition: color 0.2s; position: relative; }
.nav-btn svg { width: 22px; height: 22px; }
.nav-btn.active { color: var(--vl); }
.nav-btn.active::after { content: ''; position: absolute; top: -1px; left: 50%; transform: translateX(-50%); width: 24px; height: 2px; background: var(--vl); border-radius: 0 0 2px 2px; }

/* Cards */
.card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--r2); padding: 1.25rem; margin-bottom: 1rem; }
.card-header { display: flex; align-items: center; gap: 12px; margin-bottom: 1rem; }
.card-icon { width: 44px; height: 44px; border-radius: var(--r); background: var(--vl-dim); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.card-icon svg { width: 22px; height: 22px; color: var(--vl); }
.card-title { font-size: 0.95rem; font-weight: 700; }
.card-sub { font-size: 0.75rem; color: var(--text2); margin-top: 2px; }

/* Buttons */
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 14px 20px; border-radius: var(--r); font-size: 0.9rem; font-weight: 600; cursor: pointer; border: none; transition: all 0.15s; font-family: inherit; }
.btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.btn-primary { background: var(--vl); color: #0d0d0d; }
.btn-primary:hover { background: var(--vl-hover); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-secondary { background: var(--bg3); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--vl); }
.btn-ghost { background: transparent; color: var(--vl); }
.btn-sm { padding: 10px 16px; font-size: 0.8rem; border-radius: 8px; }

/* Doc type selector */
.doc-options { display: flex; flex-direction: column; gap: 10px; }
.doc-option { display: flex; align-items: center; gap: 14px; padding: 16px; background: var(--bg3); border: 2px solid transparent; border-radius: var(--r); cursor: pointer; transition: all 0.15s; }
.doc-option:hover, .doc-option.selected { border-color: var(--vl); background: var(--vl-dim2); }
.doc-icon { width: 48px; height: 48px; border-radius: 8px; background: var(--vl-dim); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.doc-icon svg { width: 24px; height: 24px; color: var(--vl); }
.doc-label { font-size: 0.9rem; font-weight: 600; }
.doc-desc { font-size: 0.72rem; color: var(--text3); margin-top: 2px; }

/* Steps indicator */
.steps { display: flex; align-items: center; justify-content: center; gap: 6px; margin-bottom: 1.5rem; padding: 0 1rem; }
.step-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--bg4); transition: all 0.3s; }
.step-dot.active { background: var(--vl); width: 24px; border-radius: 4px; }
.step-dot.done { background: var(--success); }

/* Form inputs */
.form-group, .form-field { margin-bottom: 1.1rem; display: block; }
.form-field label, .form-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text2);
    margin: 0 0 0.45rem 0.15rem;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}
.form-field input,
.form-field textarea,
.form-field select,
.form-input {
    display: block;
    width: 100%;
    box-sizing: border-box;
    padding: 14px 16px;
    background: var(--bg3);
    border: 1.5px solid var(--border);
    border-radius: var(--r);
    color: var(--text);
    font-size: 1rem;
    font-family: inherit;
    line-height: 1.3;
    transition: border-color 0.15s, background 0.15s;
    -webkit-appearance: none;
    appearance: none;
}
.form-field input:focus,
.form-field textarea:focus,
.form-field select:focus,
.form-input:focus {
    outline: none;
    border-color: var(--vl);
    background: var(--bg4, #1a1a1a);
}
.form-field input::placeholder,
.form-field textarea::placeholder,
.form-input::placeholder { color: var(--text3); }
.form-field textarea { resize: vertical; min-height: 90px; }
.form-hint { font-size: 0.7rem; color: var(--text3); margin: 0.3rem 0 0 0.15rem; display: flex; align-items: center; gap: 4px; }
.form-hint svg { width: 14px; height: 14px; }
.form-error { color: var(--error); }

/* Disable iOS auto-zoom on focus by ensuring 16px+ font */
@supports (-webkit-touch-callout: none) {
    .form-field input,
    .form-field textarea,
    .form-input { font-size: 16px; }
}

/* Camera viewfinder */
.viewfinder { position: relative; width: 100%; aspect-ratio: 3/4; border-radius: var(--r2); overflow: hidden; background: #000; margin-bottom: 1rem; }
.viewfinder video { width: 100%; height: 100%; object-fit: cover; }
.viewfinder-overlay { position: absolute; inset: 0; pointer-events: none; }
.viewfinder-guide { position: absolute; border: 2px dashed rgba(254,206,26,0.5); border-radius: 50%; top: 15%; left: 15%; right: 15%; bottom: 25%; }
.viewfinder-guide.rect { border-radius: var(--r); top: 20%; left: 5%; right: 5%; bottom: 20%; }
.viewfinder-hint { position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,0.7); color: #fff; padding: 6px 14px; border-radius: 20px; font-size: 0.72rem; font-weight: 500; white-space: nowrap; }
.capture-btn { width: 64px; height: 64px; border-radius: 50%; border: 3px solid var(--vl); background: transparent; cursor: pointer; display: flex; align-items: center; justify-content: center; margin: 0 auto; transition: all 0.15s; }
.capture-btn:active { transform: scale(0.9); }
.capture-btn-inner { width: 48px; height: 48px; border-radius: 50%; background: var(--vl); transition: transform 0.15s; }
.capture-btn:active .capture-btn-inner { transform: scale(0.85); }

/* Photo preview */
.preview-img { width: 100%; border-radius: var(--r2); margin-bottom: 1rem; }
.preview-actions { display: flex; gap: 10px; }
.preview-actions .btn { flex: 1; }

/* Status badges */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 20px; font-size: 0.7rem; font-weight: 600; }
.badge-success { background: var(--success-dim); color: var(--success); }
.badge-error { background: var(--error-dim); color: var(--error); }
.badge-warn { background: var(--warn-dim); color: var(--warn); }
.badge-info { background: var(--vl-dim); color: var(--vl); }

/* Spinner */
.spinner { width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--vl); border-radius: 50%; animation: spin 0.8s linear infinite; }
.spinner-sm { width: 18px; height: 18px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Screen transitions */
.screen { animation: fadeUp 0.3s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* Welcome screen */
.welcome-hero { text-align: center; padding: 2rem 0 1.5rem; }
.welcome-logo { height: 72px; margin-bottom: 1rem; }
.welcome-title { font-size: 1.5rem; font-weight: 800; color: var(--vl); margin-bottom: 0.25rem; }
.welcome-sub { font-size: 0.85rem; color: var(--text2); margin-bottom: 2rem; }
.welcome-features { display: flex; flex-direction: column; gap: 12px; margin-bottom: 2rem; }
.feature-item { display: flex; align-items: center; gap: 12px; padding: 12px; background: var(--bg2); border-radius: var(--r); }
.feature-icon { width: 36px; height: 36px; border-radius: 8px; background: var(--vl-dim); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.feature-icon svg { width: 18px; height: 18px; color: var(--vl); }
.feature-text { font-size: 0.8rem; color: var(--text2); }
.feature-text strong { color: var(--text); display: block; margin-bottom: 1px; }

/* Verification result */
.verify-result { text-align: center; padding: 1.5rem 0; }
.verify-icon { width: 64px; height: 64px; border-radius: 50%; margin: 0 auto 1rem; display: flex; align-items: center; justify-content: center; }
.verify-icon.ok { background: var(--success-dim); }
.verify-icon.ok svg { color: var(--success); width: 32px; height: 32px; }
.verify-icon.fail { background: var(--error-dim); }
.verify-icon.fail svg { color: var(--error); width: 32px; height: 32px; }
.verify-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 0.25rem; }
.verify-sub { font-size: 0.8rem; color: var(--text2); }

/* Loading screen */
.loading-center { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 3rem 1rem; text-align: center; }
.loading-center .spinner { margin-bottom: 1rem; }
.loading-center p { font-size: 0.85rem; color: var(--text2); }

/* Home screen cards */
.home-stat { display: flex; align-items: center; gap: 14px; padding: 14px; background: var(--bg3); border-radius: var(--r); margin-bottom: 8px; }
.home-stat-num { font-size: 1.5rem; font-weight: 800; color: var(--vl); min-width: 40px; text-align: center; }
.home-stat-label { font-size: 0.8rem; color: var(--text2); }


.vl-ocurr-coords { display: flex; align-items: center; gap: 0.45rem; margin-top: 0.5rem; padding: 0.45rem 0.6rem; background: var(--bg2); border-radius: 8px; border: 1px solid var(--border); }
.vl-ocurr-coords span { flex: 1; font-family: ui-monospace, Menlo, monospace; font-size: 0.68rem; color: var(--text2); }
.vl-ocurr-coords button { background: var(--vl); color: #0d0d0d; border: none; border-radius: 6px; padding: 0.3rem 0.6rem; font-size: 0.62rem; font-weight: 700; cursor: pointer; display: flex; align-items: center; gap: 0.25rem; font-family: inherit; }
.vl-ocurr-coords button:active { transform: scale(0.95); }

.vl-acta-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.vl-acta-thumb-card { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; cursor: pointer; background: var(--bg2); border: 1px solid var(--border); }
.vl-acta-thumb-card img { width: 100%; height: 100%; object-fit: cover; }
.vl-acta-thumb-num { position: absolute; bottom: 6px; right: 6px; background: rgba(0,0,0,0.7); color: white; font-size: 0.65rem; font-weight: 700; padding: 2px 6px; border-radius: 8px; }

.vl-stamp-row { display: flex; align-items: center; gap: 0.45rem; margin-top: 0.5rem; padding: 0.55rem 0.7rem; background: rgba(34,197,94,0.08); border-radius: 8px; border: 1px solid rgba(34,197,94,0.25); }
.vl-stamp-row span { flex: 1; font-size: 0.72rem; color: #22c55e; font-weight: 600; }
.vl-stamp-row button { background: #22c55e; color: white; border: none; border-radius: 6px; padding: 0.3rem 0.65rem; font-size: 0.62rem; font-weight: 700; cursor: pointer; font-family: inherit; }
.vl-stamp-row button:active { transform: scale(0.95); }
.vl-stamp-modal { background: var(--bg2); border-radius: 14px; padding: 1.2rem; max-width: 500px; width: 100%; border: 1px solid var(--border); }
.vl-stamp-modal-header { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.85rem; }
.vl-stamp-modal-header h3 { margin: 0; font-size: 0.95rem; color: var(--text); }
.vl-stamp-modal-desc { font-size: 0.72rem; color: var(--text2); margin: 0 0 0.6rem; }
.vl-stamp-uri { background: var(--bg); padding: 0.6rem; border-radius: 8px; font-family: ui-monospace, Menlo, monospace; font-size: 0.7rem; color: var(--vl); word-break: break-all; margin-bottom: 0.85rem; border: 1px solid var(--border); }
.vl-stamp-actions { display: flex; gap: 0.5rem; }
.vl-stamp-actions .btn { flex: 1; }

.vl-foto-modal { position: fixed; inset: 0; background: rgba(0,0,0,0.92); z-index: 99999; display: flex; flex-direction: column; padding: 0; }
.vl-foto-modal-header { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; padding: max(env(safe-area-inset-top, 0px), 12px) 14px 10px; background: rgba(0,0,0,0.85); border-bottom: 1px solid rgba(255,255,255,0.08); }
.vl-foto-modal-titles { flex: 1; min-width: 0; }
.vl-foto-modal-title { color: white; font-size: 0.92rem; font-weight: 700; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vl-foto-modal-meta { display: flex; align-items: center; gap: 0.5rem; margin-top: 4px; flex-wrap: wrap; }
.vl-foto-badge { background: var(--vl); color: #0d0d0d; font-size: 0.62rem; font-weight: 800; padding: 2px 7px; border-radius: 8px; font-family: ui-monospace, Menlo, monospace; }
.vl-foto-size { color: rgba(255,255,255,0.65); font-size: 0.66rem; font-weight: 600; }
.vl-foto-modal-meta span { color: rgba(255,255,255,0.55); font-size: 0.66rem; }
.vl-foto-modal-close { background: rgba(255,255,255,0.95); color: #0d0d0d; border: none; border-radius: 50%; width: 40px; height: 40px; min-width: 40px; font-size: 1.05rem; font-weight: 800; cursor: pointer; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 8px rgba(0,0,0,0.4); }
.vl-foto-modal-body { flex: 1; display: flex; align-items: center; justify-content: center; padding: 12px; position: relative; overflow: hidden; }
.vl-foto-modal-img { max-width: 100%; max-height: 100%; border-radius: 8px; opacity: 0; transition: opacity 0.3s ease; box-shadow: 0 4px 24px rgba(0,0,0,0.5); }
.vl-foto-modal-img.loaded { opacity: 1; }
.vl-foto-loader { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; }
.vl-foto-spinner { width: 36px; height: 36px; border: 3px solid rgba(255,255,255,0.15); border-top-color: var(--vl); border-radius: 50%; animation: vl-spin 0.9s linear infinite; }
.vl-foto-loadtxt { color: rgba(255,255,255,0.7); font-size: 0.75rem; font-weight: 600; }
@keyframes vl-spin { to { transform: rotate(360deg); } }
.vl-foto-modal-footer { padding: 12px 14px max(env(safe-area-inset-bottom, 0px), 14px); background: rgba(0,0,0,0.85); display: flex; gap: 0.5rem; justify-content: center; }
.vl-foto-action { background: var(--vl); color: #0d0d0d; border: none; border-radius: 22px; padding: 0.65rem 1.2rem; font-weight: 700; font-size: 0.78rem; cursor: pointer; display: flex; align-items: center; gap: 0.4rem; font-family: inherit; }
.vl-foto-action:active { transform: scale(0.96); }
