/**
 * Net Feasibility Survey — Front-end styles.
 * Modern, mobile-first, accessible.
 */

:root {
    --nfs-primary: #2563eb;
    --nfs-primary-dark: #1d4ed8;
    --nfs-primary-light: #dbeafe;
    --nfs-gradient: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
    --nfs-accent: #7c3aed;
    --nfs-success: #10b981;
    --nfs-success-light: #d1fae5;
    --nfs-danger: #ef4444;
    --nfs-danger-light: #fee2e2;
    --nfs-warning: #f59e0b;
    --nfs-text: #0f172a;
    --nfs-text-muted: #64748b;
    --nfs-border: #e2e8f0;
    --nfs-border-strong: #cbd5e1;
    --nfs-bg: #ffffff;
    --nfs-bg-soft: #f8fafc;
    --nfs-radius: 12px;
    --nfs-radius-lg: 16px;
    --nfs-shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
    --nfs-shadow: 0 4px 12px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.05);
    --nfs-shadow-lg: 0 20px 40px rgba(15, 23, 42, 0.12), 0 8px 16px rgba(15, 23, 42, 0.08);
    --nfs-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Arial,
                "Noto Sans Devanagari", "Mangal", sans-serif;
}

.nfs-form-wrapper {
    width: 100%;
    max-width: 820px;
    margin: 24px auto;
    padding: 0 12px;
    font-family: var(--nfs-font);
    color: var(--nfs-text);
    box-sizing: border-box;
}

.nfs-form-wrapper *,
.nfs-form-wrapper *::before,
.nfs-form-wrapper *::after {
    box-sizing: border-box;
}

.nfs-form {
    background: var(--nfs-bg);
    border-radius: var(--nfs-radius-lg);
    box-shadow: var(--nfs-shadow-lg);
    overflow: hidden;
    border: 1px solid var(--nfs-border);
    animation: nfs-slide-up 0.35s ease-out;
}

@keyframes nfs-slide-up {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ==========================================================
   HEADER
   ========================================================== */
.nfs-form-header {
    background: var(--nfs-gradient);
    color: #fff;
    padding: 28px 24px 32px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.nfs-form-header::after {
    content: "";
    position: absolute;
    left: 0; right: 0; bottom: -1px;
    height: 24px;
    background:
        radial-gradient(circle at 10px 0, transparent 12px, var(--nfs-bg) 13px) repeat-x;
    background-size: 20px 24px;
    opacity: 0;           /* visual seam is already smooth; keep for future use */
}

.nfs-form-header-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
    backdrop-filter: blur(8px);
    margin-bottom: 14px;
    color: #fff;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
}

.nfs-form-title {
    margin: 0;
    font-size: clamp(16px, 4.2vw, 22px);
    line-height: 1.45;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: #fff;
}

.nfs-form-subtitle {
    margin: 8px 0 0;
    color: rgba(255, 255, 255, 0.85);
    font-size: clamp(12px, 3vw, 14px);
    font-weight: 500;
}

/* ==========================================================
   BODY
   ========================================================== */
.nfs-form-body {
    padding: 24px 20px 28px;
}

@media (min-width: 640px) {
    .nfs-form-body { padding: 32px 36px 36px; }
}

/* Section header with numbered badge */
.nfs-section-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 28px 0 18px;
    padding-bottom: 14px;
    border-bottom: 2px dashed var(--nfs-border);
}

.nfs-section-header:first-of-type {
    margin-top: 4px;
}

.nfs-step-badge {
    flex: 0 0 36px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--nfs-gradient);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.3);
}

.nfs-section-title {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    color: var(--nfs-text);
    line-height: 1.3;
}

.nfs-section-subtitle {
    margin: 2px 0 0;
    font-size: 13px;
    color: var(--nfs-text-muted);
    font-weight: 400;
}

/* ==========================================================
   GRIDS
   ========================================================== */
.nfs-grid {
    display: grid;
    gap: 16px;
}

@media (min-width: 640px) {
    .nfs-grid-2 { grid-template-columns: repeat(2, 1fr); }
    .nfs-grid-3 { grid-template-columns: repeat(3, 1fr); }
    .nfs-col-span-2 { grid-column: span 2; }
}

/* ==========================================================
   FIELDS
   ========================================================== */
.nfs-field {
    margin-bottom: 18px;
    position: relative;
}

.nfs-grid .nfs-field {
    margin-bottom: 0;
}

.nfs-field label,
.nfs-field .nfs-label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--nfs-text);
    font-size: 14px;
    line-height: 1.4;
}

.nfs-field input[type="text"],
.nfs-field input[type="number"],
.nfs-field select {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--nfs-border);
    border-radius: 10px;
    font-size: 16px;              /* 16px prevents iOS auto-zoom */
    background: var(--nfs-bg);
    color: var(--nfs-text);
    font-family: inherit;
    -webkit-appearance: none;
    appearance: none;
    transition: all 0.15s;
    line-height: 1.4;
}

.nfs-field select {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%2364748b' d='M6 8L0 0h12z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 12px 8px;
    padding-right: 40px;
    cursor: pointer;
}

/* ==========================================================
   PROVIDER SELECT — theme-colored dropdown (works on mobile)
   ========================================================== */
.nfs-field select[name="current_provider"] {
    border: 1.5px solid var(--nfs-primary);
    color: var(--nfs-primary);
    font-weight: 600;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%232563eb' d='M6 8L0 0h12z'/></svg>");
    background-color: var(--nfs-bg);
}

.nfs-field select[name="current_provider"]:hover {
    border-color: #7c3aed;
}

.nfs-field select[name="current_provider"]:focus {
    border-color: #7c3aed;
    box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.18);
}

/* Colour the <option> list itself — honoured on Android + desktop.
   iOS uses a native picker that ignores these styles, but the select field
   itself still picks up the theme treatment above. */
.nfs-field select[name="current_provider"] option {
    background-color: #ffffff;
    color: var(--nfs-text);
    font-weight: 500;
    padding: 10px;
}

.nfs-field select[name="current_provider"] option:checked,
.nfs-field select[name="current_provider"] option:hover,
.nfs-field select[name="current_provider"] option:focus {
    background: linear-gradient(0deg, #2563eb, #2563eb);
    background-color: #2563eb !important;
    color: #ffffff !important;
}

/* Mobile: extra-bold theme treatment so the dropdown stands out on small screens. */
@media (max-width: 600px) {
    .nfs-field select[name="current_provider"] {
        border-width: 2px;
        background-image:
            linear-gradient(0deg, rgba(37, 99, 235, 0.04), rgba(124, 58, 237, 0.04)),
            url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%237c3aed' d='M6 8L0 0h12z'/></svg>");
        background-repeat: no-repeat, no-repeat;
        background-position: center, right 14px center;
        background-size: cover, 12px 8px;
    }
}

.nfs-field input:hover,
.nfs-field select:hover {
    border-color: var(--nfs-border-strong);
}

.nfs-field input:focus,
.nfs-field select:focus {
    outline: none;
    border-color: var(--nfs-primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.nfs-required {
    color: var(--nfs-danger);
    margin-left: 3px;
    font-weight: 400;
}

/* ==========================================================
   RADIO GROUPS — pill-style
   ========================================================== */
.nfs-radio-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

@media (min-width: 520px) {
    .nfs-radio-group {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 12px;
    }
}

.nfs-radio {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border: 1.5px solid var(--nfs-border);
    border-radius: 10px;
    background: var(--nfs-bg);
    font-weight: 500;
    font-size: 15px;
    cursor: pointer;
    min-height: 48px;
    transition: all 0.15s;
    user-select: none;
    position: relative;
}

.nfs-radio:hover {
    border-color: var(--nfs-primary);
    background: var(--nfs-primary-light);
}

.nfs-radio input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.nfs-radio-check {
    flex: 0 0 20px;
    width: 20px;
    height: 20px;
    border: 2px solid var(--nfs-border-strong);
    border-radius: 50%;
    background: #fff;
    position: relative;
    transition: all 0.15s;
}

.nfs-radio-check::after {
    content: "";
    position: absolute;
    inset: 3px;
    border-radius: 50%;
    background: var(--nfs-primary);
    transform: scale(0);
    transition: transform 0.15s;
}

.nfs-radio input:checked + .nfs-radio-check {
    border-color: var(--nfs-primary);
}

.nfs-radio input:checked + .nfs-radio-check::after {
    transform: scale(1);
}

.nfs-radio:has(input:checked) {
    border-color: var(--nfs-primary);
    background: var(--nfs-primary-light);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.15);
}

.nfs-radio input:focus-visible + .nfs-radio-check {
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.18);
}

/* ==========================================================
   CONDITIONAL SECTIONS
   ========================================================== */
.nfs-conditional {
    display: none;
    border: 1.5px solid var(--nfs-border);
    border-radius: var(--nfs-radius);
    padding: 18px 18px 6px;
    margin: 16px 0;
    background: var(--nfs-bg-soft);
    position: relative;
}

.nfs-conditional.is-visible {
    display: block;
    animation: nfs-fade-in 0.25s ease-out;
}

@keyframes nfs-fade-in {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: none; }
}

.nfs-conditional legend {
    font-weight: 700;
    padding: 4px 12px;
    color: var(--nfs-primary);
    font-size: 13px;
    background: var(--nfs-bg);
    border: 1.5px solid var(--nfs-border);
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ==========================================================
   SUBMIT BUTTON
   ========================================================== */
.nfs-actions {
    margin-top: 28px;
    display: flex;
    justify-content: center;
}

.nfs-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    max-width: 320px;
    padding: 14px 28px;
    background: var(--nfs-gradient);
    color: #fff;
    border: 0;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    min-height: 52px;
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.3);
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}

.nfs-submit:hover,
.nfs-submit:focus {
    transform: translateY(-1px);
    box-shadow: 0 12px 24px rgba(37, 99, 235, 0.4);
    outline: none;
}

.nfs-submit:active {
    transform: translateY(0);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.nfs-submit svg {
    flex-shrink: 0;
}

/* Shine hover effect */
.nfs-submit::before {
    content: "";
    position: absolute;
    top: 0; left: -100%;
    width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.25), transparent);
    transition: left 0.5s;
}

.nfs-submit:hover::before {
    left: 100%;
}

/* ==========================================================
   ALERTS
   ========================================================== */
.nfs-alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 14px 16px;
    border-radius: 10px;
    margin: 0 0 18px;
    font-weight: 500;
    font-size: 14px;
    max-width: 820px;
    margin-left: auto;
    margin-right: auto;
    animation: nfs-slide-up 0.3s ease-out;
}

.nfs-alert-icon {
    font-size: 18px;
    flex-shrink: 0;
    line-height: 1;
}

.nfs-alert-success {
    background: var(--nfs-success-light);
    border: 1px solid #86efac;
    color: #065f46;
}

.nfs-alert-error {
    background: var(--nfs-danger-light);
    border: 1px solid #fca5a5;
    color: #991b1b;
}

/* Field-level errors */
.nfs-has-error input,
.nfs-has-error select,
.nfs-has-error .nfs-radio-group .nfs-radio {
    border-color: var(--nfs-danger);
}

.nfs-has-error input:focus,
.nfs-has-error select:focus {
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.15);
}

.nfs-field-error {
    color: var(--nfs-danger);
    font-size: 13px;
    margin-top: 6px;
    font-weight: 500;
}

/* Honeypot */
.nfs-hp {
    position: absolute !important;
    left: -9999px !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
    opacity: 0 !important;
}

/* ==========================================================
   INLINE SUCCESS PANEL (renders at bottom of form)
   ========================================================== */
.nfs-success-panel {
    margin-top: 26px;
    padding: 24px;
    background: linear-gradient(135deg, #ecfdf5 0%, #f0fdf4 100%);
    border: 2px solid #86efac;
    border-radius: var(--nfs-radius-lg);
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
    gap: 16px 18px;
    align-items: center;
    animation: nfs-success-in 0.5s ease-out;
    box-shadow: 0 8px 24px rgba(16, 185, 129, 0.12);
    position: relative;
    overflow: hidden;
}

.nfs-success-panel::before {
    content: "";
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, #10b981, #34d399, #10b981);
    background-size: 200% 100%;
    animation: nfs-shimmer 2.5s linear infinite;
}

@keyframes nfs-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

@keyframes nfs-success-in {
    from { opacity: 0; transform: translateY(14px) scale(0.98); }
    to   { opacity: 1; transform: none; }
}

.nfs-success-check {
    grid-row: 1 / 2;
    grid-column: 1 / 2;
    width: 68px;
    height: 68px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
    flex-shrink: 0;
}

.nfs-check-circle {
    stroke: var(--nfs-success);
    stroke-dasharray: 166;
    stroke-dashoffset: 166;
    animation: nfs-draw-circle 0.6s ease-in-out 0.15s forwards;
}

.nfs-check-tick {
    stroke: var(--nfs-success);
    stroke-dasharray: 48;
    stroke-dashoffset: 48;
    animation: nfs-draw-tick 0.3s ease-out 0.65s forwards;
}

@keyframes nfs-draw-circle {
    to { stroke-dashoffset: 0; }
}
@keyframes nfs-draw-tick {
    to { stroke-dashoffset: 0; }
}

.nfs-success-body {
    grid-row: 1 / 2;
    grid-column: 2 / 3;
}

.nfs-success-title {
    margin: 0 0 4px;
    font-size: 18px;
    font-weight: 800;
    color: #065f46;
    line-height: 1.35;
}

.nfs-success-sub {
    margin: 0 0 6px;
    color: #047857;
    font-size: 14px;
    line-height: 1.5;
}

.nfs-success-ref {
    display: inline-block;
    margin: 4px 0 0;
    padding: 3px 10px;
    background: #fff;
    border: 1px solid #86efac;
    border-radius: 999px;
    color: #065f46;
    font-size: 12px;
    font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
    font-weight: 700;
}

.nfs-success-actions {
    grid-row: 2 / 3;
    grid-column: 1 / 3;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 4px;
}

@media (min-width: 560px) {
    .nfs-success-actions {
        flex-direction: row;
    }
}

/* Mobile: stack icon above text */
@media (max-width: 480px) {
    .nfs-success-panel {
        grid-template-columns: 1fr;
        text-align: center;
        padding: 20px;
    }
    .nfs-success-check {
        grid-row: auto;
        grid-column: auto;
        margin: 0 auto;
        width: 64px;
        height: 64px;
    }
    .nfs-success-body {
        grid-row: auto;
        grid-column: auto;
    }
    .nfs-success-actions {
        grid-row: auto;
        grid-column: auto;
    }
}

/* Hide whole form sections when success panel is shown via JS */
.nfs-form.is-submitted .nfs-actions { display: none; }
.nfs-success-panel.is-hidden { display: none; }

.nfs-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 22px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    min-height: 46px;
    border: 1.5px solid transparent;
    transition: all 0.15s;
}

.nfs-btn-primary {
    background: var(--nfs-gradient);
    color: #fff;
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.25);
}

.nfs-btn-primary:hover,
.nfs-btn-primary:focus {
    transform: translateY(-1px);
    box-shadow: 0 10px 20px rgba(37, 99, 235, 0.35);
    outline: none;
}

.nfs-btn-ghost {
    background: transparent;
    color: var(--nfs-text);
    border-color: var(--nfs-border-strong);
}

.nfs-btn-ghost:hover,
.nfs-btn-ghost:focus {
    background: var(--nfs-bg-soft);
    outline: none;
}

/* ==========================================================
   RESPONSIVE TWEAKS
   ========================================================== */
@media (max-width: 400px) {
    .nfs-form-header { padding: 22px 16px 26px; }
    .nfs-form-header-icon {
        width: 56px; height: 56px;
    }
    .nfs-form-header-icon svg { width: 32px; height: 32px; }
    .nfs-form-body { padding: 20px 16px 24px; }
    .nfs-success-panel { padding: 18px; }
    .nfs-success-title { font-size: 16px; }
}

/* Print */
@media print {
    .nfs-submit, .nfs-alert, .nfs-success-actions { display: none !important; }
    .nfs-form { box-shadow: none; border: 1px solid #ddd; }
    .nfs-form-header { background: #2563eb !important; -webkit-print-color-adjust: exact; color-adjust: exact; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .nfs-form, .nfs-alert, .nfs-conditional.is-visible,
    .nfs-success-panel, .nfs-check-circle, .nfs-check-tick,
    .nfs-geo-spinner {
        animation: none !important;
        transition: none !important;
    }
}

/* ======= GPS capture field ======= */
.nfs-geo-field .nfs-optional {
    font-weight: 400;
    color: #6b7280;
    margin-left: 4px;
    font-size: 12px;
}
.nfs-geo-field .nfs-help {
    margin: 4px 0 10px;
    color: #6b7280;
    font-size: 13px;
    line-height: 1.45;
}
.nfs-geo-controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.nfs-btn-geo {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 10px;
    border: 1px solid #2563eb;
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: transform .15s ease, box-shadow .15s ease, opacity .15s ease;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.22);
}
.nfs-btn-geo:hover  { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(37, 99, 235, 0.28); }
.nfs-btn-geo:active { transform: translateY(0); }
.nfs-geo-field.is-capturing .nfs-btn-geo { opacity: 0.75; cursor: wait; }
.nfs-geo-field.is-captured  .nfs-btn-geo {
    background: #fff;
    color: #2563eb;
    border-color: #2563eb;
    box-shadow: none;
}
.nfs-btn-geo-clear {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    background: #fff;
    color: #6b7280;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}
.nfs-btn-geo-clear:hover { background: #f9fafb; color: #374151; }

.nfs-geo-status {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-top: 10px;
    font-size: 13px;
    line-height: 1.5;
    color: #374151;
    min-height: 20px;
}
.nfs-geo-status:empty { display: none; }
.nfs-geo-status a { color: #2563eb; text-decoration: underline; word-break: break-word; }
.nfs-geo-field.is-captured .nfs-geo-status { color: #047857; }
.nfs-geo-field.is-captured .nfs-geo-status svg { color: #10b981; flex-shrink: 0; margin-top: 2px; }
.nfs-geo-field.is-error .nfs-geo-status { color: #b91c1c; }
.nfs-geo-field.is-error .nfs-geo-status svg { color: #dc2626; flex-shrink: 0; margin-top: 2px; }

.nfs-geo-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid #dbeafe;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: nfs-spin 0.7s linear infinite;
    flex-shrink: 0;
    margin-top: 2px;
}
@keyframes nfs-spin { to { transform: rotate(360deg); } }

@media (max-width: 520px) {
    .nfs-btn-geo, .nfs-btn-geo-clear { width: 100%; justify-content: center; }
    .nfs-geo-controls { flex-direction: column; }
}
