/**
 * Tool 4 — Styles for Learn & Plan tool.
 *
 * @package DEI4SME
 * @since   1.0.0
 */

.dei4sme-tool4 {
    max-width: 720px;
}

.dei4sme-tool4__phase[hidden] {
    display: none;
}

.dei4sme-tool4__nav {
    display: flex;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-lg);
    padding-top: var(--spacing-md);
    border-top: 1px solid var(--color-border);
}

/* === Engagement Areas === */
.dei4sme-tool4__area {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: var(--spacing-sm) var(--spacing-md) var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

/* === Intro Section === */
.tool4__intro {
    margin-top: var(--spacing-xl);
}

.tool4__intro-content {
    margin-bottom: var(--spacing-lg);
}

.tool4__intro-content h2 {
    margin-bottom: var(--spacing-sm);
}

/* === Area Cards (Intro Page) === */
.tool4__areas-grid {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}

.tool4__area-card {
    padding-bottom: var(--spacing-lg);
    border-bottom: 1px solid var(--color-border);
}

.tool4__area-card:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.tool4__area-title {
    color: var(--color-primary);
    margin-bottom: var(--spacing-xs);
}

.tool4__area-focus {
    color: var(--color-text-light);
    margin-bottom: var(--spacing-sm);
}

/* === Best Practice Submission Section === */
.tool4__submit-practice {
    margin-top: var(--spacing-xl);
    padding-top: var(--spacing-lg);
    border-top: 1px solid var(--color-border);
}

.tool4__submit-practice h2 {
    color: var(--color-primary);
    margin-bottom: var(--spacing-xs);
}

.tool4__submit-practice p {
    color: var(--color-text-light);
    margin-bottom: var(--spacing-sm);
}

/* Practice form fields */
.tool4__practice-form {
    margin-top: var(--spacing-lg);
}

.tool4__practice-form .form-field {
    margin-bottom: var(--spacing-lg);
}

.tool4__practice-form label {
    display: block;
    font-weight: 600;
    margin-bottom: var(--spacing-xs);
}

.tool4__practice-form input,
.tool4__practice-form select,
.tool4__practice-form textarea {
    width: 100%;
    max-width: 400px;
}

.tool4__practice-form textarea {
    max-width: 100%;
}

/* === Area Detail View === */
.tool4__area-detail {
    margin-top: var(--spacing-xl);
}

.tool4__back-btn {
    display: inline-block;
    padding: 14px 28px;
    background: var(--color-bg-alt, #f0f0f0);
    color: var(--color-text);
    font-size: 15px;
    font-weight: 600;
    border: 1px solid var(--color-border, #e0e0e0);
    border-radius: var(--radius, 8px);
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s ease, border-color 0.15s ease;
    margin-bottom: var(--spacing-lg);
}

.tool4__back-btn:hover {
    background: #e4e4e4;
    border-color: #ccc;
}

.tool4__area-header {
    margin-bottom: var(--spacing-lg);
}

.tool4__why-it-pays {
    margin-bottom: var(--spacing-lg);
}

.tool4__actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-xl);
}

.tool4__actions[hidden] {
    display: none;
}

/* === Level Assessment === */
.tool4__level-assessment {
    margin-top: var(--spacing-lg);
}

.tool4__level-assessment h3 {
    color: var(--color-primary);
    margin-bottom: var(--spacing-sm);
}

.tool4__assessment-form .tool4__question {
    margin-bottom: var(--spacing-lg);
    padding-bottom: var(--spacing-md);
    border-bottom: 1px solid var(--color-border);
}

.tool4__assessment-form .tool4__question:last-of-type {
    border-bottom: none;
}

#assessment-questions > div {
    margin-bottom: var(--spacing-lg);
    padding: var(--spacing-md);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}

/* Question text */
#assessment-questions > div > p {
    font-weight: 600;
    margin-bottom: var(--spacing-lg);
    padding-bottom: var(--spacing-md);
    border-bottom: 1px solid var(--color-border);
}

/* Radio options row */
#assessment-questions > div > div {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-md);
}

/* Individual radio option */
#assessment-questions label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
}

#assessment-questions label:hover {
    background-color: var(--color-bg-alt);
}

#assessment-questions input[type="radio"]:checked + label,
#assessment-questions label:has(input:checked) {
    background-color: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}

.dei4sme-tool4__area legend {
    font-weight: 600;
    font-size: 18px;
    color: var(--color-primary);
    padding: 0 8px;
}

.dei4sme-tool4__area-desc {
    color: var(--color-text-light);
    margin-bottom: var(--spacing-sm);
}

/* === Assessment Questions === */
.dei4sme-tool4__question {
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-sm);
    border-bottom: 1px solid var(--color-border);
}

.dei4sme-tool4__question:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.dei4sme-tool4__question-text {
    font-weight: 600;
    margin-bottom: 8px;
}

.dei4sme-tool4__question--error {
    border-color: var(--color-error);
    background: rgba(192, 57, 43, 0.03);
    padding: var(--spacing-sm);
    border-radius: var(--radius);
}

.dei4sme-tool4__question--error .dei4sme-tool4__question-text {
    color: var(--color-error);
}

/* === Action Plan === */
.dei4sme-tool4__plan-area {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

.dei4sme-tool4__plan-area h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: var(--spacing-sm);
}

.dei4sme-tool4__plan-score {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 28px;
    background: var(--color-primary);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    border-radius: 14px;
    padding: 0 10px;
}

/* === Re-assessment Delta Badge === */
.tool4__level-delta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: var(--spacing-xs);
    padding: 6px 12px;
    background: var(--color-bg-alt, #f5f5f5);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.85rem;
    color: var(--color-text-muted, #555);
}

.tool4__level-delta-prev {
    text-decoration: line-through;
    opacity: 0.7;
}

.tool4__level-delta-new {
    font-weight: 600;
    color: var(--color-primary);
}

/* === Signature Upload === */
.dei4sme-tool4__signature-upload {
    margin-top: var(--spacing-lg);
    padding: var(--spacing-md);
    background: var(--color-bg-alt, #f5f5f5);
    border-radius: var(--radius);
}

.dei4sme-tool4__signature-upload label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
}

/* === Assessment Scale (matches Tool 3 visual) === */
.tool4__question {
    margin-bottom: var(--spacing-lg, 24px);
    padding-bottom: var(--spacing-md, 16px);
    border-bottom: 1px solid var(--color-border, #e0e0e0);
}

.tool4__question-text {
    display: block;
    font-weight: 500;
    margin-bottom: var(--spacing-sm, 8px);
    line-height: 1.5;
}

.tool4__scale {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-wrap: wrap;
}

.tool4__scale-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
}

.tool4__scale-item input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.tool4__scale-item span {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 2px solid var(--color-border, #ccc);
    border-radius: 50%;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.15s ease;
    background: var(--color-bg);
    color: var(--color-text);
}

.tool4__scale-item:hover span {
    border-color: var(--color-primary);
    background: rgba(66, 110, 174, 0.08);
}

.tool4__scale-item input[type="radio"]:checked + span {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}

.tool4__scale-item input[type="radio"]:focus-visible + span {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.tool4__scale-labels {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--color-text-muted, #666);
    margin-top: 4px;
    padding: 0 4px;
}

/* === Example Practices (Minimal / Moderate / Extensive) === */
.tool4__examples {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg, 24px);
}

.tool4__example-level {
    padding: var(--spacing-md, 16px);
    border: 1px solid var(--color-border, #e0e0e0);
    border-radius: var(--radius, 8px);
    border-left: 4px solid var(--color-border, #e0e0e0);
}

.tool4__example-level--minimal {
    border-left-color: var(--color-success);
    background: rgba(39, 174, 96, 0.03);
}

.tool4__example-level--moderate {
    border-left-color: var(--color-warning);
    background: rgba(243, 156, 18, 0.03);
}

.tool4__example-level--extensive {
    border-left-color: #8e44ad;
    background: rgba(142, 68, 173, 0.03);
}

.tool4__example-level-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: var(--spacing-xs, 4px);
}

.tool4__example-level--minimal .tool4__example-level-title { color: var(--color-success); }
.tool4__example-level--moderate .tool4__example-level-title { color: var(--color-level-developing); }
.tool4__example-level--extensive .tool4__example-level-title { color: #8e44ad; }

.tool4__example-level-desc {
    margin-bottom: var(--spacing-sm, 8px);
    line-height: 1.6;
}

.tool4__quick-examples h5 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text-muted, #666);
    margin-bottom: var(--spacing-xs, 4px);
}

.tool4__quick-examples ul {
    list-style: disc;
    padding-left: 1.25em;
    margin: 0;
}

.tool4__quick-examples li {
    margin-bottom: 4px;
    line-height: 1.5;
}

/* === Per-Area Action Plan Forms === */
.tool4__plan-form {
    margin-bottom: var(--spacing-lg, 24px);
}

.tool4__plan-form fieldset {
    border: 1px solid var(--color-border, #e0e0e0);
    border-radius: var(--radius, 8px);
    padding: var(--spacing-md, 16px);
}

.tool4__plan-form legend {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--color-primary);
    padding: 0 8px;
}

.tool4__plan-form .form-field {
    margin-bottom: var(--spacing-md, 16px);
}

.tool4__plan-form input[type="date"] {
    display: block;
    width: 100%;
    padding: 10px 15px;
    font-family: inherit;
    font-size: 16px;
    line-height: 1.5;
    color: var(--color-text);
    background: var(--color-bg);
    border: 2px solid var(--color-border, #ddd);
    border-radius: var(--radius, 6px);
    transition: border-color var(--transition, 0.2s), box-shadow var(--transition, 0.2s);
    box-sizing: border-box;
}

.tool4__plan-form input[type="date"]:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(66, 110, 174, 0.2);
    outline: none;
}

.tool4__plan-form label {
    display: block;
    font-weight: 600;
    margin-bottom: var(--spacing-xs, 4px);
}

.tool4__plan-form input,
.tool4__plan-form select,
.tool4__plan-form textarea {
    width: 100%;
}

.tool4__plan-form textarea {
    resize: vertical;
}

.tool4__field-examples {
    display: block;
    margin-top: 4px;
    font-size: 0.8rem;
    color: var(--color-text-muted, #888);
    font-style: italic;
}

.tool4__remove-entry-btn {
    float: right;
    background: none;
    border: 1px solid var(--color-error);
    color: var(--color-error);
    font-size: 0.85rem;
    padding: 4px 10px;
    border-radius: var(--radius, 6px);
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.tool4__remove-entry-btn:hover {
    background: var(--color-error);
    color: #fff;
}

.tool4__remove-entry-btn[hidden] {
    display: none;
}

.tool4__plan-actions {
    display: flex;
    gap: var(--spacing-sm, 8px);
    flex-wrap: wrap;
    margin-top: var(--spacing-md, 16px);
}

.tool4__plan-actions .btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.tool4__download-hint {
    margin-top: var(--spacing-xs, 4px);
    font-size: 0.85rem;
    color: var(--color-text-muted, #888);
    font-style: italic;
}

.tool4__download-hint[hidden] {
    display: none;
}

/* === Action Plan Form === */
.tool4__plan-heading {
    font-size: 24px;
    font-weight: 700;
    color: var(--color-text-heading);
    margin-bottom: 32px;
}

.tool4__plan-form {
    border: 1px solid var(--color-border-light);
    border-radius: 12px;
    padding: 32px;
    background: var(--color-bg);
    margin-bottom: 24px;
}

.tool4__plan-field {
    margin-bottom: 28px;
}

.tool4__plan-field:last-child {
    margin-bottom: 0;
}

.tool4__plan-label {
    display: block;
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text-heading);
    margin-bottom: 4px;
}

.tool4__plan-hint {
    font-size: 14px;
    color: var(--color-text-muted);
    margin: 0 0 12px 0;
}

.tool4__plan-sublabel {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text-body);
    margin-bottom: 6px;
}

.tool4__plan-input {
    display: block;
    width: 100%;
    height: 44px;
    padding: 10px 12px;
    font-size: 14px;
    border: 1px solid var(--color-border-input);
    border-radius: 8px;
    background: var(--color-bg);
    color: var(--color-text-heading);
    box-sizing: border-box;
}

.tool4__plan-input:focus,
.tool4__plan-textarea:focus {
    outline: none;
    border-color: var(--color-blue-accent);
    box-shadow: 0 0 0 2px rgba(79, 129, 201, 0.15);
}

.tool4__plan-textarea {
    display: block;
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    border: 1px solid var(--color-border-input);
    border-radius: 8px;
    background: var(--color-bg);
    color: var(--color-text-heading);
    resize: vertical;
    font-family: inherit;
    box-sizing: border-box;
}

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

.tool4__plan-row > * {
    min-width: 0;
    overflow: hidden;
}

.tool4__plan-examples {
    margin-top: 12px;
    margin-bottom: 16px;
    padding: 12px;
    background: var(--color-bg-subtle);
    border-radius: 8px;
}

.tool4__plan-examples-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-muted);
    margin: 0 0 4px 0;
}

.tool4__plan-example {
    font-size: 13px;
    color: var(--color-text-muted);
    font-style: italic;
    margin: 0 0 2px 0;
}

/* --- Radio Group (Lifecycle Stage) --- */
.tool4__plan-radio-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.tool4__plan-radio {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
    color: var(--color-text-heading);
    padding: 8px 12px;
    border: 1px solid var(--color-border-light);
    border-radius: 6px;
    transition: border-color 0.15s, background-color 0.15s;
}

.tool4__plan-radio:hover {
    border-color: var(--color-primary);
    background-color: var(--color-bg-surface);
}

.tool4__plan-radio input[type="radio"] {
    accent-color: var(--color-primary);
    width: 16px;
    height: 16px;
    margin: 0;
    flex-shrink: 0;
}

.tool4__plan-radio input[type="radio"]:checked + span {
    font-weight: 600;
    color: var(--color-primary);
}

/* Radio with description (compliance variant) */
.tool4__plan-radio--with-desc {
    align-items: flex-start;
    padding: 10px 12px;
}

.tool4__plan-radio--with-desc input[type="radio"] {
    margin-top: 3px;
}

.tool4__plan-radio-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.tool4__plan-radio-label {
    font-weight: 600;
}

.tool4__plan-radio-desc {
    font-size: 12px;
    color: var(--color-text-placeholder);
    font-weight: 400;
}

.tool4__plan-radio input[type="radio"]:checked + .tool4__plan-radio-content .tool4__plan-radio-label {
    color: var(--color-primary);
}

/* === Extend References (collapsible) === */
.tool4__extend {
    margin-top: var(--spacing-md, 16px);
}

.tool4__extend-details summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--color-primary);
    padding: var(--spacing-sm, 8px) 0;
}

.tool4__extend-details ul {
    list-style: none;
    padding: 0;
    margin: var(--spacing-sm, 8px) 0 0;
}

.tool4__extend-details li {
    margin-bottom: var(--spacing-xs, 4px);
}

.tool4__extend-details a {
    color: var(--color-primary);
    text-decoration: underline;
}

/* === Barriers Section === */
.tool4__barriers {
    margin-top: var(--spacing-xl, 32px);
    padding: var(--spacing-lg, 24px);
    background: #fef9e7;
    border: 1px solid #f9e79f;
    border-radius: var(--radius, 8px);
}

.tool4__barriers h2 {
    font-size: 1.15rem;
    color: #7d6608;
    margin-bottom: var(--spacing-sm, 8px);
}

.tool4__barriers p {
    line-height: 1.6;
    color: #5a4e07;
}

/* === References Section === */
.tool4__references {
    margin-top: var(--spacing-lg, 24px);
    padding-top: var(--spacing-lg, 24px);
    border-top: 1px solid var(--color-border, #e0e0e0);
}

.tool4__references h2 {
    font-size: 1.15rem;
    color: var(--color-primary);
    margin-bottom: var(--spacing-md, 16px);
}

.tool4__references-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.tool4__references-list li {
    margin-bottom: var(--spacing-sm, 8px);
    line-height: 1.5;
}

.tool4__references-list a {
    color: var(--color-primary);
    text-decoration: underline;
    margin-left: 4px;
}

/* === Consent Overlay (modal before area detail) === */
.dei4sme-consent-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-md, 16px);
}

.dei4sme-consent-overlay[hidden] {
    display: none;
}

.dei4sme-consent-overlay__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
}

.dei4sme-consent-overlay__dialog {
    position: relative;
    background: var(--color-bg);
    border-radius: var(--radius-lg, 12px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    padding: var(--spacing-lg, 32px);
    max-width: 540px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

.dei4sme-consent-overlay__dialog h3 {
    margin: 0 0 var(--spacing-md, 16px);
    font-size: 1.25rem;
    font-weight: 700;
}

.dei4sme-consent-overlay .dei4sme-consent-gate__checkbox {
    margin-bottom: var(--spacing-sm, 12px);
}

.dei4sme-consent-overlay__continue {
    margin-top: var(--spacing-md, 16px);
    width: 100%;
}

.dei4sme-consent-overlay__continue:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* === Responsive === */
@media (max-width: 600px) {
    .dei4sme-tool4__nav {
        flex-direction: column;
    }

    .tool4__scale-item span {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }

    .tool4__plan-row {
        grid-template-columns: 1fr;
    }

    .tool4__plan-actions {
        flex-direction: column;
    }
}
