/**
 * Styles pour le Dashboard Admin Brakata
 * Style glassmorphism cohérent avec le site principal
 */

/* ========== VARIABLES ========== */
:root {
  --primary: #00ff88;
  --primary-hover: #00d96f;
  --secondary: #00d9ff;
  --danger: #ff4c4c;
  --warning: #ffa500;
  --success: #00ff88;
  --glass-bg: rgba(255, 255, 255, 0.08);
  --glass-border: rgba(255, 255, 255, 0.28);
  --text: #ffffff;
  --text-muted: rgba(255, 255, 255, 0.7);
  --bg-dark: #0a0a0a;
}

/* ========== RESET & BASE ========== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: var(--bg-dark);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  overflow-y: auto;
}

html {
  overflow-x: hidden;
  overflow-y: auto;
  max-width: 100vw;
}

/* Background image */
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: url("brktabg.jpg") center/cover no-repeat fixed;
  opacity: 0.3;
  z-index: -1;
  will-change: auto;
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
}

/* ========== GLASSMORPHISM ========== */
.glass {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
}

/* Appliquer le blur seulement sur desktop pour éviter les problèmes de performance mobile */
@media (min-width: 769px) {
  .glass {
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
  }
}

/* Sur mobile, augmenter l'opacité du fond pour compenser l'absence de blur */
@media (max-width: 768px) {
  .glass {
    background: rgba(255, 255, 255, 0.12);
    pointer-events: auto;
  }
}

/* ========== LAYOUT ========== */
.admin-container {
  display: flex;
  width: 100%;
  max-width: 100vw;
  position: relative;
  z-index: 0;
}

/* Sidebar */
.sidebar {
  width: 260px;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  max-height: 100vh;
  padding: 2rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  z-index: 1000;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-logo {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 1rem;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border-radius: 12px;
  color: var(--text);
  text-decoration: none;
  transition: all 0.2s ease;
  font-weight: 500;
}

.sidebar-nav a:hover {
  background: rgba(255, 255, 255, 0.05);
  transform: translateX(4px);
}

.sidebar-nav a.active {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #000;
  font-weight: 600;
}

.sidebar-nav svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.sidebar-footer {
  margin-top: auto;
}

.logout-btn {
  width: 100%;
  padding: 0.875rem 1rem;
  border: none;
  border-radius: 12px;
  background: rgba(255, 76, 76, 0.1);
  color: var(--danger);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

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

/* Main Content */
.main-content {
  margin-left: 260px;
  flex: 1;
  padding: 2rem;
  min-height: 100vh;
  max-width: 100%;
  overflow-x: hidden;
}

.page-header {
  margin-bottom: 2rem;
}

.page-header h1 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.page-header p {
  color: var(--text-muted);
}

/* ========== LOGIN PAGE ========== */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
}

.login-box {
  width: 100%;
  max-width: 420px;
  padding: 2.5rem;
}

.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}

.login-logo img {
  width: 100px;
  height: auto;
}

.login-logo h1 {
  margin-top: 1rem;
  font-size: 1.75rem;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--text-muted);
}

.form-group input {
  width: 100%;
  padding: 0.875rem 1rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  color: var(--text);
  font-size: 1rem;
  transition: all 0.2s ease;
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary);
  background: rgba(255, 255, 255, 0.08);
}

.btn {
  padding: 0.875rem 1.5rem;
  border: none;
  border-radius: 12px;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  display: inline-block;
  text-align: center;
}

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #000;
  box-shadow: 0 4px 16px rgba(0, 255, 136, 0.25);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 255, 136, 0.35);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
}

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

.btn-danger:hover {
  background: #ff3333;
}

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

/* ========== STATS CARDS ========== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.stat-card {
  padding: 1.5rem;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
}

.stat-icon.primary {
  background: rgba(0, 255, 136, 0.1);
  color: var(--primary);
}

.stat-icon.secondary {
  background: rgba(0, 217, 255, 0.1);
  color: var(--secondary);
}

.stat-icon.success {
  background: rgba(0, 255, 136, 0.1);
  color: var(--success);
}

.stat-icon.warning {
  background: rgba(255, 165, 0, 0.1);
  color: var(--warning);
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.stat-label {
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* ========== TABLES ========== */
.table-container {
  overflow-x: auto;
  border-radius: 16px;
}

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

thead th {
  padding: 1rem;
  text-align: left;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.05);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

tbody tr {
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  transition: background 0.2s ease;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

tbody td {
  padding: 1rem;
}

/* ========== STATUS BADGES ========== */
.status-badge {
  display: inline-block;
  padding: 0.375rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-pending {
  background: rgba(255, 165, 0, 0.1);
  color: var(--warning);
}

.status-processing {
  background: rgba(0, 217, 255, 0.1);
  color: var(--secondary);
}

.status-shipped {
  background: rgba(0, 217, 255, 0.1);
  color: var(--secondary);
}

.status-delivered {
  background: rgba(0, 255, 136, 0.1);
  color: var(--success);
}

.status-cancelled {
  background: rgba(255, 76, 76, 0.1);
  color: var(--danger);
}

/* ========== FILTERS ========== */
.filters {
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
}

.filter-group {
  flex: 1;
  min-width: 200px;
}

.filter-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 500;
}

.filter-group select,
.filter-group input {
  width: 100%;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.875rem;
}

.filter-group select:focus,
.filter-group input:focus {
  outline: none;
  border-color: var(--primary);
}

/* ========== MODAL ========== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 2rem;
}

/* Appliquer le blur du modal seulement sur desktop */
@media (min-width: 769px) {
  .modal-overlay {
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }
}

/* Sur mobile, rendre le fond plus opaque pour compenser */
@media (max-width: 768px) {
  .modal-overlay {
    background: rgba(0, 0, 0, 0.85);
  }
}

.modal {
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 2rem;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.modal-header h2 {
  font-size: 1.5rem;
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.modal-body {
  margin-bottom: 1.5rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
}

/* ========== TOAST NOTIFICATIONS ========== */
.toast-container {
  position: fixed;
  top: 2rem;
  right: 2rem;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.toast {
  padding: 1rem 1.5rem;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  opacity: 0;
  transform: translateX(100%);
  transition: all 0.3s ease;
  min-width: 300px;
}

.toast.show {
  opacity: 1;
  transform: translateX(0);
}

.toast-success {
  background: linear-gradient(
    135deg,
    rgba(0, 255, 136, 0.9),
    rgba(0, 217, 255, 0.9)
  );
  color: #000;
}

.toast-error {
  background: rgba(255, 76, 76, 0.9);
  color: #fff;
}

.toast-info {
  background: rgba(0, 217, 255, 0.9);
  color: #000;
}

/* ========== CHARTS ========== */
.chart-container {
  padding: 1.5rem;
  margin-bottom: 2rem;
  overflow: hidden;
  height: 400px;
  max-height: 400px;
}

.chart-container canvas {
  max-width: 100% !important;
  width: 100% !important;
  max-height: 300px !important;
  height: 300px !important;
}

canvas {
  max-width: 100%;
  max-height: 300px;
}

/* Masquer les cards mobile sur desktop */
.mobile-cards {
  display: none;
}

/* Bouton de déconnexion mobile - masqué sur desktop */
.mobile-logout {
  display: none;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
  /* Afficher les cards mobile, masquer le tableau */
  .mobile-cards {
    display: flex;
  }

  /* Bottom Navigation au lieu de sidebar */
  .sidebar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60px;
    padding: 0;
    z-index: 1000;
    border-radius: 0;
    border-top: 2px solid rgba(255, 255, 255, 0.5);
    border-left: none;
    border-right: none;
    border-bottom: none;
    /* Background plus opaque et visible sur mobile */
    background: rgba(0, 0, 0, 0.9) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }

  .sidebar-logo {
    display: none;
  }

  .sidebar-nav {
    flex-direction: row;
    padding: 0.5rem;
    gap: 0.25rem;
  }

  .sidebar-nav a {
    flex: 1;
    flex-direction: column;
    padding: 0.5rem 0.25rem;
    font-size: 0.75rem;
    gap: 0.25rem;
    text-align: center;
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.9);
  }

  .sidebar-nav a.active {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #000;
    font-weight: 700;
    box-shadow: 0 2px 10px rgba(0, 255, 136, 0.3);
  }

  .sidebar-nav a:not(.active) {
    background: rgba(255, 255, 255, 0.05);
  }

  .sidebar-nav svg {
    width: 20px;
    height: 20px;
  }

  .sidebar-footer {
    display: none;
  }

  /* Bouton déconnexion mobile dans le header */
  .mobile-logout {
    display: block !important;
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 999;
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 76, 76, 0.1);
    border: 1px solid rgba(255, 76, 76, 0.3);
  }

  .mobile-logout svg {
    width: 20px;
    height: 20px;
    color: var(--danger);
  }

  /* Ajuster le contenu principal */
  .main-content {
    margin-left: 0;
    margin-bottom: 60px;
    padding: 1rem;
    min-height: calc(100vh - 60px);
    overflow-x: hidden;
    background: transparent;
  }

  /* Optimisation pour mobile */
  body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }

  .page-header {
    margin-bottom: 1.5rem;
  }

  .page-header h1 {
    font-size: 1.5rem;
  }

  /* Stats cards */
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .stat-card {
    padding: 1rem;
  }

  .stat-icon {
    width: 40px;
    height: 40px;
    margin-bottom: 0.75rem;
  }

  .stat-icon svg {
    width: 20px;
    height: 20px;
  }

  .stat-value {
    font-size: 1.5rem;
  }

  /* Filtres */
  .filters {
    flex-direction: column;
    padding: 1rem;
    gap: 1rem;
  }

  .filter-group {
    width: 100%;
    min-width: 0;
  }

  .filter-group label {
    font-size: 0.8rem;
  }

  .filter-group select,
  .filter-group input {
    font-size: 0.875rem;
  }

  /* Tables -> Cards sur mobile */
  .table-container {
    overflow: visible;
  }

  table {
    display: none;
  }

  /* Cards pour mobile */
  .mobile-cards {
    display: flex;
    flex-direction: column;
    gap: 1rem;
  }

  .mobile-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }

  .mobile-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  }

  .mobile-card-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
  }

  .mobile-card-row label {
    color: var(--text-muted);
  }

  .mobile-card-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
  }

  .mobile-card-actions .btn {
    flex: 1;
    font-size: 0.875rem;
    padding: 0.625rem 1rem;
  }

  /* Charts */
  .chart-container {
    padding: 1rem;
    height: 300px;
    max-height: 300px;
    overflow: hidden;
  }

  .chart-container h2 {
    font-size: 1.125rem;
    margin-bottom: 1rem;
  }

  .chart-container canvas {
    max-height: 220px !important;
    height: 220px !important;
  }

  /* Modal */
  .modal {
    max-width: calc(100vw - 2rem);
    max-height: calc(100vh - 2rem);
    padding: 1.5rem;
    margin: 1rem;
  }

  .modal-header h2 {
    font-size: 1.25rem;
  }

  .modal-body {
    font-size: 0.875rem;
  }

  .modal-footer {
    flex-direction: column;
    gap: 0.5rem;
  }

  .modal-footer .btn {
    width: 100%;
  }

  /* Form groups dans modal */
  .modal .form-group input,
  .modal .form-group textarea,
  .modal .form-group select {
    font-size: 1rem;
  }

  /* Toast */
  .toast-container {
    top: auto;
    bottom: 90px;
    right: 1rem;
    left: 1rem;
  }

  .toast {
    min-width: 0;
    font-size: 0.875rem;
  }

  /* Login page */
  .login-container {
    padding: 1rem;
  }

  .login-box {
    padding: 1.5rem;
  }

  .login-logo h1 {
    font-size: 1.5rem;
  }

  /* Products grid */
  #products-container {
    grid-template-columns: 1fr !important;
    gap: 1rem;
  }

  /* Buttons */
  .btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8rem;
  }

  /* Status select dans les cartes */
  .status-select {
    font-size: 0.875rem !important;
    padding: 0.5rem !important;
  }
}

/* Très petit écran (< 400px) */
@media (max-width: 400px) {
  .sidebar-nav a {
    font-size: 0.65rem;
    padding: 0.375rem 0.125rem;
  }

  .sidebar-nav svg {
    width: 18px;
    height: 18px;
  }

  .stat-value {
    font-size: 1.25rem;
  }

  .page-header h1 {
    font-size: 1.25rem;
  }

  /* Désactiver le hover sur mobile pour éviter les états collants */
  .sidebar-nav a:hover {
    transform: none;
  }

  .btn:hover {
    transform: none;
  }

  .mobile-card:hover {
    background: rgba(255, 255, 255, 0.05);
  }

  /* Active states pour mobile */
  .btn:active {
    transform: scale(0.98);
  }

  .mobile-card:active {
    background: rgba(255, 255, 255, 0.08);
  }

  .sidebar-nav a:active {
    background: rgba(255, 255, 255, 0.1);
  }
}

/* Touch-friendly sur tous les écrans */
@media (hover: none) and (pointer: coarse) {
  /* Augmenter les zones de clic sur tactile */
  .btn {
    min-height: 44px;
  }

  .sidebar-nav a {
    min-height: 44px;
  }

  select,
  input {
    min-height: 44px;
  }

  /* Désactiver les animations de hover */
  *:hover {
    transition-duration: 0s;
  }
}

/* ========== LOADING SPINNER ========== */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ========== EMPTY STATE ========== */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.empty-state svg {
  width: 64px;
  height: 64px;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
  color: var(--text);
}
