/* RoomUpItalia — Documenti legali pubblici e gestione amministrativa */

.legal-page,
.legal-admin-page {
    width: min(1180px, calc(100% - 24px));
    margin: 24px auto 56px;
}

.legal-page__shell {
    max-width: 900px;
    margin: 0 auto;
}

.legal-page__header,
.legal-content,
.legal-unavailable,
.legal-document-card,
.legal-editor-card,
.legal-editor-status,
.legal-preview,
.legal-admin-note,
.legal-editor-warning {
    border: 1px solid #dce3ee;
    border-radius: 20px;
    background: #ffffff;
    box-shadow: 0 16px 42px rgba(15, 23, 42, 0.06);
}

.legal-page__header {
    padding: 24px;
    background: linear-gradient(145deg, #eff6ff, #ffffff 68%);
}

.legal-page__eyebrow,
.legal-document-card__label {
    margin: 0 0 8px;
    color: #1d4ed8;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.legal-page__header h1,
.legal-admin-header h1,
.legal-document-card h2 {
    margin: 0;
    color: #0f172a;
    letter-spacing: -0.03em;
}

.legal-page__header h1 {
    font-size: clamp(32px, 7vw, 52px);
    line-height: 1.05;
}

.legal-page__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 18px;
}

.legal-page__meta span {
    padding: 7px 10px;
    border-radius: 999px;
    background: #e8eef8;
    color: #334155;
    font-size: 13px;
    font-weight: 700;
}

.legal-page__meta .legal-page__meta-archived {
    background: #fef3c7;
    color: #92400e;
}

.legal-content {
    margin-top: 18px;
    padding: 24px;
    color: #334155;
    font-size: 15px;
    line-height: 1.75;
}

.legal-content h2,
.legal-content h3 {
    color: #0f172a;
    line-height: 1.25;
}

.legal-content h2 {
    margin: 32px 0 12px;
    font-size: 24px;
}

.legal-content h2:first-child {
    margin-top: 0;
}

.legal-content h3 {
    margin: 24px 0 10px;
    font-size: 18px;
}

.legal-content p,
.legal-content ul,
.legal-content ol {
    margin: 0 0 16px;
}

.legal-content ul,
.legal-content ol {
    padding-left: 22px;
}

.legal-content li + li {
    margin-top: 7px;
}

.legal-content hr {
    margin: 28px 0;
    border: 0;
    border-top: 1px solid #dce3ee;
}

.legal-page__footer {
    padding: 18px 6px 0;
    color: #64748b;
    font-size: 14px;
}

.legal-page__footer a,
.legal-editor-status a,
.legal-back-link {
    color: #1d4ed8;
    font-weight: 700;
}

.legal-unavailable {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-top: 18px;
    padding: 22px;
    border-color: #fde68a;
    background: #fffbeb;
}

.legal-unavailable img,
.legal-admin-note img,
.legal-editor-warning img {
    width: 22px;
    height: 22px;
    flex: 0 0 22px;
    filter: brightness(0);
}

.legal-unavailable h2,
.legal-unavailable p {
    margin: 0;
}

.legal-unavailable p {
    margin-top: 6px;
    color: #78350f;
    line-height: 1.55;
}

.legal-admin-header {
    margin-bottom: 20px;
}

.legal-admin-header p:last-child {
    max-width: 720px;
}

.legal-admin-header--editor {
    display: block;
}

.legal-back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 18px;
    text-decoration: none;
}

.legal-back-link img {
    width: 18px;
    height: 18px;
    filter: brightness(0);
}

.legal-admin-alert {
    margin-bottom: 18px;
    padding: 14px 16px;
    border: 1px solid;
    border-radius: 14px;
    font-weight: 700;
}

.legal-admin-alert--success {
    border-color: #bbf7d0;
    background: #f0fdf4;
    color: #166534;
}

.legal-admin-alert--error {
    border-color: #fecaca;
    background: #fff1f2;
    color: #991b1b;
}

.legal-document-grid,
.legal-editor-layout {
    display: grid;
    gap: 18px;
}

.legal-document-card {
    padding: 20px;
}

.legal-document-card__top {
    display: flex;
    align-items: center;
    gap: 14px;
}

.legal-document-card__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    flex: 0 0 48px;
    border-radius: 15px;
    background: #eff6ff;
}

.legal-document-card__icon img {
    width: 24px;
    height: 24px;
    filter: brightness(0);
}

.legal-document-card h2 {
    font-size: 23px;
}

.legal-document-status {
    display: grid;
    gap: 10px;
    margin: 20px 0;
}

.legal-document-status div {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid #edf1f6;
}

.legal-document-status dt {
    color: #64748b;
}

.legal-document-status dd {
    margin: 0;
    color: #0f172a;
    font-weight: 800;
    text-align: right;
}

.legal-document-card__warning {
    padding: 12px 14px;
    border: 1px solid #fde68a;
    border-radius: 12px;
    background: #fffbeb;
    color: #92400e;
    font-size: 14px;
    line-height: 1.5;
}

.legal-document-card__actions,
.legal-editor-actions {
    display: grid;
    gap: 10px;
}

.legal-document-card__actions a,
.legal-editor-actions button {
    justify-content: center;
    text-align: center;
}

.legal-history {
    margin-top: 18px;
    border-top: 1px solid #e2e8f0;
}

.legal-history summary,
.legal-preview summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 0 0;
    color: #0f172a;
    font-weight: 800;
    cursor: pointer;
}

.legal-history__body {
    display: grid;
    gap: 10px;
    padding-top: 14px;
}

.legal-history__item {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    padding: 12px;
    border-radius: 12px;
    background: #f8fafc;
}

.legal-history__item strong,
.legal-history__item small {
    display: block;
}

.legal-history__item small,
.legal-history__item time {
    color: #64748b;
    font-size: 12px;
}

.legal-history__actions {
    display: grid;
    justify-items: end;
    gap: 4px;
}

.legal-history__actions a {
    color: #1d4ed8;
    font-size: 12px;
    font-weight: 800;
    text-decoration: none;
}

.legal-history__actions a:hover,
.legal-history__actions a:focus-visible {
    text-decoration: underline;
}

.legal-editor-card {
    padding: 20px;
}

.legal-editor-grid {
    display: grid;
    gap: 16px;
}

.legal-field {
    display: grid;
    gap: 7px;
}

.legal-field--content {
    margin-top: 18px;
}

.legal-field label {
    color: #0f172a;
    font-weight: 800;
}

.legal-field input,
.legal-field textarea {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #b8c5d8;
    border-radius: 13px;
    background: #ffffff;
    color: #0f172a;
    font: inherit;
}

.legal-field input {
    min-height: 46px;
    padding: 10px 12px;
}

.legal-field textarea {
    min-height: 520px;
    padding: 14px;
    line-height: 1.55;
    resize: vertical;
}

.legal-field input:focus,
.legal-field textarea:focus {
    border-color: #2563eb;
    outline: 3px solid rgba(37, 99, 235, 0.16);
}

.legal-field__hint,
.legal-field__error {
    margin: 0;
    font-size: 13px;
    line-height: 1.5;
}

.legal-field__hint {
    color: #64748b;
}

.legal-field__error {
    color: #b91c1c;
    font-weight: 700;
}

.legal-field__hint code {
    padding: 2px 5px;
    border-radius: 5px;
    background: #eef2f7;
}

.legal-editor-actions {
    margin-top: 20px;
}

.legal-editor-side {
    display: grid;
    align-content: start;
    gap: 16px;
}

.legal-editor-status,
.legal-editor-warning {
    padding: 18px;
}

.legal-editor-status h2,
.legal-editor-status p {
    margin: 0;
}

.legal-editor-status p + a,
.legal-editor-status h2 + p {
    display: block;
    margin-top: 8px;
}

.legal-editor-status__warning {
    color: #92400e;
}

.legal-preview {
    overflow: hidden;
}

.legal-preview summary {
    padding: 16px 18px;
}

.legal-preview__body {
    max-height: 620px;
    margin: 0;
    overflow: auto;
    border: 0;
    border-top: 1px solid #e2e8f0;
    border-radius: 0;
    box-shadow: none;
}

.legal-admin-note,
.legal-editor-warning {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-top: 18px;
    color: #475569;
    line-height: 1.55;
}

.legal-editor-warning {
    margin-top: 0;
    border-color: #fde68a;
    background: #fffbeb;
    color: #78350f;
}

.legal-admin-note p,
.legal-editor-warning p {
    margin: 0;
}

@media (min-width: 720px) {
    .legal-page,
    .legal-admin-page {
        width: min(1180px, calc(100% - 48px));
        margin-top: 34px;
    }

    .legal-page__header,
    .legal-content {
        padding: 34px;
    }

    .legal-document-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .legal-editor-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .legal-field--wide {
        grid-column: 1 / -1;
    }

    .legal-document-card__actions,
    .legal-editor-actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 1020px) {
    .legal-editor-layout {
        grid-template-columns: minmax(0, 1.55fr) minmax(320px, 0.75fr);
        align-items: start;
    }

    .legal-editor-side {
        position: sticky;
        top: 24px;
    }
}

.legal-compliance {
    overflow: hidden;
    border: 1px solid #dce3ee;
    border-radius: 20px;
    background: #ffffff;
    box-shadow: 0 16px 42px rgba(15, 23, 42, 0.06);
}

.legal-compliance summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px;
    color: #0f172a;
    font-weight: 800;
    cursor: pointer;
}

.legal-compliance summary span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    min-height: 28px;
    padding: 4px 8px;
    border-radius: 999px;
    background: #eef2f7;
    color: #334155;
    font-size: 12px;
}

.legal-compliance[open] summary {
    border-bottom: 1px solid #e2e8f0;
}

.legal-compliance__body {
    padding: 18px;
    color: #475569;
    font-size: 14px;
    line-height: 1.55;
}

.legal-compliance__body p,
.legal-compliance__body ul,
.legal-compliance__body h3 {
    margin: 0;
}

.legal-compliance__body ul {
    padding-left: 20px;
}

.legal-compliance__body p + ul,
.legal-compliance__body ul + h3,
.legal-compliance__body p + h3,
.legal-placeholder-list + h3 {
    margin-top: 14px;
}

.legal-compliance__body li + li {
    margin-top: 6px;
}

.legal-compliance__body h3 {
    color: #0f172a;
    font-size: 14px;
}

.legal-compliance__success {
    padding: 12px 14px;
    border: 1px solid #bbf7d0;
    border-radius: 12px;
    background: #f0fdf4;
    color: #166534;
    font-weight: 700;
}

.legal-placeholder-list {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 10px;
}

.legal-placeholder-list code {
    max-width: 100%;
    padding: 6px 8px;
    overflow-wrap: anywhere;
    border: 1px solid #fed7aa;
    border-radius: 8px;
    background: #fff7ed;
    color: #9a3412;
    font-size: 11px;
}

.legal-content a {
    color: #1d4ed8;
    font-weight: 700;
    text-underline-offset: 3px;
}

.legal-content a:hover,
.legal-content a:focus-visible {
    text-decoration-thickness: 2px;
}
