/*
 * PeptiClinic patient forms — onboarding + eligibility wizards.
 * Namespaced .pepti-pf-* to avoid collisions with site-wide chrome
 * and the existing [pepti_halaxy_intake] / dashboard styles.
 *
 * Theme cookie is the site-wide pepticlinic_gender (men|women|neutral),
 * read on first paint by Pepti_Halaxy_Bridge_Gender_System and exposed via
 * <html data-gender="...">. We mirror that with [data-theme] at the form
 * root so per-form theming works even on pages without the html attr.
 */

/* THEME VARIABLES — neutral */
.pepti-pf {
    --pepti-pf-primary: #7c3aed;
    --pepti-pf-primary-dark: #6d28d9;
    --pepti-pf-primary-light: #a78bfa;
    --pepti-pf-primary-bg: #f5f3ff;
    --pepti-pf-primary-bg-hover: #ede9fe;
    --pepti-pf-primary-border: rgba(124, 58, 237, 0.3);
    --pepti-pf-gradient: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);

    --pepti-pf-bg: #ffffff;
    --pepti-pf-bg-alt: #f9fafb;
    --pepti-pf-bg-card: #ffffff;
    --pepti-pf-text: #111827;
    --pepti-pf-text-secondary: #4b5563;
    --pepti-pf-text-muted: #9ca3af;
    --pepti-pf-border: #e5e7eb;
    --pepti-pf-border-hover: #d1d5db;

    --pepti-pf-success: #10b981;
    --pepti-pf-success-bg: #ecfdf5;
    --pepti-pf-error: #ef4444;
    --pepti-pf-error-bg: #fef2f2;
    --pepti-pf-warning: #f59e0b;
    --pepti-pf-warning-bg: #fffbeb;
    --pepti-pf-info: #3b82f6;
    --pepti-pf-info-bg: #eff6ff;

    --pepti-pf-radius: 12px;
    --pepti-pf-radius-sm: 8px;
    --pepti-pf-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --pepti-pf-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--pepti-pf-text);
    line-height: 1.6;
}

/* Map site-wide html[data-gender="men|women"] AND in-form [data-theme="male|female"] to the same primary palette. */
.pepti-pf[data-theme="male"],
html[data-gender="men"] .pepti-pf {
    --pepti-pf-primary: #2563eb;
    --pepti-pf-primary-dark: #1d4ed8;
    --pepti-pf-primary-light: #60a5fa;
    --pepti-pf-primary-bg: #eff6ff;
    --pepti-pf-primary-bg-hover: #dbeafe;
    --pepti-pf-primary-border: rgba(37, 99, 235, 0.3);
    --pepti-pf-gradient: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
}

.pepti-pf[data-theme="female"],
html[data-gender="women"] .pepti-pf {
    --pepti-pf-primary: #db2777;
    --pepti-pf-primary-dark: #be185d;
    --pepti-pf-primary-light: #f472b6;
    --pepti-pf-primary-bg: #fdf2f8;
    --pepti-pf-primary-bg-hover: #fce7f3;
    --pepti-pf-primary-border: rgba(219, 39, 119, 0.3);
    --pepti-pf-gradient: linear-gradient(135deg, #db2777 0%, #be185d 100%);
}

/* CONTAINER */
.pepti-pf__container {
    max-width: 800px;
    margin: 0 auto;
    padding: 24px;
}

.pepti-pf__container--narrow {
    max-width: 720px;
}

/* HEADER */
.pepti-pf__header {
    text-align: center;
    margin-bottom: 32px;
}

.pepti-pf__logo {
    height: 48px;
    margin-bottom: 16px;
}

.pepti-pf__header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--pepti-pf-text);
    margin-bottom: 8px;
}

.pepti-pf__header p {
    color: var(--pepti-pf-text-secondary);
    font-size: 0.95rem;
}

/* PROGRESS BAR */
.pepti-pf__progress {
    margin-bottom: 32px;
}

.pepti-pf__progress-bar {
    height: 6px;
    background: var(--pepti-pf-border);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 20px;
}

.pepti-pf__progress-fill {
    height: 100%;
    background: var(--pepti-pf-gradient);
    border-radius: 3px;
    transition: width 0.4s ease;
}

.pepti-pf__steps {
    display: flex;
    justify-content: space-between;
}

.pepti-pf__step {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
}

.pepti-pf__step-num {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--pepti-pf-bg);
    border: 2px solid var(--pepti-pf-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--pepti-pf-text-muted);
    margin-bottom: 8px;
    transition: all 0.3s ease;
}

.pepti-pf__step.is-active .pepti-pf__step-num {
    background: var(--pepti-pf-primary);
    border-color: var(--pepti-pf-primary);
    color: #fff;
    box-shadow: 0 0 0 4px var(--pepti-pf-primary-bg);
}

.pepti-pf__step.is-done .pepti-pf__step-num {
    background: var(--pepti-pf-success);
    border-color: var(--pepti-pf-success);
    color: #fff;
}

.pepti-pf__step.is-done .pepti-pf__step-num span { display: none; }
.pepti-pf__step.is-done .pepti-pf__step-num::after { content: "✓"; }

.pepti-pf__step-label {
    font-size: 0.75rem;
    color: var(--pepti-pf-text-muted);
    font-weight: 500;
    text-align: center;
}

.pepti-pf__step.is-active .pepti-pf__step-label {
    color: var(--pepti-pf-primary);
}

@media (max-width: 600px) {
    .pepti-pf__step-label { font-size: 0.65rem; }
}

/* CARD */
.pepti-pf__card {
    background: var(--pepti-pf-bg-card);
    border-radius: var(--pepti-pf-radius);
    box-shadow: var(--pepti-pf-shadow);
    border: 1px solid var(--pepti-pf-border);
    overflow: hidden;
}

/* SECTIONS */
.pepti-pf__section {
    display: none;
    padding: 32px;
    animation: pepti-pf-fade 0.3s ease;
}

.pepti-pf__section.is-active {
    display: block;
}

@keyframes pepti-pf-fade {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.pepti-pf__section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--pepti-pf-text);
    margin-bottom: 8px;
}

.pepti-pf__section-title .icon {
    font-size: 1.5rem;
}

.pepti-pf__section-desc {
    color: var(--pepti-pf-text-secondary);
    font-size: 0.9rem;
    margin-bottom: 24px;
}

/* FIELDS */
.pepti-pf__row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.pepti-pf__row--3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
}

@media (max-width: 600px) {
    .pepti-pf__row,
    .pepti-pf__row--3 { grid-template-columns: 1fr; }
}

.pepti-pf__field {
    margin-bottom: 20px;
}

.pepti-pf__field label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--pepti-pf-text);
    margin-bottom: 6px;
}

.pepti-pf__field label .req { color: var(--pepti-pf-error); }
.pepti-pf__field label .opt { color: var(--pepti-pf-text-muted); font-weight: 400; font-size: 0.8rem; }

.pepti-pf__field input,
.pepti-pf__field select,
.pepti-pf__field textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--pepti-pf-border);
    border-radius: var(--pepti-pf-radius-sm);
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--pepti-pf-text);
    background: var(--pepti-pf-bg);
    transition: border-color 0.2s, box-shadow 0.2s;
}

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

.pepti-pf__field input:focus,
.pepti-pf__field select:focus,
.pepti-pf__field textarea:focus {
    outline: none;
    border-color: var(--pepti-pf-primary);
    box-shadow: 0 0 0 3px var(--pepti-pf-primary-bg);
}

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

.pepti-pf__field.is-error input,
.pepti-pf__field.is-error select,
.pepti-pf__field.is-error textarea {
    border-color: var(--pepti-pf-error);
}

.pepti-pf__error-msg {
    color: var(--pepti-pf-error);
    font-size: 0.8rem;
    margin-top: 6px;
    display: none;
}

.pepti-pf__field.is-error .pepti-pf__error-msg {
    display: block;
}

.pepti-pf__help {
    font-size: 0.8rem;
    color: var(--pepti-pf-text-muted);
    margin-top: 4px;
}

/* FIELD GROUPS */
.pepti-pf__fieldset {
    background: var(--pepti-pf-bg-alt);
    border: 1px solid var(--pepti-pf-border);
    border-radius: var(--pepti-pf-radius-sm);
    padding: 20px;
    margin-bottom: 20px;
}

.pepti-pf__fieldset-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--pepti-pf-text);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* RADIO/CHECKBOX OPTIONS */
.pepti-pf__options {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.pepti-pf__options--vertical {
    flex-direction: column;
}

.pepti-pf__opt {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    border: 2px solid var(--pepti-pf-border);
    border-radius: var(--pepti-pf-radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    background: var(--pepti-pf-bg);
    flex: 1;
    min-width: 120px;
}

.pepti-pf__opt:hover {
    border-color: var(--pepti-pf-border-hover);
    background: var(--pepti-pf-bg-alt);
}

.pepti-pf__opt.is-selected {
    border-color: var(--pepti-pf-primary);
    background: var(--pepti-pf-primary-bg);
}

.pepti-pf__opt input { display: none; }

.pepti-pf__opt-mark {
    width: 20px;
    height: 20px;
    border: 2px solid var(--pepti-pf-border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
}

.pepti-pf__opt.is-selected .pepti-pf__opt-mark {
    border-color: var(--pepti-pf-primary);
    background: var(--pepti-pf-primary);
}

.pepti-pf__opt-mark::after {
    content: '';
    width: 8px;
    height: 8px;
    background: #fff;
    border-radius: 50%;
    opacity: 0;
}

.pepti-pf__opt.is-selected .pepti-pf__opt-mark::after { opacity: 1; }

.pepti-pf__opt[data-type="checkbox"] .pepti-pf__opt-mark { border-radius: 4px; }

.pepti-pf__opt[data-type="checkbox"] .pepti-pf__opt-mark::after {
    content: '✓';
    width: auto; height: auto;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
    background: none;
    border-radius: 0;
}

.pepti-pf__opt-text {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--pepti-pf-text);
}

.pepti-pf__opt-desc {
    font-size: 0.8rem;
    color: var(--pepti-pf-text-muted);
    margin-top: 2px;
}

/* SERVICE GRID (eligibility) */
.pepti-pf__services {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

@media (max-width: 600px) {
    .pepti-pf__services { grid-template-columns: repeat(2, 1fr); }
}

.pepti-pf__service {
    padding: 20px 16px;
    background: var(--pepti-pf-bg);
    border: 2px solid var(--pepti-pf-border);
    border-radius: var(--pepti-pf-radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.pepti-pf__service:hover {
    border-color: var(--pepti-pf-border-hover);
    transform: translateY(-2px);
}

.pepti-pf__service.is-selected {
    border-color: var(--pepti-pf-primary);
    background: var(--pepti-pf-primary-bg);
    box-shadow: 0 0 0 3px var(--pepti-pf-primary-bg);
}

.pepti-pf__service input { display: none; }

.pepti-pf__service-icon {
    font-size: 2rem;
    margin-bottom: 8px;
    display: block;
}

.pepti-pf__service-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--pepti-pf-text);
    margin-bottom: 4px;
}

.pepti-pf__service-desc {
    font-size: 0.75rem;
    color: var(--pepti-pf-text-muted);
}

/* QUESTION BLOCKS */
.pepti-pf__question {
    background: var(--pepti-pf-bg-alt);
    border: 1px solid var(--pepti-pf-border);
    border-radius: var(--pepti-pf-radius-sm);
    padding: 20px;
    margin-bottom: 16px;
}

.pepti-pf__question--warning {
    border-color: var(--pepti-pf-warning);
    background: var(--pepti-pf-warning-bg);
}

.pepti-pf__question-text {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--pepti-pf-text);
    margin-bottom: 14px;
}

.pepti-pf__question-note {
    font-size: 0.85rem;
    color: var(--pepti-pf-text-muted);
    margin-bottom: 12px;
}

/* CONDITIONAL SECTIONS (eligibility service-specific blocks) */
.pepti-pf__conditional {
    display: none;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 2px dashed var(--pepti-pf-border);
}

.pepti-pf__conditional.is-visible {
    display: block;
    animation: pepti-pf-fade 0.3s ease;
}

.pepti-pf__conditional-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--pepti-pf-primary);
    margin-bottom: 16px;
}

/* INFO BOXES */
.pepti-pf__info {
    background: var(--pepti-pf-info-bg);
    border: 1px solid var(--pepti-pf-info);
    border-radius: var(--pepti-pf-radius-sm);
    padding: 16px;
    margin-bottom: 20px;
    display: flex;
    gap: 12px;
}

.pepti-pf__info--warning {
    background: var(--pepti-pf-warning-bg);
    border-color: var(--pepti-pf-warning);
}

.pepti-pf__info-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.pepti-pf__info-text {
    font-size: 0.9rem;
    color: var(--pepti-pf-text-secondary);
}

/* CONSENTS */
.pepti-pf__consent {
    background: var(--pepti-pf-bg-alt);
    border: 1px solid var(--pepti-pf-border);
    border-radius: var(--pepti-pf-radius-sm);
    padding: 16px;
    margin-bottom: 16px;
}

.pepti-pf__consent-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
}

.pepti-pf__consent-check {
    width: 24px;
    height: 24px;
    border: 2px solid var(--pepti-pf-border);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
    margin-top: 2px;
}

.pepti-pf__consent.is-checked .pepti-pf__consent-check {
    background: var(--pepti-pf-primary);
    border-color: var(--pepti-pf-primary);
}

.pepti-pf__consent-check::after {
    content: '✓';
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    opacity: 0;
}

.pepti-pf__consent.is-checked .pepti-pf__consent-check::after { opacity: 1; }

.pepti-pf__consent-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--pepti-pf-text);
    margin-bottom: 4px;
}

.pepti-pf__consent-desc {
    font-size: 0.85rem;
    color: var(--pepti-pf-text-secondary);
}

.pepti-pf__consent-desc a {
    color: var(--pepti-pf-primary);
    text-decoration: underline;
}

.pepti-pf__consent input { display: none; }

/* BUTTONS */
.pepti-pf__buttons {
    display: flex;
    gap: 12px;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--pepti-pf-border);
}

.pepti-pf__btn {
    flex: 1;
    padding: 14px 24px;
    border: none;
    border-radius: var(--pepti-pf-radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
}

.pepti-pf__btn--secondary {
    background: var(--pepti-pf-bg);
    border: 1px solid var(--pepti-pf-border);
    color: var(--pepti-pf-text-secondary);
}

.pepti-pf__btn--secondary:hover {
    border-color: var(--pepti-pf-text-secondary);
    background: var(--pepti-pf-bg-alt);
}

.pepti-pf__btn--primary {
    background: var(--pepti-pf-gradient);
    color: #fff;
    box-shadow: 0 4px 12px var(--pepti-pf-primary-border);
}

.pepti-pf__btn--primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px var(--pepti-pf-primary-border);
    color: #fff;
}

.pepti-pf__btn--primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* RESULT / SUCCESS */
.pepti-pf__result {
    text-align: center;
    padding: 40px 20px;
    display: none;
}

.pepti-pf__result.is-active { display: block; }

.pepti-pf__result-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    margin: 0 auto 24px;
}

.pepti-pf__result--success .pepti-pf__result-icon {
    background: var(--pepti-pf-success-bg);
    border: 2px solid var(--pepti-pf-success);
}

.pepti-pf__result--fail .pepti-pf__result-icon {
    background: var(--pepti-pf-warning-bg);
    border: 2px solid var(--pepti-pf-warning);
}

.pepti-pf__result h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 12px;
}

.pepti-pf__result--success h2 { color: var(--pepti-pf-success); }
.pepti-pf__result--fail h2 { color: var(--pepti-pf-warning); }

.pepti-pf__result p {
    color: var(--pepti-pf-text-secondary);
    font-size: 0.95rem;
    margin-bottom: 24px;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.pepti-pf__result-reasons {
    background: var(--pepti-pf-bg-alt);
    border-radius: var(--pepti-pf-radius-sm);
    padding: 20px;
    margin: 20px auto;
    max-width: 480px;
    text-align: left;
}

.pepti-pf__result-reasons h4 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--pepti-pf-text);
    margin-bottom: 12px;
}

.pepti-pf__result-reasons ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.pepti-pf__result-reasons li {
    font-size: 0.9rem;
    color: var(--pepti-pf-text-secondary);
    padding: 8px 0;
    border-bottom: 1px solid var(--pepti-pf-border);
    display: flex;
    align-items: center;
    gap: 8px;
}

.pepti-pf__result-reasons li:last-child { border-bottom: none; }

.pepti-pf__result-reasons li::before {
    content: "•";
    color: var(--pepti-pf-warning);
    font-weight: bold;
}

/* SUCCESS DETAILS (onboarding) */
.pepti-pf__success-details {
    background: var(--pepti-pf-bg-alt);
    border-radius: var(--pepti-pf-radius-sm);
    padding: 24px;
    margin: 32px auto;
    max-width: 400px;
    text-align: left;
}

.pepti-pf__success-details h4 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--pepti-pf-text);
    margin-bottom: 16px;
}

.pepti-pf__success-item {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--pepti-pf-border);
    font-size: 0.9rem;
}

.pepti-pf__success-item:last-child { border-bottom: none; }

.pepti-pf__success-item span:first-child {
    color: var(--pepti-pf-text-muted);
    flex-shrink: 0;
    width: 28px;
    text-align: center;
}

.pepti-pf__success-item span:last-child {
    color: var(--pepti-pf-text);
    font-weight: 500;
}

/* TRUST BADGES */
.pepti-pf__trust {
    display: flex;
    justify-content: center;
    gap: 24px;
    flex-wrap: wrap;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--pepti-pf-border);
}

.pepti-pf__trust-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--pepti-pf-text-muted);
}

.pepti-pf__trust-badge .icon { font-size: 1.1rem; }

/* ALERT (rate-limit / submit error) */
.pepti-pf__alert {
    background: var(--pepti-pf-error-bg);
    border: 1px solid var(--pepti-pf-error);
    color: #991b1b;
    padding: 14px 18px;
    border-radius: var(--pepti-pf-radius-sm);
    margin: 0 32px 24px;
    font-size: 0.9rem;
}
