/* Enterprise Client Onboarding System - Styles */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --primary: #1e3a5f;
    --primary-dark: #152a45;
    --primary-light: #2d4a6f;
    --accent: #5a7a9a;
    --bg: #ffffff;
    --card-bg: transparent;
    --text: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
    --input-bg: #f8fafc;
    --shadow: none;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: #ffffff;
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Container */
.onboarding-container {
    width: 100%;
    max-width: 520px;
    margin: 0 auto;
}

/* Card */
.onboarding-card {
    background: transparent;
    position: relative;
    text-align: center;
}

/* Back Button - Floating Top Left */
.btn-back {
    position: absolute;
    top: 0;
    left: 0;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 2px solid var(--border);
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-secondary);
    padding: 0;
}

.btn-back:hover {
    background: var(--input-bg);
    border-color: var(--primary);
    color: var(--primary);
    transform: translateX(-2px);
}

.btn-back:active {
    transform: translateX(-4px);
}

.btn-back svg {
    display: block;
}

/* Step Content */
.step-content {
    padding: 0;
    min-height: 450px;
    position: relative;
}

/* Logo on welcome screen */
.step-panel .logo {
    margin-bottom: 32px;
}

.step-panel .logo img {
    max-width: 280px;
    height: auto;
}

.step-panel h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--primary);
}

.step-panel .subtitle {
    font-size: 1.0625rem;
    color: var(--text-secondary);
    margin-bottom: 40px;
}

.step-panel {
    display: none;
    animation: fadeIn 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    padding-top: 60px;
}

.step-panel#step0 {
    padding-top: 0;
}

.step-panel.active {
    display: block;
}

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

.step-panel h2 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 12px;
    text-align: center;
}

.step-panel .step-description {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 40px;
    text-align: center;
}

/* Forms */
.form-group {
    margin-bottom: 24px;
}

.form-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 10px;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.form-input,
.form-textarea,
select.form-input {
    width: 100%;
    padding: 16px 18px;
    font-size: 1rem;
    font-family: inherit;
    border: 2px solid var(--border);
    border-radius: 0;
    background: #ffffff;
    color: var(--text);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--text-muted);
}

/* Phone input group */
.phone-input-group {
    display: flex;
    gap: 0;
}

.country-select {
    width: 80px;
    padding: 16px 12px;
    font-size: 1rem;
    font-family: inherit;
    border: 2px solid var(--border);
    border-right: none;
    border-radius: 0;
    background: #ffffff;
    color: var(--text);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.phone-input {
    flex: 1;
    border-left: none;
}

.country-select:focus,
.country-select:hover {
    background: white;
    border-color: var(--primary);
    border-right: 2px solid var(--primary);
    box-shadow: 0 0 0 4px rgba(30, 58, 95, 0.08), 0 2px 8px rgba(0, 0, 0, 0.08);
}

.country-select:focus + .phone-input,
.phone-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(30, 58, 95, 0.08), 0 2px 8px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

/* OTP Input Special Styling */
.otp-input {
    text-align: center;
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: 8px;
    padding: 20px;
}

.form-input:focus,
.form-textarea:focus,
select.form-input:focus {
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 4px rgba(30, 58, 95, 0.08), 0 2px 8px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

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

.form-row {
    display: flex;
    gap: 12px;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 18px 40px;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    border-radius: 0;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    text-align: center;
    text-decoration: none;
    outline: none;
    width: 100%;
    letter-spacing: 0.3px;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 8px rgba(30, 58, 95, 0.15);
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(30, 58, 95, 0.25);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(30, 58, 95, 0.15);
}

.btn-primary:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Consent Box */
.consent-box {
    background: #f8fafc;
    padding: 24px;
    border: 2px solid var(--border);
    margin-bottom: 24px;
    text-align: left;
}

.consent-box h3 {
    margin-top: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 12px;
}

.consent-box p {
    font-size: 0.9375rem;
    line-height: 1.7;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.consent-box ul {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.7;
    margin-left: 20px;
}

.consent-box ul li {
    margin-bottom: 8px;
}

/* Checkbox Label */
.checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    cursor: pointer;
    padding: 18px;
    border: 2px solid var(--border);
    background: white;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.checkbox-label:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

.checkbox-label input[type="checkbox"] {
    width: 22px;
    height: 22px;
    cursor: pointer;
    margin-top: 2px;
    accent-color: var(--primary);
}

.checkbox-label span {
    font-size: 0.9375rem;
    color: var(--text);
    line-height: 1.6;
}

/* Debug Box */
.debug-box {
    display: none;
    background: #fef3c7;
    padding: 20px;
    margin-bottom: 24px;
    text-align: center;
    border: 2px solid #fbbf24;
}

.debug-code {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: 8px;
    display: inline-block;
    margin-left: 12px;
}

/* Inline notifications (avoid browser alert() popups) */
.inline-notice { display:none; margin: 0 0 16px 0; padding: 14px 14px; border: 2px solid var(--border); background: #f8fafc; color: var(--text); text-align: left; border-radius: 12px; }
.inline-notice.show { display:block; }
.inline-notice.error { border-color: var(--error); background: #fef2f2; }
.inline-notice.success { border-color: var(--success); background: #ecfdf5; }
.inline-notice-title { font-weight: 800; margin-bottom: 4px; }
.inline-notice-close { float:right; cursor:pointer; font-weight: 900; margin-left: 12px; }

/* Prevent horizontal overflow on long content */
.onboarding-container, .onboarding-card, .step-content, .step-panel { max-width: 100%; overflow-x: hidden; }
.consent-box, .form-group, .form-input, textarea, input, select { max-width: 100%; }
.consent-box, .step-panel, p, li { overflow-wrap: anywhere; word-break: break-word; }

/* Desktop enhancements */
@media (min-width: 900px) {
    /* Two-column helpers */
    .grid-2 {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 18px 18px;
        align-items: start;
    }
    .grid-span-2 { grid-column: 1 / -1; }

    .meta-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-template-areas:
            "safe content"
            "actions content";
        gap: 18px;
        align-items: start;
    }
    .meta-safe { grid-area: safe; }
    .meta-content { grid-area: content; }
    .meta-actions { grid-area: actions; }

    .meta-grid .consent-box,
    .meta-grid details.consent-box {
        margin-top: 0 !important;
    }

    details.consent-box > summary {
        list-style: none;
    }
    details.consent-box > summary::-webkit-details-marker { display:none; }
    details.consent-box > summary {
        padding: 6px 0;
    }

    .meta-actions {
        position: sticky;
        top: 24px;
    }

    .meta-actions .consent-box {
        box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
    }

    body {
        padding: 48px;
        background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    }

    .onboarding-container {
        max-width: 860px;
    }

    .onboarding-card {
        background: #ffffff;
        border: 1px solid var(--border);
        border-radius: 18px;
        box-shadow: 0 20px 60px rgba(15, 23, 42, 0.10);
        padding: 28px 32px;
        text-align: left;
    }

    .step-content {
        min-height: 520px;
        padding: 8px 0;
    }

    .step-panel {
        padding-top: 16px;
    }

    .step-panel#step0 {
        padding-top: 0;
        text-align: center;
    }

    .step-panel h2 {
        text-align: left;
        font-size: 2rem;
        margin-bottom: 10px;
    }

    .step-panel .step-description {
        text-align: left;
        font-size: 1.05rem;
        margin-bottom: 28px;
    }

    .form-label {
        font-size: 0.75rem;
        letter-spacing: 0.08em;
    }

    .form-input,
    .form-textarea,
    select.form-input,
    .country-select {
        border-radius: 12px;
    }

    .phone-input-group {
        gap: 10px;
    }

    .country-select {
        border-right: 2px solid var(--border);
        width: 110px;
    }

    .phone-input {
        border-left: 2px solid var(--border);
    }

    .btn-back {
        top: 18px;
        left: 18px;
        background: #fff;
        border-radius: 12px;
    }
}

/* Loading Overlay */
.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Responsive */
@media (max-width: 899px) {
    /* Mobile/tablet: keep meta actions pinned to bottom for easy completion */
    .meta-actions {
        position: sticky;
        bottom: 0;
        z-index: 50;
        margin-top: 16px;
    }
    .meta-actions .consent-box {
        background: rgba(255,255,255,0.96);
        backdrop-filter: blur(8px);
        border-radius: 14px;
        box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.10);
    }
}

@media (max-width: 640px) {
    body {
        padding: 20px 12px;
    }

    .onboarding-header {
        padding: 0 0 32px 0;
    }

    .onboarding-header h1 {
        font-size: 1.5rem;
    }

    .onboarding-header .logo img {
        max-width: 200px;
    }

    .progress-steps {
        padding: 0 0 32px 0;
    }

    .step-content {
        padding: 32px 0;
        min-height: 350px;
    }

    .step-panel h2 {
        font-size: 1.25rem;
    }

    .step-label {
        font-size: 0.625rem;
    }

    .step-number {
        width: 32px;
        height: 32px;
        font-size: 0.75rem;
    }

    .form-row {
        flex-direction: column;
    }

    .btn {
        padding: 12px 24px;
    }
}
