@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');

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

body {
    font-family: 'Poppins', sans-serif;
    background: #ffffff;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 2rem 1rem;
}

.card {
    background: #353480;
    color: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    padding: 2.5rem;
    width: 100%;
    max-width: 900px;
}

.card h1 {
    font-size: 1.4rem;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 0.25rem;
}

.logo {
    display: block;
    height: 44px;
    width: auto;
    margin-bottom: 0.75rem;
}

.card .subtitle {
    font-size: 0.85rem;
    color: #c9c8e8;
    font-weight: 500;
    margin-bottom: 2rem;
}

label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: #e3e2f5;
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="file"] {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1.5px solid #ddd;
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
    color: #1a1a2e;
    background: #fff;
    appearance: none;
    -webkit-appearance: none;
    transition: border-color 0.2s;
    outline: none;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus {
    border-color: #4f46e5;
}

input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
    -webkit-text-fill-color: #1a1a2e;
    -webkit-box-shadow: 0 0 0 1000px #fff inset;
    box-shadow: 0 0 0 1000px #fff inset;
    transition: background-color 9999s ease-in-out 0s;
}

.field {
    margin-bottom: 1.25rem;
}

.btn {
    display: block;
    width: 100%;
    padding: 0.8rem;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary {
    background: #4f46e5;
    color: #fff;
}

.btn-primary:hover {
    background: #4338ca;
}

.btn-ia {
    background: #d61e38;
    color: #fff;
}

.btn-ia:hover {
    background: #b8172f;
}

.btn-success {
    background: #16a34a;
    color: #fff;
}

.btn-success:hover {
    background: #15803d;
}

.divider {
    border: none;
    border-top: 1.5px solid rgba(255, 255, 255, 0.2);
    margin: 1.75rem 0;
}

.alert {
    padding: 0.85rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    margin-bottom: 1.25rem;
}

.alert-error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fca5a5;
}

.alert-success {
    background: #f0fdf4;
    color: #15803d;
    border: 1px solid #86efac;
}

.qr-block {
    text-align: center;
    margin-bottom: 1.5rem;
}

.qr-block img {
    background: #fff;
    padding: 0.75rem;
    border-radius: 10px;
    width: 200px;
    height: 200px;
    max-width: 100%;
}

.qr-block .qr-hint {
    font-size: 0.8rem;
    color: #c9c8e8;
    font-weight: 500;
    margin-top: 0.85rem;
}

.qr-separator {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 1.5rem 0;
    color: #c9c8e8;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.qr-separator::before,
.qr-separator::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255, 255, 255, 0.2);
}

.btn-secondary {
    background: transparent;
    color: #ffffff;
    border: 1.5px solid rgba(255, 255, 255, 0.4);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
}

.tag {
    display: inline-block;
    background: #eef2ff;
    color: #4f46e5;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.2rem 0.6rem;
    border-radius: 99px;
    margin-bottom: 1rem;
}

.fields-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 1rem;
}

.fields-grid .field-full {
    grid-column: 1 / -1;
}

.drop-zone {
    border: 2px dashed #cbd5e1;
    border-radius: 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: #f8fafc;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    gap: 0.5rem;
}

.drop-zone:hover,
.drop-zone.dragover {
    border-color: #7c3aed;
    background: #f3e8ff;
}

.drop-zone.has-file {
    border-style: solid;
    border-color: #16a34a;
    background: #f0fdf4;
}

.drop-zone .drop-icon {
    font-size: 2rem;
    opacity: 0.5;
}

.drop-zone .drop-text {
    font-size: 0.85rem;
    color: #64748b;
    font-weight: 500;
}

.drop-zone .drop-preview {
    max-width: 100%;
    max-height: 80px;
    border-radius: 6px;
    margin-top: 0.5rem;
    object-fit: contain;
}

.driver2-toggle {
    margin: 1.5rem 0 0.5rem;
    padding: 0.75rem;
    background: #f8fafc;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    cursor: pointer;
    transition: background 0.15s;
}

.driver2-toggle:hover {
    background: #f1f5f9;
}

.driver2-toggle input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #4f46e5;
}

.driver2-toggle label {
    margin: 0;
    font-size: 0.85rem;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    text-transform: none;
    letter-spacing: 0;
    transition: all 0.2s;
    text-align: center;
}

.driver2-section {
    display: none;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 2px dashed rgba(255, 255, 255, 0.25);
}

.driver2-section.active {
    display: block;
}

.debug-block {
    margin-bottom: 1.25rem;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
}

.debug-block .debug-title {
    background: #1e293b;
    color: #94a3b8;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 0.5rem 0.9rem;
}

.debug-block pre {
    background: #0f172a;
    color: #7dd3fc;
    font-size: 0.8rem;
    padding: 1rem;
    margin: 0;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

/* ── Upload zone ── */
.upload-zone {
    border: 2px dashed #cbd5e1;
    border-radius: 10px;
    background: #f8fafc;
    padding: 1.75rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    position: relative;
}

.upload-zone.dragover {
    border-color: #7c3aed;
    background: #f3e8ff;
}

.upload-zone.has-file {
    border-style: solid;
    border-color: #16a34a;
    background: #f0fdf4;
}

.upload-zone__icon {
    display: block;
    font-size: 2rem;
    opacity: 0.45;
    margin-bottom: 0.5rem;
}

.upload-zone__text {
    display: block;
    font-size: 0.88rem;
    color: #475569;
    font-weight: 500;
}

.upload-zone__hint {
    display: block;
    font-size: 0.75rem;
    color: #94a3b8;
    margin-top: 0.3rem;
}

.upload-zone__filename {
    display: block;
    font-size: 0.8rem;
    color: #16a34a;
    font-weight: 600;
    margin-top: 0.5rem;
    word-break: break-all;
}

.upload-zone__preview {
    display: none;
    max-width: 100%;
    max-height: 90px;
    border-radius: 6px;
    margin-top: 0.75rem;
    object-fit: contain;
}

.upload-zone__preview.visible {
    display: inline-block;
}

/* ── Bloqueo por falta de consentimiento (checkbox IA) ───────────────── */
.upload-zone.zone-locked {
    opacity: 0.5;
    pointer-events: none;
    cursor: not-allowed;
}

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

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

/* Desktop: muestra zona drag&drop, oculta botón móvil */
.upload-zone__mobile  { display: none; }
.upload-zone__desktop { display: block; }

/* Móvil/tablet: oculta drag&drop, muestra botón cámara */
@media (hover: none) and (pointer: coarse) {
    .upload-zone__desktop { display: none; }
    .upload-zone__mobile  { display: block; }
    .upload-zone {
        padding: 1.25rem;
        cursor: default;
        border-style: solid;
    }
}

.btn-capture {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: #d61e38;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-capture:hover {
    background: #b8172f;
}

/* ── Modal de carga ─────────────────────────────────────────────────── */
#loading-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(15, 23, 42, 0.72);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
}

#loading-modal.visible {
    display: flex;
}

.loading-box {
    background: #fff;
    border-radius: 16px;
    padding: 2.5rem 2rem;
    width: 90%;
    max-width: 380px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.loading-spinner {
    width: 56px;
    height: 56px;
    border: 5px solid #e2e8f0;
    border-top-color: #d61e38;
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
    margin: 0 auto 1.25rem;
}

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

.loading-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #1a1a2e;
    margin-bottom: 0.4rem;
}

.loading-subtitle {
    font-size: 0.85rem;
    color: #64748b;
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.loading-progress-wrap {
    background: #f1f5f9;
    border-radius: 99px;
    height: 8px;
    overflow: hidden;
    margin-bottom: 0.6rem;
}

.loading-progress-bar {
    height: 100%;
    border-radius: 99px;
    background: #d61e38;
    width: 0%;
    transition: width 0.4s ease;
}

.loading-progress-label {
    font-size: 0.78rem;
    color: #94a3b8;
    font-weight: 500;
}

.loading-step {
    font-size: 0.8rem;
    color: #d61e38;
    font-weight: 600;
    margin-top: 0.75rem;
    min-height: 1.2em;
}

/* ── Modal de éxito ─────────────────────────────────────────────────── */
#success-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(15, 23, 42, 0.72);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
}

#success-modal.visible {
    display: flex;
}

.success-box {
    background: #fff;
    border-radius: 16px;
    padding: 2.5rem 2rem;
    width: 90%;
    max-width: 340px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: successPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

.success-icon {
    width: 72px;
    height: 72px;
    background: #16a34a;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.25rem;
}

.success-icon svg {
    width: 38px;
    height: 38px;
}

.success-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1a1a2e;
    margin-bottom: 0.4rem;
}

.success-subtitle {
    font-size: 0.85rem;
    color: #64748b;
    line-height: 1.5;
}
