/* ══════════════════════════════════════════════════════
   FaQR — Design System
   Paleta: naranja / blanco
   ══════════════════════════════════════════════════════ */
:root {
    --bg: #fff8f2;
    --card: #ffffff;
    --text: #2a1505;
    --muted: #8a6a50;
    --border: #f0d5bb;
    --border-strong: #e8c09a;
    --primary: #e8701a;
    --primary-dark: #c45810;
    --primary-soft: #fff3eb;
    --shadow: 0 22px 55px rgba(200, 90, 26, 0.11);
    --radius-xl: 28px;
    --radius-lg: 20px;
    --radius-md: 14px;
}

* { box-sizing: border-box; }
html {
    font-size: 16px;
    min-height: 100%;
    /* Mismo fondo que body para que no quede franja “azulada” del UA */
    background:
        radial-gradient(ellipse at 8% 12%, rgba(255, 155, 75, 0.42) 0%, transparent 52%),
        radial-gradient(ellipse at 92% 18%, rgba(255, 130, 50, 0.28) 0%, transparent 48%),
        radial-gradient(ellipse at 50% 88%, rgba(255, 175, 95, 0.35) 0%, transparent 55%),
        radial-gradient(ellipse at 70% 45%, rgba(255, 210, 160, 0.22) 0%, transparent 65%),
        linear-gradient(165deg, #fffdfb 0%, #fff4e8 45%, #ffefe0 100%);
    background-attachment: fixed;
}

body {
    margin: 0;
    font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    min-height: 100vh;
    /* Gradientes naranja más visibles (marca FaQR) */
    background:
        radial-gradient(ellipse at 8% 12%, rgba(255, 155, 75, 0.42) 0%, transparent 52%),
        radial-gradient(ellipse at 92% 18%, rgba(255, 130, 50, 0.28) 0%, transparent 48%),
        radial-gradient(ellipse at 50% 88%, rgba(255, 175, 95, 0.35) 0%, transparent 55%),
        radial-gradient(ellipse at 70% 45%, rgba(255, 210, 160, 0.22) 0%, transparent 65%),
        linear-gradient(165deg, #fffdfb 0%, #fff4e8 45%, #ffefe0 100%);
    background-attachment: fixed;
}

a { color: var(--primary-dark); text-decoration: none; }
a:hover { text-decoration: underline; color: var(--primary); }

/* ── Layout ─────────────────────────────────────────── */
.page-shell {
    min-height: 100vh;
    padding: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
}

.form-card,
.qr-card {
    width: min(100%, 920px);
    background: var(--card);
    border: 1px solid rgba(240, 200, 155, 0.7);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow);
}

.form-card { padding: 32px; }
.qr-card { padding: 36px; }

/* ── Header ──────────────────────────────────────────── */
.hero-head,
.qr-header {
    display: flex;
    gap: 18px;
    align-items: flex-start;
    margin-bottom: 24px;
}

/* Login: logo centrado arriba, sin desbordar la tarjeta */
.hero-head--login {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 14px;
}
.hero-head--login .hero-copy {
    width: 100%;
}

/* Contenedor logo — tamaño fijo para que PNGs grandes no rompan el layout */
.logo-box {
    flex: 0 0 88px;
    width: 88px;
    height: 72px;
    min-width: 0;
    border: 1.5px dashed var(--border-strong);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-soft);
    overflow: hidden;
}

.logo-box--compact,
.hero-head--login .logo-box {
    flex: 0 0 auto;
    width: 80px;
    height: 68px;
}

.logo-box img,
img.brand-logo {
    max-width: 56px !important;
    max-height: 48px !important;
    width: auto !important;
    height: auto !important;
    display: block;
    object-fit: contain;
}

/* Cabecera de páginas generadas (solicitud de factura) */
.logo-slot {
    flex: 0 0 88px;
    width: 88px;
    height: 72px;
    min-width: 0;
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-soft);
    border: 1.5px dashed var(--border-strong);
}
.logo-slot img {
    max-width: 56px !important;
    max-height: 48px !important;
    width: auto !important;
    height: auto !important;
    object-fit: contain;
    display: block;
}

.hero-block {
    display: flex;
    gap: 18px;
    align-items: flex-start;
    margin-bottom: 24px;
}

.logo-box__inner {
    width: 72px;
    height: 42px;
    border-radius: 10px;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: .08em;
}

.hero-copy,
.qr-header__copy { flex: 1; }

.hero-copy h1,
.hero-block h1 {
    color: var(--text);
}

.eyebrow {
    display: inline-block;
    margin-bottom: 10px;
    color: var(--primary);
    font-size: 0.79rem;
    font-weight: 800;
    letter-spacing: .09em;
    text-transform: uppercase;
}

h1, h2 {
    margin: 0 0 8px;
    line-height: 1.08;
    letter-spacing: -0.03em;
}
h1 { font-size: clamp(1.8rem, 3vw, 2.8rem); }
h2 { font-size: clamp(1.4rem, 2.4vw, 2rem); }

.hero-copy p,
.qr-header__copy p,
.page-footer,
.qr-meta,
.qr-note { color: var(--muted); }

/* ── Alertas ─────────────────────────────────────────── */
.form-alert {
    margin: 0;
    padding: 14px 16px;
    border-radius: 14px;
    font-size: 0.96rem;
    border: 1px solid transparent;
}
.form-alert.error {
    background: #fff3f2;
    border-color: #f2c4bf;
    color: #ab3f35;
}
.form-alert.success {
    background: #fff7f0;
    border-color: var(--border-strong);
    color: var(--primary-dark);
}
.hidden { display: none !important; }

/* ── Formulario ──────────────────────────────────────── */
.request-form { display: flex; flex-direction: column; gap: 18px; }

.form-section {
    margin: 0;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 18px;
}
.form-section legend {
    padding: 0 10px;
    font-weight: 700;
    font-size: 0.98rem;
    color: var(--primary-dark);
}

/* ── Grid ────────────────────────────────────────────── */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.full { width: 100%; }
.field + .field, .grid + .field, .field + .grid, .grid + .grid { margin-top: 14px; }
.grid .field, .grid + .field, .field + .grid { margin-top: 0; }

/* ── Campos ──────────────────────────────────────────── */
.field {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.field label {
    display: block;
    margin-bottom: 0;
    font-size: 0.93rem;
    font-weight: 700;
    color: var(--text);
}

.field label span { color: var(--primary); }

.field input,
.field select,
.field textarea {
    display: block;
    width: 100%;
    box-sizing: border-box;
    appearance: none;
    -webkit-appearance: none;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    min-height: 52px;
    line-height: 1.2;
    font: inherit;
    transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}

textarea { resize: vertical; min-height: 120px; }

.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: rgba(232, 112, 26, 0.7);
    box-shadow: 0 0 0 4px rgba(232, 112, 26, 0.12);
    background: #fffaf7;
}

.field input.input-error,
.field textarea.input-error {
    border-color: #d66c62;
    box-shadow: 0 0 0 4px rgba(214, 108, 98, 0.12);
}

/* Forzado para password (garantía cross-browser) */
.field input[type="password"] {
    display: block !important;
    width: 100% !important;
    box-sizing: border-box !important;
    appearance: none !important;
    -webkit-appearance: none !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-md) !important;
    padding: 14px 16px !important;
    min-height: 52px !important;
    line-height: 1.2 !important;
    font: inherit !important;
    background: #fff !important;
}
.field input[type="password"]:focus {
    outline: none !important;
    border-color: rgba(232, 112, 26, 0.7) !important;
    box-shadow: 0 0 0 4px rgba(232, 112, 26, 0.12) !important;
}

/* ── Checkbox ────────────────────────────────────────── */
.checkbox-row {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 4px 0;
    font-size: 0.95rem;
}
.checkbox-row + .checkbox-row { margin-top: 10px; }
.checkbox-row input[type="checkbox"] {
    margin-top: 3px;
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}
.checkbox-row strong {
    color: var(--primary-dark);
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: .03em;
}

/* ── Botones ─────────────────────────────────────────── */
.form-actions,
.qr-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}

.btn {
    border: none;
    border-radius: 999px;
    padding: 13px 22px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    transition: transform .18s ease, box-shadow .18s ease, background .18s ease, color .18s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-decoration: none;
    /* Evita el botón azul por defecto de Chrome / Edge */
    -webkit-appearance: none;
    appearance: none;
}
.btn:hover { transform: translateY(-1px); text-decoration: none; }
.btn:disabled { opacity: .7; cursor: wait; transform: none; }

button.btn-primary,
a.btn-primary,
input[type="submit"].btn-primary {
    color: #fff !important;
    background: linear-gradient(180deg, #f07830 0%, #d4620a 100%) !important;
    box-shadow: 0 14px 24px rgba(200, 90, 26, 0.28) !important;
    border: none !important;
}
button.btn-primary:hover,
a.btn-primary:hover,
input[type="submit"].btn-primary:hover {
    background: linear-gradient(180deg, #f88040 0%, #c55a0a 100%) !important;
    box-shadow: 0 18px 30px rgba(200, 90, 26, 0.34) !important;
    color: #fff !important;
}

.btn-secondary {
    background: #f5ece4;
    color: var(--primary-dark);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: #eedccc; }

.btn-danger {
    background: #fff0f0;
    color: #c0392b;
    border: 1px solid #f2c4bf;
}
.btn-danger:hover { background: #ffe0de; }

.btn-loader {
    width: 16px;
    height: 16px;
    border-radius: 999px;
    border: 2px solid rgba(255,255,255,.35);
    border-top-color: #fff;
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Footer ──────────────────────────────────────────── */
.page-footer {
    text-align: center;
    font-size: 0.92rem;
}
.page-footer nav {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 10px;
}

/* ── Panel QR ────────────────────────────────────────── */
.qr-layout {
    display: grid;
    grid-template-columns: 1.1fr .9fr;
    gap: 20px;
    align-items: center;
}
.qr-panel {
    border: 1px solid var(--border);
    border-radius: 22px;
    padding: 24px;
    background: linear-gradient(180deg, #ffffff 0%, #fff8f2 100%);
}
.qr-image-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 20px;
    min-height: 310px;
}
.qr-image-wrap img {
    max-width: 100%;
    width: 300px;
    height: auto;
    display: block;
    margin: 0 auto;
}
.qr-data-list { display: grid; gap: 14px; }
.qr-data-item { padding-bottom: 14px; border-bottom: 1px solid #f0dfc8; }
.qr-data-item:last-child { padding-bottom: 0; border-bottom: none; }
.qr-data-item span {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 0.86rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    font-weight: 700;
}
.qr-data-item strong { font-size: 1rem; word-break: break-word; }
.qr-data-item strong a { color: var(--text); }
.qr-note { color: var(--muted); font-size: 0.88rem; margin: 12px 0 0; }

/* ── Acciones QR inline ──────────────────────────────── */
.qr-actions-inline {
    justify-content: flex-start;
    margin-top: 18px;
}

/* ── Tabla admin ─────────────────────────────────────── */
.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}
.admin-table th {
    text-align: left;
    padding: 12px 14px;
    border-bottom: 2px solid var(--border-strong);
    color: var(--muted);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: .05em;
}
.admin-table td {
    padding: 12px 14px;
    border-bottom: 1px solid rgba(240, 213, 187, 0.5);
    vertical-align: middle;
}
.admin-table tr:last-child td { border-bottom: none; }
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
}
.badge-admin { background: var(--primary-soft); color: var(--primary-dark); }
.badge-user { background: #f0f0f0; color: #555; }
.badge-active { background: #eefaf2; color: #236340; }
.badge-inactive { background: #fff3f2; color: #ab3f35; }

/* ── Espacio publicitario ────────────────────────────── */
.ad-slot {
    background: var(--primary-soft);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    text-align: center;
    color: var(--muted);
    font-size: 0.88rem;
    margin: 18px 0;
}
.ad-slot p { margin: 0; }
.ad-slot a { color: var(--primary); font-weight: 600; }

/* ── Selector de país / campos dinámicos ─────────────── */
.country-fields { transition: opacity .2s ease; }
.country-fields.hidden-section { display: none; }

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 820px) {
    .form-card, .qr-card { padding: 22px; }
    .hero-head, .qr-header, .hero-block { flex-direction: column; }
    .logo-box { width: 88px; }
    .grid-2, .grid-4, .qr-layout { grid-template-columns: 1fr; }
    .span-2 { grid-column: auto; }
    .form-actions, .qr-actions { justify-content: stretch; }
    .btn { width: 100%; }
}

@media print {
    body { background: #fff; }
    .page-footer, .qr-actions { display: none !important; }
    .qr-card { box-shadow: none; border: none; width: 100%; }
}
