/* ==========================================================================
   SommAI by Sytelis - Composants UI Spécialisés (Thème Blanc, Gris & Vert Fluo)
   Tableau Éditable, Drag & Drop Factures, Popups Dynamiques, 2FA, Toasts
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Zone de Dépôt / Drag & Drop Factures (Étape A)
   -------------------------------------------------------------------------- */
.dropzone-container {
  background: var(--bg-surface);
  border: 2px dashed var(--border-medium);
  border-radius: var(--radius-xl);
  padding: 3.5rem 2rem;
  text-align: center;
  cursor: pointer;
  position: relative;
  transition: all var(--transition-normal);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.dropzone-container:hover, .dropzone-container.drag-over {
  border-color: var(--fluo-brand);
  background: var(--fluo-subtle);
  box-shadow: 0 4px 20px var(--fluo-glow-subtle);
}

.dropzone-container.drag-over {
  transform: scale(1.01);
}

.dropzone-icon-wrapper {
  width: 76px;
  height: 76px;
  margin: 0 auto 1.25rem;
  background: var(--fluo-subtle);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(0, 200, 83, 0.3);
  color: var(--fluo-dark);
  transition: all var(--transition-fast);
}

.dropzone-container:hover .dropzone-icon-wrapper {
  transform: translateY(-4px);
  box-shadow: 0 0 16px var(--fluo-glow);
  background: #FFFFFF;
}

.dropzone-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-heading);
  margin-bottom: 0.5rem;
}

.dropzone-subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  max-width: 500px;
  margin: 0 auto 1.5rem;
}

.dropzone-badges {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.format-badge {
  padding: 0.35rem 0.85rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-body);
}

/* État de chargement IA */
.ai-processing-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
  padding: 2rem;
}

.ai-pulse-scanner {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--fluo-glow) 0%, transparent 70%);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  margin-bottom: 1.5rem;
}

.ai-pulse-scanner::before, .ai-pulse-scanner::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  border: 2px solid var(--fluo-brand);
  animation: pulseRipple 2s cubic-bezier(0.1, 0.8, 0.3, 1) infinite;
}

.ai-pulse-scanner::after {
  animation-delay: 1s;
}

@keyframes pulseRipple {
  0% { width: 40px; height: 40px; opacity: 1; }
  100% { width: 140px; height: 140px; opacity: 0; }
}

.processing-step-text {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-heading);
  margin-bottom: 0.5rem;
}

.processing-sub-text {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* --------------------------------------------------------------------------
   2. Tableau HTML Éditable Interactif (Étape D)
   -------------------------------------------------------------------------- */
.editable-table-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.table-toolbar {
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-subtle);
}

.table-actions-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.table-actions-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.search-input-wrapper {
  position: relative;
  min-width: 260px;
}

.search-input-wrapper input {
  padding-left: 2.4rem;
  height: 38px;
  font-size: 0.88rem;
  background: #FFFFFF;
}

.search-input-wrapper .search-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
  max-height: 700px;
  background: #FFFFFF;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  scrollbar-width: thin;
  scrollbar-color: #00C853 #E2E8F0;
}

.table-responsive::-webkit-scrollbar {
  height: 10px;
  width: 8px;
}

.table-responsive::-webkit-scrollbar-track {
  background: #F1F5F9;
  border-radius: 6px;
}

.table-responsive::-webkit-scrollbar-thumb {
  background: #00C853;
  border-radius: 6px;
  border: 2px solid #F1F5F9;
}

.table-responsive::-webkit-scrollbar-thumb:hover {
  background: #00A344;
}

.sommai-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.9rem;
  text-align: left;
}

/* Seul le grand tableau de facturation (16 colonnes) nécessite un défilement horizontal large */
#invoice-preview-card .sommai-table {
  min-width: 1700px;
}

.sommai-table thead th {
  position: sticky;
  top: 0;
  z-index: 5;
  background: #0F172A;
  color: #FFFFFF;
  font-family: var(--font-heading);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 0.95rem 0.85rem;
  border-bottom: 2px solid #00E676;
  white-space: nowrap;
}

.sommai-table tbody tr {
  transition: background-color var(--transition-fast);
}

.sommai-table tbody tr:nth-child(even) {
  background: #F8FAFC;
}

.sommai-table tbody tr:hover {
  background: #F0FDF4;
}

.sommai-table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
  color: var(--text-heading);
}

/* Cellules éditables */
.cell-input {
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-heading);
  padding: 0.4rem 0.55rem;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition-fast);
}

.cell-input:hover {
  background: #FFFFFF;
  border-color: var(--border-medium);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.cell-input:focus {
  outline: none;
  background: #FFFFFF;
  border-color: var(--fluo-brand);
  box-shadow: 0 0 0 3px var(--fluo-glow-subtle);
  color: #000000;
  font-weight: 700;
}

/* Désactivation des flèches par défaut de type number qui cachent le texte */
.cell-input::-webkit-outer-spin-button,
.cell-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.cell-input[type=number] {
  -moz-appearance: textfield;
  appearance: textfield;
}

.cell-input.num-cell {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  padding: 0.4rem 0.5rem;
}

.cell-input.qty-input-box {
  text-align: center;
  font-weight: 800;
  font-size: 1rem;
  color: #0F172A;
  background: #F1F5F9;
  border: 1.5px solid #CBD5E1;
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.2rem;
  width: 65px;
  min-width: 65px;
  display: block;
  margin: 0 auto;
}

.cell-input.qty-input-box:focus {
  background: #FFFFFF;
  border-color: var(--fluo-brand);
  box-shadow: 0 0 0 3px var(--fluo-glow-subtle);
}

.cell-input.price-fluo {
  color: #059669;
  font-weight: 800;
}

.category-select-pill {
  appearance: none;
  -webkit-appearance: none;
  background: #FFFFFF;
  border: 1px solid var(--border-medium);
  color: var(--text-heading);
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.35rem 1.6rem 0.35rem 0.75rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.category-select-pill:hover, .category-select-pill:focus {
  border-color: var(--fluo-brand);
  outline: none;
}

/* Badges de Marge et Rentabilité */
.margin-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.55rem;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.margin-badge.excellent {
  background: #ECFDF5;
  color: #047857;
  border: 1px solid rgba(5, 150, 105, 0.3);
}

.margin-badge.good {
  background: #FFFBEB;
  color: #B45309;
  border: 1px solid rgba(217, 119, 6, 0.3);
}

.margin-badge.low {
  background: #FEF2F2;
  color: #B91C1C;
  border: 1px solid rgba(220, 38, 38, 0.3);
}

/* Boutons d'action de ligne */
.row-actions-btn-group {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.icon-action-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-body);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.icon-action-btn:hover {
  background: #FFFFFF;
  color: var(--text-heading);
  border-color: var(--border-dark);
  box-shadow: var(--shadow-sm);
}

.icon-action-btn.btn-trash:hover {
  background: #FEF2F2;
  color: var(--status-danger);
  border-color: rgba(239, 68, 68, 0.4);
}

/* --------------------------------------------------------------------------
   3. Système de Modales / Popups Personnalisées
   -------------------------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-normal);
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal-container {
  background: #FFFFFF;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  max-width: 600px;
  width: 100%;
  box-shadow: 0 25px 60px -12px rgba(15, 23, 42, 0.25);
  position: relative;
  transform: scale(0.94) translateY(10px);
  transition: all var(--transition-smooth);
  overflow: hidden;
}

.modal-overlay.open .modal-container {
  transform: scale(1) translateY(0);
}

.modal-header {
  padding: 1.5rem 1.75rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #FFFFFF;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-heading);
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.modal-close-btn {
  background: var(--bg-subtle);
  border: none;
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.modal-close-btn:hover {
  background: var(--border-medium);
  color: var(--text-heading);
}

.modal-body {
  padding: 1.75rem;
  max-height: calc(85vh - 140px);
  overflow-y: auto;
  background: #FFFFFF;
}

.modal-footer {
  padding: 1.25rem 1.75rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.85rem;
  background: var(--bg-subtle);
}

/* --------------------------------------------------------------------------
   4. Double Authentification (2FA / TOTP) UI
   -------------------------------------------------------------------------- */
.totp-qr-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 1.25rem auto 1.75rem;
  padding: 1rem;
  background: #FFFFFF;
  border-radius: var(--radius-lg);
  border: 4px solid #F1F5F9;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  width: fit-content;
}

.totp-qr-wrapper svg {
  display: block;
  border-radius: 4px;
}

.totp-secret-key-box {
  background: var(--bg-subtle);
  border: 1px dashed var(--border-medium);
  padding: 0.65rem 1rem;
  border-radius: var(--radius-sm);
  font-family: 'Courier New', monospace;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--fluo-dark);
  text-align: center;
  margin-bottom: 1.5rem;
  word-break: break-all;
  user-select: all;
}

.otp-pin-input-group {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  margin: 1.25rem 0;
}

.otp-digit {
  width: 48px;
  height: 58px;
  text-align: center;
  font-family: var(--font-heading);
  font-size: 1.8rem;
  font-weight: 800;
  color: #0F172A;
  background: #FFFFFF;
  border: 2px solid var(--border-medium);
  border-radius: var(--radius-md);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: all var(--transition-fast);
}

.otp-digit:focus {
  outline: none;
  border-color: var(--fluo-brand);
  box-shadow: 0 0 0 3px var(--fluo-glow-subtle);
  background: #FFFFFF;
}

.backup-codes-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  background: var(--bg-subtle);
  padding: 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  margin: 1rem 0;
}

.backup-code-item {
  font-family: monospace;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--text-heading);
  padding: 0.45rem 0.5rem;
  text-align: center;
  background: #FFFFFF;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

/* --------------------------------------------------------------------------
   5. Système de Notifications Toast
   -------------------------------------------------------------------------- */
#toast-container {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  min-width: 320px;
  max-width: 440px;
  background: #FFFFFF;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  box-shadow: 0 10px 30px -5px rgba(15, 23, 42, 0.15);
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  color: var(--text-heading);
  transform: translateX(100%);
  opacity: 0;
  transition: all var(--transition-smooth);
  position: relative;
  overflow: hidden;
}

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

.toast::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  width: 4px;
  height: 100%;
}

.toast.success::before {
  background: var(--fluo-brand);
}

.toast.error::before {
  background: var(--status-danger);
}

.toast.warning::before {
  background: var(--status-warning);
}

.toast-icon {
  font-size: 1.25rem;
  font-weight: bold;
  flex-shrink: 0;
}

.toast.success .toast-icon { color: var(--fluo-dark); }
.toast.error .toast-icon { color: var(--status-danger); }
.toast.warning .toast-icon { color: var(--status-warning); }

.toast-content {
  flex: 1;
}

.toast-title {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 800;
  margin-bottom: 0.2rem;
  color: var(--text-heading);
}

.toast-message {
  font-size: 0.85rem;
  color: var(--text-body);
  line-height: 1.4;
}
