/*
  A2TDEV responsive upgrade 09
  Final small-device QA and edge-case guard layer.
  This file intentionally loads last so legacy/page CSS cannot reintroduce
  horizontal overflow, oversized tables, clipped forms, or unreachable overlays.
*/

:root {
  --a2t-mobile-edge: 16px;
  --a2t-mobile-edge-sm: 12px;
  --a2t-mobile-radius: 20px;
  --a2t-mobile-radius-sm: 14px;
  --a2t-mobile-tap: 44px;
  --a2t-mobile-header: var(--a2t-header-height, 68px);
  --a2t-mobile-safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html,
body {
  max-width: 100%;
}

html.a2t-small-screen,
html.a2t-small-screen body {
  overflow-x: hidden;
}

html.a2t-small-screen body {
  min-width: 0 !important;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html.a2t-small-screen body.a2t-nav-open,
html.a2t-small-screen body.a2t-notification-open,
html.a2t-small-screen body.a2t-modal-open {
  width: 100%;
  overflow: hidden !important;
  overscroll-behavior: contain;
}

@media (max-width: 760px) {
  html,
  body,
  #a2t-main-content,
  .x-content,
  main,
  section,
  article,
  aside,
  header,
  footer,
  nav,
  .container,
  .container-fluid,
  .row,
  [class*="container"],
  [class*="wrapper"],
  [class*="shell"],
  [class*="inner"],
  [class*="grid"],
  [class*="layout"],
  [class*="panel"],
  [class*="card"],
  [class*="box"] {
    min-width: 0;
  }

  body {
    background-attachment: scroll !important;
  }

  #a2t-main-content,
  .x-content {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: clip;
  }

  .x-content > * {
    max-width: 100%;
  }

  img,
  video,
  canvas,
  svg,
  iframe,
  embed,
  object {
    max-width: 100%;
  }

  img,
  video,
  canvas,
  svg {
    height: auto;
  }

  iframe,
  embed,
  object {
    display: block;
  }

  pre,
  code,
  kbd,
  samp {
    max-width: 100%;
    white-space: pre-wrap;
    word-break: break-word;
  }

  pre {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  p,
  li,
  dd,
  blockquote,
  figcaption,
  .a2t-notification-copy span,
  .a2t-notification-copy em,
  .blog-card p,
  .product-card p,
  .store-card p,
  .project-card p {
    overflow-wrap: anywhere;
  }

  a,
  button,
  input,
  select,
  textarea,
  summary,
  [role="button"] {
    touch-action: manipulation;
  }

  button,
  .btn,
  .button,
  input[type="button"],
  input[type="submit"],
  input[type="reset"],
  .a2t-btn,
  .a2t-nav-cta,
  .a2t-mobile-cta,
  .a2t-mobile-cart-link,
  .a2t-mobile-nav-notification {
    min-height: var(--a2t-mobile-tap);
  }

  input,
  select,
  textarea {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    font-size: 16px !important;
  }

  textarea {
    resize: vertical;
  }

  label,
  legend {
    overflow-wrap: anywhere;
  }

  form,
  fieldset,
  .form-group,
  .mb-3,
  .input-group,
  .a2t-form,
  .a2t-form-card,
  .checkout-form,
  .auth-form,
  .profile-form,
  .project-form {
    max-width: 100%;
    min-width: 0;
  }

  fieldset {
    padding-inline: 0;
  }

  .input-group {
    flex-wrap: wrap;
  }

  .input-group > .form-control,
  .input-group > .form-select,
  .input-group > .btn,
  .input-group > * {
    min-width: 0;
  }

  .input-group > .btn,
  .input-group > button {
    flex: 1 1 auto;
  }

  .btn-group,
  .button-group,
  .action-group,
  .actions,
  .card-actions,
  .hero-actions,
  .page-actions,
  .form-actions,
  .filter-actions,
  .checkout-actions,
  .proposal-actions,
  .payment-actions,
  .profile-actions,
  .review-actions,
  .comment-actions {
    flex-wrap: wrap;
    gap: 10px;
    min-width: 0;
  }

  .btn-group > *,
  .button-group > *,
  .action-group > *,
  .actions > *,
  .card-actions > *,
  .hero-actions > *,
  .page-actions > *,
  .form-actions > *,
  .filter-actions > *,
  .checkout-actions > *,
  .proposal-actions > *,
  .payment-actions > *,
  .profile-actions > * {
    min-width: 0;
  }

  .a2t-responsive-table-wrap,
  .table-responsive,
  .table-wrap,
  .invoice-wrap,
  .orders-table-wrap,
  .dashboard-table-wrap,
  .cart-table-wrap,
  .project-table-wrap,
  .work-report-table-wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--a2t-mobile-radius-sm);
  }

  table:not(.a2t-mobile-card-table) {
    max-width: none;
  }

  .a2t-responsive-table-wrap > table,
  .table-responsive > table,
  .table-wrap > table {
    margin-bottom: 0;
  }

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    word-break: normal;
  }

  th,
  td {
    vertical-align: top;
  }

  .a2t-js-table-card {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 12px;
  }

  .a2t-js-table-card thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .a2t-js-table-card tbody,
  .a2t-js-table-card tr,
  .a2t-js-table-card td {
    display: block;
    width: 100%;
  }

  .a2t-js-table-card tr {
    padding: 12px;
    border: 1px solid rgba(15, 23, 42, 0.1);
    border-radius: 16px;
    background: var(--a2t-card, #fff);
    box-shadow: 0 12px 34px rgba(15, 23, 42, 0.07);
  }

  .a2t-js-table-card td {
    border: 0 !important;
    padding: 8px 0 !important;
    display: grid;
    grid-template-columns: minmax(94px, 36%) minmax(0, 1fr);
    gap: 12px;
    align-items: start;
    text-align: right;
  }

  .a2t-js-table-card td::before {
    content: attr(data-a2t-label);
    text-align: left;
    font-size: 0.78rem;
    font-weight: 800;
    color: var(--a2t-muted, #64748b);
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  .a2t-js-table-card td:empty {
    display: none;
  }

  .a2t-js-table-card td[data-a2t-label=""],
  .a2t-js-table-card td:not([data-a2t-label]) {
    grid-template-columns: 1fr;
    text-align: left;
  }

  .a2t-site-header,
  .a2t-nav-shell,
  .a2t-mobile-menu,
  .a2t-notification-modal,
  .a2t-notification-dialog,
  .a2t-notification-head,
  .a2t-notification-list {
    max-width: 100vw;
  }

  .a2t-site-header {
    transform: translateZ(0);
    contain: layout paint;
  }

  .a2t-nav-shell {
    width: min(100%, 100vw);
  }

  .a2t-brand,
  .a2t-footer-logo {
    white-space: nowrap;
    min-width: 0;
  }

  .a2t-nav-actions {
    min-width: 0;
    gap: 8px;
  }

  .a2t-theme-toggle,
  .a2t-mobile-menu-btn,
  .a2t-mobile-nav-notification {
    flex: 0 0 auto;
  }

  .a2t-mobile-menu {
    padding-top: calc(var(--a2t-mobile-header) + 8px);
  }

  .a2t-mobile-menu-inner {
    width: min(100% - 20px, 440px);
    margin-inline: auto;
    max-height: calc((var(--a2t-vh, 1vh) * 100) - var(--a2t-mobile-header) - 18px - var(--a2t-mobile-safe-bottom));
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .a2t-mobile-nav-quick {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
  }

  .a2t-mobile-cart-link strong {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .a2t-notification-modal {
    align-items: start;
    padding-top: calc(var(--a2t-mobile-header) + 8px);
    padding-inline: 10px;
    padding-bottom: calc(12px + var(--a2t-mobile-safe-bottom));
  }

  .a2t-notification-dialog {
    width: min(100%, 460px);
    max-height: calc((var(--a2t-vh, 1vh) * 100) - var(--a2t-mobile-header) - 20px - var(--a2t-mobile-safe-bottom));
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .a2t-notification-head {
    position: sticky;
    top: 0;
    z-index: 4;
    flex: 0 0 auto;
  }

  .a2t-notification-head h2,
  .a2t-notification-head p {
    max-width: 100%;
  }

  .a2t-notification-actions {
    align-self: flex-start;
    flex: 0 0 auto;
  }

  .a2t-notification-list,
  .a2t-notification-empty {
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  .a2t-notification-item {
    grid-template-columns: 38px minmax(0, 1fr) auto;
  }

  .a2t-notification-copy {
    min-width: 0;
  }

  .a2t-notification-copy strong,
  .a2t-notification-copy span,
  .a2t-notification-copy em {
    max-width: 100%;
  }

  .modal,
  .modal-dialog,
  .modal-content,
  dialog,
  [role="dialog"] {
    max-width: 100vw;
  }

  .modal-dialog {
    margin: 10px;
  }

  .modal-content {
    max-height: calc((var(--a2t-vh, 1vh) * 100) - 20px);
    overflow: auto;
  }

  .dropdown-menu,
  .popover,
  .tooltip,
  .flatpickr-calendar,
  .select2-container,
  .select2-dropdown {
    max-width: calc(100vw - 20px) !important;
  }

  .sticky-top,
  [style*="position: sticky"],
  [style*="position:sticky"] {
    top: calc(var(--a2t-mobile-header) + 8px);
  }

  .page-hero,
  .hero,
  .a2t-hero,
  .blog-hero,
  .store-hero,
  .product-hero,
  .project-hero,
  .profile-hero,
  .auth-card,
  .checkout-shell,
  .cart-shell,
  .wishlist-shell,
  .blog-shell,
  .store-shell,
  .project-shell,
  .dashboard-shell,
  .service-detail-shell,
  .freelancer-detail-shell,
  .a2t-legal-shell {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .row {
    --bs-gutter-x: 1rem;
    --bs-gutter-y: 1rem;
  }

  .row > * {
    min-width: 0;
  }

  .col,
  [class^="col-"],
  [class*=" col-"] {
    min-width: 0;
  }

  [class*="grid"] > *,
  [class*="layout"] > *,
  [class*="columns"] > *,
  [class*="rail"] > *,
  [class*="list"] > * {
    min-width: 0;
  }

  .a2t-mobile-scroll-rail,
  .category-rail,
  .filter-rail,
  .tabs,
  .nav-tabs,
  .a2t-tabs,
  .product-section-index,
  .blog-category-rail,
  .dashboard-filter-row,
  .project-type-tabs,
  .stepper,
  .a2t-stepper {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    max-width: 100%;
    padding-bottom: 4px;
  }

  .a2t-mobile-scroll-rail::-webkit-scrollbar,
  .category-rail::-webkit-scrollbar,
  .filter-rail::-webkit-scrollbar,
  .tabs::-webkit-scrollbar,
  .nav-tabs::-webkit-scrollbar,
  .a2t-tabs::-webkit-scrollbar,
  .product-section-index::-webkit-scrollbar,
  .blog-category-rail::-webkit-scrollbar,
  .dashboard-filter-row::-webkit-scrollbar,
  .project-type-tabs::-webkit-scrollbar,
  .stepper::-webkit-scrollbar,
  .a2t-stepper::-webkit-scrollbar {
    display: none;
  }

  .a2t-mobile-scroll-rail > *,
  .category-rail > *,
  .filter-rail > *,
  .tabs > *,
  .nav-tabs > *,
  .a2t-tabs > *,
  .product-section-index > *,
  .blog-category-rail > *,
  .dashboard-filter-row > *,
  .project-type-tabs > *,
  .stepper > *,
  .a2t-stepper > * {
    flex: 0 0 auto;
    scroll-snap-align: start;
  }

  .a2t-overflow-contained {
    max-width: 100% !important;
    min-width: 0 !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  .a2t-overflow-contained:not(table) {
    border-radius: inherit;
  }

  .a2t-mobile-stack {
    display: grid !important;
    grid-template-columns: 1fr !important;
  }

  .a2t-mobile-full,
  .a2t-mobile-full.btn,
  .a2t-mobile-full.a2t-btn {
    width: 100% !important;
  }

  .a2t-toast,
  #snackbar,
  .toast-container {
    left: var(--a2t-mobile-edge) !important;
    right: var(--a2t-mobile-edge) !important;
    bottom: calc(14px + var(--a2t-mobile-safe-bottom)) !important;
    width: auto !important;
    max-width: none !important;
  }

  #loader-overlay {
    max-width: 100vw;
  }

  .loader-circle {
    transform: scale(0.86);
    transform-origin: center;
  }
}

@media (max-width: 640px) {
  :root {
    --a2t-mobile-edge: 14px;
    --a2t-mobile-edge-sm: 10px;
  }

  .hide-mobile,
  .desktop-only,
  .a2t-desktop-only {
    display: none !important;
  }

  .mobile-only,
  .a2t-mobile-only {
    display: revert !important;
  }

  h1,
  .h1 {
    font-size: clamp(2rem, 10vw, 2.75rem) !important;
    line-height: 1.02 !important;
  }

  h2,
  .h2 {
    font-size: clamp(1.55rem, 7vw, 2.1rem) !important;
    line-height: 1.08 !important;
  }

  h3,
  .h3 {
    font-size: clamp(1.25rem, 5.8vw, 1.55rem) !important;
    line-height: 1.16 !important;
  }

  .lead,
  .subtitle,
  .page-subtitle,
  .hero-subtitle,
  .section-subtitle {
    font-size: 1rem !important;
    line-height: 1.6 !important;
  }

  .section,
  section,
  .page-section {
    scroll-margin-top: calc(var(--a2t-mobile-header) + 16px);
  }

  .card,
  .a2t-card,
  .panel,
  .a2t-panel,
  .product-card,
  .blog-card,
  .project-card,
  .auth-card,
  .checkout-card,
  .dashboard-card,
  .profile-card,
  .service-card {
    border-radius: var(--a2t-mobile-radius) !important;
  }

  .a2t-notification-head {
    gap: 12px;
  }

  .a2t-notification-head p {
    display: none;
  }

  .a2t-notification-item {
    padding: 12px;
    gap: 10px;
  }
}

@media (max-width: 430px) {
  :root {
    --a2t-mobile-edge: 12px;
    --a2t-mobile-edge-sm: 8px;
  }

  .a2t-nav-shell {
    padding-inline: 10px !important;
    gap: 8px !important;
  }

  .a2t-brand {
    font-size: 1rem !important;
    letter-spacing: -0.04em !important;
  }

  .a2t-nav-actions {
    gap: 6px !important;
  }

  .a2t-theme-toggle,
  .a2t-mobile-menu-btn,
  .a2t-mobile-nav-notification,
  .a2t-icon-btn {
    width: 42px !important;
    min-width: 42px !important;
    height: 42px !important;
    min-height: 42px !important;
  }

  .a2t-mobile-menu-inner {
    width: calc(100vw - 16px);
    border-radius: 20px;
    padding: 12px;
  }

  .a2t-mobile-nav-quick {
    gap: 8px;
  }

  .a2t-mobile-cart-link {
    padding: 10px 12px !important;
  }

  .a2t-mobile-cart-link span,
  .a2t-mobile-cart-link strong {
    font-size: 0.84rem !important;
  }

  .a2t-mobile-profile-link {
    padding: 10px 12px !important;
  }

  .a2t-mobile-links a {
    min-height: 44px;
    padding: 11px 12px !important;
  }

  .a2t-notification-modal {
    padding-inline: 8px;
  }

  .a2t-notification-dialog {
    border-radius: 20px !important;
  }

  .a2t-notification-head {
    padding: 14px !important;
  }

  .a2t-notification-head h2 {
    font-size: 1.25rem !important;
  }

  .a2t-notification-actions strong,
  [data-notification-count] {
    min-width: 22px;
    height: 22px;
    font-size: 0.72rem;
  }

  .a2t-notification-list {
    padding: 10px !important;
  }

  .a2t-notification-item {
    grid-template-columns: 34px minmax(0, 1fr) auto;
    border-radius: 16px !important;
  }

  .a2t-notification-icon {
    width: 34px !important;
    height: 34px !important;
  }

  .a2t-js-table-card td {
    grid-template-columns: 1fr;
    text-align: left;
    gap: 4px;
  }

  .a2t-js-table-card td::before {
    display: block;
  }

  #snackbar {
    font-size: 0.92rem;
    padding: 12px 14px;
  }
}

@media (max-width: 360px) {
  :root {
    --a2t-mobile-edge: 10px;
  }

  body {
    font-size: 15px;
  }

  .a2t-nav-shell {
    padding-inline: 8px !important;
  }

  .a2t-theme-toggle,
  .a2t-mobile-menu-btn,
  .a2t-mobile-nav-notification,
  .a2t-icon-btn {
    width: 40px !important;
    min-width: 40px !important;
    height: 40px !important;
    min-height: 40px !important;
  }

  .a2t-brand span {
    display: none;
  }

  h1,
  .h1 {
    font-size: clamp(1.82rem, 10vw, 2.24rem) !important;
  }

  h2,
  .h2 {
    font-size: clamp(1.42rem, 8vw, 1.8rem) !important;
  }

  .btn,
  .a2t-btn,
  button,
  input[type="submit"] {
    font-size: 0.94rem;
  }

  .a2t-mobile-menu-inner,
  .a2t-notification-dialog {
    border-radius: 18px !important;
  }
}

@media (max-height: 540px) and (max-width: 900px) {
  .a2t-mobile-menu {
    padding-top: calc(var(--a2t-mobile-header) + 4px);
  }

  .a2t-mobile-menu-inner,
  .a2t-notification-dialog,
  .modal-content {
    max-height: calc((var(--a2t-vh, 1vh) * 100) - var(--a2t-mobile-header) - 10px - var(--a2t-mobile-safe-bottom)) !important;
  }

  .a2t-mobile-profile-link,
  .a2t-mobile-cta {
    padding-block: 10px !important;
  }

  .a2t-mobile-links {
    gap: 6px !important;
  }

  .a2t-mobile-links a {
    min-height: 40px !important;
  }
}

@media (hover: none) and (pointer: coarse) {
  a:hover,
  button:hover,
  .btn:hover,
  .card:hover,
  .product-card:hover,
  .blog-card:hover,
  .service-card:hover {
    transform: none !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

html[data-theme="dark"] .a2t-js-table-card tr {
  border-color: rgba(148, 163, 184, 0.18);
  background: rgba(15, 23, 42, 0.92);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.28);
}

html[data-theme="dark"] .a2t-js-table-card td::before {
  color: rgba(226, 232, 240, 0.68);
}

/* Legacy account activity page brought into the responsive site shell. */
.a2t-activity-dashboard {
  width: min(1120px, calc(100% - 32px));
  margin: 40px auto 80px;
}

.a2t-activity-hero {
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 28px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(248, 250, 252, 0.86));
  padding: clamp(24px, 5vw, 48px);
  box-shadow: 0 20px 70px rgba(15, 23, 42, 0.08);
}

.a2t-activity-hero h1 {
  margin: 8px 0 10px;
  font-size: clamp(2.2rem, 6vw, 4.6rem);
  letter-spacing: -0.07em;
}

.a2t-activity-hero p {
  max-width: 680px;
  margin: 0;
  color: var(--a2t-muted, #64748b);
  font-size: 1.05rem;
  line-height: 1.7;
}

.a2t-activity-list {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.a2t-activity-card,
.a2t-activity-empty {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 22px;
  background: var(--a2t-card, #fff);
  padding: 16px;
  box-shadow: 0 14px 38px rgba(15, 23, 42, 0.06);
}

.a2t-activity-dot {
  width: 12px;
  height: 12px;
  margin-top: 7px;
  border-radius: 999px;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  box-shadow: 0 0 0 6px rgba(37, 99, 235, 0.12);
}

.a2t-activity-copy {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.a2t-activity-copy strong,
.a2t-activity-empty strong {
  color: var(--a2t-text, #0f172a);
  overflow-wrap: anywhere;
}

.a2t-activity-copy span,
.a2t-activity-copy small,
.a2t-activity-empty span {
  color: var(--a2t-muted, #64748b);
}

.a2t-activity-empty {
  grid-template-columns: 1fr;
}

html[data-theme="dark"] .a2t-activity-hero,
html[data-theme="dark"] .a2t-activity-card,
html[data-theme="dark"] .a2t-activity-empty {
  border-color: rgba(148, 163, 184, 0.16);
  background: rgba(15, 23, 42, 0.86);
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.28);
}

@media (max-width: 760px) {
  .a2t-activity-dashboard {
    width: calc(100% - 24px);
    margin: 20px auto 52px;
  }

  .a2t-activity-hero {
    border-radius: 22px;
    padding: 22px;
  }

  .a2t-activity-card,
  .a2t-activity-empty {
    border-radius: 18px;
    padding: 14px;
  }
}
