/**
 * public/css/app.css
 * Styles principaux de l'application MaBelleCave
 * Extrait de header.php et footer.php pour optimiser le cache navigateur
 */

/* === Variables CSS === */
:root {
  --sidebar-width: 280px;
  --sidebar-bg: #2c3e50;
  --sidebar-text: #ecf0f1;
  --sidebar-hover: #34495e;
  --accent-color: #e74c3c;
  --success-color: #27ae60;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* === Sidebar Styles === */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: var(--sidebar-width);
  background: linear-gradient(180deg, var(--sidebar-bg) 0%, #34495e 100%);
  color: var(--sidebar-text);
  overflow-y: auto;
  transition: all 0.3s ease;
  z-index: 1000;
  box-shadow: 4px 0 10px rgba(0,0,0,0.1);
}

.sidebar.collapsed {
  width: 70px;
}

.sidebar-header {
  padding: 1.5rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  background: rgba(0,0,0,0.1);
}

.sidebar-brand {
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 1.2rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sidebar-brand:hover {
  color: #fff;
}

.sidebar-brand .fa-wine-bottle {
  color: var(--accent-color);
  font-size: 1.4rem;
}

.sidebar-nav {
  padding: 1rem 0;
}

.nav-section {
  margin-bottom: 2rem;
}

.nav-section-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #bdc3c7;
  padding: 0 1rem;
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.sidebar.collapsed .nav-section-title {
  display: none;
}

.nav-section-subtitle {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #95a5a6;
  padding: 0.5rem 1rem 0.25rem;
  margin-top: 0.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  font-weight: 600;
}

.sidebar.collapsed .nav-section-subtitle {
  display: none;
}

.nav-item {
  margin-bottom: 0.25rem;
}

.nav-link {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  color: var(--sidebar-text);
  text-decoration: none;
  transition: all 0.3s ease;
  border-left: 3px solid transparent;
  position: relative;
  overflow: hidden;
}

.nav-link:hover,
.nav-link.active {
  background: var(--sidebar-hover);
  color: #fff;
  border-left-color: var(--accent-color);
}

.nav-link i {
  width: 20px;
  margin-right: 0.75rem;
  text-align: center;
  font-size: 1.1rem;
}

.sidebar.collapsed .nav-link {
  justify-content: center;
  padding: 0.75rem;
}

.sidebar.collapsed .nav-link span {
  display: none;
}

.sidebar.collapsed .nav-link i {
  margin-right: 0;
}

/* === Dropdown Styles === */
.nav-dropdown {
  background: rgba(0,0,0,0.1);
}

.nav-dropdown .nav-link {
  padding-left: 2.5rem;
  font-size: 0.9rem;
  border-left: none;
}

.nav-dropdown .nav-link:hover {
  background: rgba(255,255,255,0.1);
  border-left: 3px solid var(--success-color);
}

/* === Main Content === */
.main-content {
  margin-left: var(--sidebar-width);
  transition: margin-left 0.3s ease;
  min-height: 100vh;
  background: #f8f9fa;
  position: relative;
  z-index: 1;
}

.sidebar.collapsed + .main-content {
  margin-left: 70px;
}

/* === Top Header === */
.top-header {
  background: #fff;
  padding: 1rem 2rem;
  border-bottom: 1px solid #dee2e6;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  position: relative;
  z-index: 999;
}

/* === Bouton toggle sidebar === */
.sidebar-toggle {
  background: none !important;
  border: none !important;
  font-size: 1.2rem;
  color: #6c757d;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 0.375rem;
  transition: all 0.3s ease;
}

.sidebar-toggle:hover {
  background: #e9ecef !important;
  color: #495057;
}

.sidebar-toggle:focus {
  outline: 2px solid #0d6efd;
  outline-offset: 2px;
}

/* === User info === */
.user-info {
  display: flex;
  align-items: center;
  gap: 1rem;
  position: relative;
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(45deg, var(--accent-color), #c0392b);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 1.1rem;
}

.user-name {
  color: #495057;
  font-weight: 500;
}

/* === User Dropdown === */
.user-dropdown {
  position: relative;
}

.user-dropdown-toggle {
  display: flex !important;
  align-items: center;
  background: none !important;
  border: none !important;
  padding: 0.5rem !important;
  border-radius: 0.5rem;
  cursor: pointer !important;
  transition: all 0.3s ease;
  text-decoration: none !important;
}

.user-dropdown-toggle:hover,
.user-dropdown-toggle:focus,
.user-dropdown-toggle.active {
  background: #f8f9fa !important;
  color: #2c3e50 !important;
  text-decoration: none !important;
}

.user-dropdown-toggle::after {
  content: '\f107';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  margin-left: 0.5rem;
  font-size: 0.8rem;
  transition: transform 0.3s ease;
}

.user-dropdown-toggle.active::after {
  transform: rotate(180deg);
}

.user-dropdown-menu {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  left: auto;
  background: white;
  border: 1px solid #dee2e6;
  border-radius: 0.75rem;
  box-shadow: 0 0.5rem 1rem rgba(0,0,0,0.15);
  min-width: 220px;
  z-index: 1070;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.3s ease;
  padding: 0.5rem 0;
}

.user-dropdown-menu.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.user-dropdown-item {
  display: block;
  padding: 0.75rem 1.25rem;
  color: #495057;
  text-decoration: none;
  transition: all 0.3s ease;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-size: 0.9rem;
}

.user-dropdown-item:hover,
.user-dropdown-item:focus {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  text-decoration: none;
}

.user-dropdown-item.text-danger:hover,
.user-dropdown-item.text-danger:focus {
  background: linear-gradient(135deg, #ff6b6b 0%, #ee5a52 100%);
  color: white;
}

.user-dropdown-divider {
  height: 0;
  margin: 0.5rem 0;
  overflow: hidden;
  border-top: 1px solid #dee2e6;
}

/* ═══════════════════════════════════════════════════════════════
   DROPDOWN UTILISATEUR PREMIUM - Style Glassmorphism
   ═══════════════════════════════════════════════════════════════ */
.user-dropdown-toggle-premium {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: none;
  border: none;
  padding: 0.4rem;
  border-radius: 2rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.user-dropdown-toggle-premium:hover {
  background: rgba(114, 47, 55, 0.08);
}

.user-admin-badge {
  background: linear-gradient(135deg, #722F37 0%, #8B0000 100%);
  color: white;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.user-avatar-premium {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #722F37 0%, #8B0000 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.85rem;
  position: relative;
  box-shadow: 0 2px 8px rgba(114, 47, 55, 0.3);
  transition: all 0.3s ease;
}

.user-dropdown-toggle-premium:hover .user-avatar-premium {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(114, 47, 55, 0.4);
}

.user-status-dot {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 10px;
  height: 10px;
  background: #10b981;
  border-radius: 50%;
  border: 2px solid white;
  animation: pulse-status 2s infinite;
}

@keyframes pulse-status {
  0%, 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5); }
  50% { box-shadow: 0 0 0 4px rgba(16, 185, 129, 0); }
}

/* Menu dropdown avec glassmorphism - CACHÉ par défaut */
.user-dropdown-menu-premium {
  position: absolute !important;
  top: calc(100% + 0.75rem) !important;
  right: 0 !important;
  width: 280px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(114, 47, 55, 0.1);
  border-radius: 1rem;
  box-shadow: 0 20px 50px rgba(114, 47, 55, 0.2),
              0 0 0 1px rgba(255, 255, 255, 0.5) inset;
  z-index: 1070 !important;
  /* IMPORTANT: Caché par défaut */
  display: none !important;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px) scale(0.95);
  transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

/* Visible uniquement avec la classe .show */
.user-dropdown-menu-premium.show {
  display: block !important;
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Header du dropdown */
.user-dropdown-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  background: linear-gradient(135deg, rgba(114, 47, 55, 0.08) 0%, rgba(139, 0, 0, 0.05) 100%);
  border-bottom: 1px solid rgba(114, 47, 55, 0.1);
}

.user-dropdown-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #722F37 0%, #8B0000 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(114, 47, 55, 0.3);
}

.user-dropdown-info {
  flex: 1;
  min-width: 0;
}

.user-dropdown-info strong {
  display: block;
  font-size: 0.95rem;
  color: #1f2937;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-dropdown-info > span {
  display: block;
  font-size: 0.75rem;
  color: #6b7280;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.15rem 0.4rem;
  border-radius: 0.25rem;
  margin-top: 0.25rem;
}

.user-role-badge.admin {
  background: rgba(114, 47, 55, 0.15);
  color: #722F37;
}

.user-role-badge.user {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
}

/* Mini stats */
.user-dropdown-stats {
  display: flex;
  justify-content: space-around;
  padding: 0.75rem;
  background: rgba(114, 47, 55, 0.03);
  border-bottom: 1px solid rgba(114, 47, 55, 0.08);
}

.user-stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}

.user-stat-item i {
  font-size: 0.8rem;
  color: #722F37;
}

.user-stat-value {
  font-size: 1rem;
  font-weight: 700;
  color: #1f2937;
}

.user-stat-label {
  font-size: 0.65rem;
  color: #9ca3af;
  text-transform: uppercase;
}

/* Menu items */
.user-dropdown-menu-items {
  padding: 0.5rem;
}

.user-dropdown-item-premium {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  color: #374151;
  text-decoration: none;
  border-radius: 0.5rem;
  transition: all 0.2s ease;
  font-size: 0.9rem;
}

.user-dropdown-item-premium:hover {
  background: linear-gradient(135deg, rgba(114, 47, 55, 0.1) 0%, rgba(139, 0, 0, 0.08) 100%);
  color: #722F37;
  transform: translateX(4px);
}

.user-dropdown-item-premium i {
  width: 20px;
  text-align: center;
  font-size: 0.85rem;
  color: #6b7280;
  transition: color 0.2s ease;
}

.user-dropdown-item-premium:hover i {
  color: #722F37;
}

/* Footer déconnexion */
.user-dropdown-footer {
  padding: 0.5rem;
  border-top: 1px solid rgba(114, 47, 55, 0.08);
  background: rgba(239, 68, 68, 0.03);
}

.user-dropdown-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem;
  color: #ef4444;
  text-decoration: none;
  border-radius: 0.5rem;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.2s ease;
}

.user-dropdown-logout:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #dc2626;
}

.user-dropdown-logout i {
  font-size: 0.9rem;
}

/* Responsive mobile */
@media (max-width: 768px) {
  .user-admin-badge {
    display: none;
  }

  .user-dropdown-menu-premium {
    width: 260px;
    right: -0.5rem;
  }
}

.content-area {
  padding: 2rem;
  position: relative;
  z-index: 1;
}

/* === Mobile Responsiveness === */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    z-index: 1000;
  }

  .sidebar.show {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
  }

  .sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    display: none;
  }

  .sidebar-overlay.show {
    display: block;
  }

  .user-info .user-name {
    display: none;
  }
}

/* === Badges et indicateurs === */
.nav-badge {
  background: var(--accent-color);
  color: white;
  padding: 0.25rem 0.5rem;
  border-radius: 10px;
  font-size: 0.75rem;
  margin-left: auto;
}

/* === Animations nav-link === */
.nav-link::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
  transition: left 0.6s;
}

.nav-link:hover::before {
  left: 100%;
}

.color-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  vertical-align: middle;
  margin-right: 6px;
  border: 1px solid #ccc;
}

/* ========================================
   HIÉRARCHIE Z-INDEX CRITIQUE
   ======================================== */

.main-content {
  z-index: 1 !important;
  position: relative !important;
}

.content-area {
  z-index: 1 !important;
  position: relative !important;
}

.top-header {
  z-index: 999 !important;
  position: relative !important;
}

.sidebar {
  z-index: 1000 !important;
  position: fixed !important;
}

.user-dropdown-menu,
.dropdown-menu {
  z-index: 1070 !important;
  position: absolute !important;
}

.modal-backdrop {
  z-index: 1050 !important;
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
}

.modal {
  z-index: 1055 !important;
  position: fixed !important;
}

.modal.show {
  display: block !important;
}

.modal-dialog {
  z-index: 1060 !important;
  position: relative !important;
}

.toast-container {
  z-index: 2000 !important;
  position: fixed !important;
}

.modal-content {
  position: relative !important;
  z-index: 1 !important;
  pointer-events: auto !important;
}

.modal-header,
.modal-body,
.modal-footer {
  pointer-events: auto !important;
}

/* === Transitions fluides === */
.nav-link,
.btn,
.card,
.form-control,
.form-select {
  transition: all 0.3s ease;
}

/* === Amélioration des boutons === */
.btn {
  border-radius: 0.5rem;
  font-weight: 500;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

/* === Amélioration des cartes === */
.card {
  border: none;
  border-radius: 1rem;
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.card-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 1rem 1rem 0 0 !important;
  font-weight: 600;
}

/* === Amélioration des tableaux === */
.table {
  border-radius: 0.5rem;
  overflow: hidden;
}

.table thead th {
  background: #f8f9fa;
  border: none;
  font-weight: 600;
  color: #495057;
}

.table tbody tr:hover {
  background: rgba(103, 126, 234, 0.05);
}

/* === Amélioration des formulaires === */
.form-control, .form-select {
  border-radius: 0.5rem;
  border: 2px solid #e9ecef;
}

.form-control:focus, .form-select:focus {
  border-color: #667eea;
  box-shadow: 0 0 0 0.2rem rgba(103, 126, 234, 0.25);
}

/* === Amélioration des alertes === */
.alert {
  border-radius: 0.75rem;
  border: none;
}

/* === Fix dropdown utilisateur === */
.user-info .dropdown-menu {
  display: block;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.3s ease;
  pointer-events: none;
}

.user-info .dropdown-menu.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

.user-info .dropdown:hover .dropdown-menu {
  display: block;
}

/* === Loading spinner === */
.spinner-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1070;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.spinner-overlay.show {
  opacity: 1;
  visibility: visible;
}

/* === Responsive === */
@media (max-width: 576px) {
  .content-area {
    padding: 1rem;
  }

  .top-header {
    padding: 0.75rem 1rem;
  }

  .user-info .user-name {
    display: none;
  }
}
