/* =========== Obiettivi Dealer =========== */
.obiettivi-content.obiettivi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}

.obiettivo-box {
  background: #ffffff;
  border: 1px solid #e6ecf5;
  border-radius: 10px;
  padding: 10px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

.obiettivo-box .ob-op {
  font-size: 11px;
  color: #6b7a90;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.obiettivo-box .ob-name {
  color: #1e4ddb;
  font-weight: 700;
  font-size: 13px;
  text-transform: uppercase;
  line-height: 1.15;
  min-height: 30px;
}

.obiettivo-box .ob-divider {
  height: 2px;
  background: #e6ecf5;
  border-radius: 2px;
  margin: 8px 0 6px 0;
}

.obiettivo-box .ob-count {
  font-size: 20px;
  font-weight: 800;
  color: #1e4ddb;
  line-height: 1;
  margin: 2px 0 6px 0;
}

.obiettivo-box .ob-percent {
  font-size: 11px;
  color: #7b8794;
  margin-bottom: 4px;
}

.obiettivo-box .ob-level {
  font-size: 11px;
  color: #7b8794;
}

.obiettivo-box .ob-mancano {
  font-size: 11px;
  color: #c0392b;
  font-weight: 600;
}

/* Pagination controls inside obiettivi header */
.obiettivi-pager {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 8px;
}
.obiettivi-pager .pager-btn {
  padding: 3px 8px;
  font-size: 12px;
}
.obiettivi-pager .pager-indicator {
  font-size: 12px;
  color: #6b7a90;
}
/* Stili specifici per la tabella attivazioni agente */

/* Stile per il selettore operatore nella card agente */
#operatore-select-agente {
  background: #f0f4ff;
  border: 1px solid #c9d7f5;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.95rem;
  color: #1e4ddb;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s;
}

#operatore-select-agente:focus {
  border-color: #1e4ddb;
  outline: none;
}

/* Stili per la tabella attivazioni agente */
#tabella-attivazioni-agente {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: #ffffff;
  font-family: 'Noto Sans', sans-serif;
  font-size: 0.78rem;
  color: #1f2532;
  border-radius: 0;
  box-shadow: none;
  overflow: hidden;
  line-height: 1.352;
  table-layout: fixed; /* fissa le larghezze delle colonne e previene slittamenti */
}

#tabella-attivazioni-agente thead {
  background: #f1f4fb;
}

#tabella-attivazioni-agente thead th {
  padding: 8px 12px;
  font-size: 0.85rem;
  font-weight: 700;
  color: #30589e; /* allinea al blu header dashboard-master */
  text-align: left;
  border-bottom: 2px solid #d4def0;
  background: linear-gradient(180deg, #f1f5fc, #e9f0fc);
  white-space: nowrap;
}

#tabella-attivazioni-agente tbody tr:nth-child(even) {
  background-color: #f9fbfd;
}

#tabella-attivazioni-agente tbody tr:hover {
  background-color: #eef3ff;
}

#tabella-attivazioni-agente tbody td {
  padding: 6px 12px;
  border-bottom: 1px solid #e9edf3;
  font-size: 0.78rem;
  color: #2e3547;
  vertical-align: middle;
  white-space: normal; /* consenti a default il wrapping nelle celle */
  line-height: 1.3;
}

/* Bordi arrotondati */
#tabella-attivazioni-agente thead th:first-child {
  border-top-left-radius: 12px;
}

#tabella-attivazioni-agente thead th:last-child {
  border-top-right-radius: 12px;
}

/* Stili per la tabella ordini agente: uniformi alla tabella attivazioni */
#tabella-ordini-agente {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: #ffffff;
  font-family: 'Noto Sans', sans-serif;
  font-size: 0.78rem;
  color: #1f2532;
  border-radius: 0;
  box-shadow: none;
  overflow: hidden;
  line-height: 1.352;
  table-layout: fixed;
}

#tabella-ordini-agente thead {
  background: #f1f4fb;
}

#tabella-ordini-agente thead th {
  padding: 8px 12px;
  font-size: 0.85rem;
  font-weight: 700;
  color: #30589e; /* stesso blu header */
  text-align: left;
  border-bottom: 2px solid #d4def0;
  background: linear-gradient(180deg, #f1f5fc, #e9f0fc);
  white-space: nowrap;
}

#tabella-ordini-agente tbody tr:nth-child(even) {
  background-color: #f9fbfd;
}

#tabella-ordini-agente tbody tr:hover {
  background-color: #eef3ff;
}

#tabella-ordini-agente tbody td {
  padding: 6px 12px;
  border-bottom: 1px solid #e9edf3;
  font-size: 0.78rem;
  color: #2e3547;
  vertical-align: middle;
  white-space: normal;
  line-height: 1.3;
}

#tabella-ordini-agente thead th:first-child { border-top-left-radius: 12px; }
#tabella-ordini-agente thead th:last-child  { border-top-right-radius: 12px; }

/* Stili per i controlli del grafico agente */
.chart-controls {
    display: flex;
    gap: 12px;
    margin-left: auto;
    align-items: center;
    flex-wrap: wrap;
    padding: 0 20px;
    margin-top: 10px;
}

.date-range {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: #555;
}

.form-select, .form-control {
    padding: 6px 10px;
    border: 1px solid #e4e9f4;
    border-radius: 6px;
    font-size: 0.85rem;
    background-color: #f8f9fa;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-select:focus, .form-control:focus {
    border-color: #1e4ddb;
    outline: none;
    box-shadow: 0 0 0 2px rgba(30, 77, 219, 0.1);
}

.btn {
    padding: 6px 16px;
    background-color: #1e4ddb;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background-color 0.2s;
    white-space: nowrap;
}

.btn:hover {
    background-color: #153cb2;
}

/* Responsive per schermi piccoli */
@media (max-width: 1200px) {
    .chart-controls {
        width: 100%;
        margin-top: 15px;
        gap: 8px;
    }
    
    .date-range {
        margin: 5px 0;
        width: 100%;
        justify-content: space-between;
    }
    
    .form-select, .form-control {
        flex: 1;
    }
}

/* Stile per il contenitore del grafico */
.chart-container {
    padding: 0 20px 20px;
    position: relative;
}

/* Stile per la legenda del grafico */
.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 15px;
    justify-content: center;
}

.legend-item {
    display: flex;
    align-items: center;
    font-size: 0.85rem;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 6px;
    display: inline-block;
}

/* Stili per il messaggio di caricamento del grafico */
.chart-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background-color: rgba(255, 255, 255, 0.9);
    z-index: 10;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(30, 77, 219, 0.2);
    border-top-color: #1e4ddb;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

.loading-text {
    color: #333;
    font-size: 0.95rem;
    font-weight: 500;
    margin-top: 10px;
}

/* Stili per i messaggi di errore */
.errore-caricamento {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: rgba(255, 255, 255, 0.95);
    z-index: 20;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    border: 1px solid #ffebee;
}

.errore-contenuto {
    max-width: 90%;
}

.errore-icona {
    display: block;
    font-size: 2.5rem;
    margin-bottom: 10px;
    color: #d32f2f;
}

.errore-testo {
    display: block;
    color: #d32f2f;
    font-size: 0.95rem;
    margin-bottom: 15px;
    line-height: 1.4;
}

.errore-pulsante {
    background-color: #1e4ddb;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px 16px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.errore-pulsante:hover {
    background-color: #153cb2;
}

/* Animazione di caricamento */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Stili per schermi piccoli */
@media (max-width: 768px) {
    .chart-loading,
    .errore-caricamento {
        padding: 15px;
    }
    
    .loading-spinner {
        width: 30px;
        height: 30px;
    }
    
    .loading-text,
    .errore-testo {
        font-size: 0.85rem;
    }
    
    .errore-pulsante {
        padding: 6px 12px;
        font-size: 0.85rem;
    }
}

#tabella-attivazioni-agente tbody tr:last-child td:first-child {
  border-bottom-left-radius: 12px;
}

#tabella-attivazioni-agente tbody tr:last-child td:last-child {
  border-bottom-right-radius: 12px;
}

/* Applica stesso arrotondamento alla tabella ordini */
#tabella-ordini-agente tbody tr:last-child td:first-child {
  border-bottom-left-radius: 12px;
}

#tabella-ordini-agente tbody tr:last-child td:last-child {
  border-bottom-right-radius: 12px;
}

/* Rimuovi il bordo inferiore sull'ultima riga per evitare la linea scura attaccata al bordo card */
#tabella-attivazioni-agente tbody tr:last-child td,
#tabella-ordini-agente tbody tr:last-child td {
  border-bottom: 0;
}

/* --- Agente: ottimizzazione larghezze colonne Attivazioni Dealer --- */
#tabella-attivazioni-agente thead th:nth-child(1),
#tabella-attivazioni-agente tbody td:nth-child(1) { /* DEALER */
  width: 50%; /* spazio maggiore per nomi dealer lunghi */
  text-align: left;
  white-space: normal;
  word-break: break-word;
}

#tabella-attivazioni-agente thead th:nth-child(2),
#tabella-attivazioni-agente tbody td:nth-child(2) { /* FW FISSI */
  width: 12.5%; /* compatta per numeri */
  text-align: center;
}

#tabella-attivazioni-agente thead th:nth-child(3),
#tabella-attivazioni-agente tbody td:nth-child(3) { /* FW MOBILI */
  width: 12.5%; /* compatta per numeri */
  text-align: center;
}

#tabella-attivazioni-agente thead th:nth-child(4),
#tabella-attivazioni-agente tbody td:nth-child(4) { /* FW ENERGY */
  width: 12.5%; /* compatta per numeri */
  text-align: center;
}

#tabella-attivazioni-agente thead th:nth-child(5),
#tabella-attivazioni-agente tbody td:nth-child(5) { /* SKY */
  width: 12.5%; /* compatta per numeri */
  text-align: center;
}


/* --- Agente: niente scrollbar interne alle tabelle --- */
#dashboard-agente .table-container {
  max-height: none !important;
  overflow: visible !important;
  padding-bottom: 8px; /* evita tagli visivi dell'ultima riga */
}

/* --- Agente: evita clipping nella card obiettivi --- */
#obiettivi-agente {
  overflow: visible;
}

#obiettivi-container-agente {
  overflow: visible;
}
