/* DoItMyService - Admin Mobile v1
 * Phone/tablet layer for the admin panel. Everything is inside max-width queries,
 * so the desktop panel is unchanged. html.dims-app = opened inside the DIMS Admin app.
 */

@media (max-width: 991.98px) {
  :root {
    --dm-radius: 14px;
    --dm-radius-sm: 10px;
    --dm-shadow: 0 1px 2px rgba(20, 24, 40, .05), 0 6px 18px rgba(20, 24, 40, .06);
    --dm-line: rgba(20, 24, 40, .08);
    --dm-muted: #7b8191;
    --dm-ground: #f3f4f7;
  }

  html { -webkit-text-size-adjust: 100%; }
  html, body { overflow-x: clip; }
  body { background: var(--dm-ground); -webkit-tap-highlight-color: transparent; }

  /* ---------- header ---------- */
  .header.fixed-top {
    height: auto;
    min-height: 56px;
    padding-top: env(safe-area-inset-top, 0px);
    background: rgba(255, 255, 255, .92);
    -webkit-backdrop-filter: saturate(160%) blur(10px);
    backdrop-filter: saturate(160%) blur(10px);
    box-shadow: 0 1px 0 var(--dm-line);
  }
  .header .header-icon, .header .toggle-menu-button { min-width: 40px; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; }
  #modalOpener { min-height: 38px; }

  /* ---------- main area ---------- */
  .main-area {
    padding-block-start: calc(68px + env(safe-area-inset-top, 0px));
    padding-inline-start: 0 !important;
    padding-inline-end: 0 !important;
    block-size: auto;
    min-height: 100vh;
  }
  .main-content > .container-fluid, .main-area .container-fluid { padding-left: 12px; padding-right: 12px; }
  .page-title-wrap { gap: 8px; flex-wrap: wrap; }
  .page-title, .page-title-wrap h2 { font-size: 1.15rem !important; line-height: 1.3; }

  /* ---------- cards ---------- */
  .card { border-radius: var(--dm-radius); border: 1px solid var(--dm-line); box-shadow: var(--dm-shadow); }
  .card-body.p-30, .p-30 { padding: 16px !important; }
  .card-body { padding: 14px; }
  .card-header { padding: 12px 14px; border-radius: var(--dm-radius) var(--dm-radius) 0 0 !important; }
  .mb-30 { margin-bottom: 16px !important; }
  .p-20 { padding: 14px !important; }

  /* ---------- tabs: one swipeable line ---------- */
  .nav--tabs, .nav-tabs, .nav--tabs__style2, .nav-pills {
    flex-wrap: nowrap !important;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    white-space: nowrap;
    gap: 4px;
    max-width: 100%;
  }
  .nav--tabs::-webkit-scrollbar, .nav-tabs::-webkit-scrollbar, .nav-pills::-webkit-scrollbar { display: none; }
  .nav--tabs .nav-item, .nav-tabs .nav-item, .nav-pills .nav-item { flex: 0 0 auto; }
  .nav--tabs .nav-link, .nav-tabs .nav-link, .nav-pills .nav-link { padding: 8px 12px; font-size: .9rem; }
  .border-bottom.mx-lg-4 { gap: 8px !important; }

  /* ---------- toolbars / filters ---------- */
  .data-table-top { flex-direction: column; align-items: stretch !important; gap: 10px !important; }
  .data-table-top > * { width: 100%; }
  .search-form, .search-form__input_group { width: 100% !important; max-width: 100% !important; }
  .data-table-top .d-flex { flex-wrap: wrap; gap: 8px !important; }

  /* ---------- forms ---------- */
  input[type=checkbox], input[type=radio] { min-height: 0 !important; }
  .form-control, .form-select, .theme-input-style, .select2-container .select2-selection--single {
    min-height: 44px;
    font-size: 16px;
    border-radius: var(--dm-radius-sm) !important;
  }
  textarea.form-control, textarea.theme-input-style { min-height: 96px; }
  .select2-container { width: 100% !important; }
  .select2-container .select2-selection--single .select2-selection__rendered { line-height: 42px; }
  .select2-container .select2-selection--single .select2-selection__arrow { height: 42px; }
  .select2-container--default .select2-selection--multiple { min-height: 44px; border-radius: var(--dm-radius-sm); }
  .form-floating > label { font-size: .9rem; }
  .btn { min-height: 40px; border-radius: var(--dm-radius-sm); }
  .btn-sm { min-height: 34px; }
  .switcher, .form-switch { transform-origin: left center; }

  /* sticky submit bar at the bottom of long forms */
  form .d-flex.justify-content-end.gap-3:last-child,
  form .d-flex.justify-content-end.gap-xl-4:last-child,
  form .d-flex.gap-3.justify-content-end:last-child {
    position: sticky;
    bottom: 0;
    z-index: 5;
    margin: 12px -16px -16px;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
    background: rgba(255, 255, 255, .96);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    border-top: 1px solid var(--dm-line);
    border-radius: 0 0 var(--dm-radius) var(--dm-radius);
  }
  form .d-flex.justify-content-end.gap-3:last-child .btn,
  form .d-flex.gap-3.justify-content-end:last-child .btn { flex: 1 1 0; }

  /* ---------- tables: scroll fallback ---------- */
  .table-responsive { -webkit-overflow-scrolling: touch; border-radius: var(--dm-radius-sm); }
  .table { font-size: .9rem; }
  .table > :not(caption) > * > * { padding: 10px 10px; }

  /* ---------- modals ---------- */
  .modal-dialog:not(.modal-fullscreen) { margin: 10px; max-width: calc(100% - 20px); }
  .modal-content { border-radius: 18px; border: 0; }
  .modal-dialog-centered { min-height: calc(100% - 20px); }

  /* ---------- dropdowns ---------- */
  .dropdown-menu { max-width: calc(100vw - 24px); border-radius: 12px; box-shadow: var(--dm-shadow); }

  /* ---------- floating helpers (setup guide / guideline) ---------- */
  .view-guideline-btn { display: none !important; width: 40px !important; height: 40px !important; top: auto !important; bottom: calc(84px + env(safe-area-inset-bottom, 0px)) !important; right: 12px !important; border-radius: 12px !important; box-shadow: var(--dm-shadow); }
  .setup-guide { transform: scale(.82); transform-origin: left bottom; bottom: calc(14px + env(safe-area-inset-bottom, 0px)) !important; }
  .easy-setup-dropdown { max-width: calc(100vw - 24px); }

  /* ---------- statistics tiles: two per row ---------- */
  .row > [class*="col-"]:has(> .statistics-card) { flex: 0 0 50%; max-width: 50%; }
  .row.g-4:has(> [class*="col-"] > .statistics-card) { --bs-gutter-x: 10px; --bs-gutter-y: 10px; }
  .statistics-card { padding: 14px !important; min-height: 0 !important; }
  .statistics-card img { max-width: 34px; max-height: 34px; }
  .statistics-card h3, .statistics-card .title { font-size: .85rem !important; }
  .statistics-card { border-radius: var(--dm-radius); }
  .statistics-card h2, .statistics-card .fs-24, .statistics-card .fz-24 { font-size: 1.35rem !important; }

  /* ---------- sidebar ---------- */
  .aside { inline-size: min(84vw, 300px); box-shadow: 0 0 40px rgba(0, 0, 0, .18); }

  /* ---------- footer ---------- */
  .footer { padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
}

/* ---------- phone: tables become cards ---------- */
@media (max-width: 767.98px) {
  table.dims-cards { display: block; width: 100% !important; min-width: 0 !important; background: transparent; border: 0; }
  table.dims-cards thead { display: none; }
  table.dims-cards tbody { display: grid; gap: 10px; }
  table.dims-cards tr {
    display: block;
    background: #fff;
    border: 1px solid var(--dm-line);
    border-radius: var(--dm-radius);
    box-shadow: var(--dm-shadow);
    padding: 6px 12px;
  }
  table.dims-cards > tbody > tr > td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0 !important;
    border: 0 !important;
    border-bottom: 1px dashed var(--dm-line) !important;
    text-align: end;
    white-space: normal !important;
    min-width: 0;
    word-break: break-word;
  }
  table.dims-cards > tbody > tr > td:last-child { border-bottom: 0 !important; }
  table.dims-cards > tbody > tr > td::before {
    content: attr(data-label);
    flex: 0 0 38%;
    max-width: 38%;
    text-align: start;
    font-size: .78rem;
    font-weight: 600;
    letter-spacing: .02em;
    text-transform: uppercase;
    color: var(--dm-muted);
  }
  table.dims-cards > tbody > tr > td[data-label=""]::before { display: none; }
  table.dims-cards > tbody > tr > td > * { max-width: 62%; }
  table.dims-cards > tbody > tr > td[data-label=""] > * { max-width: 100%; }
  table.dims-cards > tbody > tr > td.dims-actions { justify-content: flex-end; padding-top: 10px !important; }
  table.dims-cards > tbody > tr > td.dims-actions::before { display: none; }
  table.dims-cards > tbody > tr > td.dims-actions > * { max-width: 100%; }
  table.dims-cards > tbody > tr > td.dims-serial { display: none; }
  table.dims-cards > tbody > tr > td.dims-empty { justify-content: center; text-align: center; }
  table.dims-cards > tbody > tr > td.dims-empty::before { display: none; }
  table.dims-cards .media, table.dims-cards .d-flex { justify-content: flex-end; }
  .table-responsive:has(> table.dims-cards) { overflow: visible; }
  .card-body:has(> .table-responsive > table.dims-cards), .card-body:has(table.dims-cards) { background: transparent; }

  .row > [class*="col-"] { min-width: 0; }
  .provider-details-overview, .provider-details-overview__collect-cash { flex-direction: column; }
}

/* ---------- login page ---------- */
@media (max-width: 991.98px) {
  .login-wrap { grid-template-columns: minmax(0, 1fr) !important; min-height: 100dvh; }
  .login-left { min-height: 0 !important; height: auto !important; padding: 24px 16px 40px; }
  .login-left .tf-box { margin: 0 !important; padding: 18px !important; height: auto !important; max-width: 100%; }
  .login-left .login-logo { max-height: 52px; width: auto; max-width: 70%; }
  .login-left h2 { font-size: 1.2rem; text-wrap: balance; }
  .login-right-wrap { min-width: 0; border-radius: 22px 22px 0 0; margin-top: -22px; position: relative; z-index: 1; }
  .login-right { padding: 22px 18px !important; max-width: 100%; }
  .login-right .mb-5 { margin-bottom: 1.25rem !important; }
  .login-right input:not([type=checkbox]):not([type=radio]) { min-height: 46px; font-size: 16px; }
  .login-right .btn { min-height: 48px; border-radius: 12px; }
  .login-footer { flex-wrap: wrap; }
}

/* ---------- inside the DIMS Admin app ---------- */
html.dims-app .footer { display: none; }
html.dims-app .main-area { padding-bottom: 12px; }
html.dims-app body { overscroll-behavior-y: contain; }
@media (max-width: 991.98px) {
  html.dims-app .view-guideline-btn { bottom: calc(16px + env(safe-area-inset-bottom, 0px)) !important; }
}

@media (prefers-reduced-motion: reduce) {
  .aside, .modal.fade .modal-dialog { transition: none !important; }
}
