/* ==========================================================================
   Tango Télécom — CRM Partenaires
   ========================================================================== */

:root {
  --tt-dark: #1c1420;
  --tt-dark-2: #271b2d;
  --tt-orange: #f26522;
  --tt-orange-2: #fb8a3c;
  --tt-orange-light: #fff1e6;
  --tt-bg: #f6f4f2;
  --tt-card: #ffffff;
  --tt-text: #241c28;
  --tt-text-muted: #847c8c;
  --tt-border: #ebe6e9;
  --tt-blue: #2f6fed;
  --tt-blue-light: #e9f0fe;
  --tt-amber: #d98c1f;
  --tt-amber-light: #fdf1dd;
  --tt-green: #1f9d55;
  --tt-green-light: #e5f8ec;
  --tt-red: #d64545;
  --tt-red-light: #fbe9e9;
  --tt-yellow: #b58900;
  --tt-yellow-light: #fdf6d8;
  --tt-purple: #6d4fc4;
  --tt-purple-light: #ece7fa;
  --tt-gray-light: #f0eef1;
  --shadow-card: 0 1px 2px rgba(28, 20, 32, 0.04), 0 4px 16px rgba(28, 20, 32, 0.05);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  color: var(--tt-text);
  background: var(--tt-bg);
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* ---------------------------------------------------------------------- */
/* Auth pages (login / update password)                                   */
/* ---------------------------------------------------------------------- */

.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 12% 18%, rgba(242, 101, 34, 0.14), transparent 40%),
    radial-gradient(circle at 88% 82%, rgba(242, 101, 34, 0.10), transparent 45%),
    linear-gradient(160deg, var(--tt-dark) 0%, var(--tt-dark-2) 55%, #32202b 100%);
  padding: 32px 16px;
}

.auth-wrap {
  width: 100%;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.auth-logo-card {
  background: #fff;
  border-radius: 18px;
  padding: 18px 28px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
  margin-bottom: 28px;
}

.auth-logo-img {
  display: block;
  height: 44px;
  width: auto;
}

.auth-card {
  width: 100%;
  background: var(--tt-card);
  border-radius: 20px;
  padding: 36px 32px 32px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.auth-title {
  margin: 0 0 6px;
  font-size: 26px;
  font-weight: 800;
  color: var(--tt-dark);
  text-align: center;
}

.auth-subtitle {
  margin: 0 0 28px;
  text-align: center;
  color: var(--tt-text-muted);
  font-size: 14px;
}

.field {
  position: relative;
  display: flex;
  align-items: center;
  border: 1.5px solid var(--tt-border);
  border-radius: 12px;
  margin-bottom: 16px;
  background: #fff;
  transition: border-color 0.15s ease;
}

.field:focus-within {
  border-color: var(--tt-orange);
}

.field-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  color: var(--tt-text-muted);
  flex-shrink: 0;
}

.field input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  padding: 14px 14px 14px 0;
  font-size: 14px;
  color: var(--tt-text);
}

.form-error {
  background: var(--tt-red-light);
  color: var(--tt-red);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  margin: 0 0 16px;
}

.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(135deg, var(--tt-orange-2), var(--tt-orange));
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 15px 20px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.04em;
  box-shadow: 0 8px 20px rgba(242, 101, 34, 0.3);
  transition: filter 0.15s ease, transform 0.15s ease;
}

.btn-primary:hover { filter: brightness(1.05); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-block { width: 100%; }

.auth-footer {
  margin-top: 24px;
  color: rgba(255, 255, 255, 0.55);
  font-size: 12.5px;
  text-align: center;
}

/* ---------------------------------------------------------------------- */
/* App shell                                                              */
/* ---------------------------------------------------------------------- */

.app-body { background: var(--tt-bg); }

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 250px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--tt-dark) 0%, var(--tt-dark-2) 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-logo {
  background: #fff;
  border-radius: 12px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
}

.sidebar-logo img { height: 30px; width: auto; display: block; }

.sidebar-nav { display: flex; flex-direction: column; gap: 4px; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.72);
}

.nav-link.active {
  background: var(--tt-orange);
  color: #fff;
}

.sidebar-spacer { flex: 1; }

.sidebar-user {
  padding: 12px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 8px;
}

.sidebar-user-name { font-size: 13.5px; font-weight: 700; color: #fff; }
.sidebar-user-email {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.55);
  margin-top: 2px;
  word-break: break-all;
}

.sidebar-logout {
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: rgba(255, 255, 255, 0.85);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
}

.sidebar-logout:hover { background: rgba(255, 255, 255, 0.08); }

.main {
  flex: 1;
  min-width: 0;
  padding: 28px 32px 60px;
}

.main-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.main-title {
  margin: 0;
  font-size: 26px;
  font-weight: 800;
  color: var(--tt-dark);
}

.main-subtitle {
  margin: 4px 0 0;
  color: var(--tt-text-muted);
  font-size: 14px;
}

.main-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.main-header-actions .btn-primary {
  width: auto;
  padding: 10px 16px;
  font-size: 13.5px;
  border-radius: 10px;
  box-shadow: none;
}

.btn-ghost {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid var(--tt-border);
  color: var(--tt-text);
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: var(--shadow-card);
}

.btn-ghost:hover { background: var(--tt-gray-light); }

.btn-secondary {
  background: var(--tt-dark);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 11px 16px;
  font-size: 13.5px;
  font-weight: 700;
}

.btn-secondary:hover { filter: brightness(1.15); }

/* ---------------------------------------------------------------------- */
/* KPI cards                                                              */
/* ---------------------------------------------------------------------- */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--tt-card);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow-card);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.kpi-label { font-size: 13px; color: var(--tt-text-muted); font-weight: 600; }
.kpi-value { font-size: 28px; font-weight: 800; color: var(--tt-dark); margin-top: 4px; }
.kpi-hint { font-size: 12px; color: var(--tt-text-muted); margin-top: 4px; }

.kpi-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.kpi-icon-blue { background: var(--tt-blue-light); color: var(--tt-blue); }
.kpi-icon-amber { background: var(--tt-amber-light); color: var(--tt-amber); }
.kpi-icon-green { background: var(--tt-green-light); color: var(--tt-green); }
.kpi-icon-navy { background: var(--tt-orange-light); color: var(--tt-orange); }

/* ---------------------------------------------------------------------- */
/* Charts                                                                 */
/* ---------------------------------------------------------------------- */

.chart-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-bottom: 20px;
}

.chart-card {
  background: var(--tt-card);
  border-radius: 16px;
  padding: 18px 18px 10px;
  box-shadow: var(--shadow-card);
}

.chart-card h3 {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 700;
  color: var(--tt-dark);
}

.chart-wrap { height: 190px; position: relative; }

/* ---------------------------------------------------------------------- */
/* Leads section                                                         */
/* ---------------------------------------------------------------------- */

.leads-section {
  background: var(--tt-card);
  border-radius: 16px;
  padding: 22px;
  box-shadow: var(--shadow-card);
}

.leads-header h2 { margin: 0; font-size: 18px; font-weight: 800; color: var(--tt-dark); }
.leads-count { margin: 2px 0 0; font-size: 13px; color: var(--tt-text-muted); }

.leads-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 18px 0;
}

.search-field {
  flex: 1;
  min-width: 240px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--tt-gray-light);
  border: 1px solid var(--tt-border);
  border-radius: 10px;
  padding: 0 12px;
  color: var(--tt-text-muted);
}

.search-field input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  padding: 11px 0;
  font-size: 13.5px;
  color: var(--tt-text);
}

.select-pill {
  border: 1px solid var(--tt-border);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--tt-text);
  background: #fff;
}

.table-wrap { overflow-x: auto; border-radius: 12px; border: 1px solid var(--tt-border); }

.leads-table { width: 100%; border-collapse: collapse; min-width: 1200px; }

.leads-table thead th {
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--tt-text-muted);
  background: var(--tt-gray-light);
  padding: 12px 14px;
  white-space: nowrap;
  border-bottom: 1px solid var(--tt-border);
}

.leads-table tbody td {
  padding: 13px 14px;
  font-size: 13.5px;
  color: var(--tt-text);
  border-bottom: 1px solid var(--tt-border);
  vertical-align: top;
}

.leads-table tbody tr { cursor: pointer; transition: background 0.1s ease; }
.leads-table tbody tr:hover { background: var(--tt-orange-light); }
.leads-table tbody tr:last-child td { border-bottom: none; }

.cell-strong { font-weight: 700; color: var(--tt-dark); }
.cell-muted { color: var(--tt-text-muted); font-size: 12.5px; }
.cell-id { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; color: var(--tt-text-muted); }

.table-empty {
  text-align: center;
  padding: 40px 14px !important;
  color: var(--tt-text-muted);
  cursor: default !important;
}

.status-select,
.vendeur-select {
  border: 1px solid var(--tt-border);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 700;
  background: #fff;
  color: var(--tt-text);
}

.status-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}

.status-nouveau { background: var(--tt-blue-light); color: var(--tt-blue); }
.status-contacte { background: var(--tt-amber-light); color: var(--tt-amber); }
.status-suivi-chaud { background: var(--tt-blue-light); color: var(--tt-blue); }
.status-suivi-tiede { background: var(--tt-yellow-light); color: var(--tt-yellow); }
.status-futur-suivi { background: var(--tt-purple-light); color: var(--tt-purple); }
.status-pas-repondu { background: var(--tt-gray-light); color: var(--tt-text-muted); }
.status-prix-cher { background: #fdeee0; color: #b9611a; }
.status-pas-interesse { background: var(--tt-gray-light); color: #8a6a75; }
.status-spam { background: var(--tt-red-light); color: var(--tt-red); }
.status-vendu { background: var(--tt-green-light); color: var(--tt-green); }

/* Surbrillance de ligne : retard de suivi (rouge) prime sur chaud/tiède */
.leads-table tbody tr.row-overdue,
.leads-table tbody tr.row-rejected { background: var(--tt-red-light); }
.leads-table tbody tr.row-overdue:hover,
.leads-table tbody tr.row-rejected:hover { background: #f7d9d9; }
.leads-table tbody tr.row-hot { background: var(--tt-blue-light); }
.leads-table tbody tr.row-hot:hover { background: #d6e4fc; }
.leads-table tbody tr.row-warm { background: var(--tt-yellow-light); }
.leads-table tbody tr.row-warm:hover { background: #faecb0; }

.date-input {
  border: 1px solid var(--tt-border);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 12px;
  background: #fff;
  color: var(--tt-text);
  min-width: 140px;
}

.attempts-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

.attempts-count {
  font-size: 13px;
  font-weight: 700;
  color: var(--tt-dark);
  min-width: 14px;
  text-align: center;
}

.attempts-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: var(--tt-orange);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.attempts-btn:hover { filter: brightness(1.1); }
.attempts-btn:disabled { background: var(--tt-border); color: var(--tt-text-muted); cursor: not-allowed; }

.cell-amounts { margin-top: 6px; display: flex; flex-direction: column; gap: 3px; }
.cell-value { font-size: 12px; font-weight: 700; color: var(--tt-dark); white-space: nowrap; }
.cell-commission { color: var(--tt-green); }

.amount-label {
  display: inline-block;
  min-width: 62px;
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--tt-text-muted);
  margin-right: 6px;
}

/* ---------------------------------------------------------------------- */
/* Modal                                                                  */
/* ---------------------------------------------------------------------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(28, 20, 32, 0.55);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 16px;
  z-index: 100;
  overflow-y: auto;
}

.modal-overlay[hidden] { display: none; }

.modal {
  width: 100%;
  max-width: 560px;
  background: #fff;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

.modal-narrow { max-width: 420px; }

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 22px;
  background: linear-gradient(135deg, var(--tt-dark), var(--tt-dark-2));
  color: #fff;
}

.modal-header h3 { margin: 0; font-size: 18px; font-weight: 800; }
.modal-sub { margin-top: 4px; font-size: 12.5px; color: rgba(255, 255, 255, 0.65); }

.modal-close {
  background: rgba(255, 255, 255, 0.12);
  border: none;
  color: #fff;
  border-radius: 8px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.modal-body {
  padding: 20px 22px;
  max-height: 65vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-block {
  background: var(--tt-gray-light);
  border-radius: 12px;
  padding: 16px;
}

.modal-block-highlight {
  background: var(--tt-orange-light);
  border: 1px dashed var(--tt-orange-2);
}

.modal-block label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--tt-dark);
  margin-bottom: 8px;
}

.modal-block textarea,
.modal-block input,
.modal-block select {
  width: 100%;
  border: 1px solid var(--tt-border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13.5px;
  color: var(--tt-text);
  background: #fff;
  resize: vertical;
}

.modal-block-highlight .btn-primary {
  margin-top: 10px;
  width: auto;
  padding: 10px 18px;
  font-size: 12.5px;
}

.modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.modal-grid-save { grid-column: 1 / -1; }

.modal-block h4 {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 800;
  color: var(--tt-dark);
}

.modal-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
}

.modal-info-grid > div { display: flex; flex-direction: column; gap: 3px; }

.info-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--tt-text-muted);
  font-weight: 700;
}

.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--tt-border);
  display: flex;
  justify-content: flex-end;
}

.modal-footer-split { justify-content: space-between; }

/* ---------------------------------------------------------------------- */
/* Responsive                                                             */
/* ---------------------------------------------------------------------- */

@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .chart-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: relative; flex-direction: row; align-items: center; flex-wrap: wrap; }
  .sidebar-spacer { display: none; }
  .sidebar-user { display: none; }
  .main { padding: 20px 16px 40px; }
  .kpi-grid { grid-template-columns: 1fr; }
  .modal-grid, .modal-info-grid { grid-template-columns: 1fr; }
}
