/* ============================================
   Health & Medical Form Styles
   ============================================ */

/* --- Trailman selector --- */
.hf-trailman-select {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 20px 28px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
}
.hf-trailman-select label {
    font-family: var(--font-heading);
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--brown-dark);
    white-space: nowrap;
}
.hf-trailman-select select {
    flex: 1;
    padding: 10px 14px;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 0.95rem;
    color: var(--gray-900);
    background: var(--white);
}
.hf-trailman-select select:focus {
    outline: none;
    border-color: var(--tl-blue);
}

/* --- Sections --- */
.hf-section {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 28px 32px;
    margin-bottom: 20px;
}
.hf-section-title {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--brown-dark);
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--gray-200);
}

.hf-subsection {
    margin-bottom: 20px;
}
.hf-subsection-title {
    font-family: var(--font-heading);
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--tl-blue);
    margin-bottom: 12px;
}
.hf-optional {
    font-weight: 400;
    color: var(--gray-500);
    font-size: 0.8rem;
    text-transform: none;
}

.hf-hint {
    font-size: 0.85rem;
    color: var(--gray-500);
    line-height: 1.5;
    margin-bottom: 16px;
}

/* --- Form fields --- */
.hf-row {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.hf-field {
    flex: 1;
    min-width: 160px;
}
.hf-field-full {
    flex: 1 1 100%;
}
.hf-field-sm {
    flex: 0 0 180px;
    min-width: 140px;
}
.hf-field-xs {
    flex: 0 0 100px;
    min-width: 80px;
}
.hf-field label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--gray-700);
    margin-bottom: 4px;
}
.hf-field input,
.hf-field select,
.hf-field textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 0.9rem;
    color: var(--gray-900);
    background: var(--white);
    transition: border-color 0.2s;
}
.hf-field input:focus,
.hf-field select:focus,
.hf-field textarea:focus {
    outline: none;
    border-color: var(--tl-blue);
}
.hf-field input[readonly] {
    background: var(--gray-100);
    color: var(--gray-500);
}
.hf-field textarea {
    resize: vertical;
    min-height: 60px;
}

/* --- Radio / Checkbox --- */
.hf-radio-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}
.hf-radio,
.hf-checkbox {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--gray-700);
    cursor: pointer;
}
.hf-radio input,
.hf-checkbox input {
    margin-top: 3px;
    accent-color: var(--tl-blue);
}
.hf-checkbox-block {
    margin-top: 16px;
    padding: 16px;
    background: var(--gray-100);
    border-radius: var(--radius);
}

/* --- Conditions (health history) --- */
.hf-condition {
    display: grid;
    grid-template-columns: 100px 1fr 1fr;
    gap: 12px;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--gray-100);
}
.hf-condition:last-child {
    border-bottom: none;
}
.hf-condition-toggle {
    display: flex;
    gap: 12px;
}
.hf-condition-toggle label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
    color: var(--gray-700);
    cursor: pointer;
}
.hf-condition-toggle input {
    accent-color: var(--tl-blue);
}
.hf-condition-name {
    font-size: 0.85rem;
    color: var(--gray-900);
}
.hf-condition-extra {
    font-size: 0.75rem;
    color: var(--gray-500);
}
.hf-condition-explain input {
    width: 100%;
    padding: 6px 10px;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 0.8rem;
    color: var(--gray-900);
    background: var(--white);
}
.hf-condition-explain input:focus {
    outline: none;
    border-color: var(--tl-blue);
}

/* --- Immunizations --- */
.hf-imm-header {
    display: grid;
    grid-template-columns: 70px 1fr 110px 70px 110px;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 2px solid var(--gray-200);
}
.hf-imm-header span {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--gray-500);
}
.hf-imm-row {
    display: grid;
    grid-template-columns: 70px 1fr 110px 70px 110px;
    gap: 8px;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid var(--gray-100);
}
.hf-imm-toggle {
    display: flex;
    gap: 10px;
}
.hf-imm-toggle label {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 0.75rem;
    color: var(--gray-700);
    cursor: pointer;
}
.hf-imm-toggle input {
    accent-color: var(--tl-blue);
}
.hf-imm-name {
    font-size: 0.85rem;
    color: var(--gray-900);
}
.hf-imm-input input {
    width: 100%;
    padding: 5px 8px;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 0.8rem;
    color: var(--gray-900);
    background: var(--white);
}
.hf-imm-input input:focus {
    outline: none;
    border-color: var(--tl-blue);
}
.hf-imm-had {
    display: flex;
    gap: 10px;
}
.hf-imm-had label {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 0.75rem;
    color: var(--gray-700);
    cursor: pointer;
}
.hf-imm-had input[type="radio"] {
    accent-color: var(--tl-blue);
}

/* --- Add buttons --- */
.hf-btn-add {
    display: block;
    width: 100%;
    padding: 10px;
    font-family: var(--font-heading);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--tl-blue);
    background: none;
    border: 2px dashed var(--gray-200);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 8px;
}
.hf-btn-add:hover {
    border-color: var(--tl-blue);
    background: #E8F0FE;
}

/* Allergy / Medication rows */
.hf-allergy-row,
.hf-medication-row {
    position: relative;
}
.hf-allergy-row + .hf-allergy-row,
.hf-medication-row + .hf-medication-row {
    padding-top: 8px;
    border-top: 1px solid var(--gray-100);
}

/* --- Upload area --- */
.hf-upload-area {
    position: relative;
    border: 2px dashed var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 32px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    overflow: hidden;
}
.hf-upload-area:hover {
    border-color: var(--tl-blue);
    background: #E8F0FE;
}
.hf-upload-area.has-file {
    border-style: solid;
    border-color: var(--green-forest);
    background: #f0fdf4;
    cursor: default;
}
.hf-upload-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}
.hf-upload-area.has-file .hf-upload-input {
    display: none;
}
.hf-upload-placeholder {
    pointer-events: none;
}
.hf-upload-icon {
    font-size: 2.5rem;
    margin-bottom: 8px;
}
.hf-upload-placeholder p {
    font-size: 0.9rem;
    color: var(--gray-700);
    margin-bottom: 4px;
}
.hf-upload-hint {
    font-size: 0.8rem;
    color: var(--gray-500);
}
.hf-upload-preview {
    max-width: 300px;
    max-height: 200px;
    border-radius: var(--radius);
    margin: 0 auto;
}
.hf-upload-remove {
    display: block;
    margin: 12px auto 0;
    background: none;
    border: 1px solid var(--crimson);
    color: var(--crimson);
    font-family: var(--font-body);
    font-size: 0.8rem;
    padding: 6px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
}
.hf-upload-remove:hover {
    background: var(--crimson);
    color: #fff;
}
.hf-upload-status {
    font-size: 0.8rem;
    color: var(--gray-500);
    text-align: center;
    margin-top: 8px;
    min-height: 20px;
}

/* --- Consent text --- */
.hf-consent-text {
    background: var(--gray-100);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
    font-size: 0.85rem;
    color: var(--gray-700);
    line-height: 1.7;
}
.hf-consent-text p {
    margin-bottom: 12px;
}
.hf-consent-text p:last-child {
    margin-bottom: 0;
}
.hf-consent-signatures {
    margin-bottom: 16px;
}

/* --- Submit --- */
.hf-submit-area {
    text-align: center;
    padding: 24px 0;
}
.hf-submit-area .btn-primary {
    max-width: 400px;
    padding: 16px 48px;
    font-size: 1.05rem;
}
.hf-message {
    margin-top: 12px;
    font-size: 0.85rem;
    border-radius: var(--radius);
    min-height: 0;
}
.hf-message:empty {
    display: none;
}
.hf-message.error {
    display: block;
    padding: 12px;
    background: #fdf0f0;
    color: var(--crimson);
    border: 1px solid rgba(186,39,44,0.15);
}
.hf-message.success {
    display: block;
    padding: 12px;
    background: #f0fdf4;
    color: #2D5E2A;
    border: 1px solid rgba(45,94,42,0.15);
}

/* --- Loading --- */
.hf-loading {
    text-align: center;
    padding: 48px 0;
    color: var(--gray-500);
}

/* --- Responsive --- */
@media (max-width: 700px) {
    .hf-section {
        padding: 20px 16px;
    }
    .hf-row {
        flex-direction: column;
        gap: 8px;
    }
    .hf-field-sm,
    .hf-field-xs {
        flex: 1 1 100%;
    }
    .hf-condition {
        grid-template-columns: 1fr;
        gap: 4px;
    }
    .hf-imm-header {
        display: none;
    }
    .hf-imm-row {
        grid-template-columns: 1fr;
        gap: 6px;
        padding: 10px 0;
    }
    .hf-imm-row::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 0.85rem;
        color: var(--gray-900);
    }
    .hf-trailman-select {
        flex-direction: column;
        align-items: stretch;
    }
}

/* --- Dark mode --- */
/* (Rewritten 2026-08-05: the old block was authored against the LIGHT values
 * of the variables, so in dark mode sections went near-white and text became
 * invisible — audit #89. Literals below follow dash.css conventions.) */
[data-theme="dark"] .hf-section {
    background: #2A2826;
}
[data-theme="dark"] .hf-field input,
[data-theme="dark"] .hf-field select,
[data-theme="dark"] .hf-field textarea,
[data-theme="dark"] .hf-condition-explain input,
[data-theme="dark"] .hf-imm-input input {
    background: #1A1816;
    border-color: #3A3734;
    color: #EDEAE5;
}
[data-theme="dark"] .hf-trailman-select {
    background: #2A2826;
}
[data-theme="dark"] .hf-trailman-select select {
    background: #1A1816;
    border-color: #3A3734;
    color: #EDEAE5;
}
[data-theme="dark"] .hf-consent-text,
[data-theme="dark"] .hf-checkbox-block {
    background: #242220;
}
[data-theme="dark"] .hf-upload-area:hover {
    background: #242220;
}
[data-theme="dark"] .hf-condition-name,
[data-theme="dark"] .hf-imm-name {
    color: #EDEAE5;
}
[data-theme="dark"] .hf-upload-row.has-file { background: #1F2A1F; }
[data-theme="dark"] .hf-message.success { background: #1A2A1A; color: #81C784; }
[data-theme="dark"] .hf-message.error { background: #2A1A1A; color: #E57373; }
