/* ═══════════════════════════════════════════════
   HepaSkin Chestionar – Frontend Styles
   ═══════════════════════════════════════════════ */

#hepaskin-form-wrap.hsk-wrap {
    /* Fallback values – overridden by inline styles from PHP */
    --hsk-primary: #1B3A5C;
    --hsk-primary-light: #2A5680;
    --hsk-accent: #C8102E;
    --hsk-high: #C8102E;
    --hsk-moderate: #E6A817;
    --hsk-low: #28A745;
    --hsk-text: #1A2332;
    --hsk-bg: #FFFFFF;

    --hsk-bg-soft: #fafbfc;
    --hsk-border: #e3e8ee;
    --hsk-muted: #6b7785;

    max-width: 820px;
    margin: 40px auto;
    padding: 0 16px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--hsk-text);
    line-height: 1.5;
    overflow-x: hidden;
    width: 100%;
    box-sizing: border-box;
}

#hepaskin-form-wrap *,
#hepaskin-form-wrap *::before,
#hepaskin-form-wrap *::after {
    box-sizing: border-box;
}

/* ── Progress ─────────────────────────────────── */
.hsk-progress {
    height: 6px;
    background: var(--hsk-border);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 12px;
}
.hsk-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--hsk-primary), var(--hsk-accent));
    width: 14%;
    transition: width 0.4s ease;
    border-radius: 3px;
}

.hsk-steps {
    display: flex;
    justify-content: space-between;
    margin-bottom: 24px;
    padding: 0 4px;
    gap: 4px;
    font-size: 12px;
    color: var(--hsk-muted);
    font-weight: 500;
}
.hsk-steps span {
    flex: 1;
    text-align: center;
    transition: color 0.3s;
    /* Previne despărțirea cuvintelor mid-word (ex: "Consimțămân-t") */
    word-break: keep-all;
    overflow-wrap: normal;
    hyphens: none;
    -webkit-hyphens: none;
    -ms-hyphens: none;
    line-height: 1.25;
}
.hsk-steps span.active {
    color: var(--hsk-primary);
    font-weight: 700;
}
.hsk-steps span.completed {
    color: #6b7785;
}

@media (max-width: 600px) {
    .hsk-steps {
        font-size: 10px;
        padding: 0;
    }
}

/* ── Form container ──────────────────────────── */
#hepaskin-form {
    background: var(--hsk-bg);
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(27, 58, 92, 0.08);
    padding: 32px;
    border: 1px solid var(--hsk-border);
    overflow: hidden;
    max-width: 100%;
    box-sizing: border-box;
}

@media (max-width: 600px) {
    #hepaskin-form { padding: 20px; }
}

/* ── Step header ─────────────────────────────── */
.hsk-step-header {
    display: flex;
    align-items: center;
    gap: 18px;
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--hsk-border);
}
.hsk-step-number {
    flex-shrink: 0;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--hsk-primary), var(--hsk-primary-light));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(27, 58, 92, 0.25);
}
.hsk-step-header h2 {
    margin: 0 0 4px 0;
    font-size: 22px;
    color: var(--hsk-primary);
    font-weight: 700;
}
.hsk-step-header p {
    margin: 0;
    color: var(--hsk-muted);
    font-size: 14px;
}

/* ── Fields ───────────────────────────────────── */
.hsk-fields {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.hsk-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

@media (max-width: 600px) {
    .hsk-row { grid-template-columns: 1fr; }
}

.hsk-field {
    display: flex;
    flex-direction: column;
}
.hsk-field-wide {
    grid-column: 1 / -1;
}

.hsk-field label,
.hsk-group-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--hsk-text);
    margin-bottom: 6px;
}

.hsk-req {
    color: var(--hsk-accent);
    font-weight: 700;
}

.hsk-field input[type="text"],
.hsk-field input[type="email"],
.hsk-field input[type="tel"],
.hsk-field input[type="number"],
.hsk-field input[type="date"],
.hsk-conditional input {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid var(--hsk-border);
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    color: var(--hsk-text);
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.hsk-field input:focus,
.hsk-conditional input:focus {
    outline: none;
    border-color: var(--hsk-primary);
    box-shadow: 0 0 0 3px rgba(27, 58, 92, 0.12);
}

.hsk-hint {
    font-size: 12px;
    color: var(--hsk-muted);
    margin: -4px 0 6px 0;
    font-style: italic;
}

/* ── Radio buttons ───────────────────────────── */
.hsk-radio-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.hsk-radio-group--vertical {
    flex-direction: column;
}

.hsk-radio {
    flex: 1;
    min-width: 110px;
    cursor: pointer;
    position: relative;
}
.hsk-radio input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.hsk-radio span {
    display: block;
    padding: 11px 16px;
    border: 1.5px solid var(--hsk-border);
    border-radius: 8px;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
    background: #fff;
    transition: all 0.2s;
}
.hsk-radio:hover span {
    border-color: var(--hsk-primary);
    background: rgba(27, 58, 92, 0.04);
}
.hsk-radio input:checked + span {
    border-color: var(--hsk-primary);
    background: var(--hsk-primary);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(27, 58, 92, 0.2);
}

/* ── Checkboxes ──────────────────────────────── */
.hsk-check {
    display: flex !important;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    border: 1.5px solid var(--hsk-border);
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    transition: all 0.2s;
    overflow: visible;
}
.hsk-check:hover {
    border-color: var(--hsk-primary);
    background: rgba(27, 58, 92, 0.03);
}
.hsk-check input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.hsk-check-mark {
    flex-shrink: 0 !important;
    width: 22px !important;
    min-width: 22px !important;
    height: 22px !important;
    border: 2px solid #b8c2cf;
    border-radius: 5px;
    background: #fff;
    position: relative;
    transition: all 0.2s;
    margin-top: 1px;
    display: block !important;
}
.hsk-check-mark::after {
    content: "";
    position: absolute;
    left: 6px;
    top: 2px;
    width: 6px;
    height: 11px;
    border: solid #fff;
    border-width: 0 2.5px 2.5px 0;
    transform: rotate(45deg) scale(0);
    transition: transform 0.15s;
}
.hsk-check input:checked ~ .hsk-check-mark {
    background: var(--hsk-primary);
    border-color: var(--hsk-primary);
}
.hsk-check input:checked ~ .hsk-check-mark::after {
    transform: rotate(45deg) scale(1);
}
.hsk-check-label {
    flex: 1;
    font-size: 14.5px;
    line-height: 1.4;
}
.hsk-check input:checked ~ .hsk-check-label {
    color: var(--hsk-primary);
    font-weight: 500;
}

/* ── Field group (radio + conditional) ──────── */
.hsk-field-group {
    background: #f6f8fb;
    border-radius: 10px;
    padding: 16px 18px;
    border: 1px solid var(--hsk-border);
}

.hsk-conditional {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px dashed #d0d8e3;
    display: none;
    animation: hskSlideDown 0.3s ease;
}
.hsk-conditional.is-visible {
    display: block;
}
/* Checkboxes inside conditionals need explicit layout */
.hsk-conditional .hsk-check {
    display: flex !important;
    align-items: flex-start;
    gap: 12px;
    overflow: visible;
}
.hsk-conditional .hsk-check-mark {
    flex-shrink: 0;
    min-width: 22px;
    width: 22px;
    height: 22px;
}
.hsk-conditional label {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    display: block;
}

@keyframes hskSlideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── Consent box ─────────────────────────────── */
.hsk-consent-box {
    background: #f6f8fb;
    border-left: 4px solid var(--hsk-primary);
    padding: 16px 20px;
    border-radius: 4px;
    margin-bottom: 20px;
    font-size: 13.5px;
    color: var(--hsk-muted);
    line-height: 1.6;
}
.hsk-consent-box p { margin: 0 0 10px 0; }
.hsk-consent-box p:last-child { margin: 0; }

.hsk-check--consent {
    background: #fff;
}

/* ── Navigation ──────────────────────────────── */
.hsk-nav {
    display: flex;
    align-items: center;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 2px solid var(--hsk-border);
    gap: 12px;
}
.hsk-nav-spacer { flex: 1; }

.hsk-btn {
    padding: 13px 28px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.hsk-btn--primary {
    background: linear-gradient(135deg, var(--hsk-primary), var(--hsk-primary-light));
    color: #fff;
    box-shadow: 0 4px 14px rgba(27, 58, 92, 0.25);
}
.hsk-btn--primary:hover {
    box-shadow: 0 6px 20px rgba(27, 58, 92, 0.35);
    filter: brightness(1.1);
}
.hsk-btn--primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}
.hsk-btn--outline {
    background: #fff;
    color: var(--hsk-primary);
    border: 1.5px solid var(--hsk-primary);
}
.hsk-btn--outline:hover {
    background: rgba(27, 58, 92, 0.05);
}

/* ── Result ──────────────────────────────────── */
.hsk-result {
    margin-top: 24px;
    padding: 32px;
    border-radius: 12px;
    background: var(--hsk-bg);
    box-shadow: 0 4px 24px rgba(27, 58, 92, 0.08);
    text-align: center;
    border-top: 6px solid var(--hsk-primary);
    animation: hskFadeIn 0.5s ease;
}
.hsk-result--high { border-top-color: var(--hsk-high); }
.hsk-result--moderate { border-top-color: var(--hsk-moderate); }
.hsk-result--low { border-top-color: var(--hsk-low); }

.hsk-result-icon {
    font-size: 56px;
    margin-bottom: 12px;
    display: block;
}
.hsk-result-title {
    font-size: 24px;
    font-weight: 700;
    margin: 0 0 8px 0;
    color: var(--hsk-primary);
}
.hsk-result-score {
    display: inline-block;
    padding: 6px 18px;
    background: var(--hsk-primary);
    color: #fff;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 18px;
}
.hsk-result--high .hsk-result-score { background: var(--hsk-high); }
.hsk-result--moderate .hsk-result-score { background: var(--hsk-moderate); }
.hsk-result--low .hsk-result-score { background: var(--hsk-low); }

.hsk-result-message {
    font-size: 16px;
    line-height: 1.6;
    color: var(--hsk-text);
    background: var(--hsk-bg-soft);
    padding: 18px 24px;
    border-radius: 8px;
    margin: 0 auto 16px auto;
    max-width: 600px;
}

.hsk-result-footer {
    margin-top: 20px;
    font-size: 13px;
    color: var(--hsk-muted);
}

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

/* ── Error message ───────────────────────────── */
.hsk-error {
    background: #fde8eb;
    border-left: 4px solid var(--hsk-accent);
    color: #8b1228;
    padding: 12px 16px;
    border-radius: 6px;
    margin-top: 14px;
    font-size: 14px;
    font-weight: 500;
    animation: hskFadeIn 0.3s ease;
}

.hsk-field--error input {
    border-color: var(--hsk-accent) !important;
    background: #fde8eb !important;
}

/* ═══════════════════════════════════════════════
   RESPONSIVE – Tablet + Mobile
   ═══════════════════════════════════════════════ */

/* ── Tablet (≤ 768px) ──────────────────────── */
@media (max-width: 768px) {
    #hepaskin-form-wrap.hsk-wrap {
        margin: 20px auto;
        padding: 0 12px;
    }
    #hepaskin-form {
        padding: 24px 20px;
    }
    .hsk-step-header {
        gap: 14px;
        margin-bottom: 22px;
        padding-bottom: 16px;
    }
    .hsk-step-number {
        width: 46px;
        height: 46px;
        font-size: 17px;
    }
    .hsk-step-header h2 {
        font-size: 19px;
    }
    .hsk-nav {
        margin-top: 24px;
        padding-top: 18px;
    }
    .hsk-btn {
        padding: 12px 22px;
        font-size: 14px;
    }
    .hsk-result {
        padding: 24px 20px;
    }
}

/* ── Mobile (≤ 600px) ──────────────────────── */
@media (max-width: 600px) {
    #hepaskin-form-wrap.hsk-wrap {
        margin: 12px auto;
        padding: 0 6px;
        max-width: 100vw;
    }
    #hepaskin-form {
        padding: 16px 12px;
        border-radius: 10px;
    }

    /* Forțează toate elementele să stea în container */
    .hsk-fields,
    .hsk-field,
    .hsk-field-group,
    .hsk-row,
    .hsk-radio-group,
    .hsk-check,
    .hsk-consent-box,
    .hsk-conditional {
        max-width: 100%;
        box-sizing: border-box;
    }

    /* Step indicator – scrollable pe mobil */
    .hsk-steps {
        font-size: 11px;
        padding: 0;
        gap: 2px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 4px;
    }
    .hsk-steps::-webkit-scrollbar {
        display: none;
    }
    .hsk-steps span {
        flex: 0 0 auto;
        min-width: 65px;
        padding: 0 3px;
        font-size: 10px;
    }

    /* Progress bar */
    .hsk-progress {
        margin-bottom: 8px;
    }

    /* Step header */
    .hsk-step-header {
        gap: 12px;
        margin-bottom: 18px;
        padding-bottom: 14px;
    }
    .hsk-step-number {
        width: 40px;
        height: 40px;
        font-size: 15px;
        flex-shrink: 0;
    }
    .hsk-step-header h2 {
        font-size: 17px;
    }
    .hsk-step-header p {
        font-size: 13px;
    }

    /* Fields – tot single column */
    .hsk-row {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .hsk-field label,
    .hsk-group-label {
        font-size: 13px;
    }

    /* TOATE inputurile 100% width + previne zoom iOS */
    .hsk-field input[type="text"],
    .hsk-field input[type="email"],
    .hsk-field input[type="tel"],
    .hsk-field input[type="number"],
    .hsk-field input[type="date"],
    .hsk-conditional input {
        padding: 10px 12px;
        font-size: 16px;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    /* Radio buttons – wrap + full width */
    .hsk-radio-group {
        gap: 8px;
        flex-wrap: wrap;
    }
    .hsk-radio {
        min-width: unset;
        flex: 1 1 calc(50% - 8px);
    }
    .hsk-radio span {
        padding: 10px 12px;
        font-size: 14px;
    }
    /* Grupuri verticale = full width per opțiune */
    .hsk-radio-group--vertical .hsk-radio {
        flex: 1 1 100%;
    }

    /* Checkboxes */
    .hsk-check {
        padding: 10px 12px;
        gap: 10px;
    }
    .hsk-check-label {
        font-size: 13.5px;
    }
    .hsk-check-mark {
        width: 20px;
        height: 20px;
    }
    .hsk-check-mark::after {
        left: 5px;
        top: 2px;
        width: 5px;
        height: 10px;
    }

    /* Field groups */
    .hsk-field-group {
        padding: 12px 12px;
        overflow-x: hidden;
        overflow-y: visible;
    }
    .hsk-conditional .hsk-row {
        grid-template-columns: 1fr;
    }
    .hsk-conditional input[type="text"],
    .hsk-conditional input[type="number"],
    .hsk-conditional input[type="date"] {
        width: 100% !important;
        max-width: 100% !important;
    }
    /* Ensure checkboxes inside conditionals render properly */
    .hsk-conditional .hsk-check {
        display: flex !important;
        align-items: flex-start;
        gap: 12px;
        overflow: visible;
    }
    .hsk-conditional .hsk-check-mark {
        flex-shrink: 0;
        min-width: 22px;
        width: 22px;
        height: 22px;
    }

    /* Nav */
    .hsk-nav {
        margin-top: 20px;
        padding-top: 16px;
        gap: 10px;
    }
    .hsk-btn {
        padding: 12px 18px;
        font-size: 14px;
    }

    /* Consent box */
    .hsk-consent-box {
        padding: 14px 16px;
        font-size: 12.5px;
    }

    /* Result */
    .hsk-result {
        padding: 22px 16px;
    }
    .hsk-result-icon {
        font-size: 44px;
    }
    .hsk-result-title {
        font-size: 20px;
    }
    .hsk-result-message {
        padding: 14px 16px;
        font-size: 14px;
    }
    .hsk-result-footer {
        font-size: 12px;
    }

    /* Errors */
    .hsk-error {
        font-size: 13px;
        padding: 10px 12px;
    }
}

/* ── Small phones (≤ 380px) ────────────────── */
@media (max-width: 380px) {
    #hepaskin-form {
        padding: 14px 10px;
    }
    .hsk-step-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    .hsk-step-number {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }
    .hsk-step-header h2 {
        font-size: 16px;
    }
    .hsk-nav {
        flex-direction: column;
    }
    .hsk-nav-spacer {
        display: none;
    }
    .hsk-btn {
        width: 100%;
        justify-content: center;
    }
    .hsk-steps span {
        min-width: 58px;
        font-size: 9px;
    }
}
