/* ==========================================================
   The Gateway - main stylesheet
   Light sidebar + navy blue theme (on top of Bootstrap 5.3)
   ========================================================== */

/* ---------- Font (stored locally) ---------- */
@font-face {
    font-family: "Inter";
    src: url("../vendor/inter/inter-latin-wght-normal.woff2") format("woff2");
    font-weight: 100 900;
    font-display: swap;
}

/* ---------- Colors ---------- */
:root {
    --gw-navy: #1e3a6e;
    --gw-navy-dark: #162c54;
    --gw-navy-soft: #eaf0fa;
    --gw-bg: #f5f7fb;
    --gw-border: #e6e9f0;
    --gw-muted: #6b7489;
    --gw-sidebar-width: 260px;
    --gw-control-height: 44px;  /* every input box, dropdown and Select2 box has this height (owner, 2026-11-15) */

    --bs-body-font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --bs-body-color: #1f2937;
    --bs-border-color: var(--gw-border);
    --bs-primary: #1e3a6e;
    --bs-primary-rgb: 30, 58, 110;
    --bs-link-color: #1e3a6e;
    --bs-link-color-rgb: 30, 58, 110;
    --bs-link-hover-color: #162c54;
    --bs-link-hover-color-rgb: 22, 44, 84;
}

/* ---------- Buttons ---------- */
.btn { font-weight: 500; border-radius: .6rem; }

.btn-primary {
    --bs-btn-bg: var(--gw-navy);
    --bs-btn-border-color: var(--gw-navy);
    --bs-btn-hover-bg: var(--gw-navy-dark);
    --bs-btn-hover-border-color: var(--gw-navy-dark);
    --bs-btn-active-bg: var(--gw-navy-dark);
    --bs-btn-active-border-color: var(--gw-navy-dark);
    --bs-btn-disabled-bg: var(--gw-navy);
    --bs-btn-disabled-border-color: var(--gw-navy);
}

.btn-outline-primary {
    --bs-btn-color: var(--gw-navy);
    --bs-btn-border-color: var(--gw-navy);
    --bs-btn-hover-bg: var(--gw-navy);
    --bs-btn-hover-border-color: var(--gw-navy);
    --bs-btn-active-bg: var(--gw-navy-dark);
    --bs-btn-active-border-color: var(--gw-navy-dark);
}

.btn-light { --bs-btn-bg: #fff; --bs-btn-border-color: var(--gw-border); }

/* ---------- Forms ---------- */
.form-label { font-weight: 500; font-size: .875rem; color: #374151; }
.form-control, .form-select { border-radius: .6rem; padding: .6rem .85rem; border-color: #d9dee8; }
/* Dropdowns: room on the right for the arrow, so long text never runs under it */
.form-select { padding-right: 2.25rem; }
/* One height for all boxes (not for text areas or small "sm" boxes) */
input.form-control:not(.form-control-sm), select.form-select:not(.form-select-sm) { height: var(--gw-control-height); }
.form-control:focus, .form-select:focus {
    border-color: #8aa3cf;
    box-shadow: 0 0 0 .2rem rgba(30, 58, 110, .15);
}

/* ---------- App layout ---------- */
body { background-color: var(--gw-bg); }  /* gray page, white cards and inputs */
.app { display: flex; min-height: 100vh; }
.app-main { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; }
.app-content { padding: 1.75rem; flex-grow: 1; }

/* ---------- Sidebar ---------- */
.sidebar { background-color: #fff !important; }

@media (min-width: 992px) {
    .sidebar {
        width: var(--gw-sidebar-width);
        flex-shrink: 0;
        border-right: 1px solid var(--gw-border);
        position: sticky;
        top: 0;
        height: 100vh;
    }
}

.sidebar .offcanvas-body { flex-direction: column; height: 100%; }

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 1.4rem 1.25rem;
    text-decoration: none;
    color: var(--gw-navy);
}
.sidebar-brand:hover { color: var(--gw-navy); }

.brand-logo {
    width: 40px;
    height: 40px;
    border-radius: .7rem;
    background: var(--gw-navy);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}
.brand-name { font-weight: 700; font-size: 1.1rem; line-height: 1.1; }
.brand-sub { font-size: .75rem; color: var(--gw-muted); }

.sidebar-nav { padding: 0 .9rem; flex-grow: 1; overflow-y: auto; }

.sidebar-section {
    font-size: .7rem;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #9aa3b5;
    padding: 1.1rem .75rem .45rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .6rem .75rem;
    margin-bottom: .15rem;
    border-radius: .6rem;
    color: #4b5563;
    font-weight: 500;
    font-size: .925rem;
    text-decoration: none;
    transition: background .15s, color .15s;
}
.sidebar-link i { font-size: 1.1rem; width: 1.25rem; text-align: center; }
.sidebar-link:hover { background: var(--gw-bg); color: var(--gw-navy); }
.sidebar-link.active { background: var(--gw-navy-soft); color: var(--gw-navy); font-weight: 600; }
.sidebar-link.disabled { color: #b4bac6; pointer-events: none; }
.menu-badge {
    margin-left: auto;
    min-width: 1.4rem;
    padding: .05rem .45rem;
    border-radius: 999px;
    background: #f59e0b;
    color: #fff;
    font-size: .72rem;
    font-weight: 700;
    text-align: center;
}
.sidebar-link .soon {
    margin-left: auto;
    font-size: .65rem;
    font-weight: 600;
    background: #f1f3f7;
    color: #9aa3b5;
    padding: .1rem .45rem;
    border-radius: 999px;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin: .9rem;
    padding: .75rem;
    border-radius: .75rem;
    background: var(--gw-bg);
}

/* ---------- Avatar (user initial) ---------- */
.avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--gw-navy-soft);
    color: var(--gw-navy);
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.avatar-sm { width: 32px; height: 32px; font-size: .85rem; border-radius: .55rem; }
.avatar-lg { width: 72px; height: 72px; font-size: 1.75rem; border-radius: 1.1rem; }

/* ---------- Tabs ---------- */
.nav-underline .nav-link { color: var(--gw-muted); font-weight: 500; padding: 1rem .25rem; }
.nav-underline .nav-link.active { color: var(--gw-navy); font-weight: 600; border-bottom-color: var(--gw-navy); }

.tab-count {
    display: inline-block;
    min-width: 1.6rem;
    padding: .05rem .45rem;
    margin-left: .25rem;
    border-radius: 999px;
    background: #f1f3f7;
    color: var(--gw-muted);
    font-size: .75rem;
    font-weight: 600;
    text-align: center;
}
.nav-link.active .tab-count { background: var(--gw-navy); color: #fff; }

/* ---------- Top bar ---------- */
.topbar {
    height: 68px;
    background: #fff;
    border-bottom: 1px solid var(--gw-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.75rem;
    position: sticky;
    top: 0;
    z-index: 1020;
}
.topbar-title { font-size: 1.15rem; font-weight: 600; margin: 0; }
.topbar .user-button { display: flex; align-items: center; gap: .6rem; background: none; border: 0; padding: 0; }

/* ---------- Page header (subtitle + buttons) ---------- */
/* The buttons of a page header: each on one line; on a phone they wrap to a second row instead of squeezing */
.page-header .d-flex { flex-wrap: wrap; }
.page-header .btn { white-space: nowrap; }
.page-header {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}
.page-subtitle { color: var(--gw-muted); margin: 0; }

/* ---------- Search box (icon inside the input) ---------- */
.search-box { position: relative; width: 100%; max-width: 340px; }
.search-box i { position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); color: #9aa3b5; }
.search-box .form-control { padding-left: 2.4rem; background: #fff; }

/* ---------- Filter bar (search + dropdowns) ---------- */
.filter-bar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; flex-grow: 1; }
.filter-bar .form-select { width: auto; min-width: 140px; background-color: #fff; }
/* HS Codes page: the list dropdown shows "List: Global HS 2017 (old version)" in full */
.filter-bar select[name=code_list] { min-width: 330px; padding-right: 2.25rem; font-weight: 600; color: var(--gw-navy); }
.filter-bar .search-box { max-width: 320px; min-width: 260px; flex: 1 1 300px; }  /* the hint text is never cut */
/* A longer hint (shipments list: "Tracking #, customer, phone, pallet, flight"): a wider box. Phones: full width anyway */
@media (min-width: 768px) {
    .filter-bar .search-box:has(input[data-wide]) { max-width: 380px; min-width: 380px; flex-basis: 380px; }
}
/* Phones: the dropdowns fold behind the "Filters" button (templates/filter_bar.html) */
.filter-toggle { display: none; }
@media (max-width: 767.98px) {
    .filter-toggle { display: inline-flex; align-items: center; gap: .25rem; }
    .filter-bar:not(.is-open) .filter-field, .filter-bar:not(.is-open) .filter-submit { display: none; }
    .filter-bar .search-box { max-width: none; flex: 1 1 100%; }
}

/* ---------- Checkbox list (e.g. warehouses) ---------- */
.checkbox-list {
    border: 1px solid #d9dee8;
    border-radius: .6rem;
    padding: .6rem .85rem;
    max-height: 220px;
    overflow-y: auto;
}
.checkbox-list .form-check { padding-top: .2rem; padding-bottom: .2rem; }
.checkbox-list .form-check-input:checked { background-color: var(--gw-navy); border-color: var(--gw-navy); }

/* ---------- Switch (on/off) ---------- */
.form-switch .form-check-input { width: 2.5em; height: 1.3em; cursor: pointer; }
.form-switch .form-check-input:checked { background-color: var(--gw-navy); border-color: var(--gw-navy); }
.form-switch .form-check-label { margin-left: .35rem; font-weight: 500; }

/* ---------- Cards ---------- */
/* Cards: a clear edge (darker outline + soft shadow) so they stand out from the gray page (owner, 2026-11-15) */
.card {
    border: 1px solid #c5cddb;
    border-radius: .9rem;
    box-shadow: 0 1px 3px rgba(16, 24, 40, .08);
}
/* Card title: a very light gray band, so each card's title stands out from its content (owner, 2026-11-15) */
.card-header {
    background: #eef1f6;
    border-bottom: 1px solid #c5cddb;
    padding: 1rem 1.25rem;
    font-weight: 600;
    color: var(--gw-navy);
    border-radius: .9rem .9rem 0 0 !important;
}
/* Tabs in a card header (e.g. the client page) stay white */
.card-header:has(.nav) { background: #fff; color: inherit; }
.card-body { padding: 1.25rem; }

/* Stat cards on the dashboard */
.stat-card .card-body { display: flex; align-items: center; gap: 1rem; }
.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: .75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    flex-shrink: 0;
}
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.stat-label { color: var(--gw-muted); font-size: .85rem; }

.case-stat { display: flex; align-items: center; gap: .75rem; color: inherit; padding: .5rem; border-radius: .75rem; }
.case-stat:hover { background: var(--gw-bg); color: inherit; }

.icon-navy   { background: var(--gw-navy-soft); color: var(--gw-navy); }
.icon-blue   { background: #e0f2fe; color: #0369a1; }
.icon-amber  { background: #fef3c7; color: #b45309; }
.icon-green  { background: #dcfce7; color: #15803d; }

/* ---------- Tables ---------- */
.table { margin-bottom: 0; }
.table > thead th {
    background: #f9fafc;
    color: var(--gw-muted);
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    padding: .8rem 1.25rem;
    border-bottom: 1px solid var(--gw-border);
    white-space: nowrap;
}
.table > tbody td { padding: .9rem 1.25rem; vertical-align: middle; border-color: #eef0f5; }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: #f8fafd; }
.tracking-link { font-weight: 600; text-decoration: none; white-space: nowrap; }

/* Sortable column headers (django-tables2) */
.table > thead th a { color: inherit; text-decoration: none; }
.table > thead th a:hover { color: var(--gw-navy); }
.table > thead th.orderable a::after { content: "\2195"; margin-left: .3rem; opacity: .35; }
.table > thead th.asc a::after { content: "\2191"; opacity: 1; color: var(--gw-navy); }
.table > thead th.desc a::after { content: "\2193"; opacity: 1; color: var(--gw-navy); }
.table-container { border-radius: 0 0 .9rem .9rem; }
/* A card that starts with a table (no title band): round the top too, so the card's top corners stay closed */
.card > .table-container:first-child { border-radius: .9rem; }

/* Table footer: "Showing 1-20 of 57" + pages */
/* Pages under every list: the page buttons in the middle, "Showing 1–20 of 57" centered under them */
.table-footer {
    display: flex;
    flex-direction: column-reverse;  /* buttons first, then the "Showing" text */
    align-items: center;
    gap: .4rem;
    padding: .9rem 1.25rem;
    border-top: 1px solid var(--gw-border);
}
.table-footer .pagination { flex-wrap: wrap; justify-content: center; }
.pagination { --bs-pagination-color: var(--gw-navy); --bs-pagination-active-bg: var(--gw-navy); --bs-pagination-active-border-color: var(--gw-navy); --bs-pagination-border-radius: .5rem; }

/* Empty table / list */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--gw-muted); }

/* Error pages (templates/404.html, 500.html): one centered card, no technical details */
.error-card { max-width: 560px; margin: 2rem auto; }
.error-card .card-body { padding: 2.5rem 1.5rem; }
.error-icon { font-size: 3rem; color: #9aa3b5; }
.error-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; background: var(--gw-bg); }
.error-page .error-card { width: 100%; margin: 0; }
.empty-state i { font-size: 2.5rem; color: #c3c9d5; display: block; margin-bottom: .5rem; }

/* ---------- Status badges ---------- */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .3rem .7rem;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 600;
    white-space: nowrap;
}
.status-badge::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}
.status-received   { background: var(--gw-navy-soft); color: var(--gw-navy); }
.status-in_transit { background: #e0f2fe; color: #0369a1; }
.status-on_hold    { background: #fef3c7; color: #b45309; }
.status-delivered  { background: #dcfce7; color: #15803d; }
.status-returned   { background: #f1f5f9; color: #475569; }
.status-cancelled  { background: #fee2e2; color: #b91c1c; }

/* ---------- Case & claim statuses (same look as shipment statuses) ---------- */
.status-open     { background: #fef3c7; color: #b45309; }
.status-claimed  { background: #e0f2fe; color: #0369a1; }
.status-resolved { background: #dcfce7; color: #15803d; }
.status-closed   { background: #f1f5f9; color: #475569; }
.status-pending  { background: #fef3c7; color: #b45309; }
.status-accepted { background: #dcfce7; color: #15803d; }
.status-rejected { background: #fee2e2; color: #b91c1c; }

/* "Unknown" owner badge */
.unknown-badge {
    display: inline-block;
    padding: .25rem .65rem;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 600;
    background: #fef3c7;
    color: #92400e;
    border: 1px dashed #f59e0b;
}

/* Goods type label: icon + name (e.g. "Clothes") */
.goods-badge {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .2rem .6rem;
    border-radius: 999px;
    font-size: .8rem;
    font-weight: 500;
    background: #f1f4f9;
    color: var(--gw-navy);
    border: 1px solid #dde3ee;
    white-space: nowrap;
}

/* Pallet page: fast scanning box (A) + its answer line */
.scan-box { position: relative; }
.scan-box i { position: absolute; left: .9rem; top: 50%; transform: translateY(-50%); color: var(--gw-navy); font-size: 1.1rem; }
.scan-box .form-control { padding-left: 2.6rem; font-size: 1rem; border-color: var(--gw-navy); }
.scan-result { margin-top: .5rem; padding: .45rem .75rem; border-radius: .5rem; font-size: .9rem; font-weight: 500; }
.scan-result.is-ok { background: #dcfce7; color: #15803d; }
.scan-result.is-error { background: #fee2e2; color: #b91c1c; }

/* "Add many" window (B) */
.many-filters .search-box { max-width: 280px; }
.many-filters .form-select { width: auto; min-width: 170px; }
.many-table thead th { position: sticky; top: 0; z-index: 1; }

/* "Close the pallet": 1 photos, 2 weigh and close */
.close-step { display: flex; align-items: center; gap: .5rem; font-weight: 600; color: var(--gw-navy); margin-bottom: .6rem; }
.close-step-number {
    display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px;
    border-radius: 50%; background: var(--gw-navy); color: #fff; font-size: .75rem;
}

/* Pallet page: the two bulk menus (Move / Remove, Set goods type) — a long list scrolls inside */
.bulk-menu { max-height: 320px; overflow-y: auto; }

/* 📷 count next to a tracking number */
.photo-count { font-size: .75rem; color: var(--gw-muted); white-space: nowrap; vertical-align: middle; }

/* Pallet label next to a tracking number (e.g. "PL-000003") */
.pallet-label {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    padding: .1rem .45rem;
    border-radius: .4rem;
    font-size: .72rem;
    font-weight: 600;
    background: #f1f4f9;
    color: var(--gw-muted);
    border: 1px solid #dde3ee;
    text-decoration: none;
    white-space: nowrap;
    vertical-align: middle;
}
.pallet-label:hover { border-color: currentColor; }
/* The pallet's step: the same colors as the pallet status badges */
.pallet-label-open { background: #fff4e5; color: #b26a00; border-color: #fde2b8; }
.pallet-label-closed { background: #eaf0fa; color: var(--gw-navy); border-color: #c9d6ee; }
.pallet-label-in_transit { background: #e6f4fb; color: #0b6b94; border-color: #bfe3f3; }
.pallet-label-arrived { background: #e8f6ee; color: #1e7b45; border-color: #c4e7d2; }

/* Flights (2026-11-16): status badges + the "✈ TK 1960" label next to a tracking number (same shape as the pallet label) */
.status-flight-scheduled { background: #eaf0fa; color: var(--gw-navy); }
.status-flight-delayed { background: #fff4e5; color: #b26a00; }
.status-flight-departed { background: #e6f4fb; color: #0b6b94; }
.status-flight-landed { background: #e8f6ee; color: #1e7b45; }
.status-flight-cancelled { background: #fdecec; color: #b42318; }
.flight-label {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    padding: .1rem .45rem;
    border-radius: .4rem;
    font-size: .72rem;
    font-weight: 600;
    border: 1px solid #dde3ee;
    text-decoration: none;
    white-space: nowrap;
    vertical-align: middle;
}
.flight-label:hover { border-color: currentColor; }
.flight-label-scheduled { background: #eaf0fa; color: var(--gw-navy); border-color: #c9d6ee; }
.flight-label-delayed { background: #fff4e5; color: #b26a00; border-color: #fde2b8; }
.flight-label-departed { background: #e6f4fb; color: #0b6b94; border-color: #bfe3f3; }
.flight-label-landed { background: #e8f6ee; color: #1e7b45; border-color: #c4e7d2; }
.flight-label-cancelled { background: #fdecec; color: #b42318; border-color: #f6c9c5; }
/* "✈ Flight TK 1960 · Departed · Track online" on the pallet / shipment page */
.flight-line {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .6rem;
    padding: .6rem .8rem;
    border: 1px solid #dde3ee;
    border-radius: .6rem;
    background: #f8fafd;
    margin-bottom: .75rem;
}
.flight-line > .bi-airplane { font-size: 1.1rem; color: var(--gw-navy); }
/* Flight documents: a hidden one is grey (only owner / admin see it) */
.document-hidden { opacity: .55; background: #f8f9fb; }
.min-w-0 { min-width: 0; }

/* Permission group label (e.g. "Canceller") */
.group-badge {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .15rem .55rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
    background: #ede9fe;
    color: #5b21b6;
    border: 1px solid #ddd6fe;
    white-space: nowrap;
}

/* Case type (problem) label */
.case-type {
    display: inline-block;
    padding: .25rem .6rem;
    border-radius: .4rem;
    font-size: .78rem;
    font-weight: 600;
    background: #f1f5f9;
    color: #334155;
}
.case-unknown_owner { background: #fef3c7; color: #92400e; }
.case-damaged       { background: #fee2e2; color: #b91c1c; }
.case-customs       { background: #e0f2fe; color: #0369a1; }

.from-client {
    display: inline-block;
    padding: .15rem .5rem;
    border-radius: 999px;
    font-size: .7rem;
    font-weight: 600;
    background: #ede9fe;
    color: #6d28d9;
}
.case-late          { background: #e0f2fe; color: #0369a1; }
.case-missing_items { background: #fee2e2; color: #b91c1c; }

/* Photos */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: .6rem; }
.photo-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: .6rem; border: 1px solid var(--gw-border); }
/* Photo upload box: drag photos here or click to choose (static/js/photo-drop.js) */
.photo-drop {
    position: relative;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .15rem;
    padding: 1rem; min-height: 110px; text-align: center; cursor: pointer;
    border: 2px dashed #c5cddb; border-radius: .75rem; background: #f9fafc; color: var(--gw-muted);
    transition: border-color .15s, background-color .15s;
}
.photo-drop:hover, .photo-drop:focus { border-color: var(--gw-navy); outline: none; }
.photo-drop.is-dragging { border-color: var(--gw-navy); background: var(--gw-navy-soft); color: var(--gw-navy); }
.photo-drop-icon { font-size: 1.6rem; color: var(--gw-navy); }
.photo-drop-text { font-size: .9rem; }
.photo-drop-text strong { color: var(--gw-navy); }
.photo-drop-hint { font-size: .75rem; }
/* The real file box stays inside the zone (the form sends it) but is not seen */
.photo-drop-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.photo-drop-previews { display: flex; flex-wrap: wrap; gap: .5rem; }
.photo-drop-previews:not(:empty) { margin-top: .6rem; }
.photo-drop-preview { position: relative; width: 64px; height: 64px; }
.photo-drop-preview img { width: 100%; height: 100%; object-fit: cover; border-radius: .5rem; border: 1px solid var(--gw-border); }
.photo-drop-remove {
    position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; padding: 0;
    display: flex; align-items: center; justify-content: center;
    border: 0; border-radius: 50%; background: #1f2937; color: #fff; font-size: .8rem; line-height: 1;
}
.photo-drop-remove:hover { background: #b91c1c; }

/* Shipment photos: clickable small pictures + the big view */
.photo-thumb { position: relative; padding: 0; border: 0; background: none; cursor: zoom-in; border-radius: .6rem; }
.photo-thumb img { display: block; }
.photo-thumb:hover img { border-color: var(--gw-navy); }
.photo-thumb.is-hidden img { opacity: .35; filter: grayscale(1); }
.photo-hidden-label {
    position: absolute; left: .35rem; bottom: .35rem;
    padding: .1rem .4rem; border-radius: .35rem; font-size: .7rem; font-weight: 600;
    background: #fee2e2; color: #b91c1c;
}
/* Pallet photo step ("Closed", "Arrived") on the small picture and in the big view */
.photo-step-label {
    position: absolute; left: .35rem; bottom: .35rem;
    padding: .1rem .4rem; border-radius: .35rem; font-size: .7rem; font-weight: 600;
    background: rgba(30, 58, 110, .85); color: #fff;
}
.photo-step-label.static { position: static; background: var(--gw-navy-soft); color: var(--gw-navy); }
.photo-big { background: #11161f; display: flex; align-items: center; justify-content: center; height: 65vh; }
.photo-big img { max-width: 100%; max-height: 100%; object-fit: contain; }
.photo-caption {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem;
    padding: .75rem 1rem; border-top: 1px solid var(--gw-border);
}
#photo-carousel .carousel-control-prev, #photo-carousel .carousel-control-next { height: 65vh; width: 10%; }
.thumb { width: 48px; height: 48px; border-radius: .5rem; object-fit: cover; border: 1px solid var(--gw-border); }
.thumb-empty { display: inline-flex; align-items: center; justify-content: center; background: var(--gw-bg); color: #9aa3b5; font-size: 1.2rem; }

/* Claims */
.claim { padding: 1rem 0; border-bottom: 1px solid var(--gw-border); }
.claim:first-child { padding-top: 0; }
.claim:last-child { border-bottom: 0; padding-bottom: 0; }
.claim-message { background: var(--gw-bg); border-radius: .6rem; padding: .75rem 1rem; font-size: .9rem; }

/* ---------- Role badges ---------- */
.role-badge { display: inline-block; padding: .3rem .7rem; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.role-owner     { background: var(--gw-navy); color: #fff; }
.role-warehouse { background: #e0f2fe; color: #0369a1; }
.role-client    { background: #fef3c7; color: #b45309; }

/* ---------- Info list (label : value) ---------- */
.info-list { margin: 0; }
.info-list dt { color: var(--gw-muted); font-weight: 500; font-size: .8rem; margin-bottom: .15rem; }
.info-list dd { font-weight: 500; margin-bottom: 1rem; }

/* ---------- Movements timeline ---------- */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline-item { position: relative; padding-left: 2rem; padding-bottom: 1.4rem; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before {
    content: "";
    position: absolute;
    left: .45rem;
    top: 1.3rem;
    bottom: -.1rem;
    width: 2px;
    background: var(--gw-border);
}
.timeline-item:last-child::before { display: none; }
.timeline-dot {
    position: absolute;
    left: 0;
    top: .2rem;
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    background: #fff;
    border: 3px solid #c3cde0;
}
.timeline-item:first-child .timeline-dot { border-color: var(--gw-navy); background: var(--gw-navy); }
.timeline-meta { font-size: .8rem; color: var(--gw-muted); }

/* The same time in UTC: a small gray label next to / under the local time */
.utc-time {
    display: inline-block;
    font-size: .72rem;
    font-variant-numeric: tabular-nums;
    color: var(--gw-muted);
    background: #f1f4f9;
    border-radius: 4px;
    padding: 1px 6px;
    margin-top: 2px;
}

/* Created / Modified lines at the bottom of the shipment info */
.audit-row { display: grid; grid-template-columns: 90px 100px 1fr auto; gap: .5rem; align-items: center; padding: 2px 0; }
/* The username: always one line ("w.shabany" never breaks); a very long one is cut with "…" */
.audit-row > :nth-child(2) { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 575.98px) {
    .audit-row { grid-template-columns: 1fr 1fr; }
}

/* ---------- Route (received at -> now at -> going to) ---------- */
.route { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.route-stop { display: flex; align-items: center; gap: .75rem; }
.route-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--gw-bg);
    color: var(--gw-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}
.route-icon-now { background: var(--gw-navy); color: #fff; }
.route-label { font-size: .75rem; color: var(--gw-muted); text-transform: uppercase; letter-spacing: .05em; }
.route-line { flex: 1; min-width: 30px; border-top: 2px dashed #c3cde0; position: relative; }
/* Arrowhead at the end of each line (owner, 2026-11-16): same color as its line (grey = still to go) */
.route-line::after {
    content: "";
    position: absolute;
    right: -2px;
    top: -7px;  /* centered on the 2px line */
    border-left: 9px solid #c3cde0;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
}
/* Done part of the trip: solid navy line + navy arrow, light navy icon */
.route-line-done { border-top-style: solid; border-top-color: var(--gw-navy); }
.route-line-done::after { border-left-color: var(--gw-navy); }
.route-icon-done { background: #e6ecf6; color: var(--gw-navy); }
.route-icon-delivered { background: #198754; color: #fff; }
.route-icon-cancelled { background: #dc3545; color: #fff; }

@media (max-width: 767.98px) {
    .route { flex-direction: column; align-items: flex-start; gap: .5rem; }
    /* Phones: the stops are one under another -> a short down arrow between them (same colors) */
    .route-line {
        flex: none;
        min-width: 0;
        height: 22px;
        margin-left: 21px;  /* under the middle of the 44px icon */
        border-top: 0;
        border-left: 2px dashed #c3cde0;
    }
    .route-line::after {
        right: auto;
        top: auto;
        left: -7px;
        bottom: -2px;
        border-top: 9px solid #c3cde0;
        border-left: 6px solid transparent;
        border-right: 6px solid transparent;
        border-bottom: 0;
    }
    .route-line-done { border-left-style: solid; border-left-color: var(--gw-navy); }
    .route-line-done::after { border-top-color: var(--gw-navy); border-left-color: transparent; }
}

/* ---------- Alerts ---------- */
.alert { border-radius: .75rem; border: 0; }

/* ---------- Login page ---------- */
.auth-page { min-height: 100vh; display: flex; }
.auth-side {
    flex: 1;
    background: linear-gradient(145deg, var(--gw-navy) 0%, #0f2147 100%);
    color: #fff;
    padding: 3rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.auth-side .brand-logo { background: rgba(255, 255, 255, .15); }
.auth-side h1 { font-weight: 700; font-size: 2.2rem; line-height: 1.2; }
.auth-feature { display: flex; gap: .75rem; align-items: center; margin-bottom: .9rem; opacity: .9; }
.auth-feature i { font-size: 1.2rem; }
.auth-form-wrap { flex: 1; display: flex; align-items: center; justify-content: center; padding: 2rem; background: #fff; }
.auth-form { width: 100%; max-width: 380px; }

/* ---------- Small screens ---------- */
@media (max-width: 991.98px) {
    .app-content { padding: 1.25rem 1rem; }
    .topbar { padding: 0 1rem; }
    .auth-side { display: none; }
}


/* ---------- Select2 (searchable dropdowns) — look like Bootstrap fields ---------- */
.select2-container { width: 100% !important; }
.select2-container--default .select2-selection--single {
    height: var(--gw-control-height);  /* the same height as the other boxes */
    border: 1px solid #d9dee8;
    border-radius: .6rem;
    display: flex;
    align-items: center;
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
    flex: 1;
    display: flex;
    align-items: center;
    padding-left: .75rem;
    padding-right: 2rem;  /* room for the arrow */
    line-height: 1.5;
}
/* The "×" (clear) button: on the right, next to the arrow, easy to click */
.select2-container--default .select2-selection--single .select2-selection__clear {
    order: 2;
    margin-left: auto;
    padding: 0 .4rem;
    font-size: 1.15rem;
    font-weight: 400;
    line-height: 1;
    color: var(--gw-muted);
}
.select2-container--default .select2-selection--single .select2-selection__clear:hover { color: #dc3545; }
/* The chosen text: one line, "…" when too long (made by templateSelection in select2-setup.js) */
.select2-chosen { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.select2-container--default .select2-selection--single .select2-selection__clear { flex-shrink: 0; }
.select2-container--default .select2-selection--single .select2-selection__arrow { height: 100%; right: 6px; }
.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--open .select2-selection--single {
    border-color: #86a2d6;
    box-shadow: 0 0 0 .2rem rgba(30, 58, 110, .15);
}
.select2-dropdown { border-color: #dee2e6; border-radius: .375rem; box-shadow: 0 6px 18px rgba(0, 0, 0, .08); }
.select2-search--dropdown .select2-search__field { border-radius: .375rem; padding: .375rem .5rem; }
.select2-container--default .select2-results__option--highlighted[aria-selected] { background: var(--gw-navy); }
.select2-results__option .customer-result-sub { font-size: .8rem; opacity: .75; }


/* Pallet statuses */
.status-pallet-open { background: #fff4e5; color: #b26a00; }
.status-pallet-closed { background: #eaf0fa; color: var(--gw-navy); }
.status-pallet-in_transit { background: #e6f4fb; color: #0b6b94; }
.status-pallet-arrived { background: #e8f6ee; color: #1e7b45; }
.status-pallet-unpacked { background: #f1f2f5; color: #5c6476; }


/* Pallet page: the left column (info + buttons) stays in view while scrolling a long list of shipments */
@media (min-width: 1200px) {
    .pallet-side {
        position: sticky;
        top: calc(68px + 1rem);  /* under the top bar */
        max-height: calc(100vh - 68px - 2rem);
        overflow-y: auto;  /* a tall close form can still be scrolled inside */
    }
}

/* Pallet page on phones / tablets: the cards in the order of the work, not the two desktop columns
   (info -> next step -> add shipments -> shipments -> close -> photos -> history) */
@media (max-width: 1199.98px) {
    .pallet-layout { display: flex; flex-direction: column; flex-wrap: nowrap; gap: 1.5rem; margin: 0; }  /* nowrap: else every card is as wide as the table */
    .pallet-layout > [class*="col-"], .pallet-layout .pallet-side { display: contents; }
    .pallet-part, .pallet-part > .card { margin-top: 0 !important; margin-bottom: 0 !important; }
    .pallet-part { min-width: 0; }  /* a wide table scrolls inside its card instead of stretching every card */
    .pallet-info { order: 1; }
    .pallet-steps { order: 2; }
    .pallet-add { order: 3; }
    .pallet-shipments { order: 4; }
    .pallet-close { order: 5; }
    .pallet-photos { order: 6; }
    .pallet-history { order: 7; }
}

/* Tick boxes in tables (e.g. the pallet's shipments): a clearly visible border */
.table .form-check-input { width: 1.1rem; height: 1.1rem; border: 1.5px solid #8a94a8; cursor: pointer; }
.table .form-check-input:checked { background-color: var(--gw-navy); border-color: var(--gw-navy); }
