/* ==========================================================================
   Pyramid Shipping — brand design system
   --------------------------------------------------------------------------
   Single source of truth for colour, elevation, radius and shape.
   Every view must consume these variables. Do not redeclare :root anywhere
   else, and do not hardcode a brand hex in a Blade file.

   Direction: this file uses CSS logical properties (inline-start/end) so the
   same rules serve Arabic (RTL) and French/English (LTR) without a second
   stylesheet. Physical left/right only appears where the property has no
   logical equivalent with adequate browser support.
   ========================================================================== */

:root {
    /* --- Brand ----------------------------------------------------------- */
    --primary: #10347d;
    --primary-dark: #0a2255;
    --primary-deep: #061539;
    --primary-light: #2c55ad;

    --accent: #fbb216;
    --accent-dark: #d99400;
    --accent-deep: #8a5c00;
    /* accent text on white — passes AA */

    /* Tinted surfaces derived from the two brand colours. */
    --primary-soft: rgba(16, 52, 125, 0.07);
    --primary-softer: rgba(16, 52, 125, 0.04);
    --primary-border: rgba(16, 52, 125, 0.18);
    --primary-hairline: rgba(16, 52, 125, 0.1);

    --accent-soft: rgba(251, 178, 22, 0.14);
    --accent-border: rgba(251, 178, 22, 0.45);

    /* --- Semantic state --------------------------------------------------
       Kept clearly distinct from the brand. Navy is the brand, not "success",
       and amber is the accent, not "warning" — but amber and warning are
       close enough that warning leans orange-red to stay distinguishable. */
    --success: #047857;
    --success-soft: rgba(4, 120, 87, 0.1);
    --warning: #b45309;
    --warning-soft: rgba(180, 83, 9, 0.1);
    --danger: #b91c1c;
    --danger-soft: rgba(185, 28, 28, 0.08);
    --info: var(--primary);
    --info-soft: var(--primary-soft);
    --neutral: #64748b;
    --neutral-soft: rgba(100, 116, 139, 0.1);

    /* --- Neutrals -------------------------------------------------------- */
    --body-bg: #f7f9fd;
    --surface: #ffffff;
    --surface-muted: #f4f6fb;
    --text-main: #111827;
    --text-muted: #64748b;
    --text-faint: #94a3b8;
    --border-color: #e2e8f0;
    --card-border: rgba(16, 52, 125, 0.1);

    /* --- Elevation ------------------------------------------------------- */
    --soft-shadow: 0 12px 30px rgba(10, 34, 85, 0.07);
    --card-shadow: 0 16px 40px rgba(10, 34, 85, 0.08);
    --lifted-shadow: 0 22px 60px rgba(10, 34, 85, 0.12);
    --focus-shadow: 0 0 0 0.25rem rgba(251, 178, 22, 0.28);

    /* --- Shape ----------------------------------------------------------- */
    --radius-sm: 10px;
    --radius: 14px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    --radius-pill: 999px;

    /* --- Layout ---------------------------------------------------------- */
    --sidebar-width: 270px;

    /* --- Gradients ------------------------------------------------------- */
    --grad-primary: linear-gradient(
        135deg,
        var(--primary),
        var(--primary-dark)
    );
    --grad-primary-deep: linear-gradient(
        135deg,
        var(--primary-deep),
        var(--primary)
    );
    --grad-accent: linear-gradient(135deg, var(--accent), var(--accent-dark));
    --grad-brand-bar: linear-gradient(90deg, var(--primary), var(--accent));

    /* --- Typography ------------------------------------------------------
       Cairo covers Arabic and Latin; Montserrat carries the Latin wordmark
       and display numerals. */
    --font-body: "Cairo", "Segoe UI", system-ui, sans-serif;
    --font-display: "Montserrat", "Cairo", sans-serif;
}

/* ==========================================================================
   Base
   ========================================================================== */

* {
    font-family: var(--font-body);
}

body {
    min-height: 100vh;
    overflow-x: hidden;
    color: var(--text-main);
    background:
        radial-gradient(
            circle at top left,
            rgba(16, 52, 125, 0.07),
            transparent 28%
        ),
        radial-gradient(
            circle at bottom right,
            rgba(251, 178, 22, 0.08),
            transparent 30%
        ),
        var(--body-bg);
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--primary-dark);
}

/* Focus is amber on every surface: it reads against navy chrome and against
   white cards, and it is never confused with an error state. */
a:focus-visible,
button:focus-visible,
[tabindex]:focus-visible,
.btn:focus-visible,
.form-control:focus-visible,
.form-select:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* ==========================================================================
   Bootstrap colour overrides
   ========================================================================== */

.text-primary {
    color: var(--primary) !important;
}

.bg-primary {
    background-color: var(--primary) !important;
}

.border-primary {
    border-color: var(--primary) !important;
}

.text-accent {
    color: var(--accent-deep) !important;
}

.bg-accent {
    background-color: var(--accent) !important;
    color: var(--primary-deep) !important;
}

.bg-brand-gradient {
    background: var(--grad-primary) !important;
    color: #fff !important;
}

.brand-bar {
    height: 5px;
    background: var(--grad-brand-bar);
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
    border-radius: var(--radius);
    font-weight: 700;
    transition: all 0.2s ease;
}

.btn-primary {
    background: var(--grad-primary);
    border-color: transparent;
    color: #fff;
}

.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active,
.btn-primary.active,
.btn-check:checked + .btn-primary {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    border-color: transparent;
    color: #fff;
    box-shadow: 0 8px 20px rgba(16, 52, 125, 0.24);
}

/* The single highlighted call to action on a page. Used sparingly —
   if every button is amber, amber stops meaning anything. */
.btn-accent {
    background: var(--grad-accent);
    border-color: transparent;
    color: var(--primary-deep);
}

.btn-accent:hover,
.btn-accent:focus {
    background: linear-gradient(135deg, var(--accent-dark), var(--accent));
    color: var(--primary-deep);
    box-shadow: 0 8px 20px rgba(251, 178, 22, 0.32);
}

.btn-outline-primary {
    color: var(--primary);
    border-color: var(--primary-border);
    background: var(--surface);
}

.btn-outline-primary:hover,
.btn-outline-primary:focus {
    color: #fff;
    background: var(--grad-primary);
    border-color: transparent;
}

.btn-soft {
    background: var(--accent-soft);
    color: var(--accent-deep);
    border: 1px solid var(--accent-border);
}

.btn-soft:hover {
    background: var(--accent);
    color: var(--primary-deep);
    border-color: var(--accent);
}

/* Destructive and confirming actions keep their own colours. A delete button
   must never look like a save button. */
.btn-danger {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

.btn-success {
    background: var(--success);
    border-color: var(--success);
    color: #fff;
}

/* ==========================================================================
   Cards & surfaces
   ========================================================================== */

.page-card,
.stat-card,
.tracking-card,
.brand-card {
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.96);
    box-shadow: var(--soft-shadow);
    overflow: hidden;
}

.stat-card {
    transition:
        transform 0.2s ease,
        box-shadow 0.2s ease,
        border-color 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-3px);
    border-color: var(--accent-border);
    box-shadow: var(--lifted-shadow);
}

.glass {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px);
    border: 1px solid var(--card-border);
    box-shadow: var(--card-shadow);
}

/* Icon tile used on stat cards and empty states. */
.brand-icon-tile {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 54px;
    height: 54px;
    border-radius: 18px;
    background: linear-gradient(
        135deg,
        var(--primary-soft),
        var(--accent-soft)
    );
    color: var(--primary);
    font-size: 1.5rem;
}

/* ==========================================================================
   Forms
   ========================================================================== */

.form-label {
    color: #374151;
    font-size: 0.9rem;
    font-weight: 600;
}

.form-control,
.form-select {
    min-height: 39px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius);
    background-color: var(--surface);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-light);
    box-shadow: var(--focus-shadow);
}

.form-control.is-invalid,
.form-select.is-invalid {
    border-color: var(--danger);
}

.form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

.form-check-input:focus {
    border-color: var(--primary-light);
    box-shadow: var(--focus-shadow);
}

/* Custom select caret. background-position uses a physical side, so it is
   flipped per direction below. */
.form-select {
    --bs-form-select-bg-img: none;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: none !important;
}

.form-select:not(.select2-hidden-accessible) {
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2310347d' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-size: 10px 6px !important;
}

[dir="rtl"] .form-select:not(.select2-hidden-accessible) {
    padding-left: 2.25rem;
    padding-right: 0.75rem;
    background-position: left 0.9rem center !important;
}

[dir="ltr"] .form-select:not(.select2-hidden-accessible) {
    padding-right: 2.25rem;
    padding-left: 0.75rem;
    background-position: right 0.9rem center !important;
}

/* ==========================================================================
   Tables
   ========================================================================== */

.table {
    --bs-table-hover-bg: var(--primary-softer);
}

.table > thead {
    background: var(--primary-soft);
}

.table > thead th {
    color: var(--primary);
    font-weight: 800;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--primary-hairline);
    white-space: nowrap;
}

.table > tbody td {
    vertical-align: middle;
    border-color: #eef2f7;
}

/* Tables are the most common overflow offender on mobile. */
.table-responsive {
    border-radius: var(--radius);
}

/* ==========================================================================
   Badges & alerts
   ========================================================================== */

.badge-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    border-radius: var(--radius-pill);
    padding: 0.3em 0.8em;
    font-size: 0.75rem;
    font-weight: 700;
}

.badge-brand {
    background: var(--primary-soft);
    color: var(--primary);
    border: 1px solid var(--primary-border);
}

.badge-accent {
    background: var(--accent-soft);
    color: var(--accent-deep);
    border: 1px solid var(--accent-border);
}

.badge-success {
    background: var(--success-soft);
    color: var(--success);
    border: 1px solid rgba(4, 120, 87, 0.25);
}

.badge-warning {
    background: var(--warning-soft);
    color: var(--warning);
    border: 1px solid rgba(180, 83, 9, 0.25);
}

.badge-danger {
    background: var(--danger-soft);
    color: var(--danger);
    border: 1px solid rgba(185, 28, 28, 0.25);
}

.badge-neutral {
    background: var(--neutral-soft);
    color: var(--neutral);
    border: 1px solid rgba(100, 116, 139, 0.25);
}

.alert {
    border: 0;
    border-radius: var(--radius);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
    border-inline-start: 4px solid transparent;
}

.alert-success {
    background: var(--success-soft);
    color: var(--success);
    border-inline-start-color: var(--success);
}

.alert-warning {
    background: var(--warning-soft);
    color: var(--warning);
    border-inline-start-color: var(--warning);
}

.alert-danger {
    background: var(--danger-soft);
    color: var(--danger);
    border-inline-start-color: var(--danger);
}

.alert-info {
    background: var(--primary-soft);
    color: var(--primary);
    border-inline-start-color: var(--primary);
}

/* ==========================================================================
   Pagination
   ========================================================================== */

.pagination {
    gap: 6px;
    margin-bottom: 0;
    flex-wrap: wrap;
}

.pagination .page-link {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    height: 38px;
    border: 1px solid var(--primary-border);
    border-radius: var(--radius);
    color: var(--primary);
    font-weight: 700;
    box-shadow: none;
    transition: all 0.2s ease;
}

.pagination .page-link:hover,
.pagination .page-item.active .page-link {
    color: #fff;
    background: var(--grad-primary);
    border-color: transparent;
    box-shadow: 0 8px 20px rgba(16, 52, 125, 0.24);
}

.pagination .page-item.disabled .page-link {
    color: var(--text-faint);
    background: var(--surface-muted);
    border-color: var(--border-color);
    box-shadow: none;
}

/* Laravel's default paginator ships chevrons that point the wrong way in RTL. */
[dir="rtl"] .pagination svg {
    transform: scaleX(-1);
}

/* ==========================================================================
   Timeline (order tracking)
   ========================================================================== */

.timeline-marker {
    z-index: 2;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--primary-border);
    border-radius: 50%;
    background: var(--surface);
    font-size: 1rem;
    box-shadow: 0 6px 14px rgba(15, 23, 42, 0.08);
}

.timeline-item.active .timeline-marker {
    color: var(--accent) !important;
    background: var(--grad-primary);
    border-color: transparent !important;
    box-shadow: 0 10px 22px rgba(16, 52, 125, 0.26);
}

.timeline-line {
    width: 2px;
    flex-grow: 1;
    min-height: 42px;
    margin-top: 6px;
    border-radius: 10px;
    background: linear-gradient(
        to bottom,
        var(--primary-border),
        rgba(226, 232, 240, 0.9)
    );
}

.timeline-box {
    padding: 12px 14px;
    border: 1px solid #eef2f7;
    border-radius: var(--radius);
    background: var(--surface);
    transition: all 0.2s ease;
}

.timeline-item.active .timeline-box {
    border-color: var(--primary-border);
    background: linear-gradient(135deg, var(--primary-softer), var(--surface));
}

/* ==========================================================================
   Scrollbar
   ========================================================================== */

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(16, 52, 125, 0.32);
    border-radius: var(--radius-pill);
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(16, 52, 125, 0.5);
}

/* ==========================================================================
   Select2 — themed to match .form-control
   ========================================================================== */

.select2-container {
    width: 100% !important;
}

.select2-container--default .select2-selection--single {
    min-height: 39px !important;
    height: 39px !important;
    padding: 5px 12px !important;
    border: 1.5px solid var(--border-color) !important;
    border-radius: var(--radius) !important;
    background: var(--surface) !important;
}

.select2-container--default
    .select2-selection--single
    .select2-selection__rendered {
    padding: 0 !important;
    color: var(--text-main) !important;
    line-height: 27px !important;
    text-align: start;
}

.select2-container--default
    .select2-selection--single
    .select2-selection__placeholder {
    color: #6c757d !important;
}

.select2-container--default
    .select2-selection--single
    .select2-selection__arrow {
    top: 6px !important;
    width: 18px !important;
    height: 26px !important;
}

[dir="rtl"]
    .select2-container--default
    .select2-selection--single
    .select2-selection__arrow {
    right: auto !important;
    left: 10px !important;
}

[dir="ltr"]
    .select2-container--default
    .select2-selection--single
    .select2-selection__arrow {
    left: auto !important;
    right: 10px !important;
}

.select2-container--default
    .select2-selection--single
    .select2-selection__arrow
    b {
    border-color: var(--primary) transparent transparent transparent !important;
}

.select2-container--default.select2-container--open
    .select2-selection--single
    .select2-selection__arrow
    b {
    border-color: transparent transparent var(--primary) transparent !important;
}

.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--open .select2-selection--single,
.select2-container--default.select2-container--focus
    .select2-selection--multiple {
    border-color: var(--primary-light) !important;
    box-shadow: var(--focus-shadow) !important;
}

.select2-container--default .select2-selection--multiple {
    min-height: 42px !important;
    border: 1.5px solid var(--border-color) !important;
    border-radius: var(--radius) !important;
}

.select2-container--default
    .select2-selection--multiple
    .select2-selection__choice {
    padding: 3px 8px !important;
    border: 1px solid var(--primary) !important;
    border-radius: 8px !important;
    background: var(--primary) !important;
    color: #fff !important;
}

.select2-container--default
    .select2-selection--multiple
    .select2-selection__choice__remove {
    margin-inline-end: 6px !important;
    border: none !important;
    color: var(--accent) !important;
}

.select2-container--default
    .select2-selection--multiple
    .select2-selection__choice__remove:hover {
    background: transparent !important;
    color: #fff !important;
}

.select2-dropdown {
    overflow: hidden;
    border: 1px solid var(--border-color) !important;
    border-radius: var(--radius) !important;
    box-shadow: var(--lifted-shadow);
}

[dir="rtl"] .select2-dropdown {
    direction: rtl;
}

[dir="ltr"] .select2-dropdown {
    direction: ltr;
}

.select2-search--dropdown {
    padding: 8px !important;
}

.select2-search--dropdown .select2-search__field {
    width: 100% !important;
    padding: 7px 10px !important;
    border: 1.5px solid var(--border-color) !important;
    border-radius: var(--radius-sm) !important;
    outline: none !important;
}

.select2-search--dropdown .select2-search__field:focus {
    border-color: var(--primary-light) !important;
    box-shadow: var(--focus-shadow) !important;
}

.select2-container--default
    .select2-selection--multiple
    .select2-search__field {
    height: 30px !important;
    line-height: 30px !important;
    padding: 0 !important;
    font-family: var(--font-body) !important;
}

.select2-container--default
    .select2-results__option--highlighted[aria-selected] {
    background: var(--primary) !important;
    color: #fff !important;
}

.select2-container--default .select2-results__option[aria-selected="true"] {
    background: var(--accent-soft) !important;
    color: var(--primary-deep) !important;
    font-weight: 700;
}

/* ==========================================================================
   Language switcher
   ========================================================================== */

.lang-switch .dropdown-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.8rem;
    border: 1px solid var(--primary-border);
    border-radius: var(--radius-pill);
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 700;
    font-size: 0.85rem;
    line-height: 1;
}

.lang-switch .dropdown-toggle:hover {
    background: var(--accent-soft);
    border-color: var(--accent-border);
    color: var(--accent-deep);
}

.lang-switch .dropdown-menu {
    min-width: 168px;
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    box-shadow: var(--lifted-shadow);
    padding: 0.35rem;
}

.lang-switch .dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.88rem;
    padding: 0.5rem 0.7rem;
}

.lang-switch .dropdown-item:hover {
    background: var(--primary-soft);
    color: var(--primary);
}

.lang-switch .dropdown-item.active {
    background: var(--grad-primary);
    color: #fff;
}

.lang-switch .lang-flag {
    font-size: 1.05rem;
    line-height: 1;
}

/* On the dark public hero the switcher inverts. */
.nav-dark:not(.scrolled) .lang-switch .dropdown-toggle {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.24);
    color: #fff;
}

/* ==========================================================================
   Direction helpers
   ========================================================================== */

/* Icons that encode direction (arrows, chevrons, carets) must mirror in RTL.
   Add .dir-flip to any such icon. Icons that do not encode direction
   (search, trash, bell) must NOT carry it. */
[dir="rtl"] .dir-flip {
    transform: scaleX(-1);
}

/* Latin content inside an RTL page: order references, tracking numbers,
   phone numbers, currency codes. Without this, "PRM-1024" renders with the
   digits and hyphen reordered. */
.ltr-text {
    direction: ltr;
    unicode-bidi: isolate;
    display: inline-block;
}

.numeric {
    font-variant-numeric: tabular-nums;
    direction: ltr;
    unicode-bidi: isolate;
}

/* ==========================================================================
   Motion
   ========================================================================== */

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

/* ==========================================================================
   Print
   ========================================================================== */

@media print {
    .sidebar,
    .topbar,
    .public-nav,
    .mobile-cta,
    .lang-switch,
    .no-print {
        display: none !important;
    }

    body {
        background: #fff !important;
    }

    .page-card,
    .stat-card {
        box-shadow: none !important;
        border: 1px solid #ccc !important;
    }
}
