/* ===========================================================
   ISTAT Lavoro Calabria - stili scoped (.ilc-wrap)
   Nessuno stile globale: tutto prefissato per evitare conflitti
   con il tema e con altri plugin ISTAT presenti sul sito.
   =========================================================== */

.ilc-wrap {
    --ilc-cal: #e74c3c;
    --ilc-ita: #2c3e50;
    --ilc-nord: #16a085;
    --ilc-centro: #f39c12;
    --ilc-sud: #2980b9;
    --ilc-card: rgba(255, 255, 255, 0.97);
    --ilc-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    --ilc-radius: 18px;

    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: #2c3e50;
    max-width: 1400px;
    margin: 0 auto;
    padding: 16px;
    background: transparent;
    box-sizing: border-box;
}
.ilc-wrap *, .ilc-wrap *::before, .ilc-wrap *::after { box-sizing: border-box; }

/* ---------- Header ---------- */
.ilc-wrap .ilc-header {
    background: var(--ilc-card);
    border-radius: var(--ilc-radius);
    padding: 26px 30px;
    margin-bottom: 24px;
    box-shadow: var(--ilc-shadow);
}
.ilc-wrap .ilc-header h1 {
    color: var(--ilc-cal);
    font-size: 2.2em;
    font-weight: 800;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    line-height: 1.2;
}
.ilc-wrap .ilc-badge {
    background: linear-gradient(135deg, var(--ilc-cal), #c0392b);
    color: #fff;
    font-size: 0.5em;
    padding: 5px 12px;
    border-radius: 20px;
    font-weight: 600;
}
.ilc-wrap .ilc-header p {
    color: #3d3d3d;
    margin: 8px 0 0;
    font-size: 1.08em;
    line-height: 1.55;
}
.ilc-wrap .ilc-fonte { font-size: 0.95em; color: #555; }
.ilc-wrap .ilc-fonte a { color: #b03a2e; font-weight: 600; }
.ilc-wrap .ilc-fonte a:hover { text-decoration: underline; }

/* ---------- View toggle ---------- */
.ilc-wrap .ilc-view-toggle {
    display: flex;
    gap: 0;
    background: #d4dae3;
    border-radius: 12px;
    padding: 6px;
    margin: 0 auto 18px;
    width: fit-content;
}
.ilc-wrap .ilc-view-toggle button {
    border: none;
    background: transparent;
    padding: 12px 26px;
    cursor: pointer;
    font-weight: 700;
    border-radius: 9px;
    color: #2c3e50;
    transition: all .25s;
    font-size: 1.06em;
    display: flex;
    align-items: center;
    gap: 8px;
}
.ilc-wrap .ilc-view-toggle button.active {
    background: linear-gradient(135deg, var(--ilc-cal), #c0392b);
    color: #fff;
    box-shadow: 0 3px 12px rgba(231, 76, 60, .35);
}
.ilc-wrap .ilc-view-toggle button:hover:not(.active) { background: #c2cad6; }
.ilc-wrap .ilc-view-toggle button:focus-visible {
    outline: 3px solid #2c3e50;
    outline-offset: 2px;
}

/* ---------- Controls ---------- */
.ilc-wrap .ilc-controls {
    background: var(--ilc-card);
    border-radius: var(--ilc-radius);
    padding: 22px;
    margin-bottom: 24px;
    box-shadow: var(--ilc-shadow);
}
.ilc-wrap .ilc-control-row { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-end; }
.ilc-wrap .ilc-control-group { flex: 1; min-width: 200px; }
.ilc-wrap .ilc-control-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 700;
    color: #1f2d3d;
    font-size: 1em;
}
.ilc-wrap .ilc-control-group select,
.ilc-wrap .ilc-control-group input {
    width: 100%;
    padding: 12px 13px;
    border: 2px solid #c8ccd2;
    border-radius: 10px;
    font-size: 15px;
    transition: all .25s;
    background: #fff;
    color: #1f2d3d;
}
.ilc-wrap .ilc-control-group select:focus,
.ilc-wrap .ilc-control-group input:focus {
    outline: none;
    border-color: var(--ilc-cal);
    box-shadow: 0 0 0 3px rgba(231, 76, 60, .18);
}

.ilc-wrap .ilc-btn {
    background: linear-gradient(135deg, var(--ilc-cal), #c0392b);
    color: #fff;
    border: none;
    padding: 12px 20px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 700;
    transition: all .25s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
}
.ilc-wrap .ilc-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(231, 76, 60, .35); }
.ilc-wrap .ilc-btn:focus-visible { outline: 3px solid #1f2d3d; outline-offset: 2px; }
.ilc-wrap .ilc-btn-info { background: linear-gradient(135deg, #2e86c1, #1f618d); }
.ilc-wrap .ilc-btn:disabled { opacity: .6; cursor: not-allowed; transform: none; }

/* ---------- Territory filter ---------- */
.ilc-wrap .ilc-territory-filter { display: flex; flex-wrap: wrap; gap: 10px; }
.ilc-wrap .ilc-territory-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 15px;
    background: #eaeef3;
    border-radius: 20px;
    cursor: pointer;
    transition: all .25s;
    font-size: 1em;
    font-weight: 700;
    color: #1f2d3d;
    user-select: none;
    border: 2px solid transparent;
}
.ilc-wrap .ilc-territory-checkbox input { margin: 0; cursor: pointer; width: 16px; height: 16px; }
.ilc-wrap .ilc-territory-checkbox:hover { background: #dde3eb; }
.ilc-wrap .ilc-territory-checkbox:focus-within { outline: 2px solid #1f2d3d; outline-offset: 2px; }
.ilc-wrap .ilc-territory-checkbox .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}
.ilc-wrap .ilc-territory-checkbox.ilc-calabria {
    background: linear-gradient(135deg, var(--ilc-cal), #c0392b);
    color: #fff;
    transform: scale(1.06);
    box-shadow: 0 4px 14px rgba(231, 76, 60, .4);
    border-color: #fff;
}
.ilc-wrap .ilc-territory-checkbox.ilc-calabria .dot { background: #fff; }
.ilc-wrap .ilc-territory-checkbox.ilc-calabria:hover { transform: scale(1.08); }
.ilc-wrap .ilc-territory-checkbox.disabled { opacity: .95; cursor: not-allowed; }
.ilc-wrap .ilc-territory-checkbox.provincia .dot { border-radius: 3px; }

/* ---------- Dashboard grid ---------- */
.ilc-wrap .ilc-dashboard { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; margin-bottom: 24px; }
.ilc-wrap .ilc-card {
    background: var(--ilc-card);
    border-radius: var(--ilc-radius);
    padding: 22px;
    box-shadow: var(--ilc-shadow);
    transition: transform .25s;
}
.ilc-wrap .ilc-card:hover { transform: translateY(-4px); }
.ilc-wrap .ilc-card h3 {
    color: #1f2d3d;
    margin: 0 0 16px;
    font-size: 1.3em;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
}
.ilc-wrap .ilc-card h3 i { color: var(--ilc-cal); }
.ilc-wrap .ilc-full-width { grid-column: 1 / -1; }

/* ---------- Hero ---------- */
.ilc-wrap .ilc-hero {
    background: linear-gradient(135deg, #fff, #fff5f4);
    border-left: 6px solid var(--ilc-cal);
}
.ilc-wrap .ilc-hero-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; }
.ilc-wrap .ilc-stat-item {
    text-align: center;
    padding: 16px 12px;
    border-radius: 14px;
    background: linear-gradient(135deg, #f8f9fa, #eef1f3);
    border-top: 3px solid #ccc;
}
.ilc-wrap .ilc-stat-item.calabria { border-top-color: var(--ilc-cal); background: linear-gradient(135deg, #fff, #fdecea); }
.ilc-wrap .ilc-stat-item.italia { border-top-color: var(--ilc-ita); }
.ilc-wrap .ilc-stat-value { font-size: 2em; font-weight: 800; color: #1f2d3d; }
.ilc-wrap .ilc-stat-value.cal { color: #c0392b; }
.ilc-wrap .ilc-stat-label { font-size: 0.92em; color: #3d3d3d; margin-top: 5px; text-transform: uppercase; letter-spacing: .5px; font-weight: 700; }
.ilc-wrap .ilc-stat-sub { font-size: 0.86em; color: #555; margin-top: 3px; }
.ilc-wrap .ilc-gap-pos { color: #c0392b; font-weight: 800; }
.ilc-wrap .ilc-gap-neg { color: #117a65; font-weight: 800; }

/* ---------- Chart ---------- */
.ilc-wrap .ilc-chart-container { position: relative; height: 380px; margin-top: 10px; }
.ilc-wrap .ilc-chart-container.ilc-small { height: 300px; }

/* ---------- Table ---------- */
.ilc-wrap .ilc-data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 8px;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 3px 12px rgba(0, 0, 0, .08);
    font-size: 0.98em;
}
.ilc-wrap .ilc-data-table th {
    background: linear-gradient(135deg, #1f2d3d, #34495e);
    color: #fff;
    padding: 12px 11px;
    text-align: center;
    font-weight: 700;
    font-size: 1.02em;
    position: sticky;
    top: 0;
}
.ilc-wrap .ilc-data-table th.calabria-th { background: linear-gradient(135deg, var(--ilc-cal), #c0392b); }
.ilc-wrap .ilc-data-table td { padding: 10px 11px; border-bottom: 1px solid #e2e5ea; text-align: center; color: #1f2d3d; }
.ilc-wrap .ilc-data-table td.anno { font-weight: 700; text-align: left; color: #1f2d3d; background: #f0f2f6; }
.ilc-wrap .ilc-data-table td.calabria-td { background: #fdecea; font-weight: 700; color: #c0392b; }
.ilc-wrap .ilc-data-table tr:hover td { background: #f4f6f8; }
.ilc-wrap .ilc-data-table tr:hover td.calabria-td { background: #fbd9d4; }
.ilc-wrap .ilc-table-wrap { max-height: 420px; overflow: auto; border-radius: 12px; }

/* ---------- Loading / nodata ---------- */
.ilc-wrap .ilc-loading, .ilc-wrap .ilc-no-data { text-align: center; padding: 36px; color: #555; font-size: 1.02em; }
.ilc-wrap .ilc-loading i { font-size: 2em; animation: ilc-spin 1s linear infinite; color: var(--ilc-cal); }
.ilc-wrap .ilc-no-data i { font-size: 2.6em; margin-bottom: 12px; opacity: .6; color: #777; }
@keyframes ilc-spin { to { transform: rotate(360deg); } }

/* ---------- Modal ---------- */
.ilc-wrap .ilc-modal,
.ilc-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .55);
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: ilc-fadeIn .25s;
}
.ilc-modal-content {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
    max-width: 680px;
    width: 90%;
    max-height: 84vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: ilc-slideIn .25s;
}
.ilc-modal-header {
    padding: 18px 24px;
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.ilc-modal-header h3 { margin: 0; font-size: 1.15em; display: flex; gap: 10px; align-items: center; }
.ilc-modal-close {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 18px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ilc-modal-close:hover { background: rgba(255, 255, 255, .2); }
.ilc-modal-body { padding: 22px 24px; overflow-y: auto; line-height: 1.6; }
.ilc-info-item { margin-bottom: 16px; padding: 13px 16px; background: #f8f9fa; border-radius: 10px; border-left: 4px solid #e74c3c; }
.ilc-info-item h4 { margin: 0 0 6px; font-size: 1em; color: #2c3e50; }
.ilc-info-item p { margin: 0; color: #3d3d3d; font-size: 0.96em; }
.ilc-info-item.note { border-left-color: #f39c12; font-size: 0.92em; }
@keyframes ilc-fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes ilc-slideIn { from { opacity: 0; transform: translateY(-40px) scale(.95); } to { opacity: 1; transform: none; } }

/* ---------- Toast ---------- */
.ilc-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #2c3e50;
    color: #fff;
    padding: 13px 20px;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
    z-index: 100001;
    opacity: 0;
    transform: translateY(20px);
    transition: all .3s;
}
.ilc-toast.show { opacity: 1; transform: none; }

/* ---------- Footer ---------- */
.ilc-wrap .ilc-footer {
    text-align: center;
    color: #555;
    padding: 20px;
    font-size: 0.95em;
    line-height: 1.6;
}

/* ---------- Modalita' compact: toggle dettagli ---------- */
.ilc-wrap .ilc-details-toggle-wrap {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    margin: 0 0 20px;
}
.ilc-wrap .ilc-btn-secondary {
    background: linear-gradient(135deg, #7f8c8d, #5a6a6b);
}
.ilc-wrap .ilc-btn-secondary:hover {
    box-shadow: 0 8px 20px rgba(127, 140, 141, .35);
}
.ilc-wrap .ilc-details-hint {
    font-size: 0.95em;
    color: #555;
}
.ilc-wrap .ilc-details-section {
    margin-top: 8px;
    animation: ilc-fadeIn .3s ease;
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .ilc-wrap .ilc-dashboard { grid-template-columns: 1fr; }
    .ilc-wrap .ilc-control-row { flex-direction: column; align-items: stretch; }
    .ilc-wrap .ilc-header h1 { font-size: 1.7em; }
}
