/* =====================================================================
   PANNELLO AMMINISTRAZIONE  (usa css/theme.css)
   ===================================================================== */

:root {
    --accent: var(--brand);
    --accent-orange: var(--amber);
    --accent-green: var(--ok);
    --text-main: var(--text);
    --text-muted: var(--text-3);
    --field-bg: var(--sunken);
}

body { padding: 24px; }
.container { max-width: 1360px; margin: 0 auto; display: flex; flex-direction: column; gap: 22px; }
.disclaimer-mini { max-width: 1360px; }

.head-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.who {
    display: flex; align-items: center; gap: 8px;
    font-size: 0.8rem; font-weight: 700; color: #ffb877;
    background: rgba(255, 157, 77, 0.11); border: 1px solid rgba(255, 157, 77, 0.35);
    padding: 8px 14px; border-radius: 999px;
}

/* ------------------------- LAYOUT E MENU ------------------------- */
.layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 22px; align-items: start; }
.layout > main { min-width: 0; }

.side {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 14px;
    display: flex; flex-direction: column; gap: 6px;
    position: sticky; top: 24px;
    box-shadow: var(--shadow);
}
.side-title { font-size: 0.66rem; font-weight: 800; letter-spacing: 0.12em; color: var(--text-3); text-transform: uppercase; padding: 6px 10px 8px; }
.nav-btn {
    background: transparent; border: 1px solid transparent; color: var(--text-2);
    padding: 12px; border-radius: 11px;
    font: 600 0.88rem var(--font);
    display: flex; align-items: center; gap: 12px; cursor: pointer; text-align: left;
    transition: background 0.15s, color 0.15s;
}
.nav-btn i { width: 18px; text-align: center; color: var(--amber); }
.nav-btn:hover { background: rgba(255, 255, 255, 0.05); color: var(--text); }
.nav-btn.active { background: linear-gradient(90deg, rgba(229, 56, 59, 0.26), rgba(229, 56, 59, 0.05)); border-color: rgba(229, 56, 59, 0.45); color: #fff; }
.nav-badge { margin-left: auto; font-size: 0.68rem; font-weight: 800; padding: 1px 9px; border-radius: 999px; background: rgba(255, 255, 255, 0.09); }

.tab { display: none; flex-direction: column; gap: 22px; min-width: 0; }
.tab.active { display: flex; }

.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.panel-head h2 { font-size: 1.02rem; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.panel-head h2 i { color: var(--amber); }
.panel-head p { font-size: 0.8rem; color: var(--text-3); margin-top: 3px; font-weight: 500; }
.tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ------------------------- KPI ------------------------- */
.kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; }
.kpi {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: 14px; padding: 15px 16px;
    display: flex; align-items: center; gap: 13px;
    box-shadow: var(--shadow);
}
.kpi-icon { width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center; background: rgba(229, 56, 59, 0.16); color: var(--amber); flex-shrink: 0; }
.kpi small { display: block; font-size: 0.64rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3); }
.kpi strong { font-size: 1.3rem; font-weight: 800; line-height: 1.2; }

.two-col { display: grid; grid-template-columns: 1.2fr 1fr; gap: 22px; }

/* ------------------------- LISTE E TABELLE ------------------------- */
.scroll { overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding-right: 4px; }

.row-head, .row { display: grid; gap: 12px; align-items: center; padding: 11px 14px; }
.row-head { font-size: 0.66rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3); position: sticky; top: 0; background: var(--surface-3); border-radius: 8px; z-index: 2; }
.row { background: var(--surface-2); border: 1px solid var(--line); border-radius: 11px; font-size: 0.84rem; }
.row:hover { border-color: rgba(229, 56, 59, 0.45); }
.cols-log { grid-template-columns: 1.1fr 1.6fr 0.8fr 0.8fr 0.9fr 1fr 0.9fr; }
.cols-reset { grid-template-columns: 1.4fr 1fr 1.6fr; }

.rank {
    display: grid; grid-template-columns: 32px 1fr auto; gap: 12px; align-items: center;
    padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 11px;
}
.rank-pos { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 0.78rem; background: var(--surface-3); }
.rank.p1 { border-color: rgba(251, 191, 36, 0.5); background: linear-gradient(90deg, rgba(251, 191, 36, 0.1), var(--surface-2)); }
.rank.p1 .rank-pos { background: #fbbf24; color: #3b2300; }
.rank.p2 .rank-pos { background: #cbd5e1; color: #1e293b; }
.rank.p3 .rank-pos { background: #d97706; color: #2b1400; }

.activity { display: flex; gap: 12px; align-items: flex-start; padding: 11px 13px; background: var(--surface-2); border-radius: 11px; border: 1px solid var(--line); font-size: 0.83rem; }
.activity i { margin-top: 3px; color: var(--amber); }

/* ------------------------- FILTRI ------------------------- */
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-bottom: 14px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { font-size: 0.76rem; font-weight: 700; padding: 5px 13px; border-radius: 999px; background: var(--sunken); border: 1px solid var(--line); color: #ffb877; }

.pw-note { display: flex; gap: 10px; align-items: flex-start; font-size: 0.8rem; line-height: 1.55; color: #ffc995; background: rgba(255, 157, 77, 0.1); border: 1px solid rgba(255, 157, 77, 0.3); border-radius: 11px; padding: 11px 14px; margin-bottom: 18px; }
.pw-note i { margin-top: 3px; }
.pw-note strong { color: #fff; }

/* ------------------------- AGENTI ------------------------- */
.agents-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 22px; align-items: start; }
.agents-layout > div { min-width: 0; }

.agent-card { background: var(--surface-2); border: 1px solid var(--line); border-radius: 13px; padding: 15px; display: flex; flex-direction: column; gap: 12px; }
.agent-card:hover { border-color: rgba(229, 56, 59, 0.45); }
.agent-top { display: flex; align-items: center; gap: 12px; }
.avatar { width: 44px; height: 44px; border-radius: 13px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-weight: 800; background: linear-gradient(145deg, #ee4447, #8f1d21); }
.agent-name { font-weight: 700; font-size: 0.94rem; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.agent-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; font-size: 0.8rem; }
.agent-grid > div > span { display: block; }
.agent-grid .k { font-size: 0.62rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3); margin-bottom: 2px; font-style: normal; }
.agent-grid .tag-list { display: flex; flex-wrap: wrap; gap: 5px; }
.tag { display: inline-flex; align-items: center; gap: 6px; font-size: 0.7rem; font-weight: 700; padding: 3px 9px; border-radius: 8px; background: rgba(255, 157, 77, 0.13); color: #ffb877; border: 1px solid rgba(255, 157, 77, 0.35); }
.agent-grid .tag { display: inline-flex; }
.agent-actions { display: flex; gap: 8px; justify-content: flex-end; }
.pw { display: inline-flex !important; align-items: center; gap: 8px; font-family: var(--mono); }
.pw button { background: none; border: none; color: var(--text-3); cursor: pointer; }
.pw button:hover { color: #fff; }

/* ------------------------- CODICE agenti.js ------------------------- */
.code-wrap { background: #080505; border: 1px solid var(--line); border-radius: 13px; overflow: hidden; }
.code-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 14px; background: #130c0c; border-bottom: 1px solid var(--line); font-family: var(--mono); font-size: 0.75rem; flex-wrap: wrap; }
.code-bar .dots { display: flex; gap: 6px; }
.code-bar .dots i { width: 10px; height: 10px; border-radius: 50%; background: #5a2a2a; display: block; }
.code-bar .dots i:first-child { background: var(--brand); }
.code-bar .dots i:nth-child(2) { background: var(--amber); }
.code-box { max-height: 560px; overflow: auto; padding: 12px 0; font-family: var(--mono); font-size: 0.74rem; line-height: 1.65; }
.ln-row { display: flex; padding-right: 14px; white-space: pre; }
.ln { flex: 0 0 46px; text-align: right; padding-right: 14px; color: #62504f; user-select: none; }
.ln-row.flash { animation: flash 1.8s ease-out; }
@keyframes flash { 0% { background: rgba(255, 157, 77, 0.3); } 100% { background: transparent; } }
.code-box .c { color: #85736f; font-style: italic; }
.code-box .k { color: #ffb877; }
.code-box .s { color: #86efac; }
.code-box .kw { color: #f87171; }
.code-box .n { color: #fbbf24; }
.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px var(--ok); margin-right: 6px; animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }
.src-note { font-size: 0.78rem; color: var(--text-3); line-height: 1.55; margin-top: 12px; }

/* ------------------------- MODALE AGENTE ------------------------- */
.modal { width: 100%; max-width: 660px; max-height: 94vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--brand); border-radius: 20px; padding: 28px; box-shadow: 0 30px 70px -20px rgba(0, 0, 0, 0.9); }
.modal h3 { font-size: 1.15rem; font-weight: 800; display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.modal h3 i { color: var(--amber); }
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 15px; }
.modal .field { min-width: 0; }
.modal .input { width: 100%; }
.pw-row .input { width: auto; min-width: 0; }
.form-grid .full { grid-column: 1 / -1; }
.pw-row { display: flex; gap: 8px; }
.pw-row .input { flex: 1; }
.spec-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.spec-opt { display: flex; align-items: center; gap: 10px; padding: 11px 13px; background: var(--sunken); border: 1px solid var(--line); border-radius: 10px; cursor: pointer; font-size: 0.86rem; font-weight: 600; user-select: none; }
.spec-opt:hover { border-color: rgba(229, 56, 59, 0.5); }
.spec-opt input { accent-color: var(--brand); width: 16px; height: 16px; }
.spec-opt:has(input:checked) { border-color: var(--brand); background: rgba(229, 56, 59, 0.15); }
.form-error { display: none; background: rgba(248, 113, 113, 0.12); border: 1px solid rgba(248, 113, 113, 0.4); color: #fca5a5; padding: 11px 13px; border-radius: 10px; font-size: 0.84rem; margin-top: 15px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

/* ------------------------- RESPONSIVE ------------------------- */
@media (max-width: 1280px) { .agents-layout { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 1100px) {
    .kpis { grid-template-columns: repeat(2, 1fr); }
    .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
    body { padding: 14px; }
    .layout { grid-template-columns: minmax(0, 1fr); }
    .side { position: static; flex-direction: row; overflow-x: auto; }
    .side-title { display: none; }
    .nav-btn { white-space: nowrap; }
    .row-head { display: none; }
    .cols-log, .cols-reset { grid-template-columns: 1fr 1fr; }
    .form-grid, .spec-grid { grid-template-columns: 1fr; }
}
