/* Importation des polices Google Fonts (Sans-Serif) */
@import url('https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,100;0,300;0,400;0,700;0,900;1,100;1,300;1,400;1,700;1,900&family=Montserrat:ital,wght@0,100..900;1,100..900&display=swap');

/* ====== RESET GLOBAL ====== */
/* min-height (pas height) : un overflow-x:hidden posé ailleurs (layout)
   fait déduire overflow-y:auto par la spec dès que l'un des deux axes
   n'est pas "visible" — avec une height fixe à 100%, ça transforme
   html/body en boîte de défilement interne plafonnée à l'écran au lieu
   de laisser la page défiler normalement. min-height laisse la boîte
   grandir avec le contenu, donc rien à clipper. */
html, body {
  min-height: 100%;
  margin: 0;
  padding: 0;
}

/* ====== Variables globales ====== */
:root {
  --color-primary: #4b3cc4;
  --color-secondary: #f4f2ff;
  --color-accent: #d2b4ff;
  --color-success: #28c76f;
  --color-danger: #ea5455;
  --sidebar-bg: linear-gradient(135deg, #1f1c2c, #4b3cc4);
  --sidebar-width: 250px;
}

/* ====== Styles admin-panel ====== */
body.admin-panel {
  font-family: 'Inter', sans-serif;
  background: #f9fafc;
  display: flex;
  min-height: 100vh;
}

/* Le layout (sidebar/sign_in.html.erb) place un <div> sans classe entre
   <body> et .sidebar/.main-content. Comme body est flex mais que
   .sidebar est position:fixed (sort du flux), ce <div> est le SEUL
   enfant flex réel — sans largeur propre, il se réduit à la taille de
   son contenu (fit-content) au lieu de remplir le viewport, ce qui
   empêche .main-content de résoudre son width: calc(100% - ...) et le
   fait rétrécir à son tour, laissant un grand vide à droite. */
body.admin-panel > div {
  width: 100%;
  min-width: 0;
}

/* ==================== Sidebar ==================== */
body.admin-panel .sidebar {
  background: var(--sidebar-bg);
  height: 100vh;
  width: var(--sidebar-width);
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1050;
  box-shadow: 3px 0 15px rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: left 0.3s ease;
}

body.admin-panel .sidebar .text-center h4 {
  font-weight: bold;
  color: #fff;
}

body.admin-panel .sidebar a {
  color: rgba(255, 255, 255, 0.9);
  padding: 12px 20px;
  display: block;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 500;
  transition: all 0.3s;
}

body.admin-panel .sidebar a:hover,
body.admin-panel .sidebar a.active {
  background-color: rgba(255,255,255,0.15);
  color: #fff;
  transform: translateX(3px);
}

/* ==================== Main content ==================== */
body.admin-panel .main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  width: calc(100% - var(--sidebar-width));
  transition: margin-left 0.3s;
}

/* Neutraliser padding Bootstrap container-fluid sur main-content */
.container-fluid {
  max-width: 1400px; /* ou une autre valeur */
  margin-left: auto;
  margin-right: auto;
}

body.admin-panel .main-content.container-fluid {
  padding-left: 0 !important;
  padding-right: 0 !important;
  max-width: 100% !important;
}

/* Responsive sidebar & main content */
@media (max-width: 767.98px) {
  body.admin-panel .sidebar {
    left: -100%;
  }

  body.admin-panel .sidebar.show {
    left: 0;
  }

  body.admin-panel .main-content {
    margin-left: 0 !important;
    width: 100% !important;
  }
}

/* ==================== Filtres (page Parfums) ==================== */
/* L'ancien .btn-group Bootstrap ne se repliait jamais (white-space:nowrap
   sur les boutons), d'où le débordement horizontal forcé sur mobile.
   Remplacé par des pastilles qui se replient normalement avec flex-wrap,
   dans une carte dédiée qui utilise mieux l'espace disponible. */
.admin-filters-card {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
  padding: 20px 24px 24px;
}

.admin-filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid #eef0f3;
}

.admin-filter-pill {
  padding: 8px 18px;
  border-radius: 999px;
  border: 1.5px solid #e2e5ea;
  background: #fff;
  color: #495057;
  font-size: 0.86rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.admin-filter-pill:hover {
  border-color: var(--color-primary, #4b3cc4);
  color: var(--color-primary, #4b3cc4);
  text-decoration: none;
}

.admin-filter-pill.active {
  background: var(--color-primary, #4b3cc4);
  border-color: var(--color-primary, #4b3cc4);
  color: #fff;
}

.admin-filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 16px;
}

.admin-filter-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.admin-filter-field--search {
  flex: 2 1 280px;
}

.admin-filter-field--brand {
  flex: 1 1 220px;
}

.admin-filter-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: #6c757d;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin: 0;
}

.admin-filter-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.admin-filter-empty-msg {
  margin: 16px 0 0;
  color: #6c757d;
  font-size: 0.9rem;
}

@keyframes admin-brand-highlight-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(75, 60, 196, 0); }
  30% { box-shadow: 0 0 0 6px rgba(75, 60, 196, 0.25); }
}

.admin-brand-highlight .card {
  animation: admin-brand-highlight-pulse 1.6s ease;
  border-radius: 8px;
}

@media (max-width: 576px) {
  .admin-filters-card {
    padding: 16px;
  }

  .admin-filter-row {
    flex-direction: column;
    align-items: stretch;
  }

  /* flex-basis (280px/220px) vise la largeur en desktop ; une fois le
     conteneur passé en colonne, le même flex-basis s'applique à la
     HAUTEUR (axe principal désormais vertical), d'où le grand vide
     laissé sous chaque champ. On repasse en taille naturelle. */
  .admin-filter-field--search,
  .admin-filter-field--brand {
    flex: none;
  }

  .admin-filter-actions {
    flex-direction: column;
  }

  .admin-filter-actions .btn {
    width: 100%;
  }
}

/* ==================== Footer ==================== */
/* L'ancien footer avait un long séparateur en tirets cadratins codé en
   dur, une chaîne non-sécable : elle ne passait jamais à la ligne et
   forçait un débordement horizontal sur TOUTES les pages admin en
   mobile. Remplacé par une barre flex qui se replie normalement. */
.admin-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}

.admin-footer-sep {
  width: 40px;
  height: 1px;
  background: currentColor;
  opacity: 0.3;
  flex-shrink: 0;
}

/* ==================== Header ==================== */
body.admin-panel header {
  background: white;
  border-bottom: 1px solid #e5e5e5;
  padding: 15px 20px;
}

body.admin-panel header h1 {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--color-primary);
}

/* ==================== Flash messages ==================== */
/* Alignées sur le thème admin (couleurs/rayon des cartes) au lieu du
   Bootstrap .alert brut vert/rouge générique. */
body.admin-panel .alert {
  border: none;
  border-radius: 12px;
  padding: 0.9rem 1.1rem;
  font-weight: 500;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
}

body.admin-panel .alert-success {
  background-color: #e8f9f0;
  color: #1a7a4c;
}

body.admin-panel .alert-danger {
  background-color: #fdecec;
  color: #b42318;
}

/* ==================== Boutons ==================== */
body.admin-panel .btn {
  border-radius: 30px;
  transition: all 0.3s ease;
}

body.admin-panel .btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

body.admin-panel .btn-primary {
  background: var(--color-primary);
  border: none;
}

body.admin-panel .btn-primary:hover {
  background: #3a2fa0;
}

body.admin-panel .btn-outline-primary {
  border: 1px solid var(--color-primary);
  color: var(--color-primary);
}

body.admin-panel .btn-outline-primary:hover {
  background: var(--color-primary);
  color: white;
}

body.admin-panel .btn-outline-danger {
  border: 1px solid var(--color-danger);
  color: var(--color-danger);
}

body.admin-panel .btn-outline-danger:hover {
  background: var(--color-danger);
  color: white;
}

/* ==================== Cartes (ajusté pour brands) ==================== */
body.admin-panel .card {
  border: none;
  border-radius: 16px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.05);
  overflow: hidden;
  transition: all 0.3s ease;
  height: auto;
  min-height: 300px;
  max-height: 400px;
}

body.admin-panel .card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.12);
}

body.admin-panel .card-title {
  font-size: 1rem;
  font-weight: 600;
  color: #444;
}

/* Grille responsive (3-4 cartes par ligne sur desktop, 1 sur mobile)
   au lieu de l'ancien flex: 0 0 80% qui forçait une carte géante par
   ligne quelle que soit la taille d'écran. */
body.admin-panel .brand-list-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.5rem;
}

/* Ajustement du corps de la carte pour un padding fixe */
body.admin-panel .card-body {
  padding: 1.25rem !important;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
}

/* ==================== Cartes des parfums ==================== */
body.admin-panel .parfums-grid-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.5rem;
  padding: 0 15px;
}

body.admin-panel .parfums-grid-container .parfum-card {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

body.admin-panel .parfum-card-image {
  height: 220px;
  overflow: hidden;
  width: 100%;
  flex-shrink: 0;
}

body.admin-panel .parfum-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

body.admin-panel .parfum-card-image.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f0f0f0;
  height: 100%;
  color: #6c757d;
}

body.admin-panel .parfum-card-content {
  padding: 1rem;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

body.admin-panel .parfum-card-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: #444;
  margin-bottom: 0.5rem;
}

body.admin-panel .parfum-card-availability {
  font-size: 0.9rem;
  color: #6c757d;
  margin-bottom: 0.5rem;
}

body.admin-panel .parfum-card-actions {
  margin-top: 1rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

body.admin-panel .action-button {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 20px;
  color: white;
  text-decoration: none;
  font-size: 0.9rem;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

body.admin-panel .action-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* ==================== Responsive Images (ajusté pour brands et parfums) ==================== */
body.admin-panel img {
  max-width: 100%;
  height: auto;
}

/* Ajustement spécifique pour les images dans les cartes des brands */
body.admin-panel #brands_container img {
  max-height: 200px;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ==================== Sidebar Responsive - Important pour la fermeture sur mobile ==================== */
@media (max-width: 767.98px) {
  body.admin-panel .sidebar {
    left: -100%;
  }

  body.admin-panel .sidebar.show {
    left: 0;
  }

  /* Ajustement responsive pour les cartes des parfums */
  body.admin-panel .parfums-grid-container .parfum-card {
    flex: 0 0 100% !important;
    max-width: 100% !important;
    aspect-ratio: auto;
  }

  /* Ajustement responsive pour les cartes des brands */
  body.admin-panel .brand-list-container .card {
    flex: 0 0 100% !important;
    max-width: 100% !important;
  }
}

/* Sidebar close button (mobile) */
.sidebar .btn-close {
  filter: invert(1);
}

/* Empêche débordement vertical du contenu */
body.admin-panel main {
  overflow-y: auto;
}

/* ==================== Cartes des parfums (show) ==================== */
body.admin-panel .card {
  overflow: visible;
}

body.admin-panel .card .row {
  align-items: flex-start;
}

body.admin-panel .card .d-flex {
  flex-wrap: nowrap;
  width: 100%;
}

body.admin-panel .card .me-2 {
  flex-shrink: 0;
  max-width: 300px;
  margin-right: 0.5rem !important;
}

body.admin-panel .card .ps-2 {
  padding-left: 0.5rem !important;
  flex-grow: 1;
}

body.admin-panel .card .card-body {
  padding: 2rem;
}


/* Styles SweetAlert2 : le fond sombre (backdrop) est volontairement gardé
   — sans lui, la boîte de dialogue flotte sans séparation visuelle avec
   la page derrière, ce qui la fait paraître cassée/non stylée. */
body.admin-panel .swal2-popup {
  max-width: 90vw;
  padding: 1.5em;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: white;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

body.admin-panel .swal2-icon {
  width: 3em !important;
  height: 3em !important;
  margin: 1em auto 0.5em !important;
  font-size: 2em !important;
}

body.admin-panel .swal2-icon-show {
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Mobile : la popup peut dépasser la hauteur de l'écran (titre + texte
   long + boutons) et forcer à scroller la page derrière pour voir les
   boutons. On la contraint à la hauteur visible, avec son propre
   scroll interne si le texte est vraiment long, et on resserre les
   espacements/tailles pour qu'elle tienne plus facilement d'un coup. */
@media (max-width: 576px) {
  body.admin-panel .swal2-popup {
    max-width: 94vw;
    max-height: 88vh;
    overflow-y: auto;
    padding: 1.1em;
  }

  body.admin-panel .swal2-title {
    font-size: 1.25em;
    margin-bottom: 0.3em;
  }

  body.admin-panel .swal2-html-container {
    font-size: 0.92em;
    margin: 0.5em 0 0;
  }

  body.admin-panel .swal2-icon {
    width: 2.4em !important;
    height: 2.4em !important;
    margin: 0.5em auto 0.3em !important;
    font-size: 1.6em !important;
  }

  body.admin-panel .swal2-actions {
    margin-top: 0.8em;
    gap: 8px;
  }

  body.admin-panel .swal2-styled {
    padding: 0.5em 1.2em;
    font-size: 0.9em;
  }
}

/* Styles pour l'image du logo de la marque dans brands/show */
body.admin-panel .card-img-top.brand-logo-img {
  max-width: 250px !important; /* Limite la largeur maximale */
  max-height: 150px !important; /* Limite la hauteur maximale */
  width: auto !important; /* Permet une mise à l'échelle proportionnelle */
  height: auto !important;
  margin: 0 auto; /* Centre l'image horizontalement */
  object-fit: contain !important; /* Privilégie le maintien des proportions */
}

/* Applique la classe spécifique à l'image dans brands/show */
body.admin-panel #brand-show .card .card-img-top {
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
}

/* Styles pour les images des parfums dans brands/show */
body.admin-panel #brand-show .card .parfum-image {
  max-width: 200px !important; /* Limite la largeur maximale */
  max-height: 150px !important; /* Ajuste la hauteur maximale */
  width: auto !important; /* Permet une mise à l'échelle proportionnelle */
  height: auto !important; /* Maintient les proportions */
  object-fit: contain !important; /* Affiche l'image entière */
  object-position: center !important; /* Centre l'image */
  margin: 0 auto !important; /* Centre horizontalement */
  display: block !important; /* Assure un comportement standard */
}

/* Style spécifique pour le logo du brand dans brands/show */
.brand-logo {
  max-width: 250px !important;
  max-height: 150px !important;
  width: auto !important;
  height: auto !important;
  object-fit: contain !important;
  object-position: center !important;
  display: block !important;
  margin: 0 auto !important; /* Centre l'image */
}

/* Annule les styles Bootstrap pour cette image */
.brand-logo.card-img-top {
  width: auto !important;
}


/* PAGINATION ADMIN */

.admin-pagination-info {
  padding: 12px 16px;
  background-color: #f0f4f8;
  border-left: 4px solid #007bff;
  border-radius: 4px;
  font-size: 14px;
}

.admin-pagination-container {
  display: flex;
  justify-content: center;
  margin-top: 32px;
  margin-bottom: 32px;
}

.pagination {
  display: flex;
  list-style: none;
  padding: 0;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.page-item {
  display: inline-block;
}

.page-item.disabled .page-link {
  color: #ccc;
  cursor: not-allowed;
  background-color: transparent;
  border-color: #e0e0e0;
}

.page-item.active .page-link {
  background-color: #007bff;
  border-color: #007bff;
  color: white;
  font-weight: 600;
  cursor: default;
}

.page-link {
  display: inline-block;
  padding: 10px 12px;
  min-width: 44px;
  text-align: center;
  background-color: white;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  color: #007bff;
  text-decoration: none;
  transition: all 0.3s ease;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.page-link:hover:not(.page-item.disabled .page-link):not(.page-item.active .page-link) {
  background-color: #f0f4f8;
  border-color: #007bff;
  color: #0056b3;
  box-shadow: 0 2px 6px rgba(0, 123, 255, 0.1);
}

.page-link:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.15);
}

/* Responsive */
@media (max-width: 576px) {
  .pagination {
    gap: 4px;
  }

  .page-link {
    padding: 8px 10px;
    min-width: 40px;
    font-size: 12px;
  }

  .admin-pagination-info {
    font-size: 12px;
  }
}

/* ==================== Fil d'Ariane / navigation entre pages ==================== */
.admin-breadcrumbs {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
}

.admin-breadcrumb-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 50%;
  background: #fff;
  border: 1px solid #e4e1f7;
  color: var(--color-primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  transition: background-color 0.15s ease, transform 0.15s ease;
}

.admin-breadcrumb-back:hover {
  background: var(--color-secondary);
  color: var(--color-primary);
  transform: translateX(-2px);
}

.admin-breadcrumb-trail {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
  min-width: 0;
}

.admin-breadcrumb-item {
  display: flex;
  align-items: center;
  min-width: 0;
}

.admin-breadcrumb-sep {
  display: flex;
  align-items: center;
  color: #b9b4e0;
  font-size: 0.7rem;
}

.admin-breadcrumb-link {
  color: #6c6a89;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  transition: color 0.15s ease;
}

.admin-breadcrumb-link:hover {
  color: var(--color-primary);
  text-decoration: underline;
}

.admin-breadcrumb-current {
  color: #1f1c2c;
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 320px;
}

.admin-breadcrumb-mobile-label {
  display: none;
  color: #1f1c2c;
  font-size: 0.95rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Mobile : la piste complète prend trop de place, on garde la flèche
   retour + le libellé du parent pour une navigation rapide et lisible. */
@media (max-width: 576px) {
  .admin-breadcrumb-trail {
    display: none;
  }

  .admin-breadcrumb-mobile-label {
    display: block;
    min-width: 0;
  }
}