/* =============================================================================
   Linkorae Freight USA — GLOBAL RESPONSIVE OVERRIDES
   -----------------------------------------------------------------------------
   This file is LOADED LAST on every page. It fixes all mobile/desktop bugs
   without touching brand colors or business logic. Mobile-first.
   Breakpoints: sm 640 · md 768 · lg 1024 · xl 1280 · 2xl 1536 (Tailwind std)
   ============================================================================= */

/* ---------- 1. Kill horizontal scroll everywhere ---------- */
html, body {
  max-width: 100% !important;
  overflow-x: hidden !important;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

*, *::before, *::after {
  box-sizing: border-box;
  max-width: 100%;
}

/* Images / video / iframes never overflow */
img, video, iframe, svg, canvas {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Pre/code might still overflow — allow internal scroll */
pre, code, table {
  max-width: 100%;
  overflow-x: auto;
}

/* ---------- 2. Universal fluid container ---------- */
.lk-container,
.container,
.nav-container,
.quote-wrap,
.acct-wrap,
.acct-shell {
  width: 100% !important;
  max-width: 1280px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 16px;
  padding-right: 16px;
}
@media (min-width: 640px)  { .lk-container, .container, .nav-container { padding-left: 24px; padding-right: 24px; } }
@media (min-width: 1024px) { .lk-container, .container, .nav-container { padding-left: 32px; padding-right: 32px; } }

/* ---------- 3. Typography (mobile-first, min 16px) ---------- */
body {
  font-size: 16px;
  line-height: 1.55;
}
h1 { font-size: clamp(22px, 6vw, 40px); line-height: 1.2; }
h2 { font-size: clamp(20px, 5vw, 32px); line-height: 1.25; }
h3 { font-size: clamp(18px, 4vw, 24px); line-height: 1.3; }
p, li, label { font-size: clamp(15px, 3.6vw, 16px); }

/* Prevent auto-zoom on iOS when tapping inputs (requires ≥16px) */
input, select, textarea, button {
  font-size: 16px;
}

/* ---------- 4. Buttons — tap targets + stacking ---------- */
.btn, .lk-btn, button.primary, button.secondary,
.hero-cta-primary, .hero-cta-secondary,
.lk-quote-submit, .lk-checkout-btn {
  min-height: 48px;
  padding: 12px 20px;
  font-size: 16px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Button rows — stack on mobile, row on desktop */
.lk-btn-row,
.button-row,
.cta-row,
.hero-ctas,
.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}
.lk-btn-row > *,
.button-row > *,
.cta-row > *,
.hero-ctas > *,
.action-buttons > * {
  width: 100%;
}
@media (min-width: 640px) {
  .lk-btn-row,
  .button-row,
  .cta-row,
  .hero-ctas,
  .action-buttons {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .lk-btn-row > *,
  .button-row > *,
  .cta-row > *,
  .hero-ctas > *,
  .action-buttons > * {
    width: auto;
    flex: 0 1 auto;
  }
}

/* ---------- 5. Form inputs ---------- */
input[type="text"], input[type="email"], input[type="tel"],
input[type="number"], input[type="password"], input[type="url"],
input[type="search"], select, textarea,
.lk-form-field, .quote-input {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(10,22,40,0.15);
  background: #fff;
  font: inherit;
}
textarea { min-height: 96px; resize: vertical; }

/* Form rows cap at 500px on desktop */
.lk-form, form.constrained-form {
  max-width: 100%;
}
@media (min-width: 768px) {
  .lk-form.constrained, form.constrained-form {
    max-width: 520px;
  }
}

/* ---------- 6. Cards / grids ---------- */
.lk-card, .quote-card, .service-card, .value-card, .case-card,
.acct-card, .order-card {
  width: 100%;
  box-sizing: border-box;
}

.lk-grid, .grid-auto {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
@media (min-width: 640px)  { .lk-grid, .grid-auto { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; } }
@media (min-width: 1024px) { .lk-grid, .grid-auto { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; } }
@media (min-width: 1280px) { .lk-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

/* ---------- 7. Loading spinner (always centered) ---------- */
.spinner,
.lk-spinner {
  display: inline-block;
  width: 40px;
  height: 40px;
  border: 3px solid rgba(10,22,40,0.15);
  border-top-color: #FF6B00;
  border-radius: 50%;
  animation: lk-spin 0.8s linear infinite;
  margin: 0 auto;
}
@keyframes lk-spin { to { transform: rotate(360deg); } }

.lk-loading,
#acct-loading,
.loading-state {
  display: flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 20px !important;
  min-height: 50vh;
  gap: 14px;
}
.lk-loading > *,
#acct-loading > * { margin: 0 !important; }

/* ---------- 8. Navbar — hamburger on mobile ---------- */
.navbar, nav.lk-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #0A1628;
}
.nav-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 60px;
  gap: 12px;
}

/* Mobile: hide desktop nav list, show hamburger button */
@media (max-width: 1023px) {
  .navbar .nav-links,
  .navbar .nav-cta,
  .nav-menu {
    display: none !important;
  }
  .nav-toggle, .hamburger-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: transparent;
    border: 0;
    color: #fff;
    cursor: pointer;
    padding: 0;
    flex-direction: column;
    gap: 5px;
  }
  .nav-toggle span {
    display: block;
    width: 24px;
    height: 2px;
    background: #fff;
    border-radius: 2px;
    transition: transform .25s, opacity .2s;
  }

  /* When body has .nav-mobile-open (how main.js does it) — reveal menu */
  body.nav-mobile-open .navbar .nav-links,
  body.nav-mobile-open .navbar .nav-cta {
    display: flex !important;
    flex-direction: column !important;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #0A1628;
    padding: 12px 20px 20px;
    gap: 4px;
    margin: 0;
    box-shadow: 0 8px 20px rgba(0,0,0,0.25);
    border-top: 1px solid rgba(255,255,255,0.08);
    list-style: none;
    z-index: 99;
  }
  body.nav-mobile-open .navbar .nav-cta {
    top: auto;
    position: relative;
    padding: 8px 20px 16px;
    background: #0A1628;
    box-shadow: none;
  }
  body.nav-mobile-open .navbar .nav-links li { list-style: none; }
  body.nav-mobile-open .navbar .nav-links a,
  body.nav-mobile-open .navbar .nav-cta a {
    padding: 14px 12px;
    border-radius: 8px;
    color: #fff;
    text-decoration: none;
    font-size: 16px;
    min-height: 48px;
    display: flex;
    align-items: center;
    width: 100%;
    justify-content: flex-start;
  }
  body.nav-mobile-open .navbar .nav-cta a {
    background: #FF6B00;
    color: #0A1628;
    font-weight: 700;
    justify-content: center;
  }
  body.nav-mobile-open .navbar .nav-links a:hover {
    background: rgba(255,255,255,0.08);
  }
}

/* Desktop: show inline nav, hide hamburger */
@media (min-width: 1024px) {
  .nav-toggle, .hamburger-btn { display: none !important; }
}

/* ---------- 9. Hero sections — no overflow ---------- */
.hero, .lk-hero, .page-hero {
  padding: 48px 16px;
  text-align: center;
  overflow: hidden;
}
.hero h1, .lk-hero h1, .page-hero h1 {
  font-size: clamp(28px, 7vw, 48px);
  line-height: 1.15;
  margin-bottom: 14px;
  word-break: break-word;
}
.hero p, .lk-hero p, .page-hero p {
  font-size: clamp(15px, 4vw, 18px);
  line-height: 1.55;
  max-width: 680px;
  margin: 0 auto 24px;
}
@media (min-width: 768px) {
  .hero, .lk-hero, .page-hero { padding: 72px 24px; }
}

/* ---------- 10. Tables: make horizontally scrollable on mobile ---------- */
.lk-table-wrap, .table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 16px;
}
.lk-table-wrap table, .table-responsive table {
  min-width: 560px;
  width: 100%;
  border-collapse: collapse;
}

/* ---------- 11. Checkout / Quote specific fixes ---------- */
.lk-quote-currency { font-size: clamp(16px, 4vw, 32px); margin-right: 4px; opacity: 1; font-weight: 700; }

/* Checkout success hero */
.lk-hero-success {
  padding: 24px 16px;
}
.lk-hero-success .lk-prelim-amount {
  font-size: clamp(24px, 7vw, 40px) !important;
  word-break: break-word;
}

/* Step-list cards inside checkout */
.lk-step-card {
  padding: 16px !important;
}
.lk-step-card ol, .lk-step-card ul {
  padding-left: 20px !important;
}

/* ---------- 12. Admin panel mobile adjustments ---------- */
.ad-shell, .ad-sidebar, .ad-main {
  max-width: 100% !important;
}
@media (max-width: 1023px) {
  .ad-shell {
    display: block !important;
  }
  .ad-sidebar {
    position: fixed !important;
    left: -100% !important;
    top: 60px !important;
    bottom: 0 !important;
    width: 280px !important;
    z-index: 1000;
    transition: left .25s ease !important;
    overflow-y: auto;
  }
  .ad-sidebar.ad-open {
    left: 0 !important;
  }
  .ad-main {
    width: 100% !important;
    padding: 16px !important;
  }
  .ad-topbar {
    position: sticky;
    top: 0;
    z-index: 99;
  }
  /* Show mobile menu button */
  .ad-mobile-toggle {
    display: inline-flex !important;
  }
}
@media (min-width: 1024px) {
  .ad-mobile-toggle { display: none !important; }
}

/* Admin tables */
.ad-table { width: 100%; }
@media (max-width: 767px) {
  .ad-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .ad-table { min-width: 720px; }
}

/* ---------- 13. Modals — full-width on mobile ---------- */
.ad-modal, .lk-modal {
  width: calc(100% - 24px) !important;
  max-width: 720px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  margin: 20px auto;
}
@media (min-width: 768px) {
  .ad-modal, .lk-modal { width: 90% !important; }
}

/* ---------- 14. Safer default for any stray wide element ---------- */
div, section, article, header, footer, main, aside {
  max-width: 100%;
}

/* ---------- 15. Account page specific responsive fixes ---------- */
@media (max-width: 1023px) {
  .account-shell {
    display: block !important;
    grid-template-columns: 1fr !important;
  }
  .acct-sidebar {
    position: static !important;
    width: 100% !important;
    margin-bottom: 20px;
  }
  .acct-nav {
    display: flex;
    flex-direction: row;
    gap: 8px;
    overflow-x: auto;
    padding: 8px;
  }
  .acct-nav li { flex-shrink: 0; }
  .acct-main {
    padding: 16px !important;
  }
  .acct-card {
    padding: 16px !important;
    margin-bottom: 12px;
  }
}

/* Order cards in My Orders list */
.order-card {
  padding: 16px;
  border: 1px solid #E5E7EB;
  border-radius: 12px;
  background: #fff;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
@media (min-width: 640px) {
  .order-card {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

/* ---------- 16. Safety net: force long text to wrap ---------- */
.lk-wrap-anywhere { overflow-wrap: anywhere; word-break: break-word; }
.lk-no-overflow   { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 17. Print / accessibility ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- 18. Utility classes used by pages ---------- */
.lk-hide-mobile { display: none !important; }
.lk-show-mobile { display: block !important; }
@media (min-width: 768px) {
  .lk-hide-mobile { display: initial !important; }
  .lk-show-mobile { display: none !important; }
}