/* ============================================
   CETEMOH - Composants partagés
   Utilisé par le site public ET le backoffice
   ============================================ */

/* === Breadcrumb === */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0;
    margin-bottom: 1rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    list-style: none;
    flex-wrap: wrap;
}
.breadcrumb li { display: flex; align-items: center; gap: 0.5rem; }
.breadcrumb li + li::before { content: '›'; color: var(--border); font-weight: 600; }
.breadcrumb a { color: var(--primary-light); text-decoration: none; transition: color var(--transition); }
.breadcrumb a:hover { color: var(--primary); text-decoration: underline; }
.breadcrumb .bc-current { color: var(--text); font-weight: 500; }

/* === Empty state === */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-muted);
}
.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.4;
}
.empty-state-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.5rem;
}
.empty-state-text {
    font-size: 0.9rem;
    max-width: 400px;
    margin: 0 auto 1.5rem;
    line-height: 1.5;
}

/* === Skeleton loader === */
.skeleton {
    background: linear-gradient(90deg, var(--border-soft) 25%, var(--border) 50%, var(--border-soft) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}
.skeleton-text { height: 0.9rem; margin-bottom: 0.5rem; }
.skeleton-text:last-child { width: 60%; }
.skeleton-title { height: 1.4rem; width: 40%; margin-bottom: 0.75rem; }
.skeleton-avatar { width: 40px; height: 40px; border-radius: 50%; }
.skeleton-card { height: 120px; }
@keyframes skeleton-shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* === Spinner (独立) === */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2.5px solid var(--border);
    border-top-color: var(--primary-light);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
.spinner-lg { width: 36px; height: 36px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* === Boutons standardisés === */
.btn { position: relative; overflow: hidden; }
.btn-success { background: var(--success); color: #fff; border: none; }
.btn-success:hover { background: #047857; }
.btn-warning { background: var(--warning); color: #fff; border: none; }
.btn-warning:hover { background: #b45309; }
.btn-info { background: var(--info); color: #fff; border: none; }
.btn-info:hover { background: #0284c7; }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg); border-color: var(--primary-light); color: var(--primary-light); }
.btn:disabled, .btn[disabled] { opacity: 0.55; cursor: not-allowed; pointer-events: none; }

/* === Alertes standardisées === */
.alert-warning {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fcd34d;
    border-left: 4px solid var(--warning);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
}
[data-theme="dark"] .alert-warning { background: #422006; color: #fbbf24; border-color: #92400e; }

/* === Badges de statut === */
.badge-success { background: var(--success); color: #fff; }
.badge-danger { background: var(--danger); color: #fff; }
.badge-warning { background: var(--warning); color: #fff; }
.badge-info { background: var(--info); color: #fff; }
.badge-neutral { background: var(--border); color: var(--text-muted); }

/* === KPI card (dashboard) === */
.kpi-card {
    background: var(--bg-white);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: box-shadow var(--transition), transform var(--transition);
}
.kpi-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}
.kpi-icon.blue { background: #dbeafe; color: var(--blue-600); }
.kpi-icon.green { background: #d1fae5; color: var(--success); }
.kpi-icon.orange { background: #fef3c7; color: var(--warning); }
.kpi-icon.red { background: #fee2e2; color: var(--danger); }
.kpi-value { font-size: 1.6rem; font-weight: 700; color: var(--text); line-height: 1.2; }
.kpi-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.15rem; }
[data-theme="dark"] .kpi-card { background: var(--bg-white); border-color: var(--border); }
[data-theme="dark"] .kpi-icon.blue { background: rgba(37, 99, 235, 0.15); }
[data-theme="dark"] .kpi-icon.green { background: rgba(5, 150, 105, 0.15); }
[data-theme="dark"] .kpi-icon.orange { background: rgba(217, 119, 6, 0.15); }
[data-theme="dark"] .kpi-icon.red { background: rgba(220, 38, 38, 0.15); }

/* === Tabs (onglets) === */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 1.5rem;
    overflow-x: auto;
}
.tab-btn {
    padding: 0.65rem 1.25rem;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color var(--transition), border-color var(--transition);
    white-space: nowrap;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--primary-light); border-bottom-color: var(--primary-light); }

/* === Context badge (header) === */
.context-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.75rem;
    background: var(--primary-light);
    color: #fff;
    border-radius: 50px;
    font-size: 0.78rem;
    font-weight: 500;
    white-space: nowrap;
}

/* === Tooltip === */
[data-tooltip] { position: relative; }
[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    padding: 0.35rem 0.65rem;
    background: var(--sky-900);
    color: #fff;
    font-size: 0.75rem;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
    z-index: 1000;
}
[data-tooltip]:hover::after { opacity: 1; }

/* === Transitions douces === */
.fade-in { animation: fadeIn 0.3s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.slide-down { animation: slideDown 0.25s ease-out; }
@keyframes slideDown { from { opacity: 0; max-height: 0; } to { opacity: 1; max-height: 500px; } }

/* === Form validation states === */
.form-control.is-invalid {
    border-color: #dc2626;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12);
}

.form-control.is-valid {
    border-color: #059669;
    box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.12);
}

.invalid-feedback {
    display: none;
    color: #dc2626;
    font-size: 0.8rem;
    margin-top: 0.3rem;
}

.form-control.is-invalid ~ .invalid-feedback {
    display: block;
}

/* === Focus visible (accessibilité) === */
:focus-visible {
    outline: 2px solid var(--primary-light);
    outline-offset: 2px;
}
button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible {
    outline: 2px solid var(--primary-light);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15);
}

/* Focus pour les onglets */
.tab-btn:focus-visible {
    outline: 2px solid var(--primary-light);
    outline-offset: -2px;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

/* Focus pour les formulaires */
.form-control:focus-visible {
    outline: 2px solid var(--primary-light);
    outline-offset: 2px;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* Focus pour les badges cliquables et elements de statut */
.badge-success:focus-visible,
.badge-danger:focus-visible,
.badge-warning:focus-visible,
.badge-info:focus-visible {
    outline: 2px solid var(--primary-light);
    outline-offset: 2px;
}

/* === Reduced motion (accessibilité) === */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
    html { scroll-behavior: auto; }
    .skeleton { animation: none; }
    .spinner { animation: none; }
}

/* === High contrast mode (accessibilité) === */
@media (forced-colors: active) {
    .btn {
        border: 1px solid ButtonText;
    }
    .tab-btn.active {
        border-bottom-color: Highlight;
    }
    .kpi-card,
    .badge-success,
    .badge-danger,
    .badge-warning,
    .badge-info {
        border: 1px solid ButtonText;
    }
}

/* === Selection améliorée === */
::selection {
    background: rgba(37, 99, 235, 0.2);
    color: inherit;
}
