/**
 * KBALeads — CSS Grid Framework & Form Styles
 *
 * All selectors are scoped to .kba-form-card to avoid conflicts with
 * other plugins or the active theme. Elementor style controls that use
 * the {{WRAPPER}} selector will override these defaults at widget level.
 *
 * @package KBALeads
 * @since   2.0.0
 */

/* ── Card ─────────────────────────────────────────────────────────────────── */

.kba-form-card {
    position: relative;
    padding: 40px;
    border-radius: 20px;
    background: #ffffff;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    box-sizing: border-box;
}

.kba-form-title {
    margin-top: 0;
    margin-bottom: 24px;
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e293b;
}

/* ── CSS Grid wrapper ─────────────────────────────────────────────────────── */

.kba-fields-wrapper {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 18px 20px;
    margin-bottom: 20px;
}

/* Column widths — map to grid-column span */
.kba-col-100 { grid-column: span 12; }
.kba-col-50  { grid-column: span 6; }
.kba-col-33  { grid-column: span 4; }
.kba-col-25  { grid-column: span 3; }

/* Layout overrides */
.kba-layout-vertical .kba-field-item  { grid-column: span 12 !important; }
.kba-layout-horizontal                { display: flex; flex-wrap: wrap; gap: 18px 20px; }
.kba-layout-horizontal .kba-field-item { flex: 1 1 auto; min-width: 150px; }

/* ── Field item ───────────────────────────────────────────────────────────── */

.kba-field-item {
    display: flex;
    flex-direction: column;
    min-width: 0; /* Prevent grid blowout */
}

/* ── Labels ───────────────────────────────────────────────────────────────── */

.kba-field-label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    color: #475569;
    line-height: 1.4;
}

.kba-required {
    color: #ef4444;
    margin-left: 2px;
}

/* ── Inputs ───────────────────────────────────────────────────────────────── */

.kba-input {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    background: #f8fafc;
    font-size: 1rem;
    color: #1e293b;
    box-sizing: border-box;
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
    -webkit-appearance: none;
    appearance: none;
}

.kba-input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
    background: #ffffff;
}

.kba-input::placeholder {
    color: #94a3b8;
}

.kba-textarea {
    resize: vertical;
    min-height: 100px;
}

/* ── Radio / Checkbox group ───────────────────────────────────────────────── */

.kba-option-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 20px;
    padding: 6px 0;
}

.kba-option-label {
    display: flex;
    align-items: center;
    gap: 7px;
    cursor: pointer;
    font-size: 0.95rem;
    color: #334155;
}

.kba-option-label input[type="radio"],
.kba-option-label input[type="checkbox"] {
    width: 17px;
    height: 17px;
    accent-color: #2563eb;
    cursor: pointer;
}

/* ── Switch / Toggle ──────────────────────────────────────────────────────── */

.kba-switch-wrap {
    display: flex;
    align-items: center;
    padding: 6px 0;
}

.kba-switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
    flex-shrink: 0;
}

.kba-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.kba-slider {
    position: absolute;
    inset: 0;
    background-color: #cbd5e1;
    border-radius: 34px;
    cursor: pointer;
    transition: background-color 0.35s ease;
}

.kba-slider::before {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    left: 4px;
    bottom: 4px;
    background: #ffffff;
    border-radius: 50%;
    transition: transform 0.35s ease;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.kba-switch input:checked + .kba-slider {
    background-color: #2563eb;
}

.kba-switch input:checked + .kba-slider::before {
    transform: translateX(24px);
}

.kba-switch input:focus-visible + .kba-slider {
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25);
}

/* ── File upload ──────────────────────────────────────────────────────────── */

.kba-file-wrap input[type="file"] {
    padding: 10px 0;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 0.9rem;
    color: #475569;
}

/* ── HTML block ───────────────────────────────────────────────────────────── */

.kba-html-block {
    padding: 4px 0;
    font-size: 0.95rem;
    color: #475569;
    line-height: 1.6;
}

/* ── Submit button ────────────────────────────────────────────────────────── */

.kba-submit {
    display: block;
    width: 100%;
    padding: 15px 24px;
    margin-top: 8px;
    background-color: #2563eb;
    color: #ffffff;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: background-color 0.25s ease, opacity 0.25s ease, transform 0.15s ease;
    line-height: 1.4;
}

.kba-submit:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.kba-submit:active {
    transform: translateY(0);
}

.kba-submit:focus-visible {
    outline: 3px solid rgba(37, 99, 235, 0.4);
    outline-offset: 2px;
}

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

.kba-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.75);
    display: none;
    align-items: center;
    justify-content: center;
    border-radius: inherit;
    z-index: 100;
    backdrop-filter: blur(2px);
}

.kba-overlay.is-active {
    display: flex;
}

.kba-spinner {
    width: 34px;
    height: 34px;
    border: 4px solid #e2e8f0;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: kba-spin 0.75s linear infinite;
}

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

/* ── Success modal ────────────────────────────────────────────────────────── */

.kba-modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 99999;
}

.kba-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(4px);
    cursor: pointer;
}

.kba-modal-content {
    position: relative;
    background: #ffffff;
    padding: 48px 40px;
    border-radius: 24px;
    text-align: center;
    max-width: 420px;
    width: 100%;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    animation: kba-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes kba-pop {
    from { opacity: 0; transform: scale(0.88); }
    to   { opacity: 1; transform: scale(1); }
}

.kba-modal-check {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    background: #dcfce7;
    color: #16a34a;
    border-radius: 50%;
    font-size: 2.2rem;
    margin: 0 auto 20px;
}

.kba-modal-content h2 {
    margin: 0 0 10px;
    font-size: 1.5rem;
    color: #1e293b;
}

.kba-modal-content p {
    color: #64748b;
    margin-bottom: 28px;
    line-height: 1.6;
}

/* ── intl-tel-input override — fits our input style ──────────────────────── */

.kba-form-card .iti {
    width: 100%;
}

.kba-form-card .iti__flag-container {
    z-index: 10;
}

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

@media (max-width: 768px) {
    .kba-col-50,
    .kba-col-33,
    .kba-col-25 {
        grid-column: span 12;
    }

    .kba-form-card {
        padding: 28px 20px;
    }

    .kba-layout-horizontal .kba-field-item {
        flex: 1 1 100%;
    }
}

@media (max-width: 480px) {
    .kba-modal-content {
        padding: 36px 24px;
    }
}
