/**
 * CLARALEX - Highlights System (Material Design 3)
 * Stili per l'evidenziazione semantica del testo nei contratti.
 * 
 * AccessibilitÃ : Colori ottimizzati per contrasto WCAG 2.1 (>4.5:1).
 * Performance: Utilizzo di variabili CSS e transizioni hardware-accelerated.
 */

:root {
    /* Tavolozza Colori Semaforo (Google MD3) */
    --claralex-danger-base: #d93025;
    --claralex-danger-bg: rgba(217, 48, 37, 0.15);
    
    --claralex-warning-base: #f9ab00;
    --claralex-warning-bg: rgba(249, 171, 0, 0.2);
    
    --claralex-success-base: #1e8e3e;
    --claralex-success-bg: rgba(30, 142, 62, 0.15);
    
    --claralex-info-base: #1a73e8;
    --claralex-info-bg: rgba(26, 115, 232, 0.15);

    /* ProprietÃ  Comuni */
    --claralex-radius: 4px;
    --claralex-transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* Supporto Dark Mode Browser */
@media (prefers-color-scheme: dark) {
    :root {
        --claralex-danger-bg: rgba(217, 48, 37, 0.3);
        --claralex-warning-bg: rgba(249, 171, 0, 0.35);
        --claralex-success-bg: rgba(30, 142, 62, 0.3);
        --claralex-info-bg: rgba(26, 115, 232, 0.3);
    }
}

/* Selettore Base per Highlights */
mark.claralex-highlight {
    background-color: transparent;
    border-bottom: 2px solid transparent;
    border-radius: var(--claralex-radius);
    padding: 2px 4px;
    margin: 0 1px;
    color: inherit; /* Mantiene il colore del testo originale per leggibilitÃ  */
    transition: var(--claralex-transition);
    cursor: help;
    display: inline; /* Previene layout shift */
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
}

mark.claralex-highlight:focus {
    outline: 2px solid rgba(26, 115, 232, 0.65);
    outline-offset: 1px;
}

/* Classi Semantiche (Semaforo) */

/* ROSSO: Pericolo / Clausola Vessatoria */
mark.claralex-highlight.highlight-danger {
    background-color: var(--claralex-danger-bg);
    border-bottom-color: var(--claralex-danger-base);
}

/* GIALLO: Attenzione / Clausola Sospetta */
mark.claralex-highlight.highlight-warning {
    background-color: var(--claralex-warning-bg);
    border-bottom-color: var(--claralex-warning-base);
}

/* VERDE: Sicura / Clausola Trasparente */
mark.claralex-highlight.highlight-success {
    background-color: var(--claralex-success-bg);
    border-bottom-color: var(--claralex-success-base);
}

/* BLU: Informativa / Dettagli */
mark.claralex-highlight.highlight-info {
    background-color: var(--claralex-info-bg);
    border-bottom-color: var(--claralex-info-base);
}

/* Hover effect per interattivitÃ  */
mark.claralex-highlight:hover {
    filter: brightness(0.95);
}

mark.claralex-highlight.claralex-highlight--active {
    animation: claralexPulse 1.3s ease;
    box-shadow: 0 0 0 4px rgba(26, 115, 232, 0.14);
}

.claralex-status {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 2147483647;
    width: 320px;
    padding: 14px 16px;
    border-radius: 18px;
    color: #ffffff;
    font-family: Arial, sans-serif;
    line-height: 1.4;
    box-shadow: 0 16px 36px rgba(17, 24, 39, 0.24);
    backdrop-filter: blur(8px);
}

.claralex-status__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.claralex-status--hidden {
    display: none;
}

.claralex-status__title {
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 4px;
}

.claralex-status__body {
    font-size: 12px;
    opacity: 0.96;
}

.claralex-status__actions {
    margin-top: 10px;
}

.claralex-status__close {
    border: none;
    background: rgba(255, 255, 255, 0.18);
    color: #ffffff;
    width: 26px;
    height: 26px;
    border-radius: 999px;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
}

.claralex-status--info {
    background: rgba(26, 115, 232, 0.96);
}

.claralex-status--success {
    background: rgba(30, 142, 62, 0.96);
}

.claralex-status--warning {
    background: rgba(185, 116, 0, 0.96);
}

.claralex-status--danger {
    background: rgba(217, 48, 37, 0.96);
}

.claralex-button,
.claralex-inline-button,
.claralex-icon-button {
    font-family: Arial, sans-serif;
}

.claralex-button {
    border: none;
    border-radius: 999px;
    padding: 9px 14px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.claralex-button--light {
    background: rgba(255, 255, 255, 0.92);
    color: #0f172a;
}

.claralex-dock {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 2147483646;
    border: none;
    border-radius: 999px;
    padding: 10px 14px;
    color: #ffffff;
    font-size: 12px;
    font-weight: 800;
    box-shadow: 0 14px 30px rgba(15, 23, 42, 0.22);
    cursor: pointer;
}

.claralex-dock--hidden {
    display: none;
}

.claralex-dock--info {
    background: #1a73e8;
}

.claralex-dock--warning {
    background: #b97400;
}

.claralex-dock--danger {
    background: #d93025;
}

.claralex-dock--success {
    background: #1e8e3e;
}

.claralex-inline-button {
    border: none;
    border-radius: 999px;
    background: #e8f0fe;
    color: #184a9c;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    flex-shrink: 0;
}

.claralex-inline-button--secondary {
    background: #eef2f7;
    color: #475569;
}

.claralex-icon-button {
    border: none;
    background: transparent;
    color: #5f6368;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}

.claralex-panel {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 2147483646;
    width: min(440px, 96vw);
    height: 100vh;
    background: #f7f9fc;
    color: #111827;
    box-shadow: -16px 0 40px rgba(15, 23, 42, 0.18);
    transform: translateX(104%);
    transition: transform 0.25s ease;
    font-family: Arial, sans-serif;
}

.claralex-panel--hidden {
    transform: translateX(104%);
}

.claralex-panel--open {
    transform: translateX(0);
}

.claralex-panel__header {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding: 18px 18px 12px;
    border-bottom: 1px solid #dbe2ea;
    background: #ffffff;
}

.claralex-panel__eyebrow {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #184a9c;
    font-weight: 700;
    margin-bottom: 4px;
}

.claralex-panel__title {
    font-size: 20px;
    font-weight: 700;
}

.claralex-panel__body {
    height: calc(100vh - 78px);
    overflow-y: auto;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.claralex-panel__summary {
    position: sticky;
    top: 0;
    z-index: 3;
    font-size: 15px;
    line-height: 1.5;
    font-weight: 700;
    padding-top: 2px;
    background: linear-gradient(180deg, #f7f9fc 0%, #f7f9fc 80%, rgba(247, 249, 252, 0) 100%);
}

.claralex-summary-card,
.claralex-action-card {
    background: #ffffff;
    border: 1px solid #dbe2ea;
    border-radius: 18px;
    padding: 14px;
    box-shadow: 0 10px 22px rgba(15, 23, 42, 0.05);
}

.claralex-summary-card--danger {
    background: linear-gradient(180deg, #fff6f5 0%, #ffffff 100%);
    border-color: rgba(217, 48, 37, 0.28);
}

.claralex-summary-card--warning {
    background: linear-gradient(180deg, #fff9ed 0%, #ffffff 100%);
    border-color: rgba(249, 171, 0, 0.3);
}

.claralex-summary-card--success,
.claralex-summary-card--info {
    background: linear-gradient(180deg, #f5f9ff 0%, #ffffff 100%);
    border-color: rgba(26, 115, 232, 0.18);
}

.claralex-summary-card__eyebrow,
.claralex-action-card__label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 800;
    color: #184a9c;
}

.claralex-summary-card__body,
.claralex-action-card__body {
    margin-top: 6px;
    font-size: 14px;
    line-height: 1.6;
    color: #1f2937;
}

.claralex-summary-card__meta {
    margin-top: 8px;
    font-size: 12px;
    color: #64748b;
}

.claralex-panel__action {
    font-size: 13px;
    line-height: 1.5;
    color: #475569;
}

.claralex-panel__tools {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.claralex-tool-button {
    border: 1px dashed #b8c4d7;
    background: #ffffff;
    color: #184a9c;
    border-radius: 14px;
    padding: 12px 10px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.claralex-panel__activity {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.claralex-panel__audio {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.claralex-panel__triage {
    position: sticky;
    top: 108px;
    z-index: 2;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    padding: 4px 0 2px;
    background: linear-gradient(180deg, #f7f9fc 0%, #f7f9fc 80%, rgba(247, 249, 252, 0) 100%);
}

.claralex-triage-card {
    border-radius: 18px;
    padding: 14px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    text-align: center;
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.08);
}

.claralex-triage-card__count {
    font-size: 26px;
    font-weight: 800;
    line-height: 1;
}

.claralex-triage-card__label {
    font-size: 12px;
    font-weight: 700;
}

.claralex-triage-card--danger {
    background: rgba(217, 48, 37, 0.12);
    color: #a61b13;
}

.claralex-triage-card--warning {
    background: rgba(249, 171, 0, 0.18);
    color: #8a5b00;
}

.claralex-triage-card--success {
    background: rgba(30, 142, 62, 0.12);
    color: #166534;
}

.claralex-panel__clauses {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-bottom: 28px;
}

.claralex-analysis-card {
    background: #ffffff;
    border-radius: 18px;
    padding: 15px;
    border-left: 6px solid #1a73e8;
    box-shadow: 0 10px 20px rgba(15, 23, 42, 0.06);
    cursor: pointer;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.claralex-analysis-card:hover {
    transform: translateY(-2px) scale(1.01);
    box-shadow: 0 16px 30px rgba(15, 23, 42, 0.11);
}

.claralex-analysis-card--danger {
    border-left-color: #d93025;
}

.claralex-analysis-card--warning {
    border-left-color: #f9ab00;
}

.claralex-analysis-card--success {
    border-left-color: #1e8e3e;
}

.claralex-analysis-card--info {
    border-left-color: #1a73e8;
}

.claralex-analysis-card--active {
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.18);
}

.claralex-analysis-card--expanded {
    box-shadow: 0 16px 28px rgba(15, 23, 42, 0.12);
}

.claralex-analysis-card--pulse {
    animation: claralexPanelPulse 1.1s ease;
}

.claralex-analysis-card__header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
}

.claralex-analysis-card__title {
    font-size: 15px;
    font-weight: 800;
    line-height: 1.35;
}

.claralex-analysis-card__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.claralex-analysis-card__meta {
    font-size: 12px;
    color: #64748b;
    margin-top: 3px;
}

.claralex-analysis-card__preview {
    margin-top: 10px;
    font-size: 13px;
    line-height: 1.5;
    color: #334155;
}

.claralex-analysis-card--expanded .claralex-analysis-card__preview {
    display: none;
}

.claralex-analysis-card__body[hidden] {
    display: none;
}

.claralex-analysis-card__body {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 12px;
}

.claralex-analysis-card__summary {
    margin-top: 2px;
    font-size: 13px;
    line-height: 1.55;
    color: #1f2937;
    font-weight: 600;
}
.claralex-analysis-card__description {
    font-size: 13px;
    line-height: 1.5;
}

.claralex-analysis-card__reason {
    font-size: 12px;
    line-height: 1.5;
    color: #475569;
    margin-top: 8px;
}

.claralex-analysis-card__quotes {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.claralex-analysis-card__quotes-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 800;
    color: #64748b;
}

.claralex-analysis-card__quote {
    background: #f8fafc;
    border: 1px solid #dbe2ea;
    border-radius: 12px;
    padding: 9px 10px;
    font-size: 12px;
    line-height: 1.45;
    color: #334155;
    text-align: left;
    width: 100%;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.claralex-analysis-card__quote--active {
    border-color: #1a73e8;
    box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.12);
}

.claralex-analysis-empty {
    background: #ffffff;
    border-radius: 16px;
    padding: 14px;
    font-size: 13px;
    line-height: 1.5;
    color: #475569;
}

.claralex-activity-item {
    display: grid;
    grid-template-columns: 70px 1fr;
    gap: 10px;
    align-items: start;
    background: #ffffff;
    border-radius: 14px;
    padding: 10px 12px;
    border-left: 4px solid #1a73e8;
    font-size: 12px;
    line-height: 1.45;
}

.claralex-activity-item__time {
    color: #64748b;
    font-weight: 700;
}

.claralex-activity-item--warning {
    border-left-color: #f9ab00;
}

.claralex-activity-item--danger {
    border-left-color: #d93025;
}

.claralex-activity-item--success {
    border-left-color: #1e8e3e;
}

.claralex-audio-card {
    background: #ffffff;
    border-radius: 18px;
    padding: 14px;
    border: 1px solid #dbe2ea;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.05);
}

.claralex-audio-card--alert {
    border-color: rgba(249, 171, 0, 0.5);
    background: linear-gradient(180deg, #fff9ed 0%, #ffffff 100%);
}

.claralex-audio-card--positive {
    border-color: rgba(30, 142, 62, 0.3);
    background: linear-gradient(180deg, #f4fbf6 0%, #ffffff 100%);
}

.claralex-audio-card--calm,
.claralex-audio-card--loading {
    border-color: rgba(26, 115, 232, 0.22);
    background: linear-gradient(180deg, #f4f8ff 0%, #ffffff 100%);
}

.claralex-audio-card__headline {
    font-size: 14px;
    font-weight: 800;
    line-height: 1.35;
}

.claralex-audio-card__meta {
    margin-top: 4px;
    font-size: 12px;
    color: #64748b;
}

.claralex-audio-card__text {
    margin-top: 10px;
    font-size: 13px;
    line-height: 1.6;
    color: #334155;
}

.claralex-audio-card__error {
    margin-top: 10px;
    font-size: 12px;
    line-height: 1.5;
    color: #8a5b00;
}

@keyframes claralexPulse {
    0% { box-shadow: 0 0 0 0 rgba(26, 115, 232, 0.28); }
    100% { box-shadow: 0 0 0 10px rgba(26, 115, 232, 0); }
}

@keyframes claralexPanelPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.01); }
    100% { transform: scale(1); }
}

.claralex-tool-button--primary {
    background: linear-gradient(180deg, #1490ff 0%, #0d77ef 100%);
    border-style: solid;
    border-color: transparent;
    color: #ffffff;
    box-shadow: 0 10px 20px rgba(26, 115, 232, 0.18);
}

.claralex-analysis-card__badge {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    border-radius: 999px;
    padding: 5px 9px;
    font-size: 11px;
    font-weight: 800;
    margin-bottom: 8px;
}

.claralex-analysis-card__badge--danger {
    background: rgba(217, 48, 37, 0.12);
    color: #a61b13;
}

.claralex-analysis-card__badge--warning {
    background: rgba(249, 171, 0, 0.18);
    color: #8a5b00;
}

.claralex-analysis-card__badge--success {
    background: rgba(30, 142, 62, 0.12);
    color: #166534;
}

.claralex-analysis-card__badge--info {
    background: rgba(26, 115, 232, 0.12);
    color: #184a9c;
}

.claralex-analysis-card__summary {
    margin-top: 2px;
    font-size: 13px;
    line-height: 1.55;
    color: #1f2937;
    font-weight: 600;
}
.claralex-analysis-card__description {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

@media (max-width: 720px) {
    .claralex-status {
        top: auto;
        right: 12px;
        left: 12px;
        bottom: 12px;
        width: auto;
        border-radius: 20px;
    }

    .claralex-panel {
        width: 100vw;
        max-width: 100vw;
    }

    .claralex-panel__body {
        padding: 14px;
        gap: 12px;
    }

    .claralex-panel__tools {
        grid-template-columns: 1fr;
    }

    .claralex-analysis-card__header {
        flex-direction: column;
    }

    .claralex-analysis-card__actions {
        width: 100%;
        justify-content: flex-start;
    }
}


.claralex-analysis-card__quote:hover {
    transform: translateY(-1px);
    border-color: rgba(26, 115, 232, 0.28);
    box-shadow: 0 10px 18px rgba(26, 115, 232, 0.08);
}



