/*
 * Talksasa phone and small-tablet layer.
 *
 * Hand-written plain CSS, loaded last (after overrides.css, the portal styles and
 * style.css) by panels/styles.blade.php and the full-page auth layout. It is the
 * source of truth: there is no SCSS for it, so no build step is needed. Desktop
 * (≥768px) is untouched apart from the bottom-bar spacing rules scoped to it.
 *
 * Breakpoints follow Bootstrap: phones ≤575.98px, small tablets ≤767.98px.
 */

/* ---------- Bottom navigation (phones/tablets only; markup in panels/mobile-bottom-nav) ---------- */
.mobile-bottom-nav { display: none; }

@media (max-width: 767.98px) {
  body.has-mobile-bottom-nav { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  body.has-mobile-bottom-nav .footer { margin-bottom: calc(64px + env(safe-area-inset-bottom)); }
  body.has-mobile-bottom-nav .scroll-top { bottom: calc(76px + env(safe-area-inset-bottom)) !important; }

  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1031;
    height: calc(64px + env(safe-area-inset-bottom));
    padding: 0 4px env(safe-area-inset-bottom);
    background: var(--bg-primary, #fff);
    border-top: 1px solid var(--border-light, rgba(34, 41, 47, 0.12));
    box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.08);
  }
  html.dark-mode .mobile-bottom-nav,
  .dark-layout .mobile-bottom-nav { background: var(--bg-secondary, #1e293b); }
  .mobile-bottom-nav__item {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-width: 0;
    position: relative;
    color: var(--text-secondary, #6e6b7b);
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1;
    text-decoration: none;
    background: none;
    border: 0;
    -webkit-tap-highlight-color: transparent;
  }
  .mobile-bottom-nav__item svg { width: 22px; height: 22px; }
  .mobile-bottom-nav__item span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .mobile-bottom-nav__item.is-active { color: var(--primary, #7367f0); }
  .mobile-bottom-nav__item.is-active::before {
    content: "";
    position: absolute;
    top: 0;
    left: 28%;
    right: 28%;
    height: 3px;
    border-radius: 0 0 3px 3px;
    background: var(--primary, #7367f0);
  }
  .mobile-bottom-nav__item--primary svg {
    width: 26px;
    height: 26px;
    padding: 4px;
    border-radius: 10px;
    color: #fff;
    background: var(--primary, #7367f0);
  }
  .mobile-bottom-nav__badge {
    position: absolute;
    top: 8px;
    left: calc(50% + 6px);
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border-radius: 9px;
    background: #ea5455;
    color: #fff;
    font-size: 0.65rem;
    line-height: 17px;
    text-align: center;
  }
  .mobile-bottom-nav__badge:empty,
  .mobile-bottom-nav__badge[data-count="0"] { display: none; }

  /* Toasts sit above the bar, centred. */
  #toast-container.toast-top-right,
  #toast-container.toast-bottom-right {
    top: auto !important;
    bottom: calc(76px + env(safe-area-inset-bottom)) !important;
    right: 12px !important;
    left: 12px !important;
  }
  #toast-container > div { width: 100% !important; }
}

/* ---------- Forms and tap targets ---------- */
@media (max-width: 767.98px) {
  /* 16px stops iOS Safari zooming into every field. */
  input.form-control,
  textarea.form-control,
  select.form-select,
  select.form-control,
  .form-control,
  .form-select,
  .select2-container .select2-selection,
  .select2-container .select2-search__field,
  .wl-login-input {
    font-size: 16px !important;
  }
  .form-control,
  .form-select,
  .select2-container--default .select2-selection--single {
    min-height: 44px;
  }
  .select2-container--default .select2-selection--single .select2-selection__rendered { line-height: 42px; }
  .select2-container--default .select2-selection--single .select2-selection__arrow { height: 42px; }

  .btn { min-height: 40px; }
  .btn-sm { min-height: 36px; }
  .btn-icon, .btn-sm.btn-icon { min-width: 40px; }

  .input-group > .btn,
  .input-group-text { min-height: 44px; }

  .page-link { min-width: 40px; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; }

  /* Long values (sender IDs, UIDs, numbers, URLs) wrap instead of pushing the page wider. */
  .card-body, .modal-body, .data-card__content { overflow-wrap: anywhere; }
  .badge { white-space: normal; text-align: left; }
}

/* ---------- Page shell and spacing ---------- */
@media (max-width: 767.98px) {
  html .content.app-content { padding-left: 12px !important; padding-right: 12px !important; }
  .portal-list-section,
  .dashboard-section { padding-left: 0 !important; padding-right: 0 !important; }

  .portal-list-header { margin-bottom: 16px !important; gap: 12px !important; flex-direction: column; align-items: stretch !important; }
  .portal-list-title,
  .quick-send-page-header__title { font-size: 1.4rem !important; line-height: 1.25; }
  .portal-list-subtitle,
  .quick-send-page-header__subtitle { font-size: 0.9rem; }
  .page-header-icon-wrap { width: 40px !important; height: 40px !important; min-width: 40px; }
  .page-header-icon-wrap svg, .page-header-icon { width: 20px !important; height: 20px !important; }
  .portal-list-header > .d-flex.gap-1 { width: 100%; }

  .card { margin-bottom: 14px; }
  .card-body { padding: 14px; }
  .card-header { padding: 14px 14px 0; }

  .breadcrumb-wrapper, .content-header-left .breadcrumbs-top { display: none; }
}

/* ---------- Stat cards: compact, two per row ---------- */
@media (max-width: 767.98px) {
  .dashboard-stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 10px !important; }
  .stat-card { padding: 12px !important; min-height: 0 !important; }
  .stat-card .stat-value { font-size: 1.5rem !important; }
  .stat-card__label { font-size: 0.7rem !important; letter-spacing: 0.02em; }
  .stat-card__icon { width: 36px !important; height: 36px !important; }
  .stat-card__icon svg { width: 18px !important; height: 18px !important; }
  .stat-card__meta, .stat-card .stat-meta { font-size: 0.72rem; }
}
@media (hover: none) {
  .stat-card:hover, .card:hover, .data-card:hover { transform: none !important; }
}

/* ---------- Tables ---------- */
@media (max-width: 767.98px) {
  .table > :not(caption) > * > *,
  .table-modern td, .table-modern th,
  .table td, .table th { padding: 10px 12px !important; }

  .dataTables_wrapper .dataTables_length,
  .dataTables_wrapper .dataTables_filter,
  .dataTables_wrapper .dataTables_info,
  .dataTables_wrapper .dataTables_paginate { text-align: center !important; float: none !important; }
  .dataTables_wrapper .dataTables_filter input { width: 100% !important; margin-left: 0 !important; }
  .dataTables_wrapper .dataTables_filter label { width: 100%; display: flex; flex-direction: column; align-items: stretch; gap: 4px; text-align: left; }
  .dataTables_wrapper .dataTables_paginate .pagination { justify-content: center !important; flex-wrap: wrap; }

  /* Responsive "details" modal and child rows read as label/value pairs. */
  .dtr-modal .dtr-modal-display { width: 94% !important; max-height: 85vh; overflow-y: auto; }
  table.dataTable > tbody > tr.child ul.dtr-details { width: 100%; }
  table.dataTable > tbody > tr.child ul.dtr-details > li { display: flex; flex-wrap: wrap; gap: 4px 12px; }
  table.dataTable > tbody > tr.child span.dtr-title { min-width: 40%; font-weight: 600; }
}

/* ---------- Tabs and pills scroll in one row ---------- */
@media (max-width: 767.98px) {
  .nav-tabs, .nav-pills {
    flex-wrap: nowrap !important;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .nav-tabs::-webkit-scrollbar, .nav-pills::-webkit-scrollbar { display: none; }
  .nav-tabs .nav-item, .nav-pills .nav-item { flex: 0 0 auto; }
  .nav-tabs .nav-link, .nav-pills .nav-link { white-space: nowrap; }
}

/* ---------- Modals and dialogs ---------- */
@media (max-width: 575.98px) {
  .modal-dialog:not(.modal-dialog-centered):not(.modal-sm) {
    width: 100vw;
    max-width: none;
    height: 100%;
    margin: 0;
  }
  .modal-dialog:not(.modal-dialog-centered):not(.modal-sm) .modal-content {
    height: 100%;
    border: 0;
    border-radius: 0;
  }
  .modal-dialog:not(.modal-dialog-centered):not(.modal-sm) .modal-body { overflow-y: auto; }
  .modal-footer { flex-direction: column-reverse; align-items: stretch; gap: 8px; }
  .modal-footer > * { width: 100%; margin: 0 !important; }

  .swal2-popup { width: calc(100vw - 24px) !important; }
  .swal2-actions { flex-direction: column-reverse; width: 100%; gap: 8px; }
  .swal2-actions .swal2-styled, .swal2-actions .btn { width: 100%; margin: 0 !important; }
}

/* ---------- Navbar ---------- */
@media (max-width: 575.98px) {
  .header-navbar .navbar-container { padding-left: 8px !important; padding-right: 8px !important; }
  .header-navbar .nav-link { min-width: 40px; min-height: 40px; display: inline-flex !important; align-items: center; justify-content: center; }
  .header-navbar .dropdown-language .selected-language { display: none; }
}

/* ---------- Quick Send ---------- */
@media (max-width: 767.98px) {
  .quick-send-wrapper { min-height: 0 !important; padding: 0 !important; }
  .quick-send-wrapper > .container-xl { padding-left: 0; padding-right: 0; }
  .quick-send-page-header { margin-bottom: 12px !important; }
  .quick-send-card { border-radius: 14px; }
  .quick-send-card__header { padding: 14px !important; }
  .quick-send-card__body { padding: 14px !important; }
  .quick-send-card__body .form-section {
    padding: 0 0 18px !important;
    margin-bottom: 18px !important;
    border: 0 !important;
    border-bottom: 1px solid var(--border-light, rgba(34, 41, 47, 0.12)) !important;
    background: transparent !important;
    box-shadow: none !important;
  }
  .quick-send-card__body .originator-item { padding: 12px !important; }
  .quick-send-card__body .preview-card { padding: 14px !important; margin-top: 14px !important; }
  .quick-send-form button[type="submit"] { width: 100%; min-height: 48px; }
}

/* ---------- Charts ---------- */
@media (max-width: 575.98px) {
  .apexcharts-legend { justify-content: center !important; }
}

/* ---------- Sign-up wizard and login ---------- */
@media (max-width: 575.98px) {
  .bs-stepper .bs-stepper-header { overflow-x: auto; flex-wrap: nowrap; }
  .bs-stepper .bs-stepper-content .d-flex.justify-content-between > .btn { flex: 1 1 0; }
  .bs-stepper .bs-stepper-content .d-flex.justify-content-between { gap: 10px; }
  .wl-login-password-toggle, .form-password-toggle .input-group-text { min-width: 44px; justify-content: center; }
}

/* ---------- Filter panels collapse on phones ---------- */
.portal-filter-card__chevron { display: none; }
@media (max-width: 767.98px) {
  .portal-filter-card .portal-filter-card__header { display: flex; align-items: center; justify-content: space-between; cursor: pointer; }
  .portal-filter-card__chevron { display: inline-block; width: 18px; height: 18px; transition: transform 0.2s; }
  .portal-filter-card.is-open .portal-filter-card__chevron { transform: rotate(180deg); }
  /* Only cards with a toggle header collapse; header-less cards stay open. */
  .portal-filter-card:not(.is-open):has(> .portal-filter-card__header) > .portal-filter-card__body { display: none !important; }
  .portal-filter-grid { grid-template-columns: 1fr !important; gap: 12px !important; }
  .reports-filter-actions { display: flex; gap: 8px; }
  .reports-filter-actions > .btn { flex: 1 1 0; }
}

/* ---------- Contact import: one card per CSV column ---------- */
@media (max-width: 767.98px) {
  .import-mapping-table thead { display: none; }
  .import-mapping-table, .import-mapping-table tbody, .import-mapping-table tr, .import-mapping-table td { display: block; width: 100%; }
  .import-mapping-table td {
    margin-bottom: 10px;
    padding: 12px !important;
    border: 1px solid var(--border-light, rgba(34, 41, 47, 0.12));
    border-radius: 10px;
  }
  .import-mapping-sample { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; font-size: 0.85rem; }
  .import-mapping-sample span { color: var(--text-secondary, #6e6b7b); overflow-wrap: anywhere; }
  .import-mapping-table .select2-container { width: 100% !important; }
}

/* ---------- Campaign builder ---------- */
@media (max-width: 767.98px) {
  .campaign-builder-wrapper { min-height: 0 !important; padding: 0 !important; }
  .campaign-builder-wrapper > .container-xl { padding-left: 0; padding-right: 0; }
  .campaign-builder-wrapper .campaign-builder-page-header { margin-bottom: 12px !important; }
  .campaign-builder-wrapper .campaign-builder-page-header h1 { font-size: 1.4rem !important; }
  .campaign-builder-wrapper .form-section { padding: 14px !important; }
  .campaign-builder-wrapper .main-card { border-radius: 14px; }
  .row.two-col { grid-template-columns: 1fr !important; }
  /* Let the group list grow with the page instead of a small inner scroll box. */
  .contact-groups-list { max-height: none !important; overflow: visible !important; }
}

/* ---------- API docs: section list becomes a row of chips ---------- */
@media (max-width: 767.98px) {
  #features .list-group { flex-direction: row; flex-wrap: nowrap; overflow-x: auto; gap: 8px; scrollbar-width: none; }
  #features .list-group::-webkit-scrollbar { display: none; }
  #features .list-group-item {
    flex: 0 0 auto;
    white-space: nowrap;
    border: 1px solid var(--border-light, rgba(34, 41, 47, 0.12)) !important;
    border-radius: 999px !important;
    padding: 8px 14px;
  }
}

