/*
 * Scoppar Partner Onboarding — form.css  v1.2.0
 * Completely rebuilt. Production-grade, branded, accessible.
 * Design: Refined B2B — dark navy authority, gold accents, generous space.
 * Uses SC theme tokens; falls back to hardcoded values when theme absent.
 */

:root {
    --sp-navy:      var(--navy,    #001F3F);
    --sp-navy2:     var(--navy2,   #0B2C55);
    --sp-red:       var(--red,     #D32F2F);
    --sp-gold:      var(--gold,    #D4AF37);
    --sp-green:     var(--green,   #0D9B52);
    --sp-bg:        var(--bg,      #F4F6FB);
    --sp-surface:   var(--surface, #FFFFFF);
    --sp-border:    rgba(0,31,63,.09);
    --sp-text:      var(--text,    #0a1628);
    --sp-muted:     var(--muted,   #526070);
    --sp-muted2:    var(--muted2,  #8a99aa);
    --sp-radius:    12px;
    --sp-radius-lg: 20px;
    --sp-shadow:    0 1px 12px rgba(0,31,63,.07);
    --sp-shadow-md: 0 6px 28px rgba(0,31,63,.11);
    --sp-shadow-lg: 0 20px 60px rgba(0,31,63,.16);
}

/* ── Page shell ────────────────────────────────────────────────────────────── */
.sp-apply-wrap {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 0 80px;
    font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
    color: var(--sp-text);
    -webkit-font-smoothing: antialiased;
}

/* ── Language switcher ─────────────────────────────────────────────────────── */
.sp-lang-switcher {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 32px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--sp-border);
}
.sp-lang-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 16px;
    border-radius: 99px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none !important;
    border: 1.5px solid transparent;
    background: transparent;
    color: var(--sp-muted);
    transition: all .15s;
    white-space: nowrap;
}
.sp-lang-btn:hover {
    border-color: var(--sp-navy);
    color: var(--sp-navy);
    background: rgba(0,31,63,.04);
}
.sp-lang-btn.sp-lang-active {
    background: var(--sp-navy);
    border-color: var(--sp-navy);
    color: #fff;
}
@media (max-width: 480px) {
    .sp-lang-btn span { display: none; }
    .sp-lang-btn { padding: 8px 11px; }
}

/* Chinese font overrides */
[lang="zh-Hans"] .sp-form-title,
[lang="zh-Hans"] .sp-section-title,
[lang="zh-Hans"] .sp-label,
[lang="zh-Hans"] .sp-input,
[lang="zh-Hans"] .sp-select,
[lang="zh-Hans"] .sp-textarea,
[lang="zh-Hans"] .sp-btn,
[lang="zh-Hans"] .sp-checkbox-label,
[lang="zh-Hans"] .sp-form-note {
    font-family: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    letter-spacing: 0;
}

/* ── Form header ───────────────────────────────────────────────────────────── */
.sp-form-header { margin-bottom: 36px; }

.sp-form-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .11em;
    text-transform: uppercase;
    color: var(--sp-red);
    margin-bottom: 14px;
}
.sp-form-eyebrow::before {
    content: '';
    display: block;
    width: 20px;
    height: 2px;
    background: var(--sp-red);
    border-radius: 2px;
}
.sp-form-title {
    font-family: 'Manrope', sans-serif;
    font-size: clamp(26px, 4vw, 40px);
    font-weight: 900;
    color: var(--sp-navy);
    letter-spacing: -.025em;
    line-height: 1.08;
    margin-bottom: 14px;
}
.sp-form-desc {
    font-size: 16px;
    line-height: 1.72;
    color: var(--sp-muted);
    max-width: 580px;
}

/* ── Sections ──────────────────────────────────────────────────────────────── */
.sp-form-section {
    background: var(--sp-surface);
    border: 1px solid var(--sp-border);
    border-radius: var(--sp-radius-lg);
    padding: 30px 28px;
    margin-bottom: 14px;
    box-shadow: var(--sp-shadow);
    transition: box-shadow .2s;
    counter-increment: sp-section;
}
.sp-form-section:focus-within { box-shadow: var(--sp-shadow-md); }

.sp-section-title {
    font-family: 'Manrope', sans-serif;
    font-size: 15px;
    font-weight: 800;
    color: var(--sp-navy);
    margin: 0 0 22px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--sp-border);
    display: flex;
    align-items: center;
    gap: 11px;
    letter-spacing: -.01em;
}
/* Numbered badge per section */
.sp-form { counter-reset: sp-section; }
.sp-section-title::before {
    content: counter(sp-section);
    min-width: 24px;
    height: 24px;
    border-radius: 6px;
    background: var(--sp-navy);
    color: #fff;
    font-size: 11px;
    font-weight: 900;
    font-family: 'Manrope', sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* ── Grid ──────────────────────────────────────────────────────────────────── */
.sp-row { display: flex; flex-direction: column; gap: 16px; }
@media (min-width: 640px) {
    .sp-row-2 { flex-direction: row; gap: 20px; }
    .sp-row-2 > .sp-field { flex: 1; min-width: 0; }
}

/* ── Field ─────────────────────────────────────────────────────────────────── */
.sp-field { display: flex; flex-direction: column; margin-bottom: 18px; }
.sp-field:last-child { margin-bottom: 0; }

.sp-label {
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--sp-muted);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 5px;
}
.sp-req { color: var(--sp-red); font-size: 14px; line-height: 1; }

.sp-input,
.sp-select,
.sp-textarea {
    width: 100%;
    height: 52px;
    border: 1.5px solid #DDE4ED;
    border-radius: var(--sp-radius);
    padding: 0 16px;
    font-family: inherit;
    font-size: 15px;
    color: var(--sp-text);
    background: #FAFBFC;
    outline: none;
    transition: border-color .15s, box-shadow .15s, background .15s;
    box-sizing: border-box;
    appearance: none;
    -webkit-appearance: none;
}
.sp-textarea {
    height: auto;
    min-height: 110px;
    padding: 14px 16px;
    resize: vertical;
    line-height: 1.65;
}
.sp-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23526070' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 44px;
    cursor: pointer;
}
.sp-input:focus, .sp-select:focus, .sp-textarea:focus {
    border-color: var(--sp-navy);
    background: #fff;
    box-shadow: 0 0 0 3.5px rgba(0,31,63,.09);
}
.sp-input.is-error, .sp-select.is-error, .sp-textarea.is-error {
    border-color: var(--sp-red);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(211,47,47,.09);
}
.sp-field-error {
    font-size: 12.5px;
    color: var(--sp-red);
    margin-top: 6px;
    min-height: 18px;
    display: flex;
    align-items: center;
    gap: 5px;
}
.sp-field-error:not(:empty)::before { content: '⚠ '; font-size: 11px; }

/* ── Checkboxes ────────────────────────────────────────────────────────────── */
.sp-checkboxes {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 9px;
    padding: 2px 0;
}
.sp-checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13.5px;
    color: var(--sp-text);
    cursor: pointer;
    line-height: 1.4;
    padding: 11px 14px;
    border-radius: 9px;
    border: 1.5px solid #DDE4ED;
    background: #FAFBFC;
    transition: all .13s;
    user-select: none;
    font-weight: 500;
}
.sp-checkbox-label:hover {
    border-color: var(--sp-navy);
    background: rgba(0,31,63,.03);
    color: var(--sp-navy);
}
.sp-checkbox {
    width: 18px;
    height: 18px;
    border: 1.5px solid #CBD5E1;
    border-radius: 5px;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    flex-shrink: 0;
    background: #fff;
    transition: all .13s;
    position: relative;
}
.sp-checkbox:checked {
    background: var(--sp-navy);
    border-color: var(--sp-navy);
}
.sp-checkbox:checked::after {
    content: '';
    position: absolute;
    left: 4px; top: 1px;
    width: 6px; height: 10px;
    border: 2px solid #fff;
    border-top: none; border-left: none;
    transform: rotate(45deg);
}
/* Checked card highlight */
.sp-checkbox-label:has(.sp-checkbox:checked) {
    border-color: var(--sp-navy);
    background: rgba(0,31,63,.05);
    color: var(--sp-navy);
    font-weight: 700;
}

/* Terms row */
.sp-terms-label {
    font-size: 14.5px;
    line-height: 1.65;
    color: var(--sp-muted);
    padding: 0;
    border: none;
    background: transparent;
    gap: 12px;
}
.sp-terms-label:hover { border: none; background: transparent; }
.sp-terms-label a {
    color: var(--sp-navy);
    font-weight: 600;
    text-decoration: underline;
    text-decoration-color: rgba(0,31,63,.22);
    text-underline-offset: 2px;
}
.sp-terms-error { margin-top: 10px; }

/* ── Flash messages ────────────────────────────────────────────────────────── */
.sp-flash {
    padding: 14px 18px;
    border-radius: var(--sp-radius);
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 20px;
    line-height: 1.55;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}
.sp-flash-error  { background: #FEF2F2; color: #991B1B; border: 1px solid #FECACA; }
.sp-flash-success{ background: #F0FDF4; color: #065F46; border: 1px solid #A7F3D0; }

/* ── Submit footer ─────────────────────────────────────────────────────────── */
.sp-form-footer {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    margin-top: 8px;
    padding: 28px;
    background: var(--sp-surface);
    border: 1px solid var(--sp-border);
    border-radius: var(--sp-radius-lg);
    box-shadow: var(--sp-shadow);
}
.sp-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    padding: 15px 32px;
    border-radius: 11px;
    font-family: 'Manrope', sans-serif;
    font-weight: 800;
    font-size: 15px;
    text-decoration: none !important;
    border: none;
    cursor: pointer;
    transition: all .18s cubic-bezier(.4,0,.2,1);
    min-height: 52px;
    white-space: nowrap;
    letter-spacing: -.01em;
}
.sp-btn:focus-visible { outline: 3px solid rgba(0,31,63,.25); outline-offset: 3px; }
.sp-btn:active { transform: scale(.98); }
.sp-btn-primary { background: var(--sp-navy); color: #fff; box-shadow: 0 4px 16px rgba(0,31,63,.2); }
.sp-btn-primary:hover { background: var(--sp-navy2); transform: translateY(-1px); box-shadow: 0 8px 24px rgba(0,31,63,.26); }
.sp-btn-primary:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }
.sp-btn-navy  { background: var(--sp-navy);  color: #fff; }
.sp-btn-navy:hover { background: var(--sp-navy2); transform: translateY(-1px); }
.sp-btn-ghost-dark { background: #fff; color: var(--sp-navy); border: 1.5px solid #DDE4ED; }
.sp-btn-ghost-dark:hover { border-color: var(--sp-navy); background: var(--sp-bg); }
.sp-btn-spinner { animation: sp-spin 1s linear infinite; display: inline-block; }
@keyframes sp-spin { to { transform: rotate(360deg); } }
.sp-form-note { font-size: 13px; color: var(--sp-muted2); margin: 0; line-height: 1.55; }

/* ── Success state ─────────────────────────────────────────────────────────── */
.sp-success-state {
    text-align: center;
    padding: 64px 28px 56px;
    background: var(--sp-surface);
    border: 1px solid var(--sp-border);
    border-radius: 24px;
    box-shadow: var(--sp-shadow-lg);
    position: relative;
    overflow: hidden;
}
.sp-success-state::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--sp-gold) 0%, var(--sp-green) 100%);
}
.sp-success-icon {
    width: 76px; height: 76px;
    border-radius: 50%;
    background: linear-gradient(135deg, #DCFCE7, #BBF7D0);
    color: #166534;
    font-size: 34px;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 26px;
    box-shadow: 0 8px 24px rgba(21,128,61,.16);
}
.sp-success-state h2 {
    font-family: 'Manrope', sans-serif;
    font-size: clamp(22px, 4vw, 30px);
    font-weight: 900;
    color: var(--sp-navy);
    margin-bottom: 12px;
    letter-spacing: -.022em;
}
.sp-success-state p {
    font-size: 15.5px;
    color: var(--sp-muted);
    max-width: 460px;
    margin: 0 auto 32px;
    line-height: 1.72;
}

/* ── Mobile ────────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
    .sp-form-section { padding: 22px 18px; }
    .sp-form-footer  { flex-direction: column; align-items: stretch; padding: 22px 18px; }
    .sp-btn          { width: 100%; justify-content: center; }
    .sp-checkboxes   { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 380px) {
    .sp-checkboxes { grid-template-columns: 1fr; }
}

/* ── Admin modal fix ───────────────────────────────────────────────────────── */
#spa-approve-modal { display: flex !important; }
#spa-approve-modal[style*="display:none"] { display: none !important; }
