/* ================================================
   MAISON DU MAGHREB - BACK-OFFICE DESKTOP CSS
   Complément au design system mobile (styles.css)
   ================================================ */

/* ---- Layout Principal ---- */
.backoffice-layout {
  display: flex;
  min-height: 100vh;
  font-family: var(--font-body);
  background: var(--gray-50);
  color: var(--gray-900);
}

/* ---- Sidebar ---- */
.bo-sidebar {
  width: 260px;
  background: linear-gradient(180deg, #0c1829 0%, #1a2740 100%);
  color: white;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  overflow-y: auto;
  z-index: 100;
  transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
}

.bo-sidebar-logo {
  padding: 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  gap: 14px;
}

.bo-sidebar-logo .logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--blue-500), var(--blue-700));
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.bo-sidebar-logo .logo-text {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
}

.bo-sidebar-logo .logo-text small {
  display: block;
  font-weight: 400;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
  margin-top: 2px;
}

.bo-sidebar-nav {
  padding: 16px 0;
  flex: 1;
}

.bo-nav-section {
  padding: 0 16px;
  margin-bottom: 8px;
}

.bo-nav-section-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.35);
  padding: 12px 12px 8px;
}

.bo-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  color: rgba(255, 255, 255, 0.55);
  text-decoration: none;
  transition: all 0.2s ease;
  border-radius: 10px;
  margin: 2px 0;
  font-size: 14px;
  font-weight: 500;
  position: relative;
}

.bo-nav-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.7;
}

.bo-nav-item:hover {
  color: white;
  background: rgba(255, 255, 255, 0.08);
}

.bo-nav-item:hover svg {
  opacity: 1;
}

.bo-nav-item.active {
  color: white;
  background: rgba(9, 87, 151, 0.35);
}

.bo-nav-item.active svg {
  opacity: 1;
}

.bo-nav-item.active::before {
  content: '';
  position: absolute;
  left: -16px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 24px;
  background: var(--blue-400);
  border-radius: 0 3px 3px 0;
}

.bo-nav-item .nav-badge {
  margin-left: auto;
  background: var(--error);
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}

.bo-sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.bo-sidebar-footer .bo-nav-item {
  color: rgba(255, 255, 255, 0.4);
}

.bo-sidebar-footer .bo-nav-item:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

/* ---- Main Content Area ---- */
.bo-main {
  margin-left: 260px;
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ---- Top Bar ---- */
.bo-topbar {
  height: 64px;
  background: white;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.bo-topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.bo-topbar-left h1 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--gray-900);
  margin: 0;
}

.bo-topbar-left .breadcrumb {
  font-size: 13px;
  color: var(--gray-400);
}

.bo-topbar-left .breadcrumb a {
  color: var(--blue-600);
  text-decoration: none;
}

.bo-topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.bo-topbar-right .topbar-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue-500), var(--blue-700));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 14px;
}

.bo-topbar-right .topbar-bell {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: background 0.2s;
}

.bo-topbar-right .topbar-bell:hover {
  background: var(--gray-200);
}

.bo-topbar-right .topbar-bell .bell-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  background: var(--error);
  border-radius: 50%;
  border: 2px solid white;
}

/* ---- Content Area ---- */
.bo-content {
  padding: 32px;
  max-width: 1400px;
  flex: 1;
}

.bo-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.bo-page-header h2 {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  color: var(--gray-900);
  margin: 0;
}

.bo-page-header .header-actions {
  display: flex;
  gap: 12px;
}

/* ---- KPI Grid ---- */
.bo-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.bo-kpi-card {
  background: white;
  border-radius: 16px;
  padding: 22px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  border: 1px solid var(--gray-100);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.bo-kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.bo-kpi-card .kpi-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
  font-size: 20px;
}

.bo-kpi-card .kpi-icon.blue { background: var(--blue-50); color: var(--blue-600); }
.bo-kpi-card .kpi-icon.gold { background: var(--gold-50); color: var(--gold-600); }
.bo-kpi-card .kpi-icon.green { background: #ecfdf5; color: #10b981; }
.bo-kpi-card .kpi-icon.purple { background: #f5f3ff; color: #7c3aed; }
.bo-kpi-card .kpi-icon.orange { background: #fff7ed; color: #f59e0b; }
.bo-kpi-card .kpi-icon.red { background: #fef2f2; color: #ef4444; }

.bo-kpi-card .kpi-value {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 800;
  color: var(--gray-900);
  line-height: 1;
  margin-bottom: 4px;
}

.bo-kpi-card .kpi-label {
  font-size: 13px;
  color: var(--gray-500);
  font-weight: 500;
}

.bo-kpi-card .kpi-change {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  margin-top: 8px;
  padding: 3px 8px;
  border-radius: 6px;
}

.bo-kpi-card .kpi-change.up { background: #ecfdf5; color: #10b981; }
.bo-kpi-card .kpi-change.down { background: #fef2f2; color: #ef4444; }

/* ---- Data Tables ---- */
.bo-table-wrapper {
  background: white;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  border: 1px solid var(--gray-100);
}

.bo-table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-100);
  gap: 12px;
  flex-wrap: wrap;
}

.bo-table-toolbar .toolbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.bo-table-toolbar .toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.bo-search-input {
  padding: 8px 14px 8px 36px;
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  font-size: 13px;
  width: 260px;
  transition: border-color 0.2s, box-shadow 0.2s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='7' cy='7' r='4'/%3E%3Cpath d='m11 11 4 4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 12px center;
  font-family: var(--font-body);
}

.bo-search-input:focus {
  outline: none;
  border-color: var(--blue-400);
  box-shadow: 0 0 0 3px rgba(9, 87, 151, 0.1);
}

.bo-filter-select {
  padding: 8px 32px 8px 12px;
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  font-size: 13px;
  background: white;
  appearance: none;
  cursor: pointer;
  font-family: var(--font-body);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m2 4 4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

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

.bo-table th {
  text-align: left;
  padding: 13px 20px;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}

.bo-table td {
  padding: 14px 20px;
  border-bottom: 1px solid var(--gray-100);
  font-size: 14px;
  color: var(--gray-700);
  vertical-align: middle;
}

.bo-table tbody tr {
  transition: background 0.15s;
}

.bo-table tbody tr:hover td {
  background: var(--blue-50);
}

.bo-table tbody tr:last-child td {
  border-bottom: none;
}

.bo-table .cell-main {
  font-weight: 600;
  color: var(--gray-900);
}

.bo-table .cell-sub {
  font-size: 12px;
  color: var(--gray-400);
  margin-top: 2px;
}

.bo-table .cell-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.bo-table .action-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--gray-200);
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--gray-500);
}

.bo-table .action-btn:hover {
  border-color: var(--blue-300);
  color: var(--blue-600);
  background: var(--blue-50);
}

/* ---- Pagination ---- */
.bo-pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-top: 1px solid var(--gray-100);
  font-size: 13px;
  color: var(--gray-500);
}

.bo-pagination .pagination-pages {
  display: flex;
  gap: 4px;
}

.bo-pagination .page-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--gray-200);
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-600);
  transition: all 0.2s;
}

.bo-pagination .page-btn:hover {
  border-color: var(--blue-300);
  background: var(--blue-50);
}

.bo-pagination .page-btn.active {
  background: var(--blue-600);
  color: white;
  border-color: var(--blue-600);
}

/* ---- Cards Grid (for detail pages) ---- */
.bo-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 24px;
  margin-bottom: 28px;
}

.bo-card {
  background: white;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  border: 1px solid var(--gray-100);
}

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

.bo-card-header h3 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--gray-900);
  margin: 0;
}

/* ---- Two Column Layout ---- */
.bo-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.bo-two-col.sidebar-layout {
  grid-template-columns: 2fr 1fr;
}

/* ---- Status Toggle ---- */
.bo-status-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.bo-status-toggle.active {
  background: #ecfdf5;
  color: #10b981;
}

.bo-status-toggle.inactive {
  background: var(--gray-100);
  color: var(--gray-500);
}

/* ---- Chart Placeholder ---- */
.bo-chart-placeholder {
  height: 240px;
  background: linear-gradient(135deg, var(--gray-50), var(--gray-100));
  border-radius: 12px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 20px;
  gap: 8px;
}

.bo-chart-bar {
  width: 32px;
  border-radius: 6px 6px 0 0;
  transition: height 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ---- Activity Feed ---- */
.bo-activity-item {
  display: flex;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--gray-100);
}

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

.bo-activity-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 16px;
}

.bo-activity-content {
  flex: 1;
}

.bo-activity-content .activity-text {
  font-size: 14px;
  color: var(--gray-700);
  line-height: 1.4;
}

.bo-activity-content .activity-text strong {
  color: var(--gray-900);
  font-weight: 600;
}

.bo-activity-content .activity-time {
  font-size: 12px;
  color: var(--gray-400);
  margin-top: 4px;
}

/* ---- Form Layout (desktop) ---- */
.bo-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.bo-form-grid .full-width {
  grid-column: 1 / -1;
}

.bo-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding-top: 20px;
  border-top: 1px solid var(--gray-100);
  margin-top: 24px;
}

/* ---- Login Page ---- */
.bo-login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0c1829 0%, #1a3a5c 50%, #095797 100%);
  padding: 24px;
}

.bo-login-card {
  background: white;
  border-radius: 24px;
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.2);
}

.bo-login-card .login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.bo-login-card .login-logo .logo-icon {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--blue-500), var(--blue-700));
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  margin-bottom: 16px;
}

.bo-login-card .login-logo h1 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--gray-900);
  margin: 0 0 4px;
}

.bo-login-card .login-logo p {
  font-size: 14px;
  color: var(--gray-500);
  margin: 0;
}

/* ---- Animated Charts ---- */
.bo-chart-container {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 200px;
  padding: 16px 0;
}

.bo-chart-container .bo-chart-bar {
  flex: 1;
  border-radius: 6px 6px 0 0;
  transition: height 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  height: 0;
  position: relative;
  cursor: pointer;
}

.bo-chart-container .bo-chart-bar:hover {
  opacity: 0.85;
}

.bo-chart-container .bar-label {
  position: absolute;
  bottom: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  color: var(--gray-500);
  white-space: nowrap;
}

.bo-chart-container .bar-value {
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 700;
  color: var(--gray-700);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.3s;
}

.bo-chart-container .bo-chart-bar:hover .bar-value {
  opacity: 1;
}

/* ---- Alert Items ---- */
.bo-alert-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 8px;
  font-size: 13px;
}

.bo-alert-item.warning { background: #fffbeb; border: 1px solid #fcd34d; color: #92400e; }
.bo-alert-item.error { background: #fef2f2; border: 1px solid #fca5a5; color: #991b1b; }
.bo-alert-item.info { background: #eff6ff; border: 1px solid #93c5fd; color: #1e40af; }
.bo-alert-item.success { background: #ecfdf5; border: 1px solid #6ee7b7; color: #065f46; }

/* ---- Timeline ---- */
.bo-timeline-item {
  display: flex;
  gap: 16px;
  padding: 12px 0;
  position: relative;
}

.bo-timeline-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 4px;
}

/* ---- Progress Bars ---- */
.bo-progress-bar {
  margin-bottom: 12px;
}

.bo-progress-bar .bar-header {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 6px;
}

.bo-progress-bar .bar-track {
  height: 8px;
  background: #f3f4f6;
  border-radius: 4px;
  overflow: hidden;
}

.bo-progress-bar .bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease;
}

/* ---- Centre IA ---- */
.ai-gradient-banner {
  background: linear-gradient(135deg, #7c3aed, #4c1d95);
  border-radius: 16px;
  padding: 32px;
  color: white;
  margin-bottom: 24px;
}

.ai-chat-container {
  background: #f9fafb;
  border-radius: 12px;
  padding: 16px;
  min-height: 300px;
  display: flex;
  flex-direction: column;
}

.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  margin-bottom: 12px;
}

.ai-message {
  padding: 12px 16px;
  border-radius: 12px;
  margin-bottom: 8px;
  max-width: 80%;
  font-size: 14px;
  line-height: 1.5;
}

.ai-message.bot {
  background: white;
  border: 1px solid #e5e7eb;
  color: var(--gray-700);
}

.ai-message.user {
  background: #095797;
  color: white;
  margin-left: auto;
}

.ai-input-bar {
  display: flex;
  gap: 8px;
  padding: 12px;
  background: white;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
}

.ai-input-bar input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 14px;
  font-family: var(--font-body);
}

.ai-chip {
  padding: 6px 14px;
  border-radius: 20px;
  background: #f3f0ff;
  color: #7c3aed;
  font-size: 13px;
  cursor: pointer;
  border: none;
  font-weight: 500;
  transition: background 0.2s;
}

.ai-chip:hover {
  background: #ede9fe;
}

/* ---- Quick Actions ---- */
.bo-quick-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ---- Responsive ---- */
@media (max-width: 1200px) {
  .bo-two-col {
    grid-template-columns: 1fr;
  }
  .bo-two-col.sidebar-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1024px) {
  .bo-sidebar {
    width: 72px;
  }
  .bo-sidebar .logo-text,
  .bo-sidebar .nav-text,
  .bo-sidebar .bo-nav-label,
  .bo-sidebar .bo-logo-text,
  .bo-nav-section-title,
  .bo-sidebar .nav-badge {
    display: none;
  }
  .bo-sidebar-logo {
    justify-content: center;
    padding: 16px;
  }
  .bo-nav-item {
    justify-content: center;
    padding: 12px;
  }
  .bo-nav-item.active::before {
    left: -16px;
  }
  .bo-main {
    margin-left: 72px;
  }
  .bo-content {
    padding: 24px;
  }
}

@media (max-width: 768px) {
  .bo-sidebar {
    display: none;
  }
  .bo-main {
    margin-left: 0;
  }
  .bo-topbar {
    padding: 0 16px;
  }
  .bo-content {
    padding: 16px;
  }
  .bo-kpi-grid {
    grid-template-columns: 1fr 1fr;
  }
  .bo-form-grid {
    grid-template-columns: 1fr;
  }
  .bo-table-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .bo-search-input {
    width: 100%;
  }
}
