/* ══════════════════════════════════════════════════════════════════
   ROTAR WhatsApp Lead Modal — v1.0
   Modal de calificación de leads pre-WhatsApp
   ══════════════════════════════════════════════════════════════════ */

/* ── Overlay ── */
#rwa-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .55);
    backdrop-filter: blur(4px);
    z-index: 999999;
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: rwaOverlayIn .25s ease;
}
#rwa-modal-overlay.rwa-modal-open {
    display: flex;
}
@keyframes rwaOverlayIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ── Modal Box ── */
#rwa-modal-box {
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 24px 64px rgba(0,0,0,.28), 0 0 0 1px rgba(37,211,102,.12);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    animation: rwaModalIn .32s cubic-bezier(.34,1.56,.64,1);
    position: relative;
}
@keyframes rwaModalIn {
    from { opacity: 0; transform: scale(.9) translateY(24px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ── Header ── */
#rwa-modal-header {
    background: linear-gradient(135deg, #075e54, #128C7E, #25D366);
    border-radius: 20px 20px 0 0;
    padding: 22px 24px 20px;
    position: relative;
    display: flex;
    align-items: center;
    gap: 14px;
}
#rwa-modal-header-icon {
    width: 48px;
    height: 48px;
    background: rgba(255,255,255,.18);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
#rwa-modal-header-icon svg {
    width: 26px;
    height: 26px;
    fill: #fff;
}
#rwa-modal-header-text h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 800;
    color: #fff;
    line-height: 1.2;
}
#rwa-modal-header-text p {
    margin: 3px 0 0;
    font-size: 12.5px;
    color: rgba(255,255,255,.82);
}
#rwa-modal-close {
    position: absolute;
    top: 12px;
    right: 14px;
    background: rgba(255,255,255,.2);
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .2s;
    line-height: 1;
}
#rwa-modal-close:hover { background: rgba(255,255,255,.35); }

/* ── Body ── */
#rwa-modal-body {
    padding: 22px 24px 24px;
}

/* ── Fields ── */
.rwa-ml-field {
    margin-bottom: 14px;
}
.rwa-ml-label {
    display: block;
    font-size: 12.5px;
    font-weight: 700;
    color: #374151;
    margin-bottom: 5px;
}
.rwa-ml-label .rwa-required {
    color: #ef4444;
    margin-left: 2px;
}
.rwa-ml-input,
.rwa-ml-select,
.rwa-ml-textarea {
    width: 100%;
    box-sizing: border-box;
    border: 1.5px solid #e5e7eb;
    border-radius: 10px;
    padding: 10px 13px;
    font-size: 14px;
    color: #111827;
    background: #f9fafb;
    outline: none;
    transition: border-color .2s, box-shadow .2s, background .2s;
    font-family: inherit;
}
.rwa-ml-input:focus,
.rwa-ml-select:focus,
.rwa-ml-textarea:focus {
    border-color: #25D366;
    box-shadow: 0 0 0 3px rgba(37,211,102,.15);
    background: #fff;
}
.rwa-ml-input.rwa-input-error,
.rwa-ml-select.rwa-input-error {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239,68,68,.12);
}
.rwa-ml-textarea {
    min-height: 72px;
    resize: vertical;
}

/* ── Query type grid ── */
.rwa-query-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 4px;
}
.rwa-query-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border: 1.5px solid #e5e7eb;
    border-radius: 10px;
    cursor: pointer;
    transition: border-color .18s, background .18s;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    background: #f9fafb;
    user-select: none;
}
.rwa-query-option input[type=radio] {
    display: none;
}
.rwa-query-option:hover {
    border-color: #25D366;
    background: #f0fdf4;
}
.rwa-query-option.rwa-qo-selected {
    border-color: #25D366;
    background: #ecfdf5;
    color: #065f46;
}
.rwa-query-option .rwa-qo-icon {
    font-size: 18px;
    line-height: 1;
}

/* ── Row (2 cols) ── */
.rwa-ml-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 14px;
}
.rwa-ml-row .rwa-ml-field {
    margin-bottom: 0;
}

/* ── Submit button ── */
#rwa-modal-submit {
    width: 100%;
    background: linear-gradient(135deg, #25D366, #128C7E);
    color: #fff;
    border: none;
    border-radius: 12px;
    padding: 14px 20px;
    font-size: 15px;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 6px 20px rgba(37,211,102,.45);
    transition: transform .15s, box-shadow .15s;
    font-family: inherit;
    margin-top: 18px;
    letter-spacing: .3px;
}
#rwa-modal-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 28px rgba(37,211,102,.6);
}
#rwa-modal-submit:active { transform: translateY(0); }
#rwa-modal-submit svg {
    width: 20px;
    height: 20px;
    fill: #fff;
}
#rwa-modal-submit .rwa-btn-arrow { font-size: 18px; }

/* ── Skip link ── */
#rwa-modal-skip {
    display: block;
    text-align: center;
    margin-top: 10px;
    font-size: 12px;
    color: #9ca3af;
    cursor: pointer;
    text-decoration: underline;
    background: none;
    border: none;
    width: 100%;
    font-family: inherit;
    padding: 4px;
}
#rwa-modal-skip:hover { color: #6b7280; }

/* ── Saved badge ── */
.rwa-saved-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #f0fdf4;
    border: 1px solid #86efac;
    border-radius: 6px;
    padding: 3px 8px;
    font-size: 11px;
    color: #16a34a;
    font-weight: 600;
    margin-bottom: 12px;
}

/* ── Error msg ── */
.rwa-field-error {
    font-size: 11.5px;
    color: #ef4444;
    font-weight: 600;
    margin-top: 4px;
    display: none;
}
.rwa-field-error.rwa-error-visible { display: block; }

/* ── Responsive ── */
@media (max-width: 500px) {
    #rwa-modal-box { border-radius: 16px; }
    #rwa-modal-body { padding: 18px 16px 20px; }
    .rwa-query-grid { grid-template-columns: 1fr; }
    .rwa-ml-row { grid-template-columns: 1fr; }
}

/* ══════════════════════════════════════════════════════════════════
   BILLING SECTION (Cotización conditional)
   ══════════════════════════════════════════════════════════════════ */

.rwa-billing-section {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height .4s cubic-bezier(.4,0,.2,1), opacity .3s ease, margin .3s ease;
    margin-top: 0;
}

.rwa-billing-section.rwa-billing-visible {
    max-height: 400px;
    opacity: 1;
    margin-top: 4px;
}

.rwa-billing-header {
    display: flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, #f0fdf4, #ecfdf5);
    border: 1.5px solid #bbf7d0;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 700;
    color: #065f46;
    margin-bottom: 14px;
}

/* ── Boleta / Factura toggle ── */
.rwa-doctype-toggle {
    display: flex;
    gap: 8px;
    margin-top: 6px;
}

.rwa-doctype-btn,
.rwa-doctype-btn:focus,
.rwa-doctype-btn:hover,
.rwa-doctype-btn:active,
.rwa-doctype-btn:focus-visible {
    flex: 1;
    padding: 10px 14px;
    border-radius: 10px;
    border: 2px solid #e2e8f0 !important;
    background: #f8fafc !important;
    color: #64748b !important;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all .2s ease;
    text-align: center;
    -webkit-appearance: none;
    appearance: none;
    outline: none !important;
    box-shadow: none !important;
    font-family: 'Segoe UI', Arial, sans-serif;
}

.rwa-doctype-btn.rwa-doctype-active,
.rwa-doctype-btn.rwa-doctype-active:focus,
.rwa-doctype-btn.rwa-doctype-active:hover {
    border-color: #128C7E !important;
    background: linear-gradient(135deg, #f0fdf4, #ecfdf5) !important;
    color: #065f46 !important;
    box-shadow: 0 0 0 3px rgba(18,140,126,.12) !important;
}

.rwa-doctype-btn:hover:not(.rwa-doctype-active) {
    border-color: #cbd5e1 !important;
    background: #f1f5f9 !important;
    color: #334155 !important;
}

/* ══════════════════════════════════════════════════════════════════
   PEDIDO SECTION (Estado de Pedido conditional)
   ══════════════════════════════════════════════════════════════════ */

.rwa-pedido-section {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height .4s cubic-bezier(.4,0,.2,1), opacity .3s ease, margin .3s ease;
    margin-top: 0;
}

.rwa-pedido-section.rwa-pedido-visible {
    max-height: 180px;
    opacity: 1;
    margin-top: 4px;
}

.rwa-pedido-header {
    display: flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, #fff7ed, #ffedd5);
    border: 1.5px solid #fed7aa;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 700;
    color: #92400e;
    margin-bottom: 12px;
}

/* ══════════════════════════════════════════════════════════════════
   FACTURACIÓN SECTION (info card — no form fields)
   ══════════════════════════════════════════════════════════════════ */

.rwa-factura-section {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height .45s cubic-bezier(.4,0,.2,1), opacity .35s ease, margin .3s ease;
    margin-top: 0;
}

.rwa-factura-section.rwa-factura-visible {
    max-height: 320px;
    opacity: 1;
    margin-top: 4px;
    margin-bottom: 4px;
}

.rwa-factura-card {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
    border: 1.5px solid #bfdbfe;
    border-radius: 14px;
    padding: 18px 18px 16px;
    box-shadow: 0 2px 12px rgba(59,130,246,.08);
}

.rwa-factura-icon {
    font-size: 26px;
    line-height: 1;
    flex-shrink: 0;
    margin-top: 2px;
}

.rwa-factura-body {
    flex: 1;
    min-width: 0;
}

.rwa-factura-title {
    font-size: 14px;
    font-weight: 800;
    color: #1e3a8a;
    margin-bottom: 6px;
    letter-spacing: .1px;
}

.rwa-factura-text {
    font-size: 12.5px;
    color: #1d4ed8;
    margin: 0 0 8px;
    line-height: 1.5;
}

.rwa-factura-email {
    display: inline-block;
    font-size: 14px;
    font-weight: 800;
    color: #1d4ed8 !important;
    text-decoration: none !important;
    background: rgba(29,78,216,.08);
    border: 1.5px solid rgba(29,78,216,.2);
    border-radius: 8px;
    padding: 6px 14px;
    margin-bottom: 10px;
    letter-spacing: .3px;
    transition: background .2s, border-color .2s;
}

.rwa-factura-email:hover {
    background: rgba(29,78,216,.15) !important;
    border-color: rgba(29,78,216,.4) !important;
    color: #1e3a8a !important;
    text-decoration: none !important;
}

.rwa-factura-sub {
    font-size: 12px;
    color: #3b82f6;
    margin: 0 0 10px;
    line-height: 1.55;
}

.rwa-factura-sub strong {
    color: #1d4ed8;
    font-weight: 700;
}

.rwa-factura-note {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: rgba(255,255,255,.65);
    border: 1px solid #bfdbfe;
    border-radius: 20px;
    padding: 5px 12px;
    font-size: 11.5px;
    color: #1d4ed8;
    font-weight: 600;
}

.rwa-factura-note strong {
    color: #1e3a8a;
}
