/* ===== GLOBAL STYLES ===== */
:root {
  --primary: #1e3a5f;
  --primary-light: #2d5a9e;
  --accent: #e8a020;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;
  --sidebar-width: 260px;
}

* { box-sizing: border-box; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #f0f4f8;
  margin: 0;
  padding: 0;
}

/* ===== LOGIN PAGE ===== */
.login-bg {
  background: linear-gradient(135deg, #1e3a5f 0%, #2d5a9e 50%, #1e3a5f 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.login-bg::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  background: rgba(255,255,255,0.03);
  border-radius: 50%;
  top: -200px; right: -200px;
}

.login-bg::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  background: rgba(255,255,255,0.05);
  border-radius: 50%;
  bottom: -100px; left: -100px;
}

.login-card {
  background: white;
  border-radius: 20px;
  padding: 48px 40px;
  width: 420px;
  box-shadow: 0 25px 80px rgba(0,0,0,0.3);
  position: relative;
  z-index: 1;
}

.login-logo {
  width: 80px; height: 80px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px;
  box-shadow: 0 8px 25px rgba(30,58,95,0.3);
}

.login-input {
  width: 100%;
  padding: 14px 16px 14px 46px;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  font-size: 15px;
  transition: all 0.2s;
  outline: none;
  background: #f9fafb;
}

.login-input:focus {
  border-color: var(--primary-light);
  background: white;
  box-shadow: 0 0 0 4px rgba(45,90,158,0.1);
}

.login-btn {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.5px;
}

.login-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(30,58,95,0.4);
}

.login-btn:active { transform: translateY(0); }

/* ===== LAYOUT ===== */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(180deg, #1e3a5f 0%, #162d4a 100%);
  min-height: 100vh;
  position: fixed;
  left: 0; top: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-logo-icon {
  width: 44px; height: 44px;
  background: var(--accent);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: white;
}

.sidebar-logo-text {
  color: white;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.2;
}

.sidebar-logo-sub {
  color: rgba(255,255,255,0.5);
  font-size: 11px;
  font-weight: 400;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 10px;
  color: rgba(255,255,255,0.65);
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 3px;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
}

.nav-item:hover {
  background: rgba(255,255,255,0.1);
  color: white;
  transform: translateX(4px);
}

.nav-item.active {
  background: linear-gradient(135deg, var(--accent), #f0b030);
  color: white;
  box-shadow: 0 4px 15px rgba(232,160,32,0.3);
}

.nav-item .nav-icon {
  width: 20px;
  text-align: center;
  font-size: 16px;
  flex-shrink: 0;
}

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

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.07);
  border-radius: 12px;
}

.user-avatar {
  width: 36px; height: 36px;
  background: var(--accent);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 14px;
}

.user-info { flex: 1; }
.user-name { color: white; font-size: 13px; font-weight: 600; }
.user-role { color: rgba(255,255,255,0.45); font-size: 11px; }

.logout-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.45);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  transition: all 0.2s;
}

.logout-btn:hover { color: #ef4444; background: rgba(239,68,68,0.1); }

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

.topbar {
  background: white;
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-actions { display: flex; align-items: center; gap: 12px; }

.page-content {
  padding: 28px;
  flex: 1;
}

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

.kpi-card {
  background: white;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  transition: all 0.3s;
  position: relative;
  overflow: hidden;
  border-left: 4px solid transparent;
}

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

.kpi-card.blue { border-left-color: var(--info); }
.kpi-card.green { border-left-color: var(--success); }
.kpi-card.orange { border-left-color: var(--warning); }
.kpi-card.red { border-left-color: var(--danger); }
.kpi-card.purple { border-left-color: #8b5cf6; }

.kpi-icon {
  width: 52px; height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  margin-bottom: 16px;
}

.kpi-card.blue .kpi-icon { background: #eff6ff; color: var(--info); }
.kpi-card.green .kpi-icon { background: #f0fdf4; color: var(--success); }
.kpi-card.orange .kpi-icon { background: #fffbeb; color: var(--warning); }
.kpi-card.red .kpi-icon { background: #fef2f2; color: var(--danger); }
.kpi-card.purple .kpi-icon { background: #f5f3ff; color: #8b5cf6; }

.kpi-value {
  font-size: 32px;
  font-weight: 800;
  color: #1f2937;
  line-height: 1;
  margin-bottom: 6px;
}

.kpi-label {
  font-size: 13px;
  color: #6b7280;
  font-weight: 500;
}

.kpi-sub {
  font-size: 12px;
  color: #9ca3af;
  margin-top: 4px;
}

/* ===== CARDS ===== */
.card {
  background: white;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  margin-bottom: 24px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 2px solid #f3f4f6;
}

.card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ===== TABLE ===== */
.table-container {
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  background: var(--primary);
  color: white;
  padding: 12px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

thead th:first-child { border-radius: 0; }

tbody tr {
  border-bottom: 1px solid #f3f4f6;
  transition: background 0.15s;
}

tbody tr:hover { background: #f8fafc; }

tbody td {
  padding: 11px 14px;
  color: #374151;
  vertical-align: middle;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-green { background: #dcfce7; color: #166534; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-orange { background: #fef3c7; color: #92400e; }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-purple { background: #ede9fe; color: #5b21b6; }
.badge-gray { background: #f3f4f6; color: #4b5563; }

/* ===== BUTTONS ===== */
.btn {
  padding: 9px 18px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
}

.btn-primary:hover { 
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(30,58,95,0.3);
}

.btn-accent {
  background: linear-gradient(135deg, var(--accent), #f0b030);
  color: white;
}

.btn-accent:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(232,160,32,0.3);
}

.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-outline {
  background: transparent;
  border: 2px solid #e5e7eb;
  color: #374151;
}
.btn-outline:hover { border-color: var(--primary-light); color: var(--primary); }
.btn-sm { padding: 6px 12px; font-size: 12px; }

/* ===== SEARCH & FILTERS ===== */
.filter-bar {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.search-input {
  padding: 10px 16px 10px 42px;
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  background: white;
  min-width: 250px;
}

.search-input:focus { border-color: var(--primary-light); }

.filter-select {
  padding: 10px 14px;
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  font-size: 13px;
  outline: none;
  background: white;
  cursor: pointer;
  color: #374151;
  transition: border-color 0.2s;
}

.filter-select:focus { border-color: var(--primary-light); }

/* ===== CHARTS ===== */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 24px;
  margin-bottom: 28px;
}

.chart-card {
  background: white;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

.chart-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ===== AI ANALYSIS ===== */
.ai-card {
  background: linear-gradient(135deg, #1e3a5f, #2d5a9e);
  border-radius: 16px;
  padding: 28px;
  color: white;
  position: relative;
  overflow: hidden;
}

.ai-card::before {
  content: '';
  position: absolute;
  width: 300px; height: 300px;
  background: rgba(255,255,255,0.03);
  border-radius: 50%;
  top: -100px; right: -100px;
}

.ai-response {
  background: rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 20px;
  margin-top: 16px;
  font-size: 14px;
  line-height: 1.7;
  backdrop-filter: blur(10px);
}

.ai-typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.ai-typing span {
  width: 8px; height: 8px;
  background: white;
  border-radius: 50%;
  animation: typing 1.2s infinite;
}

.ai-typing span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
  0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
  30% { opacity: 1; transform: scale(1); }
}

/* ===== FORMS ===== */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 8px;
}

.form-input {
  width: 100%;
  padding: 11px 14px;
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  background: #f9fafb;
}

.form-input:focus {
  border-color: var(--primary-light);
  background: white;
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.2s;
}

.modal-overlay.show { opacity: 1; }

.modal {
  background: white;
  border-radius: 20px;
  padding: 32px;
  max-width: 600px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  transform: scale(0.95);
  transition: transform 0.2s;
  box-shadow: 0 25px 80px rgba(0,0,0,0.3);
}

.modal-overlay.show .modal { transform: scale(1); }

/* ===== ADMIN PAGE ===== */
.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px;
}

.admin-section {
  background: white;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

.admin-section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid #f3f4f6;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ===== EDITIQUE ===== */
.report-card {
  background: white;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  transition: all 0.3s;
  cursor: pointer;
  border: 2px solid transparent;
}

.report-card:hover {
  border-color: var(--primary-light);
  transform: translateY(-4px);
  box-shadow: 0 12px 30px rgba(0,0,0,0.1);
}

.report-icon {
  width: 56px; height: 56px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  margin-bottom: 16px;
}

/* ===== PRINT STYLES ===== */
@media print {
  .sidebar, .topbar, .topbar-actions, .filter-bar, .no-print { display: none !important; }
  .main-content { margin-left: 0; }
  .page-content { padding: 0; }
  .card, .kpi-card { box-shadow: none; border: 1px solid #ddd; }
  table { font-size: 11px; }
  thead th { background: #1e3a5f !important; -webkit-print-color-adjust: exact; }
}

/* ===== ANIMATIONS ===== */
.fade-in {
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.pulse {
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* ===== PROGRESS BARS ===== */
.progress-bar {
  height: 8px;
  background: #e5e7eb;
  border-radius: 10px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 10px;
  transition: width 0.5s ease;
}

/* ===== TOOLTIP ===== */
.tooltip-container { position: relative; display: inline-block; }
.tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #1f2937;
  color: white;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 1000;
}
.tooltip-container:hover .tooltip { opacity: 1; }

/* ===== PAGINATION ===== */
.pagination {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
  margin-top: 16px;
}

.page-btn {
  width: 36px; height: 36px;
  border: 2px solid #e5e7eb;
  background: white;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.page-btn:hover { border-color: var(--primary-light); color: var(--primary); }
.page-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ===== NOTIFICATION ===== */
.notif-container {
  position: fixed;
  top: 20px; right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.notif {
  background: white;
  border-radius: 12px;
  padding: 14px 18px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 300px;
  transform: translateX(120%);
  transition: transform 0.3s ease;
  border-left: 4px solid;
}

.notif.show { transform: translateX(0); }
.notif.success { border-left-color: var(--success); }
.notif.error { border-left-color: var(--danger); }
.notif.info { border-left-color: var(--info); }
.notif.warning { border-left-color: var(--warning); }

/* ===== STAT WIDGET ===== */
.stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid #f3f4f6;
}

.stat-row:last-child { border-bottom: none; }

/* ===== OFFLINE BANNER ===== */
.offline-banner {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
  padding: 10px 24px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  display: none;
}

.offline-banner.show { display: block; }

/* ===== LOADING ===== */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.spinner {
  width: 50px; height: 50px;
  border: 4px solid #e5e7eb;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .charts-grid { grid-template-columns: 1fr; }
  .page-content { padding: 16px; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .search-input { min-width: 100%; }
  .topbar { padding: 12px 16px; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .login-card { width: 95%; padding: 32px 24px; }
}
