/**
 * Styles pour le système d'invitations VDI
 *
 * @package VDI_Custom
 * @since 1.5.0
 */

/* ==========================================================================
   Variables et base
   ========================================================================== */

.vdi-clients-invitations-wrapper,
.vdi-client-detail-wrapper {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

/* ==========================================================================
   Formulaire invitation nouveau client
   ========================================================================== */

.vdi-invite-new-client {
  margin: 2rem 0;
  padding: 1.5rem;
  background: #f8f9fa;
  border: 1px solid #ddd;
  border-radius: 6px;
}

.vdi-invite-new-client h3 {
  margin: 0 0 1rem;
  color: #333;
  font-size: 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.vdi-invite-new-client h3 .dashicons {
  font-size: 1.2rem;
  color: #2271b1;
}

.vdi-invite-form-row {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.vdi-invite-email-input {
  flex: 1;
  padding: 0.65rem 1rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 1rem;
  background: white;
  transition: border-color 0.2s ease;
}

.vdi-invite-email-input:focus {
  outline: none;
  border-color: #2271b1;
  box-shadow: 0 0 0 1px #2271b1;
}

.vdi-btn-invite-new {
  padding: 0.65rem 1.5rem;
  font-size: 1rem;
  font-weight: 500;
  background: #2271b1;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
}

.vdi-btn-invite-new:hover {
  background: #135e96;
}

.vdi-btn-invite-new .dashicons {
  font-size: 1.2rem;
}

.vdi-btn-invite-new:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Honeypot - caché de manière robuste */
#vdi-website {
  position: absolute !important;
  left: -9999px !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* ==========================================================================
   Statistiques Rate Limiting
   ========================================================================== */

.vdi-rate-limit-info {
  margin-bottom: 2rem;
}

.vdi-rate-limit-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
  padding: 1.5rem;
  background: #f8f9fa;
  border-radius: 8px;
  border: 1px solid #e0e0e0;
}

.vdi-stat-box {
  text-align: center;
  padding: 1rem;
  background: white;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.vdi-stat-box strong {
  display: block;
  font-size: 0.85rem;
  color: #666;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.vdi-stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: #2271b1;
  margin: 0.5rem 0;
}

.vdi-stat-box small {
  display: block;
  color: #666;
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

/* ==========================================================================
   Recherche et filtres
   ========================================================================== */

.vdi-clients-filters {
  margin-bottom: 1.5rem;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: center;
}

.vdi-filter-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.vdi-filter-group:first-child {
  flex: 1;
  min-width: 250px;
}
.vdi-clients-filters .vdi-filter-group:has(#vdi-clients-search) {
  padding-top: 33px;
}

.vdi-clients-filters {
  align-items: flex-start !important;
}

.vdi-search-input {
  flex: 1;
  padding: 10px 15px;
  font-size: 14px;
  border: 1px solid #ddd;
  border-radius: 4px;
  transition: border-color 0.2s;
}

.vdi-search-input:focus {
  border-color: #2271b1;
  outline: none;
  box-shadow: 0 0 0 1px #2271b1;
}

.vdi-results-count {
  color: #666;
  font-size: 13px;
  white-space: nowrap;
  padding: 0 10px;
}

.vdi-sort-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.vdi-sort-controls label {
  font-size: 13px;
  font-weight: 500;
  color: #666;
  margin: 0;
}

.vdi-sort-select {
  padding: 8px 12px;
  font-size: 14px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: white;
  cursor: pointer;
  transition: border-color 0.2s;
}

.vdi-sort-select:focus {
  border-color: #2271b1;
  outline: none;
  box-shadow: 0 0 0 1px #2271b1;
}

/* ==========================================================================
   Tableau des clients
   ========================================================================== */

/* Wrapper tableau avec scroll horizontal */

.vdi-clients-table-wrapper {
  margin-top: 1.5rem;
  overflow-x: auto;
  background: white;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Tableau scrollable sur mobile */
@media (max-width: 768px) {
  .vdi-clients-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .vdi-clients-table {
    min-width: 800px; /* Force largeur minimale pour scroll horizontal */
  }
}
.vdi-clients-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  overflow: hidden;
}

.vdi-clients-table thead {
  background: #f8f9fa;
  border-bottom: 2px solid #e0e0e0;
}

.vdi-clients-table th {
  padding: 12px 15px;
  text-align: left;
  font-weight: 600;
  font-size: 0.9rem;
  color: #333;
  text-transform: capitalize;
  letter-spacing: 0.3px;
}

.vdi-clients-table tbody tr {
  border-bottom: 1px solid #e0e0e0;
  transition: background-color 0.2s;
}

.vdi-clients-table tbody tr:hover {
  background-color: #f8f9fa;
}

.vdi-clients-table td {
  padding: 15px;
  font-size: 0.95rem;
}
/* Min-width pour éviter écrasement des colonnes */
.vdi-clients-table th:nth-child(1),
.vdi-clients-table td:nth-child(1) {
  min-width: 200px; /* Client */
}

.vdi-clients-table th:nth-child(2),
.vdi-clients-table td:nth-child(2) {
  min-width: 180px; /* Compte WooCommerce */
}

.vdi-clients-table th:nth-child(3),
.vdi-clients-table td:nth-child(3) {
  min-width: 150px; /* Invitations */
}

.vdi-clients-table th:nth-child(4),
.vdi-clients-table td:nth-child(4) {
  min-width: 140px; /* Statut invitation */
}

.vdi-clients-table th:nth-child(5),
.vdi-clients-table td:nth-child(5) {
  min-width: 150px; /* Actions */
}

/* Highlight de la ligne lors de la recherche */
.vdi-row-highlight {
  background-color: #fff3cd !important;
  animation: highlight-pulse 1s ease-in-out;
}

@keyframes highlight-pulse {
  0%,
  100% {
    background-color: #fff3cd;
  }
  50% {
    background-color: #ffe69c;
  }
}

/* Colonnes spécifiques */
.vdi-client-name {
  min-width: 150px;
}

.vdi-client-email {
  color: #666;
  font-size: 0.9rem;
}

.vdi-client-wc-account {
  text-align: center;
}

/* Badges Compte WooCommerce */
.vdi-account-badge {
  display: inline-block;
  padding: 6px 16px;
  border-radius: 4px;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
  min-width: 60px;
}

.vdi-account-yes {
  background-color: #28a745;
  color: white;
}

.vdi-account-no {
  background-color: #ff9800;
  color: white;
}

.vdi-account-pending {
  background-color: #ffc107;
  color: #333;
}

/* Wrapper pour statut + bouton côte à côte */
.vdi-account-status-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.vdi-info-item-account .vdi-account-status-wrapper {
  margin-top: 0.5rem;
}

/* ==========================================================================
   Badges et statuts
   ========================================================================== */

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 600;
}

.badge-orders {
  background: #2271b1;
  color: white;
}

.vdi-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 600;
}

.vdi-status .dashicons {
  font-size: 16px;
  width: 16px;
  height: 16px;
}

.vdi-status-success {
  background: #d4edda;
  color: #155724;
}

.vdi-status-pending {
  background: #fff3cd;
  color: #856404;
}

.vdi-status-warning {
  background: #f8d7da;
  color: #721c24;
}

.vdi-status-expired {
  background: #e2e3e5;
  color: #383d41;
}

.vdi-status-cancelled {
  background: #f8d7da;
  color: #721c24;
}

/* ==========================================================================
   Boutons actions
   ========================================================================== */

.vdi-client-actions {
  text-align: center;
  min-width: 120px;
}

.button-small {
  padding: 6px 12px !important;
  font-size: 13px !important;
  height: auto !important;
  line-height: 1.4 !important;
}

.vdi-btn-send-invitation,
.vdi-btn-resend-invitation {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  vertical-align: middle;
  padding: 6px 12px !important;
}

.vdi-btn-send-invitation .dashicons,
.vdi-btn-resend-invitation .dashicons {
  font-size: 16px;
  width: 16px;
  height: 16px;
  line-height: 1;
  vertical-align: middle;
}

.spinning {
  animation: spin 1s linear infinite;
}

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

/* ==========================================================================
   Pagination
   ========================================================================== */

.vdi-pagination {
  margin-top: 2rem;
  padding: 1.5rem;
  background: #f8f9fa;
  border-radius: 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.vdi-pagination-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 10px 20px;
  background: white;
  color: #2271b1;
  text-decoration: none;
  border: 1px solid #2271b1;
  border-radius: 4px;
  font-weight: 600;
  transition: all 0.2s;
}

.vdi-pagination-btn:hover {
  background: #2271b1;
  color: white;
}

.vdi-pagination-btn .dashicons {
  font-size: 16px;
  width: 16px;
  height: 16px;
}

.vdi-pagination-info {
  font-weight: 600;
  color: #666;
}

/* ==========================================================================
   Page détail client
   ========================================================================== */

.vdi-detail-header {
  margin-bottom: 2rem;
}

.vdi-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #2271b1;
  text-decoration: underline;
  font-weight: 500;
  transition: color 0.2s;
}

.vdi-back-btn:hover {
  color: #135e96;
  text-decoration: none;
}

.vdi-back-btn .dashicons {
  font-size: 16px;
  width: 16px;
  height: 16px;
}

.vdi-client-detail-card,
.vdi-client-orders-card {
  background: white;
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  margin-bottom: 2rem;
}

.vdi-client-detail-card h2,
.vdi-client-orders-card h2 {
  margin-top: 0;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid #f0f0f0;
}

.vdi-client-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.vdi-info-item strong {
  display: block;
  font-size: 0.85rem;
  color: #666;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.vdi-info-item p {
  margin: 0;
  font-size: 1rem;
  color: #333;
}

.vdi-client-actions-detail {
  padding-top: 1.5rem;
  border-top: 1px solid #e0e0e0;
}

.vdi-client-actions-detail .description {
  margin-top: 0.75rem;
  color: #666;
  font-style: italic;
}

/* ==========================================================================
   Tableau des commandes (page détail)
   ========================================================================== */

.vdi-client-orders-card {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.vdi-orders-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 700px; /* Force scroll horizontal sur mobile */
}

.vdi-orders-table thead {
  background: #f8f9fa;
  border-bottom: 2px solid #e0e0e0;
}

.vdi-orders-table th {
  padding: 12px 15px;
  text-align: left;
  font-weight: 600;
  font-size: 0.9rem;
  color: #333;
}

/* Largeur minimale pour la colonne Statut */
.vdi-orders-table th:nth-child(3),
.vdi-orders-table td:nth-child(3) {
  min-width: 150px;
}

.vdi-orders-table tbody tr {
  border-bottom: 1px solid #e0e0e0;
}

.vdi-orders-table td {
  padding: 12px 15px;
}

.vdi-order-status {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 600;
}

.vdi-order-status-completed {
  background: #d4edda;
  color: #155724;
}

.vdi-order-status-processing {
  background: #cce5ff;
  color: #004085;
}

.vdi-order-status-pending {
  background: #fff3cd;
  color: #856404;
}

.vdi-order-status-on-hold {
  background: #f8d7da;
  color: #721c24;
}

.vdi-order-status-cancelled {
  background: #e2e3e5;
  color: #383d41;
}

.vdi-order-status-refunded {
  background: #e2e3e5;
  color: #383d41;
}

.vdi-order-status-failed {
  background: #f8d7da;
  color: #721c24;
}

/* Origine commande */
.vdi-order-origin {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 600;
}

.vdi-order-origin-vdi {
  background: #e3f2fd;
  color: #1976d2;
}

.vdi-order-origin-reunion {
  background: #fff3e0;
  color: #244496;
}

.vdi-order-origin-customer {
  background: #f3e5f5;
  color: #7b1fa2;
}

/* ==========================================================================
   Notices et messages
   ========================================================================== */

.vdi-notice {
  padding: 12px 20px;
  margin-bottom: 1.5rem;
  border-radius: 4px;
  border-left: 4px solid;
}

.vdi-notice p {
  margin: 0;
}

.vdi-notice-info {
  background: #d1ecf1;
  border-color: #0c5460;
  color: #0c5460;
}

.vdi-notice-success {
  background: #d4edda;
  border-color: #155724;
  color: #155724;
}

.vdi-notice-error {
  background: #f8d7da;
  border-color: #721c24;
  color: #721c24;
}

.vdi-notice-warning {
  background: #fff3cd;
  border-color: #856404;
  color: #856404;
}

/* Notifications flottantes */
.vdi-notice-floating {
  position: fixed;
  top: 32px;
  right: 20px;
  z-index: 9999;
  min-width: 300px;
  max-width: 400px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  opacity: 0;
  transform: translateX(400px);
  transition: all 0.3s ease-out;
}

.vdi-notice-floating.show {
  opacity: 1;
  transform: translateX(0);
}

/* ==========================================================================
   Utilitaires
   ========================================================================== */

.vdi-text-muted {
  color: #999;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media screen and (max-width: 782px) {
  .vdi-clients-invitations-wrapper,
  .vdi-client-detail-wrapper {
    padding: 10px;
  }

  .vdi-rate-limit-stats {
    grid-template-columns: 1fr;
  }

  .vdi-pagination {
    flex-direction: column;
    text-align: center;
  }

  .vdi-client-info-grid {
    grid-template-columns: 1fr;
  }

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

  .vdi-filter-group {
    width: 100%;
  }

  .vdi-filter-group:first-child {
    min-width: 100%;
  }

  .vdi-search-input,
  .vdi-sort-select {
    width: 100%;
  }

  .vdi-sort-controls {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .vdi-sort-controls label {
    font-weight: 600;
  }

  /* Garder le tableau scrollable sur mobile (pas de transformation en cards) */
  /* Désactivé pour permettre le scroll horizontal du tableau */
}

/* ==========================================================================
   Modal de confirmation d'invitation
   ========================================================================== */

.vdi-invitation-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999999;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.2s ease,
    visibility 0.2s ease;
}

.vdi-invitation-modal-overlay.show {
  opacity: 1 !important;
  visibility: visible !important;
}

.vdi-invitation-modal {
  background: white;
  border-radius: 8px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow: hidden;
  transform: scale(0.9);
  transition: transform 0.2s ease;
  position: relative;
  z-index: 1;
}

.vdi-invitation-modal-overlay.show .vdi-invitation-modal {
  transform: scale(1);
}

.vdi-invitation-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem;
  border-bottom: 1px solid #e0e0e0;
  background-color: #f8f9fa;
}

.vdi-invitation-modal-header h3 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: #333;
}

.vdi-invitation-modal-close {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: #666;
  font-size: 24px;
  line-height: 1;
  transition: color 0.2s ease;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}

.vdi-invitation-modal-close:hover {
  color: #333;
  background-color: rgba(0, 0, 0, 0.05);
}

.vdi-invitation-modal-close .dashicons {
  width: 24px;
  height: 24px;
  font-size: 24px;
}

.vdi-invitation-modal-body {
  padding: 1.5rem;
  color: #333;
  line-height: 1.6;
  max-height: 60vh;
  overflow-y: auto;
}

.vdi-invitation-modal-body p {
  margin: 0 0 1rem;
}

.vdi-invitation-modal-body p:last-child {
  margin-bottom: 0;
}

.vdi-invitation-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1.5rem;
  border-top: 1px solid #e0e0e0;
  background-color: #f8f9fa;
}

.vdi-invitation-modal-footer .button {
  margin: 0;
}

/* Style spécifique pour le bouton Renvoyer */
.vdi-btn-resend-invitation {
  background-color: grey !important;
  border-color: #eea236 !important;
  color: white !important;
}

.vdi-btn-resend-invitation:hover {
  background-color: #ec971f !important;
  border-color: #d58512 !important;
}

.vdi-btn-resend-invitation .dashicons {
  color: white;
}

/* Responsive */
@media (max-width: 600px) {
  .vdi-invitation-modal {
    width: 95%;
    max-width: none;
  }

  .vdi-invitation-modal-header,
  .vdi-invitation-modal-body,
  .vdi-invitation-modal-footer {
    padding: 1rem;
  }

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

  .vdi-invitation-modal-footer .button {
    width: 100%;
  }
}

/* Colonne Client avec nom + email + bouton */
.vdi-client-name {
  min-width: 200px;
}

.vdi-client-name strong {
  font-size: 14px;
  color: #333;
}

.vdi-client-name small {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: #666;
}

.vdi-client-name .button {
  margin-top: 8px;
  font-size: 12px;
  padding: 4px 8px;
  height: auto;
  line-height: 1.4;
}

/* Badges compte WooCommerce */
.vdi-account-badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 3px;
  font-weight: bold;
  font-size: 13px;
}

.vdi-account-yes {
  background: #d4edda;
  color: #155724;
}

.vdi-account-no {
  background: #f8d7da;
  color: #721c24;
}

/* Colonnes invitations et statut */
.vdi-client-invitation,
.vdi-client-invitation-status {
  min-width: 120px;
}

/* Responsive : garder tableau scrollable sur mobile */
/* Cette section est désactivée pour permettre le scroll horizontal */

/* ==========================================================================
   FIX
   ========================================================================== */
.vdi-client-order-card *:not(h2),
.vdi-client-detail-card *:not(h2),
.vdi-client-order-card .woocommerce-Price-amount.amount,
.vdi-client-detail-card .woocommerce-Price-amount.amount,
.vdi-client-orders-card .vdi-orders-table .woocommerce-Price-amount.amount {
  font-family: var(--labor-font-family) !important;
}

.vdi-actions button,
.vdi-client-detail-card button,
.vdi-boutique-wrapper button,
.vdi-clients-table .button,
.vdi-invite-new-client .button {
  max-width: max-content !important;
}

.vdi-boutique-intro li::before {
  top: 6px !important;
}

.vdi-order-items-list li::before {
  display: none;
}

.vdi-client-detail-wrapper .woocommerce-Price-amount.amount {
  font-size: 16px !important;
}
