/* =============================================================================
   LINKORAE CUSTOMER PORTAL — MOBILE (Jobs-level)
   -----------------------------------------------------------------------------
   Goals:
     - iOS-class polish: generous tap targets, big type, haptic-feeling taps.
     - Pure-mobile enhancements; desktop is untouched (all guards ≤ 768px).
     - Additive: drops in on top of linkorae-customer-shell.css without changes.

   What it does:
     1. Hides the top hamburger & sidebar on mobile in favor of a native-feeling
        bottom tab bar with a protruding center "New" FAB.
     2. Gives the main content proper safe-area padding (iPhone notch/home).
     3. Rebuilds the order list cards so every row is a one-tap surface with
        a clear tier/status chip hierarchy.
     4. Fluid typography for headlines; touchable list rows with press states.
     5. Pull-to-feel scroll polish, bouncy lists.
   ============================================================================= */

@media (max-width: 768px) {

  /* ============= Shell: hide desktop sidebar, collapse topbar ============= */
  .cs-shell .cs-sidebar {
    transform: translateX(-100%);
  }
  .cs-sidebar.cs-open { transform: translateX(0); }

  /* Let content breathe */
  body.has-shell .cs-main {
    margin-left: 0 !important;
    padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)) !important;
    min-height: 100vh;
  }

  /* Slimmer, glass-morphic topbar */
  .cs-topbar {
    position: sticky; top: 0; z-index: 100;
    height: 56px;
    padding: 0 16px;
    background: rgba(10, 14, 26, 0.85);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  }
  .cs-topbar__brand b {
    font-size: 17px; font-weight: 700; letter-spacing: -0.01em;
  }
  .cs-topbar__right a {
    font-size: 13px; font-weight: 600;
    color: #F5B544;
    padding: 7px 12px;
    background: rgba(245, 181, 68, 0.1);
    border-radius: 100px;
  }

  /* Comfortable content padding */
  .cs-main > * {
    padding-left: 16px !important;
    padding-right: 16px !important;
  }
  .cs-main > .cs-wrap,
  .cs-main > .mo-wrap,
  .cs-main > .od-wrap {
    max-width: 100%;
    padding-top: 20px !important;
  }

  /* ============= Big headline style ============= */
  .cs-main h1, .cs-main .mo-title {
    font-size: clamp(26px, 7.5vw, 34px) !important;
    font-weight: 800 !important;
    letter-spacing: -0.02em !important;
    line-height: 1.15 !important;
    margin-bottom: 6px !important;
  }
  .cs-main h2 {
    font-size: clamp(20px, 5vw, 24px) !important;
    font-weight: 700 !important;
    letter-spacing: -0.015em !important;
  }
  .cs-main .mo-sub,
  .cs-main .mo-title + p {
    font-size: 15px; color: rgba(255,255,255,0.58);
  }
}

/* =============================================================================
   CUSTOMER BOTTOM TAB BAR (logged-in portal only)
   ============================================================================= */

.cs-tabbar {
  display: none; /* desktop hidden */
}

@media (max-width: 768px) {
  .cs-tabbar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 200;
    display: flex;
    align-items: flex-end;
    justify-content: space-around;
    padding: 8px 4px calc(8px + env(safe-area-inset-bottom, 0px));
    background: rgba(10, 14, 26, 0.92);
    backdrop-filter: saturate(180%) blur(28px);
    -webkit-backdrop-filter: saturate(180%) blur(28px);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    /* iOS-like subtle glow */
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.5);
  }

  .cs-tabbar__item {
    flex: 1;
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 6px 4px;
    color: rgba(255, 255, 255, 0.5);
    text-decoration: none;
    font-size: 10px; font-weight: 600;
    letter-spacing: 0.01em;
    transition: color 160ms ease, transform 140ms ease;
    min-width: 0;
    -webkit-tap-highlight-color: transparent;
  }
  .cs-tabbar__item svg {
    width: 24px; height: 24px; stroke-width: 2;
    transition: transform 160ms cubic-bezier(0.34, 1.56, 0.64, 1);
  }
  .cs-tabbar__item span {
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: 100%;
  }
  .cs-tabbar__item.is-active {
    color: #F5B544;
  }
  .cs-tabbar__item.is-active svg {
    transform: scale(1.12) translateY(-1px);
  }
  .cs-tabbar__item:active {
    transform: scale(0.93);
  }

  /* Floating center "New" FAB */
  .cs-tabbar__fab {
    flex: 0 0 auto;
    position: relative;
    width: 56px; height: 56px;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #F5B544 0%, #E8A52E 100%);
    color: #0A0E1A;
    border-radius: 50%;
    box-shadow:
      0 8px 22px rgba(245, 181, 68, 0.45),
      0 0 0 3px rgba(10, 14, 26, 0.9);
    transform: translateY(-18px);
    transition: transform 180ms cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 200ms ease;
    -webkit-tap-highlight-color: transparent;
  }
  .cs-tabbar__fab:active {
    transform: translateY(-18px) scale(0.9);
    box-shadow: 0 4px 14px rgba(245, 181, 68, 0.35), 0 0 0 3px rgba(10, 14, 26, 0.9);
  }
  .cs-tabbar__fab svg { width: 28px; height: 28px; stroke-width: 2.5; }
}

/* =============================================================================
   ORDER LIST — mobile card redesign
   -----------------------------------------------------------------------------
   Targets existing my-orders markup and reshapes each order row into a tappable
   card with: big order #, status chip top-right, weight+price row, chevron.
   ============================================================================= */
@media (max-width: 768px) {

  .mo-list, .mo-orders {
    display: flex; flex-direction: column;
    gap: 12px;
    margin: 0 !important;
    padding: 0 !important;
  }

  .mo-order, .mo-card, .mo-item {
    background: #111827 !important;
    border: 1px solid rgba(255, 255, 255, 0.06) !important;
    border-radius: 18px !important;
    padding: 16px !important;
    margin: 0 !important;
    position: relative;
    transition: transform 160ms cubic-bezier(0.34, 1.56, 0.64, 1), background 160ms ease;
    -webkit-tap-highlight-color: transparent;
    overflow: hidden;
  }
  .mo-order::after, .mo-card::after, .mo-item::after {
    content: "";
    position: absolute; inset: 0;
    background: linear-gradient(135deg, rgba(245,181,68,0.0) 0%, rgba(245,181,68,0.0) 100%);
    pointer-events: none;
    transition: background 180ms ease;
  }
  .mo-order:active, .mo-card:active, .mo-item:active {
    transform: scale(0.98);
    background: #0F172A !important;
  }

  /* Top row: order # + status chip */
  .mo-order-head,
  .mo-card-head {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
  }
  .mo-order-num,
  .mo-card-num {
    font-size: 17px; font-weight: 700;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    letter-spacing: 0.01em;
    color: #fff;
  }

  /* Middle row: big stat */
  .mo-order-main,
  .mo-card-main {
    display: flex; align-items: baseline; gap: 8px;
    margin: 4px 0 8px;
  }
  .mo-order-weight,
  .mo-card-kg {
    font-size: 24px; font-weight: 800;
    letter-spacing: -0.02em;
    color: #F5B544;
  }
  .mo-order-weight-unit { font-size: 14px; font-weight: 500; color: rgba(255,255,255,0.5); }

  /* Bottom meta row */
  .mo-order-meta,
  .mo-card-meta {
    display: flex; align-items: center; justify-content: space-between;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.55);
  }
  .mo-order-price,
  .mo-card-price {
    font-weight: 700; color: #fff;
  }

  /* Filter chips row — horizontally scrollable */
  .mo-filters, .mo-filter-row {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 4px 0 12px;
    margin: 0 -16px 12px -16px !important;
    padding-left: 16px !important;
    padding-right: 16px !important;
  }
  .mo-filters::-webkit-scrollbar,
  .mo-filter-row::-webkit-scrollbar { display: none; }
  .mo-filter, .mo-chip {
    flex-shrink: 0;
    padding: 8px 14px !important;
    background: rgba(255, 255, 255, 0.06) !important;
    border: 1px solid transparent !important;
    border-radius: 100px !important;
    color: rgba(255, 255, 255, 0.7) !important;
    font-size: 13px !important; font-weight: 600 !important;
    white-space: nowrap;
  }
  .mo-filter.is-active, .mo-chip.is-active,
  .mo-filter.active, .mo-chip.active {
    background: rgba(245, 181, 68, 0.15) !important;
    color: #F5B544 !important;
    border-color: rgba(245, 181, 68, 0.35) !important;
  }

  /* Empty state on mobile — softer */
  .mo-empty {
    text-align: center;
    padding: 48px 20px !important;
    color: rgba(255,255,255,0.6);
  }
  .mo-empty-icon {
    font-size: 52px;
    margin-bottom: 10px;
  }

  /* Pagination bar — hide ugly desktop one, show compact */
  .mo-paging, .mo-pagination {
    justify-content: center !important;
    padding: 16px 0 !important;
  }

  /* ======== DASHBOARD KPI cards — mobile vertical stack ======== */
  .dash-kpi-grid, .lk-kpi-grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }
  .dash-kpi, .lk-kpi {
    padding: 14px !important;
    border-radius: 14px !important;
  }
  .dash-kpi-num, .lk-kpi-num {
    font-size: 22px !important; font-weight: 800 !important;
  }
  .dash-kpi-label, .lk-kpi-label {
    font-size: 11px !important; letter-spacing: 0.02em !important;
  }
}

/* =============================================================================
   FORMS ON MOBILE — bigger inputs, clearer labels
   ============================================================================= */
@media (max-width: 768px) {
  input[type="text"], input[type="email"], input[type="tel"], input[type="number"],
  input[type="date"], input[type="search"], input[type="password"], select, textarea {
    font-size: 16px !important; /* prevent iOS zoom */
    padding: 14px 14px !important;
    border-radius: 12px !important;
    min-height: 48px;
  }

  button, .btn, .mo-btn, .od-btn {
    min-height: 48px;
    border-radius: 12px !important;
    font-size: 15px !important; font-weight: 600 !important;
  }

  /* Primary / CTA buttons: make them unmissable */
  .btn-primary, .od-btn-primary, .cta-primary {
    padding: 16px 22px !important;
    font-size: 16px !important; font-weight: 700 !important;
    letter-spacing: -0.005em !important;
  }
}

/* =============================================================================
   ORDER DETAIL PAGE — mobile reflow
   ============================================================================= */
@media (max-width: 768px) {
  .od-wrap { padding: 16px !important; }
  .od-hero {
    padding: 18px !important;
    border-radius: 16px !important;
  }
  .od-timeline-step {
    font-size: 13px !important;
  }
  .od-upload-zone {
    padding: 20px !important;
    border-radius: 14px !important;
  }
  .od-grid, .od-cols {
    grid-template-columns: 1fr !important;
  }
}

/* =============================================================================
   ADMIN MOBILE — shrink to essentials
   ============================================================================= */
@media (max-width: 768px) {
  .admin-v2 .ad-sidebar {
    transform: translateX(-100%);
    transition: transform 260ms cubic-bezier(0.2, 0.8, 0.2, 1);
    z-index: 300;
  }
  .admin-v2 .ad-sidebar.ad-open { transform: translateX(0); }

  .admin-v2 .ad-main { margin-left: 0 !important; padding: 14px !important; }
  .admin-v2 .ad-topbar {
    padding: 0 14px; height: 54px;
    position: sticky; top: 0; z-index: 200;
    background: rgba(255,255,255,0.96);
    backdrop-filter: blur(16px);
  }

  /* Admin orders table → card-view on mobile */
  .admin-v2 .ad-table thead { display: none; }
  .admin-v2 .ad-table, .admin-v2 .ad-table tbody,
  .admin-v2 .ad-table tr, .admin-v2 .ad-table td {
    display: block; width: 100%;
  }
  .admin-v2 .ad-table tr {
    background: #fff;
    border: 1px solid #E2E8F0;
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 10px;
    position: relative;
  }
  .admin-v2 .ad-table td {
    padding: 4px 0 !important;
    border: none !important;
    display: flex; justify-content: space-between; align-items: center;
    gap: 12px;
    font-size: 14px;
  }
  .admin-v2 .ad-table td::before {
    content: attr(data-label);
    color: #64748B;
    font-weight: 500; font-size: 12px;
    text-transform: uppercase; letter-spacing: 0.05em;
  }

  /* Admin modal full-sheet on mobile */
  .admin-v2 .ad-modal, .admin-v2 .ad-sheet {
    inset: 0 !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
  }
  .admin-v2 .ad-modal-body { padding: 20px !important; }
}

/* =============================================================================
   GLOBAL MOBILE POLISH
   ============================================================================= */
@media (max-width: 768px) {
  html, body {
    -webkit-text-size-adjust: 100%;
    overscroll-behavior-y: none;
  }
  body {
    font-feature-settings: "kern" 1, "liga" 1, "tnum" 1;
  }

  /* Smooth momentum scroll */
  * { -webkit-overflow-scrolling: touch; }

  /* Kill tap-highlight flash on links */
  a, button { -webkit-tap-highlight-color: transparent; }

  /* Safe-area aware content */
  .cs-main, .mo-wrap, .od-wrap, .dash-wrap {
    padding-left: max(16px, env(safe-area-inset-left)) !important;
    padding-right: max(16px, env(safe-area-inset-right)) !important;
  }
}