/* ==========================================================================
   COMPONENTS.CSS
   Composants réutilisables (site public + espace Customer Care)
   Dépend de : variables.css, base.css
   ========================================================================== */

/* ─── Marques ─── */
.brand-beko    { color: var(--brand-beko); }
.brand-maxwell { color: var(--brand-maxwell); }

/* ==========================================================================
   BOUTONS
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 22px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--gray-100);
  color: var(--gray-800);
  cursor: pointer;
  transition: var(--transition);
}
.btn:focus-visible { outline: 3px solid rgba(46, 123, 214, 0.35); outline-offset: 2px; }
.btn:disabled,
.btn.disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: var(--white); }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); color: var(--white); box-shadow: var(--shadow-md); }

.btn-secondary { background: var(--secondary); color: var(--white); }
.btn-secondary:hover:not(:disabled) { background: var(--secondary-dark); color: var(--white); box-shadow: var(--shadow-md); }

.btn-ghost { background: transparent; color: var(--gray-700); border-color: var(--gray-300); }
.btn-ghost:hover:not(:disabled) { background: var(--gray-100); color: var(--gray-900); border-color: var(--gray-400); }

.btn-outline-light { background: transparent; color: var(--white); border-color: rgba(255, 255, 255, 0.65); }
.btn-outline-light:hover:not(:disabled) { background: var(--white); color: var(--primary); border-color: var(--white); }

.btn-success { background: var(--success); color: var(--white); }
.btn-success:hover:not(:disabled) { background: var(--success-light); color: var(--white); }

.btn-danger { background: var(--danger); color: var(--white); }
.btn-danger:hover:not(:disabled) { background: var(--danger-light); color: var(--white); }

.btn-sm { padding: 7px 14px; font-size: 0.82rem; border-radius: var(--radius-sm); }
.btn-lg { padding: 14px 30px; font-size: 1.05rem; border-radius: var(--radius-lg); }
.btn-block { display: flex; width: 100%; }

/* ==========================================================================
   FORMULAIRES
   ========================================================================== */
.form-group { margin-bottom: 20px; }
.form-grid,
.form-row  { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }

.form-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 8px;
}
.form-label .required,
.required { color: var(--danger); }

.form-control {
  width: 100%;
  padding: 11px 14px;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--gray-800);
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  transition: var(--transition);
  appearance: none;
}
.form-control::placeholder { color: var(--gray-400); }
.form-control:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(46, 123, 214, 0.15);
}
textarea.form-control { min-height: 130px; resize: vertical; line-height: 1.6; }
select.form-control {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236B7280' d='M6 8 0 2l1.4-1.4L6 5.2 10.6.6 12 2z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 38px;
}

.form-hint { font-size: 0.8rem; color: var(--gray-500); margin-top: 6px; }
.form-error { display: none; font-size: 0.8rem; color: var(--danger); margin-top: 6px; }
.form-error.visible,
.form-error.show { display: block; }

.gps-row { display: flex; gap: 10px; align-items: center; }
.gps-row .form-control { flex: 1; }
.gps-row .btn { flex-shrink: 0; white-space: nowrap; }
#gps_coords.gps-ok { border-color: var(--success, #16a34a); color: var(--success, #16a34a); }

.brand-picker { display: flex; gap: 16px; flex-wrap: wrap; }
.brand-option { cursor: pointer; }
.brand-option input { position: absolute; opacity: 0; pointer-events: none; }
.brand-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 22px;
  border: 2px solid var(--gray-300);
  border-radius: var(--radius);
  background: var(--white);
  transition: var(--transition);
}
.brand-card img { height: 34px; width: auto; object-fit: contain; }
.brand-card strong { font-size: 1rem; color: var(--gray-800); }
.brand-option:hover .brand-card { border-color: var(--primary-light); background: var(--primary-bg); }
.brand-option input:checked + .brand-card { border-color: var(--primary); background: var(--primary-bg); box-shadow: 0 0 0 3px rgba(46, 123, 214, 0.15); }
.brand-option input:checked + .brand-card strong { color: var(--primary); }

.consent-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--gray-700);
  line-height: 1.6;
  cursor: pointer;
  user-select: none;
}
.consent-checkbox input {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--primary);
  cursor: pointer;
}
.consent-checkbox em { font-style: italic; }

.btn-copy-ticket { margin-top: 10px; }

.optional-badge {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--gray-400);
  margin-left: 6px;
}

/* ==========================================================================
   CARTES
   ========================================================================== */
.card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-sm);
}
.card-hover { transition: var(--transition); }
.card-hover:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--gray-300);
}

.service-card { display: flex; flex-direction: column; height: 100%; }
.service-card h3 { margin-bottom: 6px; }
.service-card p { color: var(--gray-500); font-size: 0.9rem; margin: 0; }
.service-icon {
  width: 54px; height: 54px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.55rem;
  background: var(--primary-bg);
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.contact-card {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 28px 22px;
  transition: var(--transition);
}
.contact-card:hover { box-shadow: var(--shadow-md); border-color: var(--gray-300); }
.contact-icon {
  width: 58px; height: 58px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem;
  background: var(--primary-bg);
  border-radius: 50%;
  margin-bottom: 14px;
}

/* ==========================================================================
   EN-TÊTE DE PAGE (pages publiques)
   ========================================================================== */
.page-header {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  color: var(--white);
  padding: 60px 0 54px;
  text-align: center;
}
.page-header h1 { color: var(--white); margin-bottom: 10px; }
.page-header p { color: rgba(255, 255, 255, 0.86); max-width: 640px; margin: 0 auto; }

/* ==========================================================================
   BADGES DE STATUT
   ========================================================================== */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  line-height: 1.5;
  white-space: nowrap;
  background: var(--gray-100);
  color: var(--gray-600);
}
.status-badge.status-en_attente      { background: var(--warning-bg); color: var(--warning); }
.status-badge.status-appele          { background: var(--primary-bg); color: var(--primary); }
.status-badge.status-ticket_crm_cree { background: #EDE9FE; color: #6D28D9; }
.status-badge.status-planifie        { background: var(--info-bg); color: var(--info); }
.status-badge.status-en_cours        { background: #E7F1FB; color: var(--brand-beko); }
.status-badge.status-en_attente_pdr  { background: #FFEDE2; color: var(--secondary-dark); }
.status-badge.status-repare          { background: var(--success-bg); color: var(--success); }
.status-badge.status-cloture         { background: var(--gray-100); color: var(--gray-500); }
.status-badge.status-refuse          { background: var(--danger-bg); color: var(--danger); }
.status-badge.status-annule          { background: var(--gray-100); color: var(--gray-500); }

.status-badge.status-role    { background: #E7F1FB; color: var(--brand-beko); }
.status-badge.status-actif   { background: var(--success-bg); color: var(--success); }
.status-badge.status-inactif { background: var(--danger-bg); color: var(--danger); }

.badge-maxwell { background: var(--brand-maxwell); color: var(--white); }
.status-badge.badge-express { background: var(--secondary); color: var(--white); }

/* ==========================================================================
   ALERTES
   ========================================================================== */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px;
  margin-bottom: 16px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 0.9rem;
}
.alert-error   { background: var(--danger-bg);  color: var(--danger);  border-color: #FECACA; }
.alert-success { background: var(--success-bg); color: var(--success); border-color: #A7F3D0; }
.alert-warning { background: var(--warning-bg); color: var(--warning); border-color: #FDE68A; }
.alert-info    { background: var(--info-bg);    color: var(--info);    border-color: #A5F3FC; }

/* ==========================================================================
   NOTIFICATIONS (toasts)
   ========================================================================== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 260px;
  max-width: 380px;
  padding: 14px 18px;
  border-radius: var(--radius);
  background: var(--gray-900);
  color: var(--white);
  box-shadow: var(--shadow-xl);
  font-size: 0.9rem;
  font-weight: 500;
  pointer-events: auto;
  opacity: 0;
  transform: translateX(24px);
  transition: var(--transition-slow);
}
.toast.show { opacity: 1; transform: translateX(0); }
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
.toast.warning { background: var(--warning); }
.toast.info    { background: var(--primary); }

/* ==========================================================================
   SPINNER DE CHARGEMENT
   ========================================================================== */
.spinner {
  display: inline-block;
  width: 22px; height: 22px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.spinner-lg { width: 42px; height: 42px; border-width: 4px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ==========================================================================
   ZONE D'UPLOAD
   ========================================================================== */
.upload-zone {
  padding: 34px 20px;
  text-align: center;
  background: var(--gray-50);
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: var(--transition);
}
.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--primary-light);
  background: var(--primary-bg);
}
.upload-icon { font-size: 1.9rem; margin-bottom: 8px; }
.upload-zone p { color: var(--gray-600); font-size: 0.9rem; margin: 0; }

.upload-preview {
  display: none;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding: 12px 16px;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
}
.upload-preview.visible { display: flex; }
.upload-preview .file-name { font-weight: 600; font-size: 0.88rem; color: var(--gray-800); word-break: break-all; }
.upload-preview .file-size { font-size: 0.78rem; color: var(--gray-500); }
.remove-file {
  margin-left: auto;
  padding: 4px 9px;
  font-size: 0.95rem;
  color: var(--danger);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}
.remove-file:hover { background: var(--danger-bg); }

/* ==========================================================================
   RÉSULTAT DE TICKET (page réclamation)
   ========================================================================== */
.ticket-result { text-align: center; padding: 12px; }
.ticket-result h2 { margin-top: 20px; }
.ticket-number {
  display: inline-block;
  margin: 16px 0;
  padding: 12px 26px;
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--primary);
  background: var(--primary-bg);
  border-radius: var(--radius);
}
.ticket-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 22px;
}

/* ==========================================================================
   EN-TÊTE DE CARTE + DÉTAILS
   ========================================================================== */
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-top: 16px; }
.stat-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 4px;
}

/* ==========================================================================
   CARTES D'ÉTAT (succès / erreur)
   ========================================================================== */
.success-card { border-color: #A7F3D0; background: var(--success-bg); }
.error-card { border-color: #FECACA; background: var(--danger-bg); }
.error-card p { color: var(--danger); margin: 0; }
.ticket-note { color: var(--gray-500); max-width: 480px; margin: 0 auto; }
.success-check {
  width: 72px; height: 72px; margin: 0 auto;
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem;
  color: var(--success);
  background: var(--success-bg);
  border-radius: 50%;
}
.input-center { text-align: center; }

/* ==========================================================================
   DIVERS
   ========================================================================== */
.toolbar-hint { font-size: 0.8rem; color: var(--gray-500); }
.text-mono { font-family: var(--font-mono); }
.text-sm { font-size: 0.85rem; }
.text-xs { font-size: 0.78rem; }
.ml-auto { margin-left: auto; }

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 768px) {
  .form-grid,
  .form-row { grid-template-columns: 1fr; gap: 0; }
  .ticket-actions { flex-direction: column; }
  .ticket-actions .btn { width: 100%; }
  .toast-container { left: 16px; right: 16px; }
  .toast { max-width: none; min-width: 0; }
}
