/* ==========================================================================
   SurveyTo - Mobile UI layer
   Loaded after style.css on every user-facing page. Only visual rules:
   no element is hidden that carries functionality, nothing changes behaviour.
   ========================================================================== */

:root {
  --m-nav-h: 64px;
  --m-safe-b: env(safe-area-inset-bottom, 0px);
  --m-gutter: 12px;
  --m-radius: 14px;
  --m-orange: #ff7b00;
  --m-orange-2: #ff5200;
  --m-blue: #005bbb;
  --m-ink: #1e293b;
  --m-muted: #64748b;
  --m-line: #e8edf5;
}

body { overflow-x: hidden; }
@supports (overflow-x: clip) { body { overflow-x: clip; } }

/* --------------------------------------------------------------------------
   Tablet & phone (<= 1199px: sidebar becomes off-canvas)
   -------------------------------------------------------------------------- */
@media (max-width: 1199px) {
  body .sidebar {
    width: 280px;
    left: -290px;
    padding: 16px 14px calc(24px + var(--m-safe-b));
    box-shadow: 8px 0 30px rgba(1, 41, 112, .12);
  }
  body.toggle-sidebar .sidebar { left: 0; }
  body .sidebar-overlay { background: rgba(15, 23, 42, .35) !important; backdrop-filter: blur(2px); }
  body .sidebar-nav .nav-link { padding: 11px 14px; border-radius: 10px; font-size: 15px; }
  body .sidebar-nav .nav-content a { padding: 10px 0 10px 40px; font-size: 14px; }
}

/* --------------------------------------------------------------------------
   Phone (<= 768px)
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {

  body { font-size: 15px; -webkit-text-size-adjust: 100%; }
  #main img, #main video, #main iframe { max-width: 100%; }

  /* ---------- Header ---------- */
  body .header {
    height: calc(56px + env(safe-area-inset-top, 0px));
    padding: env(safe-area-inset-top, 0px) 6px 0 4px;
    box-shadow: 0 1px 0 var(--m-line), 0 4px 16px rgba(1, 41, 112, .06);
  }
  /* hamburger to the left of the logo (visual order only) */
  body .header > .d-flex:first-child { flex-direction: row-reverse; gap: 2px; }
  body .header .toggle-sidebar-btn {
    font-size: 28px;
    padding: 6px 8px;
    line-height: 1;
    border-radius: 10px;
  }
  body .header .toggle-sidebar-btn:active { background: #f1f5f9; }
  body .logo img { max-height: 34px !important; margin-right: 0; }
  body .header-nav .nav-icon { font-size: 22px; padding: 8px; }
  body .header-nav .nav-profile img { max-height: 34px; }
  body .header-nav .nav-item.pe-3 { padding-right: 4px !important; }
  body .header-nav .badge-number { inset: 2px 2px auto auto; font-size: 10px; padding: 2px 5px; }
  body .header-nav .profile { min-width: 260px; border-radius: 14px; overflow: hidden; }
  body .sidebar { top: calc(56px + env(safe-area-inset-top, 0px)); }

  /* ---------- Page frame ---------- */
  body #main {
    margin-top: calc(56px + env(safe-area-inset-top, 0px));
    padding: 14px var(--m-gutter) calc(var(--m-nav-h) + var(--m-safe-b) + 28px);
  }
  body #main .row { --bs-gutter-x: 12px; }
  body #main > .section > .row > [class*="col"],
  body #main > section > .row > [class*="col"] { padding-left: 6px; padding-right: 6px; }

  body .pagetitle { margin-bottom: 12px; }
  body .pagetitle h1 { font-size: 21px !important; line-height: 1.25; }
  body .breadcrumb { font-size: 12.5px; margin-bottom: 0; }

  /* ---------- Cards ---------- */
  body .card {
    margin-bottom: 14px;
    border-radius: var(--m-radius) !important;
  }
  body .card:hover { transform: none !important; }
  body .card-body { padding: 0 14px 14px; }
  body .card-title { padding: 16px 0 10px; font-size: 16.5px; line-height: 1.3; }
  body .card-header, body .card-footer { padding: 12px 14px; }

  /* "View All" style top-right links never cover the card title */
  body .card > .filter {
    position: absolute;
    top: 13px;
    right: 12px;
    z-index: 2;
  }
  body .card > .filter a,
  body .card > .filter .icon {
    font-size: 12.5px !important;
    padding: 6px 12px !important;
    border-radius: 999px !important;
    line-height: 1.2;
    display: inline-block;
  }
  body .card > .filter + .card-body .card-title { padding-right: 96px; }

  /* empty NiceAdmin footer only drew a stray line above the bottom nav */
  body #footer.footer { display: none; }

  /* ---------- Typography helpers ---------- */
  body h1 { font-size: 24px; }
  body h2 { font-size: 21px; }
  body h3 { font-size: 19px; }
  body h4 { font-size: 17px; }

  /* ---------- Forms: 16px stops iOS zoom-on-focus; comfortable targets ---------- */
  body input.form-control,
  body select.form-control,
  body select.form-select,
  body textarea.form-control,
  body .input-group > .form-control,
  body .input-group > .form-select {
    font-size: 16px !important;
    min-height: 46px;
  }
  body textarea.form-control { min-height: 96px; }
  body .input-group-text { min-width: 44px; justify-content: center; }
  body .btn { min-height: 42px; }
  body .btn-sm { min-height: 34px; }
  body .form-label, body label { font-size: 14px; }

  /* ---------- Alerts ---------- */
  body .alert { border-radius: 12px; padding: 12px 14px; font-size: 14px; }

  /* ---------- Modals ---------- */
  body .modal-dialog:not(.modal-fullscreen) { margin: 12px; }
  body .modal-content { border-radius: 16px; }
  body .modal-fullscreen .modal-content { border-radius: 0; }
  body .modal-fullscreen .modal-body { padding: 0; }
  body .modal-fullscreen .modal-footer { padding: 8px 12px calc(8px + var(--m-safe-b)); }

  /* ---------- Tables -> stacked cards ----------
     assets/js/mobile.js copies each column header into td[data-label]. */
  body .m-stack-table { display: block; width: 100%; border: 0; margin: 0; background: transparent !important; }
  body .m-stack-table thead,
  body .m-stack-table tr.m-dup-head { display: none !important; }
  body .m-stack-table tbody, body .m-stack-table tfoot { display: block; width: 100%; }
  body .m-stack-table tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 14px;
    background: #fff !important;
    border: 1px solid var(--m-line) !important;
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 10px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, .04);
    transform: none !important;
  }
  body .m-stack-table tr:hover { transform: none !important; }
  /* inside a white panel the rows become soft tiles instead of nested cards */
  body #main .card .m-stack-table tr {
    background: #f8fafc !important;
    border-color: #eef2f7 !important;
    box-shadow: none;
  }
  body .m-stack-table td,
  body .m-stack-table th {
    display: flex !important;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 3px;
    width: auto !important;
    height: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
    text-align: left !important;
    white-space: normal !important;
    overflow-wrap: anywhere;
    font-size: 14px;
    line-height: 1.35;
    box-shadow: none !important;
    position: static !important;
  }
  body .m-stack-table .m-wide { grid-column: 1 / -1; }
  body .m-stack-table td[data-label]::before,
  body .m-stack-table th[data-label]::before {
    content: attr(data-label);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--m-muted);
    line-height: 1.2;
  }
  body .m-stack-table td .badge,
  body .m-stack-table th .badge { white-space: normal; text-align: left; }
  /* single-cell rows ("There is nothing here yet") stay centered */
  body .m-stack-table td[colspan] { grid-column: 1 / -1; align-items: center; text-align: center !important; }
  body .m-stack-table td[colspan]::before { display: none; }

  /* Tables that are not stacked never push the page sideways */
  body #main .table-responsive,
  body #main .card-body { max-width: 100%; }
  body #main .table:not(.m-stack-table) { font-size: 13.5px; }
  body #main .table:not(.m-stack-table) th,
  body #main .table:not(.m-stack-table) td { padding: .55rem .5rem; }

  /* ---------- Pagination ---------- */
  body .pagination { flex-wrap: wrap; justify-content: center; gap: 4px; }
  body .pagination .page-link { min-width: 38px; min-height: 38px; display: flex; align-items: center; justify-content: center; border-radius: 10px !important; }

  /* ---------- Floating widgets: keep them above the bottom nav ---------- */
  body .back-to-top {
    right: 12px;
    bottom: calc(var(--m-nav-h) + var(--m-safe-b) + 14px);
    width: 38px;
    height: 38px;
    border-radius: 50%;
    z-index: 1001;
  }
  html:not(.in-app) #gt_float_wrapper {
    left: 10px !important;
    bottom: calc(var(--m-nav-h) + var(--m-safe-b) + 12px) !important;
    transform: none !important;
  }
  #gt_float_wrapper .gt_float_switcher {
    font-size: 13px !important;
    border-radius: 999px !important;
    box-shadow: 0 4px 14px rgba(15, 23, 42, .14) !important;
    overflow: hidden;
  }
  #gt_float_wrapper .gt_float_switcher .gt-selected .gt-current-lang { padding: 6px 10px !important; }
  #gt_float_wrapper .gt_float_switcher img { width: 22px !important; height: auto; }

  body .admin-popup { left: 12px; right: 12px; bottom: calc(var(--m-nav-h) + var(--m-safe-b) + 12px); text-align: center; }
  body #adminMsgPopup { width: calc(100% - 24px); text-align: center; }

  /* SweetAlert */
  body .swal2-popup { width: calc(100% - 24px) !important; padding: 18px !important; border-radius: 16px !important; }
}

/* --------------------------------------------------------------------------
   Page specific (phone)
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {

  /* ===== Dashboard ===== */
  body .dashboard .stat-card-col .card { margin-bottom: 0; }
  body .dashboard .info-card { padding-bottom: 0; }
  body .dashboard .stat-card-col .card-body { padding: 12px !important; }
  body .dashboard .stat-card-col .card-title {
    padding: 0 0 8px !important;
    font-size: 12px !important;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--m-muted) !important;
  }
  body .dashboard .stat-card-col h6 { font-size: 17px !important; line-height: 1.2; word-break: break-all; }
  body .dashboard .stat-card-col .ps-3 { padding-left: 10px !important; min-width: 0; }
  body .dashboard .stat-card-col .small { padding: 0 !important; }

  body .dashboard h4.fw-bold { font-size: 17px; line-height: 1.3; }
  /* Survey rows: native swipe instead of tiny arrow buttons */
  body #prime-cards-container,
  body #other-cards-container {
    overflow-x: auto !important;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin: 0 -12px;
    padding: 6px 12px 12px !important;
    gap: 10px !important;
  }
  body #prime-cards-container::-webkit-scrollbar,
  body #other-cards-container::-webkit-scrollbar { display: none; }
  body #prime-cards-container > *,
  body #other-cards-container > * { scroll-snap-align: start; }
  body #prime-scroll-left, body #prime-scroll-right,
  body #other-scroll-left, body #other-scroll-right { display: none !important; }
  body .survey-card-custom { min-width: 150px !important; padding: 12px !important; }
  body .view-all-survey { min-width: 110px !important; }

  /* Recent activity: time on its own line, text gets full width */
  body .dashboard .activity .activity-item,
  body .activity .activity-item {
    flex-wrap: wrap;
    padding: 10px 12px !important;
    margin-bottom: 10px !important;
    box-shadow: none !important;
  }
  body .activity .activity-item .activite-label {
    order: 2;
    flex: 1 1 100%;
    min-width: 0 !important;
    font-size: 12px;
    padding-left: 22px;
    margin-top: 2px;
  }
  body .activity .activity-item .activite-label::before { display: none; }
  body .activity .activity-item .activity-badge { order: 0; margin-top: 4px; }
  body .activity .activity-item .activity-content { order: 1; flex: 1 1 0; min-width: 0; padding: 0 0 0 8px !important; font-size: 14px; }

  /* Survey / offer iframe modals go full screen on phones */
  body #survey-modal-bs .survey-modal-content,
  body #offer-modal-bs .offer-modal-content {
    width: 100% !important;
    height: 100% !important;
    max-width: none;
    border-radius: 0 !important;
  }
  body #survey-modal-bs .modal-header-bs,
  body #offer-modal-bs .modal-header-bs { padding: calc(10px + env(safe-area-inset-top, 0px)) 12px 10px !important; }

  /* ===== Offers / Surveys partner walls ===== */
  body .partner-cards-grid,
  body .survey-partners-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }
  body .partner-card-custom {
    height: auto !important;
    min-height: 108px !important;
    padding: 16px 10px 12px !important;
    border-radius: 14px !important;
  }
  body .partner-card-custom .partner-logo-wrap { margin-bottom: 8px !important; }
  body .partner-card-custom .partner-logo-wrap img,
  body .partner-card-custom .partner-logo-wrap svg { max-width: 100% !important; max-height: 38px !important; }
  body .partner-card-custom .partner-name { font-size: 13px !important; }
  body .partner-card-custom:hover { transform: none !important; }
  body .row-scroll-btn { display: none !important; }
  body .apps-row-container { margin: 0 -12px; padding: 6px 12px 12px !important; gap: 12px !important; }
  body .app-card-custom { width: 104px !important; }
  body .section-header-box { gap: 10px !important; margin-bottom: 12px !important; }
  body .section-title { font-size: 1.1rem !important; }
  body .section-subtitle { font-size: .8rem !important; }

  /* ===== Tasks ===== */
  body .task-filter-container {
    flex-wrap: nowrap !important;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 10px !important;
    gap: 8px !important;
  }
  body .task-filter-container::-webkit-scrollbar { display: none; }
  body .filter-btn { flex: 0 0 auto; white-space: nowrap; }

  /* ===== Chat (public + admin) ===== */
  body .chat-messages {
    height: calc(100vh - 290px) !important;
    height: calc(100dvh - 290px) !important;
    min-height: 280px;
  }
  body #chatArea {
    height: calc(100vh - 360px) !important;
    height: calc(100dvh - 360px) !important;
    min-height: 260px;
    padding: 12px !important;
  }
  body .chat-admin-page .table-responsive.card { background: transparent !important; box-shadow: none !important; }
  body .chat-admin-page .table-responsive.card > .container { padding: 0 !important; }
  body .chat-admin-page .card-custom { margin-bottom: 0; overflow: hidden; }
  body .chat-admin-page .msg-admin .bubble,
  body .chat-admin-page .msg-user .bubble { max-width: 85% !important; }
  body .chat-admin-page .card-footer textarea { min-height: 64px; }

  /* ===== Affiliates: banner code boxes use the full width ===== */
  body .aff-banner-title { width: auto !important; display: inline-block; padding-left: 18px; padding-right: 18px; }
  body #main textarea.form-control.w-75 { width: 100% !important; font-family: ui-monospace, Menlo, monospace; }

  /* ===== Payment proofs: compact stat tiles ===== */
  body .proof-stats-row { --bs-gutter-x: 8px !important; }
  body .proof-stats-row .stat-card { margin-bottom: 12px; }
  body .proof-stats-row .stat-card .card-body { padding: 12px 10px !important; }
  body .proof-stats-row .stat-label { font-size: 10px !important; letter-spacing: .04em !important; line-height: 1.25; min-height: 25px; }
  body .proof-stats-row .stat-value { font-size: 15px !important; white-space: nowrap; }
  body .proof-stats-row .stat-icon { display: none; }
}

/* --------------------------------------------------------------------------
   Login / Register (standalone pages, no app header)
   -------------------------------------------------------------------------- */
@media (max-width: 576px) {
  body .section.register { padding: 20px 0 32px !important; justify-content: flex-start !important; }
  body .section.register .logo img { max-height: 40px !important; }
  body .section.register .card { border-radius: 18px !important; box-shadow: 0 10px 30px rgba(1, 41, 112, .08); }
  body .section.register .card-body { padding: 4px 18px 20px; }
  body .section.register .card-title { font-size: 21px !important; padding-top: 18px; }
  body .section.register .btn { min-height: 46px; border-radius: 999px; }
}

/* --------------------------------------------------------------------------
   Small phones (<= 380px)
   -------------------------------------------------------------------------- */
@media (max-width: 380px) {
  :root { --m-gutter: 10px; }
  body .logo img { max-height: 30px !important; }
  body .card-title { font-size: 15.5px; }
}
