/* --- Titulaire — Dashboard pharmacien --- */

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #0f172a;
    color: #e2e8f0;
    min-height: 100vh;
}

.hidden { display: none !important; }

/* --- Header --- */

header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: #1e293b;
    border-bottom: 1px solid #334155;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo {
    font-size: 18px;
    font-weight: 700;
    color: #38bdf8;
}

.logo-sub {
    font-size: 14px;
    color: #94a3b8;
    font-weight: 500;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

header input {
    padding: 6px 10px;
    border: 1px solid #475569;
    border-radius: 6px;
    background: #0f172a;
    color: #e2e8f0;
    font-size: 13px;
}

header button, .btn-primary {
    padding: 6px 16px;
    border: none;
    border-radius: 6px;
    background: #38bdf8;
    color: #0f172a;
    font-weight: 600;
    cursor: pointer;
    font-size: 13px;
}

header button:hover, .btn-primary:hover { background: #7dd3fc; }

.btn-secondary {
    padding: 6px 16px;
    border: 1px solid #475569;
    border-radius: 6px;
    background: transparent;
    color: #94a3b8;
    font-weight: 600;
    cursor: pointer;
    font-size: 13px;
}

.btn-secondary:hover { background: #334155; color: #e2e8f0; }

/* --- Tabs --- */

.tabs {
    display: flex;
    gap: 2px;
    padding: 0 24px;
    background: #1e293b;
    border-bottom: 1px solid #334155;
}

.tab {
    padding: 10px 20px;
    border: none;
    background: transparent;
    color: #94a3b8;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.tab:hover { color: #e2e8f0; }
.tab.active { color: #38bdf8; border-bottom-color: #38bdf8; }

/* --- Tab content --- */

.tab-content {
    padding: 20px 24px;
}

/* --- KPI cards --- */

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 20px;
}

.kpi-card {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 10px;
    padding: 18px;
}

.kpi-card .kpi-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #94a3b8;
    margin-bottom: 8px;
}

.kpi-card .kpi-value {
    font-size: 28px;
    font-weight: 700;
    color: #f1f5f9;
}

.kpi-card .kpi-value.positive { color: #22c55e; }
.kpi-card .kpi-value.warning { color: #f59e0b; }
.kpi-card .kpi-value.negative { color: #ef4444; }

/* --- Cards --- */

.card {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 10px;
    padding: 18px;
    margin-bottom: 16px;
}

.card h3 {
    font-size: 14px;
    color: #94a3b8;
    margin-bottom: 12px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.card-header h3 { margin-bottom: 0; }

.card-header select {
    padding: 4px 8px;
    border: 1px solid #475569;
    border-radius: 6px;
    background: #0f172a;
    color: #e2e8f0;
    font-size: 13px;
}

.card-wide { flex: 2; }

.dashboard-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

/* --- Trend chart (simple bars) --- */

.trend-chart {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    height: 120px;
    padding-top: 10px;
}

.trend-bar-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.trend-bar {
    width: 100%;
    border-radius: 4px 4px 0 0;
    min-height: 4px;
    transition: height 0.3s;
}

.trend-bar.accepted { background: #22c55e; }
.trend-bar.rejected { background: #ef4444; }

.trend-label {
    font-size: 11px;
    color: #64748b;
}

.trend-rate {
    font-size: 11px;
    font-weight: 600;
    color: #94a3b8;
}

/* --- Top pathologies --- */

.patho-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid #334155;
}

.patho-item:last-child { border-bottom: none; }

.patho-name {
    font-size: 13px;
    color: #e2e8f0;
}

.patho-count {
    font-size: 13px;
    font-weight: 600;
    color: #a78bfa;
}

/* --- Negative feedbacks --- */

.neg-feedback-item {
    padding: 10px 0;
    border-bottom: 1px solid #334155;
}

.neg-feedback-item:last-child { border-bottom: none; }

.neg-feedback-header {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 4px;
}

.neg-feedback-time {
    font-size: 12px;
    color: #64748b;
}

.neg-feedback-operator {
    font-size: 13px;
    font-weight: 600;
    color: #e2e8f0;
}

.neg-feedback-patho {
    font-size: 12px;
    color: #a78bfa;
}

.neg-feedback-product {
    font-size: 13px;
    color: #f59e0b;
    font-weight: 600;
}

.neg-feedback-reason {
    font-size: 12px;
    color: #94a3b8;
    font-style: italic;
    margin-top: 2px;
}

/* --- Operators table --- */

.op-table {
    width: 100%;
    border-collapse: collapse;
}

.op-table th {
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    padding: 8px 12px;
    border-bottom: 1px solid #334155;
}

.op-table td {
    padding: 10px 12px;
    font-size: 13px;
    border-bottom: 1px solid #1e293b;
}

.op-table tr:hover { background: #334155; cursor: pointer; }

.op-rate { font-weight: 700; }
.op-rate.high { color: #22c55e; }
.op-rate.medium { color: #f59e0b; }
.op-rate.low { color: #ef4444; }

/* --- Operator detail --- */

.op-detail-section {
    margin-bottom: 12px;
}

.op-detail-section h4 {
    font-size: 12px;
    color: #64748b;
    text-transform: uppercase;
    margin-bottom: 6px;
}

.op-trend-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.op-trend-badge.up { background: #065f46; color: #6ee7b7; }
.op-trend-badge.down { background: #450a0a; color: #fca5a5; }
.op-trend-badge.stable { background: #1e293b; color: #94a3b8; }

/* --- Rules --- */

.rule-card {
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 10px;
}

.rule-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.rule-name {
    font-size: 15px;
    font-weight: 700;
    color: #f1f5f9;
}

.rule-actions {
    display: flex;
    gap: 6px;
}

.rule-actions button {
    padding: 3px 10px;
    border: 1px solid #475569;
    border-radius: 4px;
    background: transparent;
    color: #94a3b8;
    font-size: 11px;
    cursor: pointer;
}

.rule-actions button:hover { background: #334155; color: #e2e8f0; }

.rule-detail {
    font-size: 13px;
    color: #94a3b8;
    line-height: 1.6;
}

.rule-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
}

.rule-badge.active { background: #065f46; color: #6ee7b7; }
.rule-badge.inactive { background: #450a0a; color: #fca5a5; }
.rule-badge.haute { background: #7c2d12; color: #fed7aa; }
.rule-badge.normal { background: #1e293b; color: #94a3b8; border: 1px solid #475569; }
.rule-badge.basse { background: #1e293b; color: #64748b; }

/* --- Modal --- */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal {
    background: #1e293b;
    border: 1px solid #475569;
    border-radius: 12px;
    padding: 24px;
    width: 90%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal h3 {
    font-size: 18px;
    color: #f1f5f9;
    margin-bottom: 16px;
}

.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-size: 12px;
    color: #94a3b8;
    margin-bottom: 4px;
    font-weight: 600;
}

.form-group input, .form-group select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #475569;
    border-radius: 6px;
    background: #0f172a;
    color: #e2e8f0;
    font-size: 13px;
}

.radio-group {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.radio-group label {
    font-size: 13px;
    color: #e2e8f0;
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
}

.radio-group input[type="radio"] { accent-color: #38bdf8; }

.search-results {
    border: 1px solid #475569;
    border-radius: 6px;
    background: #0f172a;
    max-height: 150px;
    overflow-y: auto;
    margin-top: 4px;
}

.search-result-item {
    padding: 8px 10px;
    font-size: 13px;
    color: #e2e8f0;
    cursor: pointer;
    border-bottom: 1px solid #334155;
}

.search-result-item:hover { background: #334155; }
.search-result-item:last-child { border-bottom: none; }

.search-result-ean {
    font-size: 11px;
    color: #64748b;
    margin-left: 8px;
}

.selected-product {
    padding: 8px 10px;
    background: #065f46;
    border: 1px solid #059669;
    border-radius: 6px;
    font-size: 13px;
    color: #6ee7b7;
    margin-top: 4px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}

/* --- Skills checklist --- */

#skills-filter {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #475569;
    border-radius: 6px;
    background: #0f172a;
    color: #e2e8f0;
    font-size: 13px;
    margin-bottom: 10px;
}

.skills-checklist {
    max-height: 400px;
    overflow-y: auto;
}

.skill-check-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    font-size: 13px;
    color: #e2e8f0;
}

.skill-check-item input { accent-color: #38bdf8; }

.setting-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.setting-row label {
    font-size: 13px;
    color: #e2e8f0;
}

.setting-row select {
    padding: 4px 8px;
    border: 1px solid #475569;
    border-radius: 6px;
    background: #0f172a;
    color: #e2e8f0;
    font-size: 13px;
}

/* --- Toggle switch --- */

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    cursor: pointer;
}
.toggle-switch input { display: none; }
.toggle-slider {
    position: absolute;
    inset: 0;
    background: #475569;
    border-radius: 11px;
    transition: background 0.2s;
}
.toggle-slider::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    left: 3px;
    top: 3px;
    background: #e2e8f0;
    border-radius: 50%;
    transition: transform 0.2s;
}
.toggle-switch input:checked + .toggle-slider { background: #3b82f6; }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(18px); }

/* --- Empty state --- */

.empty-state {
    text-align: center;
    padding: 40px;
    color: #64748b;
    font-size: 14px;
}

/* --- Empty state banner (donnees insuffisantes) --- */

.empty-state-banner {
    background: #1e293b;
    border: 1px dashed #475569;
    border-radius: 10px;
    padding: 16px 20px;
    color: #94a3b8;
    font-size: 13px;
    text-align: center;
    margin-bottom: 16px;
}

/* --- KPIs principaux (grands) --- */

.kpi-grid-primary {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    margin-bottom: 14px;
}

.kpi-card-primary {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 10px;
    padding: 20px;
}

.kpi-card-primary .kpi-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #94a3b8;
    margin-bottom: 8px;
}

.kpi-card-primary .kpi-value {
    font-size: 36px;
    font-weight: 700;
    color: #f1f5f9;
}

.kpi-card-primary .kpi-sub {
    font-size: 11px;
    color: #64748b;
    margin-top: 4px;
}

/* --- Dashboard toolbar --- */

.dashboard-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.dashboard-toolbar select {
    padding: 4px 8px;
    border: 1px solid #475569;
    border-radius: 6px;
    background: #0f172a;
    color: #e2e8f0;
    font-size: 13px;
}

.btn-sm {
    padding: 4px 12px;
    font-size: 12px;
}

/* --- Performance table --- */

.perf-table {
    width: 100%;
    border-collapse: collapse;
}

.perf-table th {
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    padding: 8px 10px;
    border-bottom: 1px solid #334155;
}

.perf-table td {
    padding: 8px 10px;
    font-size: 13px;
    border-bottom: 1px solid #1e293b;
}

.perf-alert {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 600;
    background: #450a0a;
    color: #fca5a5;
}

/* --- Sparkline CSS (tendance operateur) --- */

.sparkline {
    display: flex;
    align-items: flex-end;
    gap: 1px;
    height: 20px;
}

.sparkline-bar {
    flex: 1;
    border-radius: 1px 1px 0 0;
    min-height: 1px;
    background: #38bdf8;
    opacity: 0.7;
}

/* --- Calibration --- */

.calib-disclaimer {
    background: #1e293b;
    border: 1px dashed #475569;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 11px;
    color: #94a3b8;
    margin-bottom: 16px;
    line-height: 1.5;
}

.calib-section {
    margin-bottom: 18px;
}

.calib-label {
    display: block;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #94a3b8;
    font-weight: 700;
    margin-bottom: 8px;
}

.calib-slider-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.calib-endpoint {
    font-size: 11px;
    color: #64748b;
    white-space: nowrap;
}

.calib-slider-row input[type="range"] {
    flex: 1;
    accent-color: #38bdf8;
    height: 6px;
}

.calib-value {
    font-size: 16px;
    font-weight: 700;
    color: #38bdf8;
    min-width: 32px;
    text-align: center;
}

.calib-hint {
    font-size: 11px;
    color: #64748b;
    margin-top: 4px;
}

/* Preview chart : barres horizontales */
.calib-preview-chart {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.calib-preview-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.calib-preview-label {
    font-size: 12px;
    color: #94a3b8;
    min-width: 32px;
    text-align: right;
}

.calib-preview-bar-bg {
    flex: 1;
    height: 18px;
    background: #0f172a;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.calib-preview-bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s, background 0.3s;
}

.calib-preview-pct {
    font-size: 11px;
    color: #e2e8f0;
    font-weight: 600;
    min-width: 40px;
}

.calib-preview-row.active .calib-preview-label { color: #38bdf8; font-weight: 700; }
.calib-preview-row.active .calib-preview-bar { background: #38bdf8; }
.calib-preview-row.active .calib-preview-pct { color: #38bdf8; }
.calib-preview-row:not(.active) .calib-preview-bar { background: #475569; }

/* Silence distribution */
.calib-silence-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.calib-silence-item {
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 6px;
    padding: 10px;
    text-align: center;
}

.calib-silence-count {
    font-size: 20px;
    font-weight: 700;
    color: #f59e0b;
}

.calib-silence-label {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 2px;
}

/* Tag alerts */
.calib-tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.calib-tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: #450a0a;
    border: 1px solid #7f1d1d;
    border-radius: 999px;
    font-size: 12px;
    color: #fca5a5;
}

.calib-tag-chip .tag-count {
    font-size: 10px;
    color: #f87171;
    font-weight: 700;
}

/* --- Responsive --- */

@media (max-width: 900px) {
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .kpi-grid-primary { grid-template-columns: 1fr; }
    .dashboard-row { grid-template-columns: 1fr; }
}

@media (max-width: 500px) {
    .kpi-grid { grid-template-columns: 1fr; }
    .tabs { overflow-x: auto; }
}

/* --- Operators Dashboard (onglet activite) --- */

.ops-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.ops-period-selector {
    display: flex;
    gap: 4px;
}

.ops-period-btn {
    padding: 6px 14px;
    background: #1e293b;
    border: 1px solid #334155;
    color: #94a3b8;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
}

.ops-period-btn.active {
    background: #38bdf8;
    color: #0f172a;
    border-color: #38bdf8;
    font-weight: 600;
}

.ops-date-range {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #64748b;
}

.ops-date-range input[type="date"] {
    padding: 4px 8px;
    background: #1e293b;
    border: 1px solid #334155;
    color: #e2e8f0;
    border-radius: 4px;
    font-size: 12px;
}

.ops-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.ops-kpi-grid-small {
    grid-template-columns: repeat(3, 1fr);
    margin-bottom: 12px;
}

.ops-kpi-card {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 14px 16px;
    text-align: center;
}

.ops-kpi-label {
    font-size: 11px;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.ops-kpi-value {
    font-size: 28px;
    font-weight: 700;
    color: #e2e8f0;
}

.ops-kpi-value.accent { color: #38bdf8; }
.ops-kpi-value.green { color: #4ade80; }
.ops-kpi-value.muted { color: #64748b; }

.ops-kpi-sub {
    font-size: 11px;
    color: #64748b;
    margin-top: 2px;
}

.ops-badge {
    display: inline-block;
    padding: 2px 8px;
    background: #334155;
    border-radius: 4px;
    font-size: 11px;
    color: #94a3b8;
    margin: 2px 4px 2px 0;
}

.ops-badge.converted {
    background: #065f46;
    color: #4ade80;
}

.ops-session-entry {
    padding: 10px 0;
    border-bottom: 1px solid #1e293b;
}

.ops-session-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
}

.ops-info-banner {
    margin-top: 16px;
    padding: 10px 16px;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 6px;
    font-size: 12px;
    color: #64748b;
    text-align: center;
}

/* Ventes recentes */
.ops-sale-entry {
    padding: 10px 12px;
    border-bottom: 1px solid #1e293b;
}
.ops-sale-entry.has-conversion {
    border-left: 3px solid #4ade80;
    padding-left: 9px;
}
.ops-sale-header {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.ops-sale-date {
    font-size: 13px;
    color: #e2e8f0;
    font-weight: 500;
}
.ops-sale-meta {
    font-size: 12px;
    color: #64748b;
}
.ops-sale-products {
    margin-top: 4px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.ops-sale-product {
    display: inline-block;
    padding: 2px 6px;
    background: #1e293b;
    border-radius: 3px;
    font-size: 11px;
    color: #94a3b8;
}
.ops-sale-converted {
    margin-top: 4px;
    font-size: 11px;
    color: #4ade80;
}

@media (max-width: 900px) {
    .ops-kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .ops-toolbar { flex-direction: column; align-items: stretch; }
}

@media (max-width: 500px) {
    .ops-kpi-grid { grid-template-columns: 1fr; }
}
