/* ============================================================================
   entity-widgets.css — Fase 4a (Ondata 24)
   Stili dei componenti shared EntityTimeline / EntityNextAction / EntityDocuments.
   Pensati per essere coerenti con i bubble .cw-ws-* dei workspace
   (FornitoreWorkspace, CommessaWorkspace, ClienteWorkspace) e con i token Mago
   (verde accent #92B539, blu header #1B4977). Tutte le regole sono prefissate
   per evitare collisioni col resto della UI.
   ============================================================================ */

/* === EntityTimeline (prefix .cw-etl-*) ==================================== */
.cw-etl {
    background: #fff;
    border: 1px solid #d9deea;
    border-radius: 12px;
    padding: 18px 20px;
}

body.dark-mode .cw-etl {
    background: #2a2724;
    border-color: #2c3647;
    color: #c4d4e8;
}

.cw-etl-toolbar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid #eef1f8;
}

body.dark-mode .cw-etl-toolbar { border-bottom-color: #2c3647; }

.cw-etl-toolbar label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #5a6b80;
    font-weight: 600;
    margin: 0 4px 0 0;
}

.cw-etl-toolbar select {
    height: 30px;
    font-size: 0.85rem;
    padding: 2px 8px;
    border: 1px solid #d9deea;
    border-radius: 6px;
    background: #fff;
    color: #1f2a36;
}

body.dark-mode .cw-etl-toolbar select {
    background: #1f2733;
    color: #f4f6fb;
    border-color: #2c3647;
}

.cw-etl-toolbar .cw-etl-spacer { flex: 1; }

.cw-etl-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.cw-etl-table th {
    text-align: left;
    padding: 8px 12px;
    background: #f6f8ff;
    color: #5a6b80;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid #d9deea;
    position: sticky;
    top: 0;
}

.cw-etl-table th.num, .cw-etl-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.cw-etl-table td { padding: 8px 12px; border-bottom: 1px solid #eef1f8; color: #1f2a36; }
.cw-etl-table tbody tr:hover { background: #f3f6fb; }

body.dark-mode .cw-etl-table th { background: #1a2330; color: #c4d4e8; border-bottom-color: #2c3647; }
body.dark-mode .cw-etl-table td { color: #f4f6fb; border-bottom-color: #2c3647; }
body.dark-mode .cw-etl-table tbody tr:hover { background: #1a2330; }

.cw-etl-row-date { color: #5a6b80; white-space: nowrap; font-variant-numeric: tabular-nums; }

.cw-etl-typebadge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.4;
}

/* Verde accent Mago per ordini, blu header per fatture/doc, arancio per scadenze */
.cw-etl-type-ordine    { background: #e6f1d0; color: #5b7a1f; }
.cw-etl-type-fattura   { background: #d9e4ef; color: #1B4977; }
.cw-etl-type-pagamento { background: #d9efe4; color: #14633d; }
.cw-etl-type-movimento { background: #fef3c7; color: #8a5a00; }
.cw-etl-type-attivita  { background: #ede9fe; color: #5b21b6; }
.cw-etl-type-altro     { background: #f3f4f6; color: #4b5563; }

body.dark-mode .cw-etl-type-ordine    { background: #2e3d1c; color: #c7e08b; }
body.dark-mode .cw-etl-type-fattura   { background: #1c2c40; color: #a8c5e8; }
body.dark-mode .cw-etl-type-pagamento { background: #14332a; color: #92dbb1; }
body.dark-mode .cw-etl-type-movimento { background: #3a2e15; color: #f3c47a; }
body.dark-mode .cw-etl-type-attivita  { background: #2d2549; color: #c6b5f5; }
body.dark-mode .cw-etl-type-altro     { background: #2a2724; color: #c4d4e8; }

.cw-etl-empty {
    padding: 40px 20px;
    text-align: center;
    color: #5a6b80;
    background: #f9faff;
    border: 1px dashed #d9deea;
    border-radius: 10px;
}

.cw-etl-empty i { display: block; font-size: 2rem; margin-bottom: 8px; color: #94a3b8; }

body.dark-mode .cw-etl-empty { background: #1f2733; border-color: #2c3647; color: #b5ae9f; }

.cw-etl-loader { padding: 24px; text-align: center; color: #5a6b80; }

/* === EntityNextAction (prefix .cw-ena-*) ================================== */
.cw-ena {
    background: #fff;
    border: 1px solid #d9deea;
    border-radius: 12px;
    padding: 18px 20px;
}

body.dark-mode .cw-ena {
    background: #2a2724;
    border-color: #2c3647;
    color: #c4d4e8;
}

.cw-ena-toolbar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid #eef1f8;
}

body.dark-mode .cw-ena-toolbar { border-bottom-color: #2c3647; }

.cw-ena-cached-hint {
    font-size: 0.78rem;
    color: #5a6b80;
    font-style: italic;
}

.cw-ena-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cw-ena-card {
    background: #f9faff;
    border: 1px solid #d9deea;
    border-left: 4px solid #94a3b8;
    border-radius: 10px;
    padding: 12px 16px;
    transition: opacity 0.15s;
}

body.dark-mode .cw-ena-card { background: #1f2733; border-color: #2c3647; }

.cw-ena-card.cw-ena-pri-high   { border-left-color: #dc2626; }
.cw-ena-card.cw-ena-pri-medium { border-left-color: #F39200; }
.cw-ena-card.cw-ena-pri-low    { border-left-color: #92B539; }

.cw-ena-card.cw-ena-dismissed,
.cw-ena-card.cw-ena-accepted { opacity: 0.55; }

.cw-ena-head {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 6px;
}

.cw-ena-title {
    flex: 1;
    font-weight: 600;
    color: #1f2a36;
    font-size: 0.95rem;
    line-height: 1.35;
}

body.dark-mode .cw-ena-title { color: #f4f6fb; }

.cw-ena-pri {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    flex-shrink: 0;
}

.cw-ena-pri-high   { background: #fee2e2; color: #991b1b; }
.cw-ena-pri-medium { background: #fef3c7; color: #92400e; }
.cw-ena-pri-low    { background: #dcfce7; color: #166534; }

body.dark-mode .cw-ena-pri-high   { background: #4c0519; color: #fca5a5; }
body.dark-mode .cw-ena-pri-medium { background: #3a2e15; color: #f3c47a; }
body.dark-mode .cw-ena-pri-low    { background: #14332a; color: #92dbb1; }

.cw-ena-impact {
    font-size: 0.82rem;
    color: #5a6b80;
    margin-bottom: 4px;
}

.cw-ena-impact strong { color: #1B4977; }

body.dark-mode .cw-ena-impact strong { color: #a8c5e8; }

.cw-ena-rationale {
    font-size: 0.85rem;
    color: #4a5568;
    line-height: 1.5;
    margin: 4px 0 8px;
}

body.dark-mode .cw-ena-rationale { color: #b5ae9f; }

.cw-ena-due {
    font-size: 0.75rem;
    color: #5a6b80;
    margin-bottom: 8px;
}

.cw-ena-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.cw-ena-status {
    font-size: 0.78rem;
    color: #166534;
    font-weight: 600;
    margin-left: 6px;
}

.cw-ena-empty {
    padding: 36px 20px;
    text-align: center;
    color: #5a6b80;
}

.cw-ena-empty i {
    display: block;
    font-size: 2.2rem;
    color: #94a3b8;
    margin-bottom: 10px;
}

.cw-ena-log {
    margin-top: 12px;
    padding: 8px 12px;
    background: #f6f8ff;
    border-radius: 6px;
    font-family: 'Menlo', monospace;
    font-size: 0.75rem;
    color: #5a6b80;
    max-height: 140px;
    overflow-y: auto;
}

body.dark-mode .cw-ena-log { background: #1f2733; color: #b5ae9f; }

/* === EntityDocuments (prefix .cw-edoc-*) ================================== */
.cw-edoc {
    background: #fff;
    border: 1px solid #d9deea;
    border-radius: 12px;
    padding: 18px 20px;
}

body.dark-mode .cw-edoc {
    background: #2a2724;
    border-color: #2c3647;
    color: #c4d4e8;
}

.cw-edoc-toolbar {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid #eef1f8;
}

body.dark-mode .cw-edoc-toolbar { border-bottom-color: #2c3647; }

.cw-edoc-spacer { flex: 1; }

.cw-edoc-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.cw-edoc-table th {
    text-align: left;
    padding: 8px 12px;
    background: #f6f8ff;
    color: #5a6b80;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid #d9deea;
}

.cw-edoc-table td {
    padding: 8px 12px;
    border-bottom: 1px solid #eef1f8;
    color: #1f2a36;
}

.cw-edoc-table tbody tr:hover { background: #f3f6fb; }

body.dark-mode .cw-edoc-table th { background: #1a2330; color: #c4d4e8; border-bottom-color: #2c3647; }
body.dark-mode .cw-edoc-table td { color: #f4f6fb; border-bottom-color: #2c3647; }
body.dark-mode .cw-edoc-table tbody tr:hover { background: #1a2330; }

.cw-edoc-name {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #1B4977;
    font-weight: 500;
}

body.dark-mode .cw-edoc-name { color: #a8c5e8; }

.cw-edoc-name i { color: #92B539; }

.cw-edoc-empty {
    padding: 40px 20px;
    text-align: center;
    color: #5a6b80;
    background: #f9faff;
    border: 1px dashed #d9deea;
    border-radius: 10px;
}

.cw-edoc-empty i { display: block; font-size: 2rem; margin-bottom: 8px; color: #94a3b8; }

body.dark-mode .cw-edoc-empty { background: #1f2733; border-color: #2c3647; color: #b5ae9f; }

.cw-edoc-error {
    background: #fee2e2;
    color: #991b1b;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    margin-bottom: 10px;
}

body.dark-mode .cw-edoc-error { background: #4c0519; color: #fca5a5; }

.cw-edoc-loader { padding: 24px; text-align: center; color: #5a6b80; }

/* Upload modal (simple inline panel) */
.cw-edoc-upload {
    background: #f9faff;
    border: 1px dashed #92B539;
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 14px;
}

body.dark-mode .cw-edoc-upload {
    background: #1f2733;
    border-color: #5b7a1f;
}

.cw-edoc-upload-label {
    display: block;
    font-size: 0.85rem;
    color: #5a6b80;
    margin-bottom: 8px;
    font-weight: 500;
}

.cw-edoc-upload-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    align-items: center;
}

.cw-edoc-upload-status {
    font-size: 0.82rem;
    margin-left: auto;
}

.cw-edoc-upload-status.ok { color: #166534; }
.cw-edoc-upload-status.err { color: #991b1b; }
