/* ============================================================
   CONTRACTHEURES — Styles natifs Dolibarr
   ============================================================ */

/* ---------- Widget annee ---------- */
.ch-year-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0 0 12px 0;
    flex-wrap: wrap;
}
.ch-year-nav .ch-year-label {
    font-weight: 600;
    margin-right: 4px;
    opacity: 0.6;
}
.ch-year-btn {
    display: inline-block;
    padding: 4px 16px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.95em;
    text-decoration: none !important;
    background: var(--colorbacklineimpair2, #f0f2f5);
    border: 1px solid var(--colorborder, #dee2e6);
    color: var(--colortext, #333) !important;
    transition: all 0.15s ease;
}
.ch-year-btn:hover {
    background: var(--colorbacktitle1, #263c5c);
    color: #fff !important;
    border-color: transparent;
}
.ch-year-btn.ch-year-active {
    background: var(--colorbacktitle1, #263c5c);
    color: #fff !important;
    border-color: transparent;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
/* Label de periode selectionnee (couleurs fixes, independantes du theme) */
.ch-period-label {
    display: inline-block;
    padding: 4px 18px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.95em;
    background: #263c5c;
    color: #ffffff;
    border: 2px solid #263c5c;
    box-shadow: 0 2px 6px rgba(0,0,0,0.18);
    cursor: default;
    letter-spacing: 0.01em;
}

/* ---------- KPI Cards (info-box) ---------- */
.ch-kpi-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}
.ch-kpi-card {
    flex: 1;
    min-width: 180px;
    display: flex;
    align-items: stretch;
    background: var(--colorbacklineimpair2, #fff);
    border: 1px solid var(--colorborder, #e0e0e0);
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.ch-kpi-icon {
    width: 56px;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5em;
    flex-shrink: 0;
}
.ch-kpi-body {
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.ch-kpi-label {
    font-size: 0.72em;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.3px;
    opacity: 0.6;
    margin-bottom: 2px;
}
.ch-kpi-value {
    font-size: 1.35em;
    font-weight: 700;
    line-height: 1.2;
}
.ch-kpi-sub {
    font-size: 0.75em;
    opacity: 0.5;
    margin-top: 1px;
}

/* Couleurs icones KPI */
.ch-kpi-icon.ch-blue    { background: rgba(12, 62, 95, 0.12);  color: #0c3e5f; }
.ch-kpi-icon.ch-cyan    { background: rgba(23, 162, 184, 0.12); color: #17a2b8; }
.ch-kpi-icon.ch-green   { background: rgba(76, 175, 80, 0.12);  color: #4caf50; }
.ch-kpi-icon.ch-red     { background: rgba(244, 67, 54, 0.12);  color: #f44336; }
.ch-kpi-icon.ch-orange  { background: rgba(255, 152, 0, 0.12);  color: #ff9800; }
.ch-kpi-icon.ch-darkred { background: rgba(183, 28, 28, 0.12);  color: #b71c1c; }

/* ---------- Barre de progression (native Dolibarr) ---------- */
.ch-progress {
    width: 100%;
    max-width: 300px;
    height: 8px;
    background: rgba(0,0,0,0.08);
    border-radius: 4px;
    overflow: hidden;
    display: inline-block;
    vertical-align: middle;
}
.ch-progress-bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
    min-width: 2px;
}
.ch-progress.ch-lg {
    height: 18px;
    max-width: 100%;
    border-radius: 9px;
}
.ch-progress.ch-lg .ch-progress-bar {
    border-radius: 9px;
    line-height: 18px;
    font-size: 0.75em;
    font-weight: 700;
    color: #fff;
    text-align: center;
}

/* ---------- Badges statut ---------- */
.ch-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    color: #fff;
    font-size: 0.8em;
    font-weight: 700;
    white-space: nowrap;
    vertical-align: middle;
}
.ch-badge-ok       { background-color: #4caf50; }
.ch-badge-warning  { background-color: #ff9800; }
.ch-badge-critical { background-color: #f44336; }
.ch-badge-exceeded { background-color: #b71c1c; }

/* Couleurs fill barre */
.ch-fill-ok       { background-color: #4caf50; }
.ch-fill-warning  { background-color: #ff9800; }
.ch-fill-critical { background-color: #f44336; }
.ch-fill-exceeded { background-color: #b71c1c; }

/* ---------- Resume fiche contrat ---------- */
.ch-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}
.ch-progress-section {
    margin: 12px 0 16px 0;
    padding: 14px 18px;
    background: var(--colorbacklineimpair2, #fafbfc);
    border: 1px solid var(--colorborder, #dee2e6);
    border-radius: 6px;
}
.ch-progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.ch-progress-header .ch-pct {
    font-size: 1.4em;
    font-weight: 700;
}
.ch-progress-legend {
    display: flex;
    gap: 18px;
    margin-top: 8px;
    font-size: 0.85em;
}
.ch-progress-legend .ch-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 5px;
    vertical-align: middle;
}

/* ---------- Compat legacy ---------- */
.contractheures-progressbar { width: 100%; max-width: 300px; height: 20px; background-color: #e0e0e0; border-radius: 4px; overflow: hidden; display: inline-block; vertical-align: middle; }
.contractheures-progressbar-fill { height: 100%; border-radius: 4px; transition: width 0.3s ease; min-width: 2px; }
.contractheures-status-ok { background-color: #4caf50; }
.contractheures-status-warning { background-color: #ff9800; }
.contractheures-status-critical { background-color: #f44336; }
.contractheures-status-exceeded { background-color: #b71c1c; }
.contractheures-badge { display: inline-block; padding: 2px 8px; border-radius: 3px; color: #fff; font-size: 0.85em; font-weight: bold; }
.contractheures-badge-ok { background-color: #4caf50; }
.contractheures-badge-warning { background-color: #ff9800; }
.contractheures-badge-critical { background-color: #f44336; }
.contractheures-badge-exceeded { background-color: #b71c1c; }
.contractheures-summary { padding: 15px; margin-bottom: 15px; border: 1px solid #ddd; border-radius: 6px; background: #fafafa; }
.contractheures-summary .stat-label { font-weight: bold; min-width: 200px; display: inline-block; }
.contractheures-summary .stat-value { font-size: 1.1em; }
.contractheures-summary .stat-value.text-danger { color: #f44336; font-weight: bold; }

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    .ch-kpi-row { gap: 8px; }
    .ch-kpi-card { min-width: 140px; }
    .ch-summary-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
    .ch-summary-grid { grid-template-columns: 1fr; }
}

/* ---------- Tuile dashboard accueil (info-box) ---------- */
.bg-infobox-contractheures {
    color: #ff9800 !important;
}
.bg-infobox-contractheures i.fa {
    color: #ff9800 !important;
}
.fa-dol-contractheures:before {
    content: "\f252"; /* fa-hourglass-half */
}

/* Couleurs des badges par ligne dans la tuile Heures Contrat
   Lignes : 1=Contrats suivis (vert), 2=Alerte (orange), 3=Depassement (rouge).
   Les classes ch-tile-* sont posees par le JS llxFooter. */
.ch-tile-suivi {
    background-color: #4caf50 !important;
    color: #fff !important;
}
.ch-tile-alerte {
    background-color: #ff9800 !important;
    color: #fff !important;
}
.ch-tile-depassement {
    background-color: #f44336 !important;
    color: #fff !important;
}
