/**
 * TaskManager - Thème CSS
 *
 * Style : moderne, épuré, professionnel (dashboard / admin / SaaS)
 * - Design minimaliste, beaucoup d’espace blanc
 * - Neutres (blanc, gris clair) + accents bleus (actif/sélection)
 * - Formes arrondies (inputs, boutons, cartes)
 * - Typo sans-serif lisible et discrète
 * - Hiérarchie claire, sections aérées
 * - États interactifs subtils (hover, focus, loading)
 */

/* -------------------------------------------------------------------------
   Variables (palette et espacements)
   ------------------------------------------------------------------------- */
:root {
  /* Couleurs principales */
  --tm-primary: #3b82f6;
  --tm-primary-hover: #2563eb;
  --tm-primary-light: #eff6ff;
  --tm-primary-focus: rgba(59, 130, 246, 0.2);

  /* Neutres */
  --tm-bg-page: #fafafa;
  --tm-bg-card: #ffffff;
  --tm-border: #e5e7eb;
  --tm-border-focus: #93c5fd;
  --tm-text: #374151;
  --tm-text-muted: #6b7280;
  --tm-placeholder: #9ca3af;
  --tm-required: #dc6b5a;

  /* Formes arrondies */
  --tm-radius-sm: 0.375rem;
  --tm-radius: 0.5rem;
  --tm-radius-lg: 0.75rem;
  --tm-radius-xl: 1rem;

  /* Espacements */
  --tm-section-padding: 1.75rem;
  --tm-content-max-width: 72rem;
  --tm-form-group-gap: 0.25rem;
}

/* -------------------------------------------------------------------------
   Base : fond de page, typo
   ------------------------------------------------------------------------- */
body.bg-light {
  background-color: var(--tm-bg-page) !important;
  color: var(--tm-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-weight: 400;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* -------------------------------------------------------------------------
   Template "task_tracking_page.html" (Bootstrap 5.3 + Bootstrap Icons)
   - Objectif: répliquer le rendu du template et harmoniser les blades.
   ------------------------------------------------------------------------- */
:root {
  --primary-color: #2563eb;
  --secondary-color: #64748b;
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --danger-color: #ef4444;
  --light-bg: #f8fafc;
  --border-color: #e2e8f0;
  --bg-support-message: #d9fdd3;
}

body {
  background-color: var(--light-bg);
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  font-size: 0.9rem;
}

.page-header {
  background: white;
  border-bottom: 1px solid var(--border-color);
  padding: 1.25rem 0;
  margin-bottom: 1.5rem;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: #1e293b;
  margin: 0;
}

.stats-card {
  background: white;
  border-radius: 8px;
  padding: 1rem;
  border: 1px solid var(--border-color);
  transition: transform 0.2s, box-shadow 0.2s;
}

.stats-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.stats-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.stats-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: #1e293b;
  margin: 0;
}

.stats-label {
  font-size: 0.75rem;
  color: var(--secondary-color);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0;
}

.filter-section {
  background: white;
  border-radius: 8px;
  padding: 1rem;
  border: 1px solid var(--border-color);
  margin-bottom: 1rem;
}

/* Filter buttons style */
.filter-buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: white;
  color: var(--secondary-color);
  text-decoration: none;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}

.filter-btn:hover {
  background-color: #f8fafc;
  border-color: var(--primary-color);
  color: var(--primary-color);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.1);
}

.filter-btn.active {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
  color: white;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.2);
}

.filter-btn.active:hover {
  background-color: #1d4ed8;
  border-color: #1d4ed8;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(37, 99, 235, 0.3);
}

.filter-btn i {
  font-size: 0.875rem;
}

.filter-btn-reset {
  padding: 0.5rem;
  font-size: 0.875rem;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: white;
  color: var(--secondary-color);
  text-decoration: none;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
}

.filter-btn-reset:hover {
  background-color: #f1f5f9;
  border-color: var(--primary-color);
  color: var(--primary-color);
  transform: rotate(180deg);
}

.task-table {
  background: white;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
}

/* Horizontal scroll for all table wrappers (mobile-friendly) */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
}

.table {
  margin: 0;
  font-size: 0.875rem;
}

/* Keep table width so horizontal scroll works on mobile */
.task-table .table,
.table-responsive .table {
  min-width: max-content;
  width: 100%;
}

.task-table .table thead th {
  background: #f8fafc;
  color: #64748b;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--border-color);
  padding: 0.75rem;
}

.task-table .table tbody td {
  padding: 0.75rem;
  vertical-align: middle;
  border-bottom: 1px solid #f1f5f9;
}

.task-table .table tbody tr:hover {
  background-color: #f8fafc;
}

.st-ticket-row {
  cursor: pointer;
}

.st-ticket-row:focus {
  outline: none;
}

.badge {
  padding: 0.35rem 0.65rem;
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 6px;
}

.badge-type {
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.status-nouveau { background-color: #dbeafe; color: #1e40af; }
.status-en-cours { background-color: #fef3c7; color: #92400e; }
.status-resolu { background-color: #d1fae5; color: #065f46; }
.status-ferme { background-color: #f1f5f9; color: #475569; }

.priority-basse { background-color: #e0e7ff; color: #3730a3; }
.priority-moyenne { background-color: #fef3c7; color: #92400e; }
.priority-haute { background-color: #fed7aa; color: #9a3412; }
.priority-urgente { background-color: #fee2e2; color: #991b1b; }

.btn-sm {
  padding: 0.25rem 0.6rem;
  font-size: 0.8rem;
  border-radius: 6px;
}

.btn-action {
  padding: 0.35rem 0.5rem;
  border: none;
  background: transparent;
  color: var(--primary-color);
  transition: all 0.2s;
  text-decoration: none;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-action:hover {
  color: var(--primary-color);
  background-color: #f1f5f9;
}

.timer-badge {
  background-color: #dcfce7;
  color: #166534;
  padding: 0.4rem 0.7rem;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.8rem;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.agency-name {
  font-weight: 600;
  color: #1e293b;
}

.intervention-title {
  color: #334155;
  font-weight: 500;
}

.form-control, .form-select {
  font-size: 0.875rem;
  border-color: var(--border-color);
  padding: 0.5rem 0.75rem;
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 0.2rem rgba(37, 99, 235, 0.1);
}

.action-buttons {
  display: flex;
  gap: 0.25rem;
}

.pagination {
  margin: 0;
  gap: 0.25rem;
  display: flex;
  align-items: center;
}

.pagination-sm .page-link {
  padding: 0.375rem 0.625rem;
  font-size: 0.875rem;
  min-width: 2rem;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

.page-link {
  color: var(--primary-color);
  border-color: var(--border-color);
  font-size: 0.875rem;
  transition: all 0.2s ease;
  border-radius: 0.375rem;
  text-decoration: none;
  background-color: #fff;
}

.page-link:hover:not(.disabled):not(:disabled) {
  background-color: #f1f5f9;
  border-color: var(--primary-color);
  color: var(--primary-color);
  z-index: 2;
  transform: translateY(-1px);
}

.page-link:focus {
  box-shadow: 0 0 0 0.2rem rgba(37, 99, 235, 0.15);
  z-index: 3;
  outline: none;
}

.page-item.active .page-link {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
  color: #fff;
  z-index: 3;
  font-weight: 500;
}

.page-item.active .page-link:hover {
  background-color: #1d4ed8;
  border-color: #1d4ed8;
  color: #fff;
  transform: translateY(-1px);
}

.page-item.disabled .page-link {
  color: #9ca3af;
  pointer-events: none;
  cursor: not-allowed;
  background-color: #fff;
  border-color: var(--border-color);
  opacity: 0.6;
}

.page-link i {
  font-size: 0.875rem;
  line-height: 1;
}

/* Navbar Styles */
.navbar {
  padding: 0.5rem 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.navbar-brand {
  font-size: 1.1rem;
  font-weight: 700;
}

.nav-link {
  color: var(--secondary-color);
  font-size: 0.85rem;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  transition: all 0.2s;
  font-weight: 500;
  gap: 4px;
}

.nav-link:hover {
  background-color: #f8fafc;
  color: var(--primary-color);
}

.nav-link.active {
  color: var(--primary-color);
  background-color: #eff6ff;
}

/* User Dropdown Styles */
.avatar-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-color), #1d4ed8);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 0.8rem;
}

.user-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: #1e293b;
  line-height: 1.2;
}

.dropdown-toggle {
  border: none;
  background: transparent;
  padding: 0.3rem 0.6rem;
}

.dropdown-toggle:hover {
  background-color: transparent !important;
  border: none;
}

.dropdown-toggle:focus {
  box-shadow: none;
  background-color: transparent;
}

.dropdown-toggle::after {
  margin-left: 0.5rem;
}

.dropdown-menu {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  min-width: 240px;
  padding: 0.5rem;
  margin-top: 0.5rem;
}

@media (max-width: 576px) {
  .dropdown-menu {
    position: fixed !important;
    top: auto !important;
    right: 1rem !important;
    left: 1rem !important;
    transform: none !important;
    width: auto;
    min-width: auto;
    max-width: calc(100vw - 2rem);
    margin-top: 0.5rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15) !important;
  }

  .dropdown-menu.show {
    animation: slideUp 0.3s ease-out;
  }

  @keyframes slideUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
  }

  .dropdown-header { padding: 1rem; }
  .dropdown-item { padding: 0.75rem 1rem; font-size: 0.9rem; }
}

.dropdown-header {
  padding: 0.75rem 1rem;
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border-radius: 6px;
  margin-bottom: 0.5rem;
}

.dropdown-header strong {
  font-size: 0.9rem;
  color: #1e293b;
  display: block;
  margin-bottom: 0.25rem;
}

.dropdown-header .text-muted {
  font-size: 0.8rem;
  color: #64748b !important;
}

.dropdown-item {
  padding: 0.6rem 1rem;
  border-radius: 6px;
  font-size: 0.875rem;
  transition: all 0.2s;
}

.dropdown-item:hover {
  background-color: #f8fafc;
}

.dropdown-item i {
  width: 18px;
}

/* Intervention details modal */
.intervention-details .detail-item {
  margin-bottom: 0.5rem;
}

.intervention-details .detail-item label {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.7rem;
  letter-spacing: 0.5px;
}

.intervention-details .detail-item > div {
  font-size: 0.9rem;
}

.modal-dialog-scrollable .modal-body {
  max-height: calc(100vh - 200px);
}

/* Intervention time info in table */
.intervention-time-info {
  font-size: 0.8rem;
  line-height: 1.4;
}

.intervention-time-info .small {
  display: block;
  margin-bottom: 0.2rem;
}

.intervention-time-info i {
  margin-right: 0.25rem;
  font-size: 0.85rem;
}

/* -------------------------------------------------------------------------
   Formulaires : inputs, select, textarea
   ------------------------------------------------------------------------- */
.form-control,
.form-select {
  border: 1px solid var(--tm-border);
  border-radius: var(--tm-radius);
  background-color: var(--tm-bg-card);
  color: var(--tm-text);
  padding: 0.5rem 0.75rem;
  font-size: 0.9375rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control::placeholder {
  color: var(--tm-placeholder);
}

.form-control:hover:not(:focus):not(:disabled),
.form-select:hover:not(:focus):not(:disabled) {
  border-color: #d1d5db;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--tm-border-focus);
  box-shadow: 0 0 0 3px var(--tm-primary-focus);
  outline: none;
}

.form-control.is-invalid {
  border-color: #fca5a5;
}

.form-control.is-invalid:focus {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.form-select {
  cursor: pointer;
}

/* -------------------------------------------------------------------------
   Labels et champs requis
   ------------------------------------------------------------------------- */
.form-label {
  font-weight: 500;
  color: var(--tm-text);
  font-size: 0.875rem;
  margin-bottom: var(--tm-form-group-gap);
}

.form-label .required,
.form-label .text-danger {
  color: var(--tm-required);
  font-weight: 400;
}

/* -------------------------------------------------------------------------
   Boutons
   ------------------------------------------------------------------------- */
.btn {
  border-radius: var(--tm-radius);
  font-weight: 500;
  font-size: 0.875rem;
  padding: 0.5rem 1rem;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn-primary {
  background-color: var(--tm-primary);
  border-color: var(--tm-primary);
  color: #fff;
}

.btn-primary:hover {
  background-color: var(--tm-primary-hover);
  border-color: var(--tm-primary-hover);
  color: #fff;
}

.btn-primary:focus-visible {
  box-shadow: 0 0 0 3px var(--tm-primary-focus);
}

.btn-outline-secondary {
  border-color: var(--tm-border);
  color: var(--tm-text);
}

.btn-outline-secondary:hover {
  background-color: #f9fafb;
  border-color: #d1d5db;
  color: var(--tm-text);
}

.btn-danger {
  background-color: #ef4444;
  border-color: #ef4444;
}

.btn-danger:hover {
  background-color: #dc2626;
  border-color: #dc2626;
  color: #fff;
}

.btn-link {
  font-weight: 500;
}

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

/* -------------------------------------------------------------------------
   Checkbox et radio (form-check)
   ------------------------------------------------------------------------- */
.form-check-input {
  border: 1px solid var(--tm-border);
  border-radius: var(--tm-radius-sm);
  width: 1.125rem;
  height: 1.125rem;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.form-check-input:checked {
  background-color: var(--tm-primary);
  border-color: var(--tm-primary);
}

.form-check-input:focus {
  box-shadow: 0 0 0 3px var(--tm-primary-focus);
}

.form-check-label {
  color: var(--tm-text);
  font-size: 0.875rem;
}

/* -------------------------------------------------------------------------
   Navbar
   ------------------------------------------------------------------------- */
.tm-navbar.navbar,
.navbar.tm-navbar {
  position: sticky;
  top: 0;
  z-index: 1030;
  background-color: rgba(255, 255, 255, 0.92) !important;
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--tm-border);
  box-shadow: 0 8px 24px -12px rgba(15, 23, 42, 0.16);
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}

.tm-navbar .navbar-brand {
  font-weight: 600;
  font-size: 1.0625rem;
  color: var(--tm-text);
  letter-spacing: -0.01em;
}

.tm-navbar .nav-link {
  color: var(--tm-text-muted);
  font-size: 0.9375rem;
  font-weight: 500;
  padding: 0.5rem 0.85rem;
  border-radius: var(--tm-radius);
  position: relative;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.tm-navbar .nav-link:hover {
  color: var(--tm-primary);
  background-color: var(--tm-primary-light);
}

.tm-navbar .nav-link.active {
  color: var(--tm-primary);
  background-color: var(--tm-primary-light);
}
.tm-navbar .nav-link.active::after {
  content: "";
  position: absolute;
  left: 0.85rem;
  right: 0.85rem;
  bottom: 0.3rem;
  height: 3px;
  border-radius: 999px;
  background: var(--tm-primary);
}

.tm-navbar .navbar-nav {
  gap: 0.2rem;
}

.tm-navbar .navbar-toggler {
  border-color: var(--tm-border);
}

.tm-navbar .dropdown-toggle {
  color: var(--tm-text);
  font-size: 0.9375rem;
}

.tm-navbar .dropdown-toggle::after {
  margin-left: 0.35rem;
}

.tm-navbar .dropdown-item {
  font-size: 0.875rem;
  padding: 0.5rem 1rem;
  border-radius: var(--tm-radius-sm);
}

.tm-navbar .dropdown-item:hover,
.tm-navbar .dropdown-item:focus {
  background-color: var(--tm-primary-light);
  color: var(--tm-primary);
}

.tm-navbar .dropdown-menu {
  border: 1px solid var(--tm-border);
  border-radius: var(--tm-radius);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
  padding: 0.375rem;
}

/* -------------------------------------------------------------------------
   Alerts
   ------------------------------------------------------------------------- */
.alert {
  border: none;
  border-radius: var(--tm-radius);
  font-size: 0.875rem;
}

.alert-success {
  background-color: #ecfdf5;
  color: #065f46;
}

.alert-info {
  background-color: var(--tm-primary-light);
  color: #1e40af;
}

.alert-danger {
  background-color: #fef2f2;
  color: #991b1b;
}

.alert-warning {
  background-color: #fffbeb;
  color: #92400e;
}

/* -------------------------------------------------------------------------
   Erreurs de validation (invalid-feedback)
   ------------------------------------------------------------------------- */
.invalid-feedback {
  font-size: 0.8125rem;
  color: #dc2626;
  margin-top: 0.25rem;
}

/* -------------------------------------------------------------------------
   .tm-page-header
   ------------------------------------------------------------------------- */
.tm-page-header {
  padding: 0;
  margin-bottom: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--tm-text);
  letter-spacing: -0.01em;
}

/* -------------------------------------------------------------------------
   .tm-content
   ------------------------------------------------------------------------- */
.tm-content {
  max-width: var(--tm-content-max-width);
  margin-left: auto;
  margin-right: auto;
  padding: var(--tm-section-padding) 1rem;
}

@media (min-width: 576px) {
  .tm-content {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }
}

@media (min-width: 992px) {
  .tm-content {
    padding-left: 2rem;
    padding-right: 2rem;
  }
}

/* -------------------------------------------------------------------------
   .tm-card
   ------------------------------------------------------------------------- */
.tm-card {
  background: var(--tm-bg-card);
  border-radius: var(--tm-radius-lg);
  border: 1px solid var(--tm-border);
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.03);
  overflow: hidden;
}

/* -------------------------------------------------------------------------
   .tm-card-form
   ------------------------------------------------------------------------- */
.tm-card-form {
  padding: 1.75rem;
  background: var(--tm-bg-card);
  border-radius: var(--tm-radius-lg);
  border: 1px solid var(--tm-border);
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.03);
}

@media (min-width: 576px) {
  .tm-card-form {
    padding: 2rem;
  }
}

/* -------------------------------------------------------------------------
   .tm-form-group
   ------------------------------------------------------------------------- */
.tm-form-group {
  margin-bottom: 1.25rem;
}

.tm-form-group:last-child {
  margin-bottom: 0;
}

/* -------------------------------------------------------------------------
   .tm-alert-inline
   ------------------------------------------------------------------------- */
.tm-alert-inline {
  margin-bottom: 1rem;
}

/* -------------------------------------------------------------------------
   .tm-auth-box
   ------------------------------------------------------------------------- */
.tm-auth-box {
  width: 100%;
  max-width: 28rem;
  margin: 1.5rem auto 0;
  padding: 1.75rem;
  background: var(--tm-bg-card);
  border-radius: var(--tm-radius-lg);
  border: 1px solid var(--tm-border);
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.03);
}

@media (min-width: 576px) {
  .tm-auth-box {
    padding: 2rem;
  }
}

/* -------------------------------------------------------------------------
   .tm-btn-group-form
   ------------------------------------------------------------------------- */
.tm-btn-group-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

/* -------------------------------------------------------------------------
   .tm-mt-section
   ------------------------------------------------------------------------- */
.tm-mt-section {
  margin-top: 2rem;
}

@media (min-width: 576px) {
  .tm-mt-section {
    margin-top: 2.5rem;
  }
}

/* -------------------------------------------------------------------------
   Header de page (layout app) et landing
   ------------------------------------------------------------------------- */
header.bg-white.border-bottom {
  background-color: var(--tm-bg-card) !important;
  border-bottom: 1px solid var(--tm-border) !important;
}

.tm-landing-header {
  border-bottom: 1px solid var(--tm-border) !important;
  background-color: var(--tm-bg-card) !important;
}

.tm-landing-header .navbar-brand span {
  color: var(--tm-text);
}

/* -------------------------------------------------------------------------
   Modals (Bootstrap)
   ------------------------------------------------------------------------- */
.modal-content {
  border: 1px solid var(--tm-border);
  border-radius: var(--tm-radius-lg);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
}

.modal-header {
  border-bottom: 1px solid var(--tm-border);
  padding: 1rem 1.25rem;
}

.modal-body {
  padding: 1.25rem;
}

.modal-footer {
  border-top: 1px solid var(--tm-border);
  padding: 1rem 1.25rem;
}

.btn-close:focus {
  box-shadow: 0 0 0 2px var(--tm-primary-focus);
}

/* -------------------------------------------------------------------------
   Utilitaires : text-muted, liens
   ------------------------------------------------------------------------- */
.text-muted {
  color: var(--tm-text-muted) !important;
}

a:not(.btn) {
  color: var(--tm-primary);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:not(.btn):hover {
  color: var(--tm-primary-hover);
}

/* -------------------------------------------------------------------------
   Loading (spinner léger, pour usage futur)
   ------------------------------------------------------------------------- */
.tm-spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid var(--tm-border);
  border-top-color: var(--tm-primary);
  border-radius: 50%;
  animation: tm-spin 0.7s linear infinite;
}

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

.tm-input-loading {
  position: relative;
}

.tm-input-loading .tm-spinner {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  margin-top: -0.5rem;
}

/* -------------------------------------------------------------------------
   Bouton stop chronomètre
   ------------------------------------------------------------------------- */
button.stop-timer-btn {
  background: #dc3545;
  border: 1px solid #c82333;
  width: 16px;
  height: 16px;
  border-radius: 3px;
  padding: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

button.stop-timer-btn:hover {
  background: #c82333;
  border-color: #bd2130;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transform: translateY(-1px);
}

button.stop-timer-btn:active {
  background: #bd2130;
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

button.stop-timer-btn:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.25);
}

.nowarp {
  white-space: nowrap !important;
}

.fw-500 {
  font-weight: 500 !important;
}

.fw-600 {
  font-weight: 600 !important;
}

.fw-700 {
  font-weight: 700 !important;
}

/* -------------------------------------------------------------------------
   Support Tickets - Page "show" (chat layout)
   - Basé sur le template support-ticket.html
   - Palette alignée sur les variables --tm-* (thème TaskManager)
   ------------------------------------------------------------------------- */
:root {
  --st-bg: var(--tm-bg-page);
  --st-surface: var(--tm-bg-card);
  --st-surface-alt: var(--tm-primary-light);
  --st-border: var(--tm-border);
  --st-text: var(--tm-text);
  --st-text-muted: var(--tm-text-muted);
  --st-accent: var(--tm-primary);
  --st-accent-light: var(--tm-primary-light);
  --st-accent-dark: var(--tm-primary-hover);
  --st-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  --st-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.st-page {
  display: flex;
  height: calc(100vh - 75px);
  background: var(--st-bg);
}

/* Conversation Wrapper */
.st-conv-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--st-surface);
  border: 1px solid var(--st-border);
  border-radius: 12px;
  overflow: hidden;
}

.st-conv-header {
  padding: 18px 28px;
  border-bottom: 1px solid var(--st-border);
  background: var(--st-surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.st-conv-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.st-ticket-badge {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  font-weight: 600;
  background: #f8fafc;
  border: 1px solid var(--st-border);
  border-radius: 6px;
  padding: 3px 10px;
  color: var(--st-text-muted);
}

.st-conv-header h2 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  color: #1e293b;
}

.st-status-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
}

.st-status-tag.open {
  background: #dbeafe;
  color: #1e40af;
}

.st-status-tag.pending {
  background: #fef3c7;
  color: #92400e;
}

.st-status-tag.closed {
  background: #f1f5f9;
  color: #475569;
}

.st-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

/* Messages */
.st-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scroll-behavior: smooth;
  background: #f1ebe3;
}

.st-messages::-webkit-scrollbar {
  width: 6px;
}

.st-messages::-webkit-scrollbar-track {
  background: transparent;
}

.st-messages::-webkit-scrollbar-thumb {
  background: #9E9E9E;
  border-radius: 3px;
}

.st-msg {
  display: flex;
  gap: 12px;
  max-width: 95%;
}

.st-msg.agent {
  align-self: flex-start;
}

.st-msg.client {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.st-msg-avatar {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  color: #475569;
}

.st-msg-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.st-msg-meta {
  font-size: 11px;
  color: var(--st-text-muted);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.st-msg.client .st-msg-meta {
  flex-direction: row-reverse;
}

.st-msg-block.client {
  position: relative;
}
.st-msg-seen {
  position: absolute;
  bottom: 6px;
  right: 8px;
  font-size: 12px;
  color: #2563eb;
  opacity: 0.95;
}

/* Bloc message = bulle + footer pièces jointes */
.st-msg-block {
  max-width: 520px;
  overflow: hidden;
  border-radius: 8px;
  box-shadow: var(--st-shadow);
}

.st-msg-block.agent {
  border-top-left-radius: 4px;
}

.st-msg-block.client {
  border-top-right-radius: 4px;
}

.st-msg-bubble {
  padding: 12px 16px;
  border-radius: 0;
  font-size: 14px;
  line-height: 1.55;
}

/* Bulle seule (sans footer) : garder les bords arrondis */
.st-msg-block:not(:has(.st-msg-footer)) .st-msg-bubble {
  border-radius: 16px;
}

.st-msg-block.agent:not(:has(.st-msg-footer)) .st-msg-bubble {
  border-top-left-radius: 4px;
}

.st-msg-block.client:not(:has(.st-msg-footer)) .st-msg-bubble {
  border-top-right-radius: 4px;
}

/* Left (agence) */
.st-msg-bubble.agent,
.st-msg-block.agent .st-msg-bubble {
  background: #ffffff;
  border: 1px solid var(--st-border);
  border-bottom: none;
  color: var(--st-text);
}

.st-msg-block.agent:not(:has(.st-msg-footer)) .st-msg-bubble {
  border-bottom: 1px solid var(--st-border);
}

/* Right (support) */
.st-msg-bubble.client,
.st-msg-block.client .st-msg-bubble {
  background: var(--bg-support-message);
  border: none;
  color: #000000;
}

.st-msg-block.client:not(:has(.st-msg-footer)) .st-msg-bubble {
  border: none;
}

/* Footer pièces jointes – fond plus léger */
.st-msg-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px;
  border: 1px solid transparent;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.st-msg-block.agent .st-msg-footer {
  background: #f8fafc;
  border-color: var(--st-border);
  border-top-color: var(--st-border);
}

.st-msg-block.client .st-msg-footer {
  background: var(--bg-support-message);
 
}

.st-attachment {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
  text-decoration: none;
  color: inherit;
  transition: opacity 0.15s, background 0.15s;
}

.st-attachment:hover {
  opacity: 0.95;
}

.st-msg-block.agent .st-attachment {
  background: #fff;
  border: 1px solid var(--st-border);
  color: var(--st-text);
}

.st-msg-block.agent .st-attachment:hover {
  background: #f1f5f9;
}

.st-msg-block.client .st-attachment:hover {
  background: rgba(255, 255, 255, 0.35);
}

.st-attachment-image-wrap {
  margin-top: 6px;
}

.st-attachment-image-preview {
  max-height: 120px;
  max-width: 280px;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
  cursor: pointer;
  display: block;
  vertical-align: middle;
  box-shadow: 0px 2px 7px #00000026;
}

.st-image-popup-link {
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

/* Lightbox */
.st-lightbox {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.85);
  padding: 20px;
}

.st-lightbox[aria-hidden="false"] {
  display: flex;
}

.st-lightbox-backdrop {
  position: absolute;
  inset: 0;
  cursor: pointer;
}

.st-lightbox-close {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10001;
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  color: #374151;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  transition: background 0.15s, color 0.15s;
}

.st-lightbox-close:hover {
  background: #fff;
  color: #000;
}

.st-lightbox-img-wrap {
  position: relative;
  z-index: 1;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.st-lightbox-img-wrap img {
  max-width: 90vw;
  max-height: 90vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
}

/* Input Area */
.st-input-area {
  border-top: 1px solid var(--st-border);
  background: var(--st-surface);
  padding: 16px 24px;
}

.st-input-form {
  width: 100%;
}

.st-input-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  width: 100%;
}

.st-input-row-btn {
  flex-shrink: 0;
}

.st-input-row-textarea {
  flex: 1;
  min-width: 0;
  width: 100%;
}

.st-file-name-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--st-border);
}

.st-file-preview-wrap {
  flex-shrink: 0;
  border: 1px solid #ccc;
  padding: 4px;
  border-radius: 8px;
}

.st-file-clear-btn {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--st-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
}

.st-file-clear-btn:hover {
  color: #dc2626;
  background: #fef2f2;
}

.st-file-clear-btn i {
  font-size: 12px;
}

.st-input-box {
  min-height: 40px;
  border: 1px solid var(--st-border);
  border-radius: 12px;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 14px;
  resize: none;
  outline: none;
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.st-input-box:focus {
  border-color: var(--tm-border-focus);
  box-shadow: 0 0 0 3px var(--tm-primary-focus);
}

.st-file-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.st-btn-icon {
  width: 36px;
  height: 36px;
  border: 1px solid var(--st-border);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--st-text-muted);
  transition: border-color 0.15s, color 0.15s;
}

.st-btn-icon:hover {
  border-color: var(--st-accent);
  color: var(--st-accent);
}

.st-btn-send {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: green;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 9px 20px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  box-shadow: var(--st-shadow);
  flex-shrink: 0;
}

.st-btn-send-icon-only {
  padding: 10px;
  width: 40px;
  height: 40px;
}

.st-btn-send-icon-only .st-btn-send-icon {
  font-size: 1.1rem;
}

.st-btn-send:hover {
  background: #059669; /* Adapted to green (emerald-600) */
}

.st-btn-send:disabled {
  opacity: 0.85;
  cursor: not-allowed;
  pointer-events: none;
}

.st-btn-send-spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: tm-spin 0.7s linear infinite;
  flex-shrink: 0;
}

.st-btn-send-spinner.st-btn-send-spinner-visible {
  display: inline-block;
}

/* Sidebar */
.st-sidebar {
  width: 300px;
  border: 1px solid var(--st-border);
  background: var(--st-surface);
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  border-radius: 12px;
  margin-left: 16px;
}

.st-sidebar-header {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--st-border);
}

.st-sidebar-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--st-text);
  margin: 0;
  line-height: 1.35;
  word-break: break-word;
}

.st-sidebar::-webkit-scrollbar {
  width: 5px;
}

.st-sidebar::-webkit-scrollbar-thumb {
  background: var(--st-border);
  border-radius: 3px;
}

.st-sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.st-sidebar-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--st-text-muted);
}

.st-contact-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  background: #f8fafc;
  border-radius: 12px;
  border: 1px solid var(--st-border);
}

.st-contact-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: #475569;
  flex-shrink: 0;
}

.st-contact-info h3 {
  font-size: 14px;
  font-weight: 700;
  margin: 0;
  color: #1e293b;
}

.st-contact-info p {
  font-size: 12px;
  color: var(--st-text-muted);
  margin: 0;
}

.st-detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--st-border);
}

.st-detail-row:last-child {
  border-bottom: none;
}

.st-detail-label {
  font-size: 12px;
  color: var(--st-text-muted);
  font-weight: 600;
}

.st-detail-value {
  font-size: 13px;
  font-weight: 600;
}

.st-form-select {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--st-border);
  border-radius: 8px;
  font-size: 13px;
  background: #fff;
  cursor: pointer;
}

.st-form-select:focus {
  outline: none;
  border-color: var(--tm-border-focus);
  box-shadow: 0 0 0 3px var(--tm-primary-focus);
}

@media (max-width: 991px) {
  .st-page {
    flex-direction: column;
    height: auto;
  }

  .st-sidebar {
    width: 100%;
    margin-left: 0;
    margin-top: 16px;
  }

  .st-msg {
    max-width: 95%;
  }
}
