/* Admin Panel Styles - Mouskik's */

:root {
  --primary: #dc2626;
  --primary-dark: #b91c1c;
  --primary-light: #ef4444;
  --secondary: #f97316;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #dc2626;
  --dark: #7f1d1d;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;
  --white: #ffffff;
  
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
  
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--gray-700);
  background-color: var(--gray-50);
}

/* Login Page */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--gray-800) 0%, var(--primary-dark) 100%);
}

.login-container {
  width: 100%;
  max-width: 420px;
  padding: 1rem;
}

.login-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-lg);
}

.login-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.login-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--primary);
}

.login-header p {
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.875rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.login-btn {
  width: 100%;
  margin-top: 0.5rem;
}

.login-footer {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--gray-200);
  text-align: center;
  font-size: 0.875rem;
  color: var(--gray-500);
}

/* Admin Layout */
.admin-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.admin-sidebar {
  width: 260px;
  background: var(--dark);
  color: var(--white);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.admin-sidebar-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--gray-700);
}

.admin-sidebar-header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary-light);
}

.admin-sidebar-header p {
  font-size: 0.75rem;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

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

.admin-nav-title {
  padding: 0.5rem 1.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.admin-nav-list {
  list-style: none;
}

.admin-nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1.5rem;
  color: var(--gray-300);
  text-decoration: none;
  transition: all 0.2s;
  border-left: 3px solid transparent;
}

.admin-nav-item:hover {
  background: var(--gray-800);
  color: var(--white);
}

.admin-nav-item.active {
  background: var(--gray-800);
  color: var(--primary-light);
  border-left-color: var(--primary);
}

.admin-nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.admin-sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--gray-700);
  margin-top: auto;
}

.admin-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--gray-700);
  margin-bottom: 1rem;
}

.admin-user-avatar {
  width: 40px;
  height: 40px;
  background: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}

.admin-user-info {
  flex: 1;
}

.admin-user-name {
  font-weight: 600;
  font-size: 0.875rem;
}

.admin-user-role {
  font-size: 0.75rem;
  color: var(--gray-400);
}

.admin-logout {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--danger);
  font-size: 0.875rem;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  transition: background 0.2s;
}

.admin-logout:hover {
  background: rgba(239, 68, 68, 0.1);
}

/* Main Content */
.admin-main {
  flex: 1;
  margin-left: 260px;
  display: flex;
  flex-direction: column;
}

/* Header */
.admin-header {
  background: var(--white);
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.admin-header-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--gray-800);
}

.admin-header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.admin-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: all 0.2s;
}

.admin-btn-primary {
  background: var(--primary);
  color: var(--white);
}

.admin-btn-primary:hover {
  background: var(--primary-dark);
}

/* Content */
.admin-content {
  flex: 1;
  padding: 1.5rem;
  overflow-y: auto;
}

/* Stats Cards */
.admin-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.admin-stat-card {
  background: var(--white);
  padding: 1.5rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 1rem;
}

.admin-stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.admin-stat-icon.blue {
  background: #dbeafe;
  color: var(--primary);
}

.admin-stat-icon.green {
  background: #dcfce7;
  color: var(--success);
}

.admin-stat-icon.orange {
  background: #ffedd5;
  color: var(--secondary);
}

.admin-stat-icon.red {
  background: #fee2e2;
  color: var(--danger);
}

.admin-stat-content {
  flex: 1;
}

.admin-stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gray-800);
}

.admin-stat-label {
  font-size: 0.875rem;
  color: var(--gray-500);
}

/* Cards */
.admin-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
}

.admin-card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.admin-card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-800);
}

.admin-card-body {
  padding: 1.5rem;
}

/* Tables */
.admin-table-wrapper {
  overflow-x: auto;
}

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

.admin-table th,
.admin-table td {
  padding: 0.875rem 1rem;
  text-align: left;
  font-size: 0.875rem;
}

.admin-table th {
  background: var(--gray-50);
  font-weight: 600;
  color: var(--gray-600);
  border-bottom: 1px solid var(--gray-200);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
}

.admin-table td {
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
}

.admin-table tr:last-child td {
  border-bottom: none;
}

.admin-table tr:hover td {
  background: var(--gray-50);
}

/* Status Badges */
.badge {
  display: inline-flex;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.badge-gray {
  background: var(--gray-100);
  color: var(--gray-600);
}

.badge-blue {
  background: #dbeafe;
  color: #1d4ed8;
}

.badge-green {
  background: #dcfce7;
  color: #15803d;
}

.badge-red {
  background: #fee2e2;
  color: #991b1b;
}

.badge-orange {
  background: #ffedd5;
  color: #9a3412;
}

/* Forms */
.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  margin-bottom: 0.375rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-700);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 0.625rem 0.875rem;
  font-size: 0.875rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-md);
  transition: border-color 0.2s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-textarea {
  min-height: 100px;
  resize: vertical;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.admin-inline-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(160px, 220px) auto;
  gap: 1rem;
  align-items: end;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: all 0.2s;
  border: none;
  cursor: pointer;
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
}

.btn-lg {
  padding: 0.875rem 1.5rem;
  font-size: 1rem;
}

.btn-primary {
  background: var(--primary);
  color: var(--white);
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--gray-200);
  color: var(--gray-700);
}

.btn-secondary:hover {
  background: var(--gray-300);
}

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

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

.btn-outline {
  background: transparent;
  border: 1px solid var(--gray-300);
  color: var(--gray-600);
}

.btn-outline:hover {
  background: var(--gray-50);
}

/* Alerts */
.alert {
  padding: 0.875rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.alert-error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.alert-success {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.alert-warning {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  max-width: 600px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-size: 1.125rem;
  font-weight: 600;
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  color: var(--gray-500);
  transition: all 0.2s;
}

.modal-close:hover {
  background: var(--gray-100);
  color: var(--gray-700);
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--gray-200);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Responsive */
@media (max-width: 1024px) {
  .admin-stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Mobile Menu Toggle Button - Hidden by default (desktop) */
.mobile-menu-toggle {
  display: none !important;
  background: none;
  border: none;
  color: var(--gray-600);
  cursor: pointer;
  padding: 0.5rem;
  margin-right: 0.75rem;
  border-radius: var(--radius-sm);
  transition: background 0.2s;
}

.mobile-menu-toggle:hover {
  background: var(--gray-100);
}

/* Sidebar Overlay for Mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;
  opacity: 0;
  transition: opacity 0.3s;
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

/* Empêcher le scroll quand le menu est ouvert */
body.sidebar-open {
  overflow: hidden;
  touch-action: none;
}

/* Amélioration des tables sur petits écrans */
@media (max-width: 768px) {
  body.sidebar-open .admin-main {
    pointer-events: none;
  }
}

/* Responsive Tables */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-md);
}

.table-responsive table {
  min-width: 640px;
  margin-bottom: 0;
}

/* Mobile-specific styles */
@media (max-width: 768px) {
  .mobile-menu-toggle {
    display: flex !important;
    align-items: center;
    justify-content: center;
    visibility: visible !important;
  }

  .admin-sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    width: 280px;
    box-shadow: none;
  }
  
  .admin-sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }
  
  .admin-main {
    margin-left: 0;
  }
  
  .admin-header {
    padding: 0.875rem 1rem;
    position: sticky;
    top: 0;
    z-index: 50;
  }

  .admin-header-title {
    font-size: 1.1rem;
  }
  
  .admin-stats {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  
  .form-row {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .admin-card-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    padding: 1rem;
  }

  .admin-card-header .admin-btn,
  .admin-card-header button {
    width: 100%;
    justify-content: center;
  }

  .admin-card-title {
    font-size: 1.1rem;
  }

  .admin-inline-form {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .admin-content {
    padding: 0.75rem;
  }

  .admin-card-body {
    padding: 0.75rem;
  }

  /* Modals - plein écran sur mobile */
  .modal-overlay {
    padding: 0;
    align-items: flex-end;
  }

  .modal {
    width: 100%;
    max-width: 100%;
    max-height: 95vh;
    height: auto;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    margin: 0;
    animation: slideUp 0.3s ease;
  }

  @keyframes slideUp {
    from {
      transform: translateY(100%);
    }
    to {
      transform: translateY(0);
    }
  }

  .modal-header {
    padding: 1rem;
    position: sticky;
    top: 0;
    background: white;
    z-index: 10;
    border-bottom: 1px solid var(--gray-200);
  }

  .modal-body {
    padding: 1rem;
    overflow-y: auto;
    max-height: calc(95vh - 140px);
  }

  .modal-footer {
    padding: 1rem;
    flex-direction: column;
    gap: 0.5rem;
    position: sticky;
    bottom: 0;
    background: white;
    border-top: 1px solid var(--gray-200);
  }

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

  .btn {
    width: 100%;
    justify-content: center;
    padding: 0.75rem 1rem;
    min-height: 44px;
  }

  .btn-sm {
    padding: 0.5rem 0.75rem;
    min-height: 36px;
  }

  /* Line items responsive */
  .line-item {
    grid-template-columns: 1fr;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    margin-bottom: 0.75rem;
  }

  .line-item input,
  .line-item select {
    width: 100%;
    min-height: 44px;
  }

  .line-item .btn-remove {
    width: 100%;
    height: 44px;
  }

  /* Total section */
  .total-section {
    flex-direction: column;
    gap: 0.75rem;
    align-items: stretch;
    padding: 1rem;
  }

  .total-item {
    text-align: left;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--gray-200);
    padding: 0.5rem 0;
  }

  .total-item:last-child {
    border-bottom: none;
  }

  /* Tables - style carte sur mobile */
  .admin-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -0.75rem;
    padding: 0 0.75rem;
  }

  .admin-table {
    min-width: 700px;
  }

  .admin-table th,
  .admin-table td {
    padding: 0.75rem 0.5rem;
    white-space: nowrap;
  }

  .admin-table td:last-child {
    display: flex;
    gap: 0.5rem;
  }

  .admin-table .btn-sm {
    padding: 0.375rem 0.625rem;
    font-size: 0.75rem;
  }

  /* Form inputs touch-friendly */
  input[type="text"],
  input[type="number"],
  input[type="email"],
  input[type="date"],
  input[type="password"],
  textarea,
  select {
    min-height: 44px;
    font-size: 16px; /* Prevent zoom on iOS */
  }

  /* Calendar responsive */
  .calendar-grid {
    gap: 1px;
  }

  .calendar-day {
    min-height: 50px;
    padding: 0.25rem;
  }

  .calendar-header {
    padding: 0.5rem 0.25rem;
    font-size: 0.7rem;
  }

  /* Alerts */
  .alert {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    margin: 0.75rem !important;
  }
}

/* Very small screens */
@media (max-width: 480px) {
  .admin-sidebar {
    width: 100%;
  }

  .admin-sidebar-header {
    padding: 1rem;
  }

  .admin-nav-item {
    padding: 1rem;
    font-size: 1rem;
  }

  .admin-nav-icon svg {
    width: 24px;
    height: 24px;
  }

  .admin-content {
    padding: 0.5rem;
  }

  .admin-card {
    border-radius: var(--radius-md);
    margin-bottom: 0.75rem;
  }

  .admin-card-header {
    padding: 0.875rem;
  }

  .admin-card-body {
    padding: 0.75rem;
  }

  h1, h2, .admin-header-title {
    font-size: 1.1rem;
  }

  .admin-stats-card {
    padding: 1rem;
  }

  .admin-stats-value {
    font-size: 1.5rem;
  }

  .admin-stats-label {
    font-size: 0.75rem;
  }

  /* Touch targets plus grands */
  .admin-nav-item,
  .btn,
  .admin-btn,
  .admin-logout,
  button[type="submit"],
  input[type="submit"] {
    min-height: 44px;
  }

  /* Formulaires */
  .form-group {
    margin-bottom: 1rem;
  }

  .form-label {
    font-size: 0.875rem;
    margin-bottom: 0.375rem;
  }

  /* Amélioration de l'affichage des lignes dans les modals */
  .line-item {
    padding: 0.875rem;
  }

  /* Total section plus compacte */
  .total-section {
    padding: 0.75rem;
  }

  .total-value {
    font-size: 1.1rem;
  }

  .total-value.large {
    font-size: 1.25rem;
  }

  /* Tables encore plus compactes */
  .admin-table th,
  .admin-table td {
    padding: 0.625rem 0.375rem;
    font-size: 0.8rem;
  }

  .admin-table .btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.7rem;
  }

  /* Modals */
  .modal-header h3 {
    font-size: 1rem;
  }

  .modal-body h4 {
    font-size: 0.9rem;
  }

  /* Header sticky amélioré */
  .admin-header {
    padding: 0.75rem;
    min-height: 56px;
  }

  .mobile-menu-toggle {
    padding: 0.5rem;
    margin-right: 0.5rem;
  }

  .mobile-menu-toggle svg {
    width: 22px;
    height: 22px;
  }
}

/* Devis/Facture Lines */
.lines-container {
  margin-bottom: 1rem;
}

.line-item {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr auto;
  gap: 0.75rem;
  align-items: end;
  padding: 0.75rem;
  background: var(--gray-50);
  border-radius: var(--radius-md);
  margin-bottom: 0.5rem;
}

.line-item input {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
}

.line-item .btn-remove {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--danger);
  color: var(--white);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.total-section {
  display: flex;
  justify-content: flex-end;
  gap: 2rem;
  padding: 1rem;
  background: var(--gray-50);
  border-radius: var(--radius-md);
  margin-top: 1rem;
}

.total-item {
  text-align: right;
}

.total-label {
  font-size: 0.875rem;
  color: var(--gray-500);
}

.total-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--gray-800);
}

.total-value.large {
  font-size: 1.5rem;
  color: var(--primary);
}

/* Calendar/Agenda */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--gray-200);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.calendar-header {
  background: var(--gray-100);
  padding: 0.75rem;
  text-align: center;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--gray-600);
}

.calendar-day {
  background: var(--white);
  min-height: 100px;
  padding: 0.5rem;
}

.calendar-day-number {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 0.5rem;
}

.calendar-event {
  padding: 0.25rem 0.5rem;
  background: var(--primary);
  color: var(--white);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  margin-bottom: 0.25rem;
  cursor: pointer;
}

.calendar-event:hover {
  background: var(--primary-dark);
}

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