/* Tradex Tracking Management — copie 1:1 du preview React
   Scope: .tradex-tm (haute spécificité pour Hello Elementor) */

#tradex-tm.tradex-tm,
#tradex-tm.tradex-tm * {
  box-sizing: border-box;
}

#tradex-tm.tradex-tm {
  --tm-bg:        #f7f8fb;
  --tm-fg:        #1a1f2e;
  --tm-card:      #ffffff;
  --tm-muted:     #6b7280;
  --tm-border:    #e6e8ee;
  --tm-primary:   #dc2626; /* Tradex red */
  --tm-primary-h: #b91c1c;
  --tm-dark:      #111827;
  --tm-accent:    #eef1f6;
  --tm-radius:    14px;
  --tm-shadow:    0 6px 24px -10px rgba(17,24,39,.18);

  /* status palette */
  --st-conf-fg:#2563eb; --st-conf-bg:#dbeafe;
  --st-disp-fg:#7c3aed; --st-disp-bg:#ede9fe;
  --st-tran-fg:#0891b2; --st-tran-bg:#cffafe;
  --st-out-fg:#9333ea;  --st-out-bg:#f3e8ff;
  --st-deli-fg:#16a34a; --st-deli-bg:#dcfce7;

  font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
  color: var(--tm-fg);
  background: transparent;
  padding: 24px 0;
  -webkit-font-smoothing: antialiased;
}

#tradex-tm .tradex-tm__container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ---------- Top grid ---------- */
#tradex-tm .tradex-tm__grid-top {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}
@media (min-width: 900px) {
  #tradex-tm .tradex-tm__grid-top {
    grid-template-columns: 3fr 6fr 3fr;
  }
}

#tradex-tm .tradex-tm__card {
  background: var(--tm-card);
  border: 1px solid var(--tm-border);
  border-radius: var(--tm-radius);
  padding: 28px;
  box-shadow: var(--tm-shadow);
}

/* Add card */
#tradex-tm .tradex-tm__card--add {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
}
#tradex-tm .tradex-tm__icon-circle {
  width: 64px; height: 64px;
  border-radius: 999px;
  background: var(--tm-accent);
  color: var(--tm-dark);
  display: grid; place-items: center;
}
#tradex-tm .tradex-tm__card--add h2 {
  font-size: 18px; font-weight: 600; margin: 6px 0 0; color: var(--tm-fg);
}
#tradex-tm .tradex-tm__card--add p {
  font-size: 13px; color: var(--tm-muted); margin: 0; line-height: 1.45;
}

/* Track card */
#tradex-tm .tradex-tm__card--track h2 {
  font-size: 20px; font-weight: 600; margin: 0; color: var(--tm-fg);
}
#tradex-tm .tradex-tm__card--track p {
  font-size: 13px; color: var(--tm-muted); margin: 6px 0 0;
}
#tradex-tm .tradex-tm__track-form {
  display: flex; gap: 8px; margin-top: 20px;
}
#tradex-tm .tradex-tm__input-wrap {
  position: relative; flex: 1;
}
#tradex-tm .tradex-tm__search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--tm-muted); pointer-events: none;
}
#tradex-tm .tradex-tm__input-wrap input {
  width: 100%; height: 44px;
  padding: 0 12px 0 36px;
  border: 1px solid var(--tm-border);
  border-radius: 10px;
  background: #fff; color: var(--tm-fg);
  font-size: 14px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
#tradex-tm .tradex-tm__input-wrap input:focus {
  border-color: var(--tm-primary);
  box-shadow: 0 0 0 3px rgba(220,38,38,.15);
}
#tradex-tm .tradex-tm__hint {
  font-size: 12px; color: var(--tm-muted); margin: 12px 0 0;
}

/* Hero card */
#tradex-tm .tradex-tm__card--hero {
  display: none;
  padding: 28px;
  background: var(--tm-card);
  border: 1px solid var(--tm-border);
  box-shadow: var(--tm-shadow);
  overflow: hidden;
}
@media (min-width: 900px) {
  #tradex-tm .tradex-tm__card--hero { display: flex; align-items: center; justify-content: center; }
}
#tradex-tm .tradex-tm__hero-image {
  width: 100%; height: auto; max-height: 320px; object-fit: cover;
  border-radius: var(--tm-radius); display: block;
}

/* Buttons */
#tradex-tm .tradex-tm__btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 18px;
  border-radius: 10px; border: 1px solid transparent;
  font-size: 14px; font-weight: 600;
  cursor: pointer; line-height: 1;
  transition: background .15s, transform .05s, box-shadow .15s, color .15s;
  text-decoration: none;
}
#tradex-tm .tradex-tm__btn:active { transform: translateY(1px); }
#tradex-tm .tradex-tm__btn--primary {
  background: var(--tm-primary); color: #fff;
}
#tradex-tm .tradex-tm__btn--primary:hover { background: var(--tm-primary-h); }
#tradex-tm .tradex-tm__btn--dark {
  background: var(--tm-dark); color: #fff;
}
#tradex-tm .tradex-tm__btn--dark:hover { background: #000; }
#tradex-tm .tradex-tm__btn--ghost {
  background: var(--tm-accent); color: var(--tm-fg);
}
#tradex-tm .tradex-tm__btn--ghost:hover { background: #dde2eb; }
#tradex-tm .tradex-tm__card--add .tradex-tm__btn { width: 100%; margin-top: 6px; }

/* ---------- Table ---------- */
#tradex-tm .tradex-tm__table-card { padding: 24px; }
#tradex-tm .tradex-tm__table-head {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px;
}
#tradex-tm .tradex-tm__table-head h2 {
  font-size: 18px; font-weight: 600; margin: 0; color: var(--tm-fg);
}
#tradex-tm .tradex-tm__count { font-size: 12px; color: var(--tm-muted); }

#tradex-tm .tradex-tm__table-wrap { overflow-x: auto; }
#tradex-tm .tradex-tm__table {
  width: 100%; border-collapse: collapse; font-size: 14px;
}
#tradex-tm .tradex-tm__table thead th {
  text-align: left; font-weight: 500; color: var(--tm-muted);
  padding: 12px; border-bottom: 1px solid var(--tm-border);
  background: transparent;
}
#tradex-tm .tradex-tm__table tbody td {
  padding: 14px 12px; border-bottom: 1px solid var(--tm-border); color: var(--tm-fg);
  vertical-align: middle;
}
#tradex-tm .tradex-tm__table tbody tr:hover { background: #fafbfd; }
#tradex-tm .tradex-tm__table .tradex-tm__td-id { font-weight: 600; }
#tradex-tm .tradex-tm__table .tradex-tm__td-date { color: var(--tm-muted); }
#tradex-tm .tradex-tm__empty { text-align: center; padding: 48px 12px; color: var(--tm-muted); }

/* Status select styled like a badge */
#tradex-tm .tradex-tm__status-select {
  appearance: none; -webkit-appearance: none;
  height: 36px; min-width: 170px;
  padding: 0 32px 0 12px;
  border-radius: 8px; border: 1px solid transparent;
  font-size: 13px; font-weight: 600; cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
#tradex-tm .st-Order-Confirmed   { color: var(--st-conf-fg); background-color: var(--st-conf-bg); }
#tradex-tm .st-Dispatched        { color: var(--st-disp-fg); background-color: var(--st-disp-bg); }
#tradex-tm .st-In-Transit        { color: var(--st-tran-fg); background-color: var(--st-tran-bg); }
#tradex-tm .st-Out-for-Delivery  { color: var(--st-out-fg);  background-color: var(--st-out-bg);  }
#tradex-tm .st-Delivered         { color: var(--st-deli-fg); background-color: var(--st-deli-bg); }

/* Action icons */
#tradex-tm .tradex-tm__actions { display: inline-flex; gap: 4px; }
#tradex-tm .tradex-tm__icon-btn {
  width: 32px; height: 32px;
  display: inline-grid; place-items: center;
  background: transparent; border: none; cursor: pointer;
  color: var(--tm-muted); border-radius: 8px;
}
#tradex-tm .tradex-tm__icon-btn:hover { background: var(--tm-accent); color: var(--tm-fg); }
#tradex-tm .tradex-tm__icon-btn--view { color: #2563eb; }
#tradex-tm .tradex-tm__icon-btn--view:hover { background: rgba(37,99,235,.1); color: #2563eb; }
#tradex-tm .tradex-tm__icon-btn--danger { color: var(--tm-primary); }
#tradex-tm .tradex-tm__icon-btn--danger:hover { background: rgba(220,38,38,.1); color: var(--tm-primary); }

/* Hide on mobile */
#tradex-tm .tradex-tm__hide-mobile {
  display: table-cell;
}

/* Show only on mobile */
#tradex-tm .tradex-tm__show-mobile-only {
  display: none;
}

@media (max-width: 768px) {
  #tradex-tm .tradex-tm__hide-mobile {
    display: none;
  }
  #tradex-tm .tradex-tm__show-mobile-only {
    display: inline-grid;
  }
  #tradex-tm .tradex-tm__table thead th {
    font-size: 12px; padding: 10px 8px;
  }
  #tradex-tm .tradex-tm__table tbody td {
    padding: 12px 8px;
  }
  #tradex-tm .tradex-tm__td-client {
    font-weight: 600;
  }
  #tradex-tm .tradex-tm__td-action {
    text-align: center;
  }
}

/* ---------- Modal ---------- */
#tradex-tm .tradex-tm__modal {
  position: fixed; inset: 0; z-index: 99999;
  display: none; align-items: center; justify-content: center;
  padding: 16px;
}
#tradex-tm .tradex-tm__modal.is-open { display: flex; }
#tradex-tm .tradex-tm__modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(15,23,42,.55);
  backdrop-filter: blur(4px);
  animation: tm-fade .15s ease-out;
}
#tradex-tm .tradex-tm__modal-dialog {
  position: relative;
  width: 100%; max-width: 460px;
  background: #fff; border-radius: 16px;
  box-shadow: 0 30px 60px -20px rgba(0,0,0,.35);
  padding: 24px;
  animation: tm-pop .18s ease-out;
}
@keyframes tm-fade { from{opacity:0} to{opacity:1} }
@keyframes tm-pop  { from{opacity:0; transform: translateY(8px) scale(.98)} to{opacity:1; transform:none} }

#tradex-tm .tradex-tm__modal-header h3 {
  margin: 0; font-size: 18px; font-weight: 600; color: var(--tm-fg);
}
#tradex-tm .tradex-tm__modal-header p {
  margin: 6px 0 0; font-size: 13px; color: var(--tm-muted);
}

#tradex-tm .tradex-tm__form { margin-top: 18px; display: flex; flex-direction: column; gap: 14px; }
#tradex-tm .tradex-tm__field { display: flex; flex-direction: column; gap: 6px; }
#tradex-tm .tradex-tm__field label {
  font-size: 13px; font-weight: 500; color: var(--tm-fg);
}
#tradex-tm .tradex-tm__field input,
#tradex-tm .tradex-tm__field select {
  height: 42px; padding: 0 12px;
  border: 1px solid var(--tm-border); border-radius: 10px;
  background: #fff; color: var(--tm-fg);
  font-size: 14px; outline: none; width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
#tradex-tm .tradex-tm__field input:focus,
#tradex-tm .tradex-tm__field select:focus {
  border-color: var(--tm-primary);
  box-shadow: 0 0 0 3px rgba(220,38,38,.15);
}
#tradex-tm .tradex-tm__modal-footer {
  display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px;
}

/* ---------- Detail Modal Content ---------- */
#tradex-tm .tradex-tm__detail-content {
  display: flex; flex-direction: column; gap: 16px; margin: 16px 0;
}
#tradex-tm .tradex-tm__detail-row {
  display: flex; flex-direction: column; gap: 6px;
}
#tradex-tm .tradex-tm__detail-row label {
  font-size: 12px; font-weight: 600; color: var(--tm-muted); text-transform: uppercase; letter-spacing: 0.5px;
}
#tradex-tm .tradex-tm__detail-value {
  font-size: 14px; color: var(--tm-fg); font-weight: 500; padding: 8px; background: var(--tm-accent); border-radius: 8px;
}
#tradex-tm .tradex-tm__detail-select {
  height: 40px; padding: 0 12px;
  border: 1px solid var(--tm-border); border-radius: 8px;
  background: #fff; color: var(--tm-fg);
  font-size: 14px; cursor: pointer; outline: none;
  transition: border-color .15s, box-shadow .15s;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}
#tradex-tm .tradex-tm__detail-select:focus {
  border-color: var(--tm-primary);
  box-shadow: 0 0 0 3px rgba(220,38,38,.15);
}

/* Button variants */
#tradex-tm .tradex-tm__btn--danger-outline {
  background: transparent; color: var(--tm-primary);
  border: 1px solid var(--tm-primary);
}
#tradex-tm .tradex-tm__btn--danger-outline:hover {
  background: rgba(220,38,38,.1);
}

/* ---------- Toasts ---------- */
#tradex-tm .tradex-tm__toasts {
  position: fixed; top: 20px; right: 20px; z-index: 100000;
  display: flex; flex-direction: column; gap: 10px;
}
#tradex-tm .tradex-tm__toast {
  min-width: 260px; max-width: 360px;
  background: #fff; color: var(--tm-fg);
  border: 1px solid var(--tm-border); border-left: 4px solid var(--tm-dark);
  border-radius: 10px; padding: 12px 14px;
  box-shadow: 0 12px 30px -12px rgba(0,0,0,.25);
  font-size: 13px;
  animation: tm-slide .2s ease-out;
}
#tradex-tm .tradex-tm__toast--success { border-left-color: #16a34a; }
#tradex-tm .tradex-tm__toast--error   { border-left-color: var(--tm-primary); }
#tradex-tm .tradex-tm__toast strong { display: block; font-weight: 600; margin-bottom: 2px; }
@keyframes tm-slide { from{opacity:0; transform: translateX(20px)} to{opacity:1; transform:none} }

/* ---------- Button variants ---------- */
#tradex-tm .tradex-tm__btn--danger-outline {
  background: transparent; color: var(--tm-primary);
  border: 1px solid var(--tm-primary);
}
#tradex-tm .tradex-tm__btn--danger-outline:hover {
  background: rgba(220,38,38,.1);
}

/* ---------- Detail Modal Content ---------- */
#tradex-tm .tradex-tm__detail-content {
  display: flex; flex-direction: column; gap: 16px; margin: 16px 0;
}
#tradex-tm .tradex-tm__detail-row {
  display: flex; flex-direction: column; gap: 6px;
}
#tradex-tm .tradex-tm__detail-row label {
  font-size: 12px; font-weight: 600; color: var(--tm-muted); text-transform: uppercase; letter-spacing: 0.5px;
}
#tradex-tm .tradex-tm__detail-value {
  font-size: 14px; color: var(--tm-fg); font-weight: 500; padding: 8px; background: var(--tm-accent); border-radius: 8px;
}
#tradex-tm .tradex-tm__detail-select {
  height: 40px; padding: 0 12px;
  border: 1px solid var(--tm-border); border-radius: 8px;
  background: #fff; color: var(--tm-fg);
  font-size: 14px; cursor: pointer; outline: none;
  transition: border-color .15s, box-shadow .15s;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}
#tradex-tm .tradex-tm__detail-select:focus {
  border-color: var(--tm-primary);
  box-shadow: 0 0 0 3px rgba(220,38,38,.15);
}

/* ---------- Hide mobile class ---------- */
#tradex-tm .tradex-tm__hide-mobile {
  display: table-cell;
}

@media (max-width: 768px) {
  #tradex-tm .tradex-tm__hide-mobile {
    display: none;
  }
  #tradex-tm .tradex-tm__table thead th {
    font-size: 12px; padding: 10px 8px;
  }
  #tradex-tm .tradex-tm__table tbody td {
    padding: 12px 8px;
  }
  #tradex-tm .tradex-tm__td-client {
    font-weight: 600;
  }
  #tradex-tm .tradex-tm__td-action {
    text-align: center;
  }
}

@media (max-width: 600px) {
  #tradex-tm .tradex-tm__card { padding: 20px; }
  #tradex-tm .tradex-tm__track-form { flex-direction: column; }
  #tradex-tm .tradex-tm__track-form .tradex-tm__btn { width: 100%; }
  #tradex-tm .tradex-tm__modal-dialog {
    max-width: 90vw;
  }
}
