/* ============================================================
   MAHALIY ADS — THEME CSS
   Basé sur la charte graphique de mahaliy.fr
   À inclure en PREMIER dans toutes les pages PHP
   ============================================================ */

/* ── 1. IMPORT DES POLICES ────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700;800&family=Inter:wght@300;400;500;600&display=swap');

/* ── 2. VARIABLES CSS (PALETTE MAHALIY) ──────────────────── */
:root {
  /* Couleurs principales */
  --color-primary:      #7F59AB;   /* Violet Mahaliy */
  --color-primary-dark: #6342A0;   /* Violet foncé (hover) */
  --color-accent:       #9547FF;   /* Violet vif — boutons CTA */
  --color-accent-hover: #7B2FE8;   /* Bouton hover */

  /* Textes */
  --color-text:         #1e2846;   /* Bleu marine — texte principal */
  --color-text-muted:   #6B7280;   /* Gris — labels, texte secondaire */
  --color-text-light:   #FFFFFF;   /* Blanc — sur fonds sombres */

  /* Fonds */
  --color-bg:           #FFF9F9;   /* Fond principal (quasi-blanc rosé) */
  --color-bg-2:         #F3E9FF;   /* Fond sections / cards clair */
  --color-bg-dark:      #111833;   /* Fond sombre — sidebar, header */
  --color-bg-dark-2:    #1A2340;   /* Fond sombre secondaire — items sidebar */
  --color-bg-card:      #FFFFFF;   /* Fond card en mode clair */

  /* Bordures */
  --color-border:       #E8D9FF;   /* Bordure douce violet clair */
  --color-border-dark:  #2A3558;   /* Bordure en mode sombre */

  /* États */
  --color-success:      #22C55E;
  --color-warning:      #F59E0B;
  --color-danger:       #EF4444;
  --color-info:         #3B82F6;

  /* Typographie */
  --font-heading:       'Poppins', sans-serif;
  --font-body:          'Inter', sans-serif;

  /* Espacements */
  --radius-sm:          6px;
  --radius-md:          12px;
  --radius-lg:          16px;
  --radius-xl:          24px;

  /* Ombres */
  --shadow-sm:          0 1px 3px rgba(31, 40, 70, 0.08);
  --shadow-md:          0 4px 16px rgba(127, 89, 171, 0.12);
  --shadow-lg:          0 8px 32px rgba(127, 89, 171, 0.18);

  /* Transitions */
  --transition:         0.2s ease;
}

/* ── 3. RESET & BASE ──────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background-color: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── 4. LAYOUT PRINCIPAL ──────────────────────────────────── */
.wrapper,
.app-wrapper,
#app {
  display: flex;
  min-height: 100vh;
}

/* ── 5. SIDEBAR ───────────────────────────────────────────── */
.sidebar,
#sidebar,
nav.sidebar {
  width: 240px;
  min-height: 100vh;
  background-color: var(--color-bg-dark);
  border-right: 1px solid var(--color-border-dark);
  display: flex;
  flex-direction: column;
  padding: 0;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
}

/* Logo dans la sidebar */
.sidebar .logo,
.sidebar-logo,
.sidebar .brand {
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--color-border-dark);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar .logo img,
.sidebar-logo img {
  height: 36px;
  width: auto;
}

.sidebar .logo-text,
.sidebar .brand-name {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--color-text-light);
  letter-spacing: -0.02em;
}

.sidebar .logo-text span,
.sidebar .brand-name span {
  color: var(--color-accent);
}

/* Sections de navigation */
.sidebar .nav-section,
.sidebar .menu-section {
  padding: 20px 12px 8px;
}

.sidebar .nav-section-title,
.sidebar .menu-label {
  font-family: var(--font-body);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  padding: 0 8px;
  margin-bottom: 6px;
}

/* Items de navigation */
.sidebar a,
.sidebar .nav-item,
.sidebar .menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: #A0AEC0;
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 400;
  transition: all var(--transition);
  cursor: pointer;
  margin-bottom: 2px;
}

.sidebar a:hover,
.sidebar .nav-item:hover,
.sidebar .menu-item:hover {
  background-color: rgba(127, 89, 171, 0.15);
  color: var(--color-text-light);
}

.sidebar a.active,
.sidebar .nav-item.active,
.sidebar .menu-item.active {
  background: linear-gradient(135deg, rgba(127, 89, 171, 0.3), rgba(149, 71, 255, 0.2));
  color: var(--color-text-light);
  font-weight: 500;
  border-left: 3px solid var(--color-accent);
  padding-left: 9px;
}

/* Profil utilisateur en bas de sidebar */
.sidebar .user-profile,
.sidebar .sidebar-footer {
  margin-top: auto;
  padding: 16px 12px;
  border-top: 1px solid var(--color-border-dark);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar .user-profile img,
.sidebar .user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--color-primary);
}

.sidebar .user-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text-light);
}

.sidebar .user-email {
  font-size: 0.7rem;
  color: var(--color-text-muted);
}

/* ── 6. CONTENU PRINCIPAL ─────────────────────────────────── */
.main-content,
#main-content,
.content {
  margin-left: 240px;
  flex: 1;
  min-height: 100vh;
  background-color: var(--color-bg);
  display: flex;
  flex-direction: column;
}

/* ── 7. HEADER / TOPBAR ───────────────────────────────────── */
.topbar,
.header,
#header {
  background-color: var(--color-bg-dark);
  border-bottom: 1px solid var(--color-border-dark);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar h1,
.topbar .page-title {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-text-light);
  margin-right: auto;
}

/* Sélecteur de compte */
.topbar select,
.account-selector {
  background-color: var(--color-bg-dark-2);
  border: 1px solid var(--color-border-dark);
  color: var(--color-text-light);
  font-family: var(--font-body);
  font-size: 0.875rem;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color var(--transition);
  outline: none;
}

.topbar select:hover,
.account-selector:hover {
  border-color: var(--color-primary);
}

/* Champs de date */
.topbar input[type="date"],
.date-input {
  background-color: var(--color-bg-dark-2);
  border: 1px solid var(--color-border-dark);
  color: var(--color-text-light);
  font-family: var(--font-body);
  font-size: 0.875rem;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color var(--transition);
}

.topbar input[type="date"]:focus,
.date-input:focus {
  border-color: var(--color-accent);
}

/* Séparateur date */
.date-separator {
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

/* ── 8. BOUTONS ───────────────────────────────────────────── */
.btn,
button.btn {
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 20px;
  cursor: pointer;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}

.btn-primary,
button.btn-primary,
.btn-refresh,
button[type="submit"] {
  background: linear-gradient(135deg, var(--color-accent), var(--color-primary));
  color: #FFFFFF;
  box-shadow: 0 2px 8px rgba(149, 71, 255, 0.3);
}

.btn-primary:hover,
button.btn-primary:hover,
.btn-refresh:hover {
  background: linear-gradient(135deg, var(--color-accent-hover), var(--color-primary-dark));
  box-shadow: 0 4px 14px rgba(149, 71, 255, 0.45);
  transform: translateY(-1px);
}

.btn-secondary {
  background-color: var(--color-bg-2);
  color: var(--color-primary);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover {
  background-color: var(--color-border);
}

.btn-danger {
  background-color: var(--color-danger);
  color: #fff;
}

.btn-success {
  background-color: var(--color-success);
  color: #fff;
}

/* Bouton Actualiser spécifique topbar */
.topbar .btn,
.topbar button {
  padding: 8px 18px;
  font-size: 0.85rem;
}

/* ── 9. PAGE BODY / ZONE CONTENU ──────────────────────────── */
.page-body,
.content-area,
main {
  padding: 28px;
  flex: 1;
}

/* ── 10. CARDS / WIDGETS ──────────────────────────────────── */
.card,
.widget,
.panel {
  background-color: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}

.card:hover,
.widget:hover {
  box-shadow: var(--shadow-md);
}

.card-title,
.widget-title {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 16px;
}

/* Cards de KPI */
.kpi-card,
.stat-card {
  background: linear-gradient(135deg, #FFFFFF, var(--color-bg-2));
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(180deg, var(--color-accent), var(--color-primary));
  border-radius: 4px 0 0 4px;
}

.kpi-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  margin-bottom: 8px;
}

.kpi-value {
  font-family: var(--font-heading);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.2;
}

.kpi-value span.unit {
  font-size: 1rem;
  font-weight: 500;
  color: var(--color-text-muted);
}

.kpi-delta {
  font-size: 0.8rem;
  font-weight: 500;
  margin-top: 6px;
}

.kpi-delta.up   { color: var(--color-success); }
.kpi-delta.down { color: var(--color-danger); }

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

/* Grille de charts */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

/* ── 11. TABLEAUX ─────────────────────────────────────────── */
table,
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

table thead th,
.data-table thead th {
  background-color: var(--color-bg-2);
  color: var(--color-text);
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 11px 16px;
  text-align: left;
  border-bottom: 2px solid var(--color-border);
}

table tbody tr,
.data-table tbody tr {
  border-bottom: 1px solid var(--color-border);
  transition: background-color var(--transition);
}

table tbody tr:hover,
.data-table tbody tr:hover {
  background-color: var(--color-bg-2);
}

table tbody td,
.data-table tbody td {
  padding: 11px 16px;
  color: var(--color-text);
  vertical-align: middle;
}

/* ── 12. FORMULAIRES ──────────────────────────────────────── */
input[type="text"],
input[type="email"],
input[type="number"],
input[type="search"],
textarea,
select,
.form-control {
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--color-text);
  background-color: #FFFFFF;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  width: 100%;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

input:focus,
textarea:focus,
select:focus,
.form-control:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(127, 89, 171, 0.12);
}

label,
.form-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 6px;
  display: block;
}

/* ── 13. BADGES / TAGS ────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.badge-primary { background-color: var(--color-bg-2); color: var(--color-primary); }
.badge-success { background-color: #DCFCE7; color: #166534; }
.badge-warning { background-color: #FEF3C7; color: #92400E; }
.badge-danger  { background-color: #FEE2E2; color: #991B1B; }
.badge-info    { background-color: #DBEAFE; color: #1E40AF; }

/* Statut campagne */
.status-enabled  { color: var(--color-success); font-weight: 600; }
.status-paused   { color: var(--color-warning); font-weight: 600; }
.status-removed  { color: var(--color-danger); font-weight: 600; }

/* ── 14. ALERTES ──────────────────────────────────────────── */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.alert-warning { background-color: #FEF3C7; border-left: 4px solid var(--color-warning); color: #78350F; }
.alert-danger  { background-color: #FEE2E2; border-left: 4px solid var(--color-danger);  color: #7F1D1D; }
.alert-success { background-color: #DCFCE7; border-left: 4px solid var(--color-success); color: #14532D; }
.alert-info    { background-color: #DBEAFE; border-left: 4px solid var(--color-info);    color: #1E3A5F; }

/* ── 15. CHARGEMENT ───────────────────────────────────────── */
.loading-spinner,
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.loading-text {
  color: var(--color-text-muted);
  font-size: 0.875rem;
  margin-top: 12px;
}

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

/* ── 16. SCROLLBAR CUSTOM ─────────────────────────────────── */
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-primary); border-radius: 99px; opacity: 0.6; }
::-webkit-scrollbar-thumb:hover { background: var(--color-accent); }

/* ── 17. TYPOGRAPHIE UTILITAIRES ──────────────────────────── */
h1, h2, h3, h4, h5 {
  font-family: var(--font-heading);
  color: var(--color-text);
  line-height: 1.3;
}

h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.3rem; font-weight: 700; }
h3 { font-size: 1.1rem; font-weight: 600; }
h4 { font-size: 0.95rem; font-weight: 600; }

.text-muted    { color: var(--color-text-muted); }
.text-primary  { color: var(--color-primary); }
.text-accent   { color: var(--color-accent); }
.text-success  { color: var(--color-success); }
.text-danger   { color: var(--color-danger); }
.text-warning  { color: var(--color-warning); }

/* ── 18. UTILITAIRES ESPACEMENTS ──────────────────────────── */
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }

.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 24px; }

.flex          { display: flex; }
.flex-center   { display: flex; align-items: center; justify-content: center; }
.gap-2         { gap: 8px; }
.gap-3         { gap: 16px; }

/* ── 19. PAGE LOGIN ───────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--color-bg-dark) 0%, #1e2d5a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  background: var(--color-bg-card);
  border-radius: var(--radius-xl);
  padding: 44px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.login-card img.logo {
  height: 52px;
  margin-bottom: 28px;
}

.login-card h1 {
  font-size: 1.4rem;
  margin-bottom: 8px;
}

.login-card p {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  margin-bottom: 28px;
}

.btn-google {
  width: 100%;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--color-accent), var(--color-primary));
  color: #fff;
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 4px 14px rgba(149, 71, 255, 0.35);
  transition: all var(--transition);
}

.btn-google:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(149, 71, 255, 0.5);
}

/* ── 20. RESPONSIVE ───────────────────────────────────────── */
@media (max-width: 1024px) {
  .sidebar {
    width: 200px;
  }
  .main-content {
    margin-left: 200px;
  }
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .charts-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform var(--transition);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
  }
  .page-body {
    padding: 16px;
  }
  .kpi-grid {
    grid-template-columns: 1fr 1fr;
  }
}
