/* ===========================================================
   BOULANGERIE YONG - Dashboard Commercial
   =========================================================== */

:root {
    --sidebar-w: 250px;
    --sidebar-bg: #0f172a;
    --sidebar-hover: #1e293b;
    --sidebar-active: #3b82f6;
    --topbar-h: 64px;
    --body-bg: #f1f5f9;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --blue: #3b82f6;
    --green: #10b981;
    --amber: #f59e0b;
    --red: #ef4444;
    --purple: #8b5cf6;
    --teal: #14b8a6;
    --pink: #ec4899;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --shadow-lg: 0 4px 12px rgba(0,0,0,.1);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--body-bg);
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ==== SIDEBAR ==== */
#sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    background: var(--sidebar-bg);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    z-index: 100;
    transition: transform .3s;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-icon {
    font-size: 28px;
    color: var(--amber);
}
.sidebar-brand h1 {
    font-size: 22px;
    font-weight: 700;
    margin: 0;
    letter-spacing: 1px;
}
.sidebar-brand small {
    font-size: 11px;
    color: #94a3b8;
    display: block;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
}
.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 20px;
    color: #94a3b8;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all .2s;
    border-left: 3px solid transparent;
    position: relative;
}
.sidebar-nav .nav-link:hover {
    color: #fff;
    background: var(--sidebar-hover);
}
.sidebar-nav .nav-link.active {
    color: #fff;
    background: rgba(59,130,246,.15);
    border-left-color: var(--sidebar-active);
}
.sidebar-nav .nav-link i {
    width: 20px;
    text-align: center;
    font-size: 15px;
}
.badge-alert {
    position: absolute;
    right: 16px;
    background: var(--red);
    color: #fff;
    border-radius: 10px;
    padding: 1px 7px;
    font-size: 11px;
    font-weight: 600;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,.08);
}
.btn-refresh {
    width: 100%;
    padding: 10px;
    border: 1px solid rgba(255,255,255,.15);
    border-radius: 8px;
    background: transparent;
    color: #cbd5e1;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all .2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.btn-refresh:hover {
    background: rgba(255,255,255,.08);
    color: #fff;
}
.btn-refresh.loading i { animation: spin 1s linear infinite; }
.import-status {
    text-align: center;
    margin-top: 8px;
    font-size: 11px;
    color: #64748b;
}

/* ==== MAIN CONTENT ==== */
#main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ==== TOPBAR ==== */
.topbar {
    background: var(--card-bg);
    border-bottom: 1px solid #e2e8f0;
    padding: 12px 24px;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow);
}
.filters-row {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
}
.filter-group {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.filter-group label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .5px;
}
.filter-group label i { margin-right: 4px; }
.filter-group .form-control,
.filter-group .form-select {
    min-width: 150px;
    font-size: 13px;
    border-radius: 8px;
}
.filter-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}
.export-btns {
    display: flex;
    gap: 6px;
    margin-left: 8px;
    padding-left: 8px;
    border-left: 1px solid #e2e8f0;
}

/* ==== CONTENT SECTIONS ==== */
.content-section {
    display: none;
    padding: 24px;
    flex: 1;
}
.content-section.active { display: block; }

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}
.section-header h2 {
    font-size: 20px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}
.section-header h2 i { color: var(--blue); }

/* ==== KPI CARDS ==== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.kpi-small { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

.kpi-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow);
    border-left: 4px solid #e2e8f0;
    transition: transform .2s, box-shadow .2s;
}
.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}
.kpi-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}
.kpi-body { display: flex; flex-direction: column; min-width: 0; }
.kpi-value {
    font-size: 22px;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.kpi-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
    margin-top: 2px;
}

.kpi-blue  { border-left-color: var(--blue); }
.kpi-blue .kpi-icon  { background: #eff6ff; color: var(--blue); }
.kpi-green { border-left-color: var(--green); }
.kpi-green .kpi-icon { background: #ecfdf5; color: var(--green); }
.kpi-amber { border-left-color: var(--amber); }
.kpi-amber .kpi-icon { background: #fffbeb; color: var(--amber); }
.kpi-purple { border-left-color: var(--purple); }
.kpi-purple .kpi-icon { background: #f5f3ff; color: var(--purple); }
.kpi-teal  { border-left-color: var(--teal); }
.kpi-teal .kpi-icon  { background: #f0fdfa; color: var(--teal); }
.kpi-pink  { border-left-color: var(--pink); }
.kpi-pink .kpi-icon  { background: #fdf2f8; color: var(--pink); }
.kpi-red   { border-left-color: var(--red); }
.kpi-red .kpi-icon   { background: #fef2f2; color: var(--red); }

/* ==== CHARTS ==== */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}
.chart-panel {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}
.chart-panel.span-2 { grid-column: span 2; }
.chart-panel.span-3 { grid-column: span 3; }

.chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.chart-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}
.chart-header h3 i { color: var(--blue); font-size: 14px; }

.chart-panel canvas {
    max-height: 350px;
    min-height: 250px;
}

.chart-controls {
    display: flex;
    gap: 4px;
}
.chart-controls .btn {
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 6px;
}

/* ==== TABLES ==== */
.table { font-size: 13px; }
.table thead th {
    background: #f8fafc;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-secondary);
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
    position: sticky;
    top: 0;
}
.table tbody td {
    vertical-align: middle;
    white-space: nowrap;
}
.table-responsive { max-height: 500px; overflow-y: auto; }

/* ==== PAGINATION ==== */
.pagination-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    font-size: 13px;
    color: var(--text-secondary);
}

/* ==== SEARCH ==== */
.search-box { width: 260px; }

/* ==== ALERTES ==== */
.alert-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 14px;
    border-left: 4px solid #e2e8f0;
}
.alert-card.severity-danger  { border-left-color: var(--red); }
.alert-card.severity-warning { border-left-color: var(--amber); }
.alert-card.severity-info    { border-left-color: var(--blue); }
.alert-card .alert-icon {
    width: 38px; height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}
.alert-card.severity-danger .alert-icon  { background: #fef2f2; color: var(--red); }
.alert-card.severity-warning .alert-icon { background: #fffbeb; color: var(--amber); }
.alert-card.severity-info .alert-icon    { background: #eff6ff; color: var(--blue); }
.alert-card .alert-text {
    font-size: 14px;
    font-weight: 500;
}
.alert-card .alert-type {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-weight: 600;
}
.no-alerts {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}
.no-alerts i { font-size: 48px; margin-bottom: 12px; display: block; color: var(--green); }

/* ==== LOADING OVERLAY ==== */
#loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,.6);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 9999;
    color: #fff;
    font-size: 16px;
    backdrop-filter: blur(4px);
}

/* ==== ANIMATIONS ==== */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ==== RESPONSIVE ==== */
@media (max-width: 1200px) {
    .charts-grid { grid-template-columns: repeat(2, 1fr); }
    .chart-panel.span-2 { grid-column: span 2; }
    .chart-panel.span-3 { grid-column: span 2; }
}
@media (max-width: 992px) {
    #sidebar { transform: translateX(-100%); }
    #sidebar.open { transform: translateX(0); }
    #main-content { margin-left: 0; }
    .charts-grid { grid-template-columns: 1fr; }
    .chart-panel.span-2,
    .chart-panel.span-3 { grid-column: span 1; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 576px) {
    .kpi-grid { grid-template-columns: 1fr; }
    .filters-row { flex-direction: column; align-items: stretch; }
    .filter-actions { margin-left: 0; flex-wrap: wrap; }
}

/* ==== PRINT / PDF ==== */
@media print {
    #sidebar, .topbar, .btn-refresh, .filter-actions,
    .pagination-row, .search-box, #loading-overlay { display: none !important; }
    #main-content { margin-left: 0 !important; }
    .content-section { display: block !important; page-break-inside: avoid; }
    .chart-panel { box-shadow: none; border: 1px solid #e2e8f0; }
    .kpi-card { box-shadow: none; border: 1px solid #e2e8f0; }
    body { background: #fff; }
}
