/**
 * NovatraCloud Native Order Form — Modern Card-Based Design
 *
 * Mobile-first. JS-driven card selection. Smooth animations.
 * 44px+ touch targets. Works in all modern browsers (no :has()).
 *
 * @package NovatraCloud_Connect
 * @since   1.5.0
 */

/* ── CSS Variables ──────────────────────────────────────────── */
:root {
    --ncf-brand: #10b981;           /* emerald-500 */
    --ncf-brand-dark: #059669;      /* emerald-600 */
    --ncf-brand-light: #ecfdf5;     /* emerald-50 */
    --ncf-brand-lime: #a3e635;      /* lime-400 */
    --ncf-brand-ring: rgba(16, 185, 129, 0.18);
    --ncf-red: #dc2626;
    --ncf-red-light: #fef2f2;
    --ncf-green: #059669;
    --ncf-green-light: #ecfdf5;
    --ncf-gray-50: #f9fafb;
    --ncf-gray-100: #f3f4f6;
    --ncf-gray-200: #e5e7eb;
    --ncf-gray-300: #d1d5db;
    --ncf-gray-400: #9ca3af;
    --ncf-gray-500: #6b7280;
    --ncf-gray-700: #374151;
    --ncf-gray-900: #111827;
    --ncf-radius: 10px;
    --ncf-radius-lg: 14px;
    --ncf-shadow: 0 1px 3px rgba(0,0,0,0.08);
    --ncf-shadow-lg: 0 4px 12px rgba(0,0,0,0.08);
}

/* ── Wrapper ────────────────────────────────────────────────── */
.ncf-wrapper {
    max-width: 680px;
    margin: 0 auto;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--ncf-gray-900);
    line-height: 1.6;
}

.ncf-section-title {
    font-family: 'Instrument Serif', 'Inter', Georgia, serif;
    font-size: 26px;
    font-weight: 400;
    font-style: italic;
    margin: 0 0 16px;
    letter-spacing: -0.02em;
    color: var(--ncf-accent, var(--ncf-brand));
}

/* ── Sections ───────────────────────────────────────────────── */
.ncf-section {
    margin-bottom: 24px;
}

/* ── Grid ───────────────────────────────────────────────────── */
.ncf-grid-2 {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 12px;
}

@media (min-width: 500px) {
    .ncf-grid-2 {
        grid-template-columns: 1fr 1fr;
    }
}

/* ── Fields ─────────────────────────────────────────────────── */
.ncf-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.ncf-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--ncf-gray-700);
    letter-spacing: 0.01em;
}

.ncf-required {
    color: var(--ncf-red);
    font-weight: 700;
}

.ncf-input,
.ncf-select,
.ncf-textarea {
    width: 100%;
    padding: 11px 14px;
    font-size: 15px;
    font-family: inherit;
    color: var(--ncf-gray-900);
    background: #fff;
    border: 1.5px solid var(--ncf-gray-300);
    border-radius: var(--ncf-radius);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
    min-height: 46px;
    -webkit-appearance: none;
    appearance: none;
}

.ncf-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='m1 1.5 5 5 5-5' stroke='%236b7280' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
    cursor: pointer;
}

.ncf-textarea {
    resize: vertical;
    min-height: 80px;
}

.ncf-input:focus,
.ncf-select:focus,
.ncf-textarea:focus {
    outline: none;
    border-color: var(--ncf-accent, var(--ncf-brand));
    box-shadow: 0 0 0 3px var(--ncf-brand-ring);
}

.ncf-input::placeholder,
.ncf-textarea::placeholder {
    color: var(--ncf-gray-400);
}

/* ── Error state ────────────────────────────────────────────── */
.ncf-input-error {
    border-color: var(--ncf-red) !important;
    box-shadow: 0 0 0 3px rgba(220,38,38,0.1) !important;
}

.ncf-error {
    font-size: 12px;
    color: var(--ncf-red);
    display: none;
    margin-top: 2px;
}

.ncf-error.is-visible {
    display: block;
    animation: ncfFadeIn 0.2s ease;
}

/* ── Product Cards ──────────────────────────────────────────── */
.ncf-cards {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ncf-card {
    position: relative;
    display: block;
    cursor: pointer;
    border: 2px solid var(--ncf-gray-200);
    border-radius: var(--ncf-radius-lg);
    background: #fff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease, background-color 0.25s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}

.ncf-card:focus-visible {
    box-shadow: 0 0 0 3px var(--ncf-brand-ring);
}

.ncf-card:hover {
    border-color: var(--ncf-accent, var(--ncf-brand));
    box-shadow: var(--ncf-shadow-lg);
    transform: translateY(-1px);
}

.ncf-card:active {
    transform: scale(0.985);
}

/* ── Selected state ─────────────────────────────────────────── */
.ncf-card--selected {
    border-color: var(--ncf-accent, var(--ncf-brand)) !important;
    background: color-mix(in srgb, var(--ncf-accent, var(--ncf-brand)) 8%, #fff) !important;
    box-shadow: 0 0 0 3px var(--ncf-brand-ring), var(--ncf-shadow) !important;
    transform: translateY(-2px);
}

.ncf-card-inner {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 18px;
}

.ncf-card-price {
    font-size: 20px;
    font-weight: 800;
    color: var(--ncf-accent, var(--ncf-brand));
    letter-spacing: -0.02em;
    white-space: nowrap;
    flex-shrink: 0;
    min-width: 80px;
    text-align: right;
    transition: transform 0.2s ease;
}

.ncf-card--selected .ncf-card-price {
    transform: scale(1.05);
}

.ncf-card-desc {
    flex: 1;
    font-size: 14px;
    line-height: 1.45;
    color: var(--ncf-gray-700);
    min-width: 0;
}

/* ── "Selected" badge ───────────────────────────────────────── */
.ncf-card-badge {
    display: none;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ncf-accent, var(--ncf-brand));
    background: rgba(16, 185, 129, 0.08);
    padding: 3px 8px;
    border-radius: 4px;
    flex-shrink: 0;
    animation: ncfFadeIn 0.3s ease;
}

.ncf-card--selected .ncf-card-badge {
    display: block;
}

/* ── Checkmark ──────────────────────────────────────────────── */
.ncf-card-check {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
}

/* Circle fills on selection */
.ncf-check-circle {
    transition: fill 0.25s ease;
}

.ncf-card--selected .ncf-check-circle {
    fill: var(--ncf-accent, var(--ncf-brand));
    stroke: var(--ncf-accent, var(--ncf-brand));
}

/* Tick animates in */
.ncf-check-tick {
    stroke-dasharray: 20;
    stroke-dashoffset: 20;
    transition: stroke-dashoffset 0.35s ease 0.1s, stroke 0.25s ease;
}

.ncf-card--selected .ncf-check-tick {
    stroke: #fff;
    stroke-dashoffset: 0;
}

/* ── Mobile card layout ─────────────────────────────────────── */
@media (max-width: 399px) {
    .ncf-card-inner {
        flex-wrap: wrap;
        gap: 6px;
    }

    .ncf-card-price {
        font-size: 18px;
        text-align: left;
        min-width: unset;
    }

    .ncf-card-desc {
        order: 3;
        width: 100%;
    }

    .ncf-card-check {
        position: absolute;
        top: 14px;
        right: 14px;
    }

    .ncf-card-badge {
        order: 2;
    }
}

/* ── Contact link ───────────────────────────────────────────── */
.ncf-contact {
    margin: 12px 0 0;
    font-size: 13px;
    color: var(--ncf-gray-500);
    text-align: center;
}

.ncf-contact a {
    color: var(--ncf-accent, var(--ncf-brand));
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
}

.ncf-contact a:hover {
    color: var(--ncf-brand-dark);
    text-decoration: underline;
}

/* ── Submit button ──────────────────────────────────────────── */
.ncf-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 16px 32px;
    font-size: 17px;
    font-weight: 700;
    font-family: inherit;
    color: var(--ncf-btn-text, #060f0c);
    background: var(--ncf-btn-bg, #10b981);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.2s ease, opacity 0.2s ease, filter 0.2s ease;
    min-height: 54px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    margin-top: 6px;
    letter-spacing: 0.01em;
}

.ncf-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.18);
    filter: brightness(1.05);
}

.ncf-submit:active {
    transform: scale(0.97);
}

.ncf-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ── Spinner ────────────────────────────────────────────────── */
@keyframes ncfSpin {
    to { transform: rotate(360deg); }
}

.ncf-spinner {
    animation: ncfSpin 0.7s linear infinite;
}

/* ── Messages ───────────────────────────────────────────────── */
.ncf-message {
    margin-top: 18px;
    padding: 14px 18px;
    border-radius: var(--ncf-radius);
    font-size: 14px;
    font-weight: 500;
    line-height: 1.5;
    animation: ncfSlideUp 0.35s ease;
}

.ncf-message--success {
    background: var(--ncf-green-light);
    border: 1px solid #6ee7b7;
    color: var(--ncf-green);
}

.ncf-message--error {
    background: var(--ncf-red-light);
    border: 1px solid #fca5a5;
    color: #991b1b;
}

/* ── Animations ─────────────────────────────────────────────── */
@keyframes ncfFadeIn {
    from { opacity: 0; transform: translateY(-3px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes ncfSlideUp {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes ncfPopIn {
    0%   { transform: scale(0.85); opacity: 0; }
    60%  { transform: scale(1.04); }
    100% { transform: scale(1); opacity: 1; }
}

/* Staggered card entrance */
.ncf-card {
    animation: ncfFadeIn 0.4s ease backwards;
}
.ncf-card:nth-child(1) { animation-delay: 0.00s; }
.ncf-card:nth-child(2) { animation-delay: 0.06s; }
.ncf-card:nth-child(3) { animation-delay: 0.12s; }
.ncf-card:nth-child(4) { animation-delay: 0.18s; }
.ncf-card:nth-child(5) { animation-delay: 0.24s; }
.ncf-card:nth-child(6) { animation-delay: 0.30s; }

/* Badge pop-in on selection */
.ncf-card--selected .ncf-card-badge {
    animation: ncfPopIn 0.35s ease;
}

/* ── Reduced motion ─────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .ncf-card,
    .ncf-card-badge,
    .ncf-message,
    .ncf-error,
    .ncf-check-tick {
        animation: none !important;
        transition: none !important;
    }
}

/* ── Desktop ────────────────────────────────────────────────── */
@media (min-width: 768px) {
    .ncf-wrapper {
        max-width: 700px;
    }

    .ncf-card-price {
        font-size: 22px;
        min-width: 100px;
    }

    .ncf-card-inner {
        padding: 18px 22px;
    }
}
