/* ============================================================
   Exchange USDT MGA — Responsive (mobile, tablette, desktop)
   ============================================================ */

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

img, video, canvas, svg {
  max-width: 100%;
  height: auto;
}

/* ---- Layout principal ---- */
.content-wrapper {
  min-height: calc(100vh - 57px);
  overflow-x: hidden;
}

.content {
  padding: 0.75rem;
}

.content-header {
  padding: 0.75rem 0.5rem;
}

.content-header h1 {
  font-size: 1.35rem;
  line-height: 1.3;
  word-break: break-word;
}

.main-footer {
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  text-align: center;
}

/* ---- Sidebar / profil ---- */
.brand-link {
  display: flex !important;
  align-items: center;
  overflow: hidden;
}

.brand-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: calc(100% - 48px);
}

.main-sidebar .nav-link p {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- Topbar ---- */
.main-header.navbar {
  flex-wrap: wrap;
  padding: 0.25rem 0.5rem;
}

.navbar-nav .nav-link {
  padding: 0.5rem 0.65rem;
}

.mobile-rates-bar {
  display: none;
  width: 100%;
  padding: 0.35rem 0.75rem 0.5rem;
  background: #f8fafc;
  border-top: 1px solid #e5e7eb;
  gap: 0.35rem;
  flex-wrap: wrap;
  justify-content: center;
}

.mobile-rates-bar .rate-chip {
  font-size: 0.72rem;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  font-weight: 600;
  white-space: nowrap;
}

.mobile-rates-bar .rate-chip.buy {
  background: #d1fae5;
  color: #047857;
}

.mobile-rates-bar .rate-chip.sell {
  background: #dbeafe;
  color: #1d4ed8;
}

/* ---- Cartes & formulaires ---- */
.form-card .card-body,
.modern-card .card-body {
  padding: 1rem;
}

.form-card .card-header,
.list-card .card-header {
  padding: 1rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.form-card .card-header h5,
.list-card .card-header h5 {
  font-size: 1rem;
  margin-bottom: 0;
}

.card-tools .btn,
.list-card .card-header .btn {
  white-space: nowrap;
}

.form-control,
.form-control-lg,
.custom-select,
select.form-control {
  font-size: 16px; /* évite le zoom iOS sur focus */
}

.btn-lg {
  padding: 0.75rem 1rem;
  font-size: 1rem;
}

/* Toggle Achat / Vente */
.btn-group-toggle-responsive {
  display: flex;
  width: 100%;
}

.btn-group-toggle-responsive .btn {
  flex: 1 1 50%;
  white-space: normal;
  line-height: 1.25;
  padding: 0.65rem 0.5rem;
  font-size: 0.875rem;
}

/* ---- Boîte calcul Ariary ---- */
.calc-total-box {
  padding: 1rem;
}

.calc-total-amount {
  font-size: clamp(1.5rem, 6vw, 2.25rem);
  word-break: break-word;
}

.calc-total-details .col-4 {
  margin-bottom: 0.25rem;
}

.calc-destinataire {
  font-size: 0.85rem;
  text-align: center;
}

.calc-numero {
  display: block;
  margin: 0.5rem auto 0;
  width: fit-content;
  max-width: 100%;
  word-break: break-all;
  font-size: 1rem;
}

.payment-info {
  padding: 1rem;
  font-size: 0.9rem;
}

.payment-info ul {
  padding-left: 1.1rem;
  margin-bottom: 0;
}

.payment-info code {
  word-break: break-all;
  font-size: 0.8rem;
}

/* ---- Tableau de bord ---- */
.welcome-card {
  padding: 1.25rem;
  border-radius: 16px;
}

.welcome-card h2 {
  font-size: 1.25rem;
}

.stat-card-body {
  padding: 1rem;
}

.stat-icon {
  width: 48px;
  height: 48px;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.stat-value {
  font-size: 1.5rem;
}

.rate-display {
  padding: 1rem;
}

.rate-display .rate-value {
  font-size: clamp(1.25rem, 5vw, 2rem);
}

/* ---- Flux transaction ---- */
.tx-flow {
  justify-content: flex-start;
}

.tx-step {
  font-size: 0.65rem;
  padding: 0.3rem 0.5rem;
}

.tx-flow .fa-chevron-right {
  display: none;
}

/* ---- Détail transaction : adresse wallet ---- */
.table-tx-detail td:first-child {
  white-space: nowrap;
  width: 1%;
  vertical-align: top;
  padding-right: 1rem;
  color: #6b7280;
}

.table-tx-detail td:last-child {
  word-break: break-word;
  max-width: 0;
}

.tx-code {
  word-break: break-all;
  font-size: 0.85rem;
}

.wallet-address-card {
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 0.875rem 1rem;
  overflow: hidden;
}

.wallet-address-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #047857;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.5rem;
}

.wallet-address-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.5rem;
}

.wallet-address-text {
  flex: 1 1 0;
  min-width: 0;
  word-break: break-all;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  display: block;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  font-size: 0.82rem;
  color: #1f2937;
  line-height: 1.45;
}

.btn-copy-address {
  flex-shrink: 0;
  white-space: nowrap;
  border-color: #059669;
  color: #059669;
  font-weight: 600;
}

.btn-copy-address:hover {
  background: #059669;
  color: #fff;
  border-color: #059669;
}

@media (max-width: 575.98px) {
  .wallet-address-row {
    flex-direction: column;
  }

  .btn-copy-address {
    width: 100%;
  }
}

.user-detail-avatar {
  width: 52px;
  height: 52px;
  background: var(--primary-gradient);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 1rem;
  flex-shrink: 0;
}

.user-detail-modal .table td:first-child {
  width: 35%;
  color: #6b7280;
}

/* ---- Tableaux compacts (transactions côte à côte) ---- */
.tx-table-fit .table-responsive {
  overflow-x: visible;
}

.tx-table-fit .table-responsive > table {
  min-width: 0;
  width: 100%;
  table-layout: fixed;
}

.tx-compact-table {
  font-size: 0.72rem;
}

.tx-compact-table thead th {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  padding: 0.35rem 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tx-compact-table tbody td,
.tx-compact-table tfoot td {
  padding: 0.3rem 0.25rem;
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tx-compact-table .tx-ref {
  font-size: 0.68rem;
  padding: 0.1rem 0.2rem;
  white-space: nowrap;
}

.tx-compact-table .badge-tx-compact {
  font-size: 0.62rem;
  font-weight: 600;
  padding: 0.15em 0.35em;
  white-space: nowrap;
}

.tx-compact-table .btn-tx-icon {
  padding: 0.15rem 0.35rem;
  font-size: 0.7rem;
  line-height: 1;
}

.tx-compact-table .col-num { width: 1.5rem; text-align: center; }
.tx-compact-table .col-ref { width: 14%; }
.tx-compact-table .col-date { width: 18%; white-space: nowrap; }
.tx-compact-table .col-client { width: 22%; }
.tx-compact-table .col-usdt { width: 10%; text-align: right; white-space: nowrap; }
.tx-compact-table .col-mga { width: 12%; text-align: right; white-space: nowrap; }
.tx-compact-table .col-frais { width: 10%; text-align: right; white-space: nowrap; }
.tx-compact-table .col-benef { width: 10%; text-align: right; white-space: nowrap; }
.tx-compact-table .col-client { width: 18%; }
.tx-compact-table .col-pay { width: 2rem; text-align: center; }
.tx-compact-table .col-stat { width: 11%; text-align: center; }
.tx-compact-table .col-act { width: 1.75rem; text-align: center; padding: 0.2rem !important; }

.tx-split-tables .list-card .card-header {
  padding: 0.5rem 0.75rem;
}

.tx-split-tables .list-card .card-header h5,
.tx-split-tables .list-card .card-header .h6 {
  font-size: 0.9rem;
}

.tx-split-tables .dataTables_wrapper .dataTables_length,
.tx-split-tables .dataTables_wrapper .dataTables_filter,
.tx-split-tables .dataTables_wrapper .dataTables_info,
.tx-split-tables .dataTables_wrapper .dataTables_paginate {
  font-size: 0.68rem;
  padding: 0.25rem 0.5rem;
}

.tx-split-tables .dataTables_wrapper .dataTables_filter input {
  font-size: 0.72rem;
  padding: 0.15rem 0.35rem;
  height: auto;
  width: 100%;
  max-width: 8rem;
}

.tx-split-tables div.dataTables_wrapper div.dataTables_filter {
  text-align: right;
  margin-top: 0;
}

.tx-split-tables .dataTables_wrapper .row:first-child {
  margin-bottom: 0.25rem;
}

.tx-split-tables .dataTables_scrollHead,
.tx-split-tables .dataTables_scrollBody {
  overflow: visible !important;
}

/* ---- Tableaux ---- */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 0;
}

.table-responsive > table {
  min-width: 560px;
}

.tx-table-fit.table-responsive > table,
.tx-table-fit .table-responsive > table {
  min-width: 0;
}

.table td, .table th {
  vertical-align: middle;
}

.dataTables_wrapper .row {
  margin-left: 0;
  margin-right: 0;
}

.dataTables_wrapper .col-sm-12,
.dataTables_wrapper .col-md-6 {
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}

.dataTables_length select,
.dataTables_filter input {
  font-size: 16px;
  max-width: 100%;
}

div.dataTables_wrapper div.dataTables_filter {
  text-align: left;
  margin-top: 0.5rem;
}

div.dataTables_wrapper div.dataTables_filter input {
  width: 100%;
  margin-left: 0;
}

div.dataTables_wrapper div.dataTables_length {
  text-align: left;
}

.dataTables_paginate {
  overflow-x: auto;
  white-space: nowrap;
  padding-bottom: 0.25rem;
}

/* ---- Modales ---- */
.modal-dialog {
  margin: 0.75rem auto;
}

.modal-body {
  max-height: calc(100vh - 200px);
  overflow-y: auto;
}

.modal-footer {
  flex-wrap: wrap;
  gap: 0.5rem;
}

.modal-footer .btn {
  flex: 1 1 auto;
  min-width: 120px;
}

#viewer_modal .modal-content img {
  max-width: 100%;
  height: auto;
}

/* ---- Toasts ---- */
.swal2-container {
  padding: 0.5rem !important;
}

/* ---- Page header ---- */
.page-icon {
  width: 38px;
  height: 38px;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.breadcrumb {
  font-size: 0.8rem;
  padding: 0.25rem 0;
  flex-wrap: wrap;
}

/* ---- Auth (login / register) ---- */
.auth-page {
  min-height: 100vh;
  min-height: 100dvh;
  padding: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-box {
  width: 100%;
  max-width: 420px;
}

.auth-card {
  padding: 1.5rem;
}

/* ============================================================
   Breakpoints
   ============================================================ */

/* Tablette portrait & petits écrans */
@media (max-width: 991.98px) {
  .content-header .breadcrumb {
    float: none !important;
    margin-top: 0.5rem;
  }

  .content-header .col-sm-6 {
    flex: 0 0 100%;
    max-width: 100%;
  }

  .col-lg-4.mb-4,
  .col-lg-8.mb-4 {
    margin-bottom: 1rem !important;
  }
}

/* Mobile */
@media (max-width: 767.98px) {
  .content {
    padding: 0.5rem;
  }

  .content-header {
    padding: 0.5rem;
  }

  .content-header h1 {
    font-size: 1.15rem;
  }

  .page-icon {
    width: 34px;
    height: 34px;
    margin-right: 0.5rem !important;
  }

  .main-header .navbar-nav.ml-auto .nav-item .nav-link span,
  .main-header .navbar-nav.ml-auto .nav-item .nav-link {
    font-size: 0.8rem;
  }

  .mobile-rates-bar {
    display: flex;
  }

  .welcome-card .d-flex {
    flex-direction: column;
    text-align: center;
    gap: 1rem;
  }

  .welcome-card .text-right {
    text-align: center !important;
  }

  .quick-actions-grid,
  .home .row .col-md-4.mb-3 {
    margin-bottom: 0.75rem;
  }

  .btn-block.btn-lg {
    font-size: 0.95rem;
  }

  .calc-total-details .row > [class*="col-"] {
    flex: 0 0 100%;
    max-width: 100%;
    text-align: center;
    padding: 0.35rem 0;
    border-bottom: 1px solid rgba(0,0,0,0.05);
  }

  .calc-total-details .row > [class*="col-"]:last-child {
    border-bottom: none;
  }

  .list-card .card-header {
    flex-direction: column;
    align-items: flex-start !important;
  }

  .list-card .card-header .badge,
  .list-card .card-header .btn {
    align-self: flex-start;
  }

  .modal-dialog.modal-lg {
    max-width: calc(100% - 1rem);
  }

  .modal-footer .btn {
    width: 100%;
    margin: 0 !important;
  }

  .dataTables_wrapper .dataTables_info,
  .dataTables_wrapper .dataTables_paginate {
    text-align: center;
    float: none !important;
    width: 100%;
  }

  .stat-card:hover {
    transform: none;
  }
}

/* Très petits téléphones */
@media (max-width: 575.98px) {
  .brand-text {
    max-width: 140px;
    font-size: 0.85rem;
  }

  .btn-group-toggle-responsive {
    flex-direction: column;
  }

  .btn-group-toggle-responsive .btn {
    width: 100%;
    border-radius: 0.25rem !important;
    margin-bottom: 0.35rem;
  }

  .btn-group-toggle-responsive .btn:last-child {
    margin-bottom: 0;
  }

  .form-card .card-body {
    padding: 0.875rem;
  }

  .auth-card {
    padding: 1.25rem;
  }

  .main-footer strong {
    display: block;
  }
}

/* Paysage mobile */
@media (max-width: 896px) and (orientation: landscape) {
  .auth-page {
    align-items: flex-start;
    padding-top: 1rem;
    padding-bottom: 1rem;
  }

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

/* Grand écran — confort lecture */
@media (min-width: 1400px) {
  .content > .container-fluid {
    max-width: 1320px;
    margin-left: auto;
    margin-right: auto;
  }
}

/* Sidebar overlay mobile (AdminLTE) */
@media (max-width: 991.98px) {
  body.sidebar-open .main-sidebar {
    box-shadow: 0 0 24px rgba(0, 0, 0, 0.35);
  }

  .sidebar-mini.sidebar-collapse .main-sidebar {
    box-shadow: none;
  }
}

/* Touch targets accessibles */
@media (hover: none) and (pointer: coarse) {
  .nav-sidebar .nav-link,
  .btn,
  .dropdown-item,
  .page-link {
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  .nav-sidebar .nav-link p {
    margin-bottom: 0;
  }

  .btn-sm {
    min-height: 38px;
    min-width: 38px;
  }
}
