/**
 * Marhaba Shipping LLC - Global Responsive CSS
 * Mobile-first responsive rules for the ACTUAL markup vocabulary
 * (.ks-*, .mh-*, .trk-*, .login-*/.register-*/.reset-*).
 *
 * Breakpoints: <=400 small phones, <=575.98 phones, 576-767.98 large phones,
 * 768-991.98 tablets, >=992 desktop. Bootstrap 5 (public/portals) and
 * AdminLTE 3 (admin) handle their own grids; this file only fills gaps and
 * NEVER overrides AdminLTE's off-canvas sidebar.
 */

/* ===== Global safety: never allow horizontal scroll ===== */
html { overflow-x: hidden; }
body { overflow-x: hidden; position: relative; width: 100%; max-width: 100%; }
@supports (overflow: clip) { html, body { overflow-x: clip; } }
img, svg, video, canvas, iframe { max-width: 100%; height: auto; }
.container, .container-fluid, .row { max-width: 100%; }

/* Flex items (Bootstrap columns, flex rows) default to min-width:auto and
   refuse to shrink below their content, which pushes wide content (long
   headings, logo+wordmark rows) past the viewport. Allow them to shrink. */
.row > [class*="col-"],
.ks-hero [class*="col-"],
.footer-brand,
.footer-brand > div,
.ks-hero-content,
.mh-welcome-card,
.ks-data-card {
    min-width: 0;
}
.footer-brand { flex-wrap: wrap; }

/* ============================================================
   PORTAL SIDEBAR (customer / agent / warehouse) - one mechanism
   The drawer uses transform (kestrel-dashboard.css); here we add the
   toggle button visibility, the offset reset and the backdrop.
   ============================================================ */
@media (max-width: 991.98px) {
    .ks-topbar-toggle { display: inline-flex !important; }
    .ks-main-content { margin-left: 0 !important; width: 100% !important; }

    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(6, 42, 27, 0.55);
        backdrop-filter: blur(2px);
        z-index: 1039;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
    }
    .sidebar-overlay.active { opacity: 1; visibility: visible; }
    /* Lock body scroll while the drawer is open */
    body.ks-nav-open { overflow: hidden; }
}
@media (min-width: 992px) {
    .sidebar-overlay { display: none !important; }
}

/* ============================================================
   TABLETS (<= 991.98px)
   ============================================================ */
@media (max-width: 991.98px) {
    /* Public hero: stop forcing a full viewport height on small screens */
    .ks-hero { min-height: auto; }
    .ks-hero-content { padding: 60px 0 64px; }

    /* Section rhythm tightens */
    .ks-section { padding: 64px 0; }
    .ks-stats-section { padding: 48px 0; }
    .ks-cta-section { padding: 64px 0; }

    /* Table cell density */
    .ks-table th, .ks-table td { padding: 12px 12px; }
}

/* ============================================================
   PHONES (<= 767.98px)
   ============================================================ */
@media (max-width: 767.98px) {
    /* ---- Public hero ---- */
    /* Let flex columns shrink below their content's intrinsic width so long
       strings (badge, headings) never force the column past the viewport. */
    .ks-hero [class*="col-"], .ks-hero-content { min-width: 0; }
    .ks-hero-content { padding: 44px 0 52px; text-align: left; max-width: 100%; }
    .ks-hero-badge {
        font-size: 0.74rem;
        white-space: normal;
        max-width: 100%;
        align-items: flex-start;
        line-height: 1.35;
        text-align: left;
    }
    .ks-hero-subtitle { font-size: 1.02rem; max-width: 100%; }
    .ks-hero-title { max-width: 100%; overflow-wrap: break-word; }
    .ks-hero-stats { gap: 1.25rem 1.75rem; }
    .ks-hero-actions .btn { flex: 1 1 auto; justify-content: center; }

    /* ---- Section headers ---- */
    .ks-section { padding: 52px 0; }
    .ks-section-header { margin-bottom: 2.5rem; }
    .ks-section-subtitle { font-size: 0.98rem; }

    /* ---- Trust strip: readable wrap ---- */
    .ks-trust-strip { padding: 0.9rem 0; }
    .ks-trust-strip .row { gap: 0.5rem 0; }
    .ks-trust-strip .ks-trust-item { font-size: 0.8rem; }

    /* ---- Welcome / process / cards ---- */
    .mh-welcome-card { padding: 1.5rem; }
    .mh-process-step { padding: 1.5rem 1.25rem; }
    .mh-value-point { font-size: 0.86rem; }
    .ks-service-card { padding: 1.75rem 1.5rem; }
    .ks-testimonial-card { padding: 1.75rem 1.5rem; }

    /* ---- Quote form ---- */
    .ks-quote-form { padding: 1.5rem; }

    /* ---- Page hero (about/faq/blog/careers/legal) ---- */
    .ks-page-hero { padding: 96px 0 44px !important; }
    .ks-page-hero h1, .ks-page-hero .display-4 { font-size: 2rem; }

    /* ---- Footer ---- */
    .ks-footer { text-align: left; }
    .ks-footer .footer-brand { justify-content: flex-start; }

    /* ---- Contact map ---- */
    .ks-map-container { height: 280px; }

    /* ---- Dashboard content ---- */
    .ks-page-header { flex-direction: column; align-items: flex-start !important; gap: 12px; }
    .ks-table th, .ks-table td { padding: 10px 8px; font-size: 0.85rem; }
    .ks-table-header { flex-direction: column; align-items: stretch !important; }
    .ks-table-header .d-flex { flex-wrap: wrap; }
    .ks-table-actions .input-group { width: 100% !important; margin-top: 8px; }

    /* Notification dropdown never wider than the screen */
    .ks-notification-dropdown, .dropdown-menu { max-width: calc(100vw - 24px); }

    /* Modals hug the viewport */
    .modal-dialog { margin: 12px auto; max-width: calc(100% - 24px); }
}

/* ============================================================
   SMALL PHONES (<= 400px)
   ============================================================ */
@media (max-width: 400px) {
    .ks-hero-stats { gap: 1rem 1.5rem; }
    .ks-hero-actions { flex-direction: column; }
    .ks-hero-actions .btn { width: 100%; }
    .btn-lg { padding: 0.7rem 1.1rem; font-size: 0.95rem; }
    .ks-trust-strip .ks-trust-label { display: none; }
}

/* ============================================================
   TRACK PAGE (self-contained .trk-* markup)
   The page has its own <=640/<=768 rules; here we just tighten padding.
   ============================================================ */
@media (max-width: 575.98px) {
    .trk-search { padding: 22px !important; }
    .trk-banner { padding: 20px 18px !important; }
    .trk-route, .trk-steps, .trk-tl, .trk-actions, .trk-details { padding: 20px !important; }
    .trk-trackno { font-size: 1.35rem !important; word-break: break-all; }
}

/* ============================================================
   AUTH PAGES (.login-* / .register-* / .reset-*)
   ============================================================ */
@media (max-width: 767.98px) {
    .login-container, .register-container, .reset-container { padding: 20px 16px; }
    .login-form, .register-form, .reset-form { padding: 24px 20px; }
    .login-logo img, .register-logo img, .reset-logo img { height: 56px; }
    /* Hide decorative brand side-panel on phones if present */
    .login-brand-side, .register-brand-side, .auth-aside { display: none !important; }
}

/* ============================================================
   MOBILE DATA-CARD FALLBACK (shared by portal + admin wide tables)
   Paired with a `.d-none d-lg-block` table and a `.d-lg-none` list.
   ============================================================ */
.ks-card-list { display: flex; flex-direction: column; gap: 12px; }
.ks-data-card {
    background: var(--ks-bg-primary, #fff);
    border: 1px solid var(--ks-dark-100, #d3e5da);
    border-radius: var(--ks-radius-lg, 0.5rem);
    padding: 14px 16px;
    box-shadow: var(--ks-shadow-sm, 0 1px 2px rgba(6,42,27,0.06));
}
.ks-data-card-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px; margin-bottom: 10px;
    padding-bottom: 10px; border-bottom: 1px solid var(--ks-dark-100, #d3e5da);
}
.ks-data-card-title { font-weight: 700; color: var(--ks-text-primary, #14261c); font-size: 0.95rem; word-break: break-word; }
.ks-data-card-row { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; font-size: 0.88rem; }
.ks-data-card-row .k { color: var(--ks-text-muted, #6b7a70); flex: 0 0 auto; }
.ks-data-card-row .v { color: var(--ks-text-primary, #14261c); text-align: right; word-break: break-word; }
.ks-data-card-actions { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }
.ks-data-card-actions .btn { flex: 1 1 auto; justify-content: center; }

/* ============================================================
   TOUCH TARGETS - scoped to content areas only (never AdminLTE nav)
   ============================================================ */
@media (max-width: 991.98px) {
    .ks-main-content .btn,
    .ks-main-content .form-control,
    .ks-main-content .form-select,
    .content-wrapper .btn:not(.btn-xs):not(.btn-sm),
    .ks-hero .btn,
    .login-form .btn, .register-form .btn, .reset-form .btn,
    .ks-quote-form .btn {
        min-height: 44px;
    }
}

/* ===== Show/hide helpers ===== */
.show-mobile { display: none !important; }
@media (max-width: 767.98px) {
    .show-mobile { display: block !important; }
    .hide-mobile { display: none !important; }
}

/* ===== Safe area for notched phones ===== */
@supports (padding: max(0px)) {
    .ks-sidebar { padding-bottom: max(16px, env(safe-area-inset-bottom)); }
    .ks-footer, .main-footer { padding-bottom: max(16px, env(safe-area-inset-bottom)); }
}

/* ===== Print ===== */
@media print {
    .ks-sidebar, .sidebar-overlay, .ks-topbar, .no-print { display: none !important; }
    .ks-main-content { margin-left: 0 !important; width: 100% !important; }
}
