/* =============================================================================
   InvenLogix v3.0 — app.css
   Custom styles for the InvenLogix web application.
   Built on Bootstrap 5.3 + Bootstrap Icons 1.11.
   ============================================================================= */

/* ── Reset / Base ─────────────────────────────────────────────────────────── */
html, body {
    height: 100%;
    margin: 0;
}

body {
    padding-top: 56px; /* Offset for fixed navbar */
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.container-fluid.d-flex.flex-grow-1 {
    overflow: hidden;
}

/* ── Main content area ────────────────────────────────────────────────────── */
main {
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(100, 116, 139, 0.35) transparent;
}

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

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

main::-webkit-scrollbar-thumb {
    background-color: rgba(100, 116, 139, 0.35);
    border-radius: 3px;
}

main::-webkit-scrollbar-thumb:hover {
    background-color: rgba(100, 116, 139, 0.6);
}

/* ── MAC sticker unknown-serial modal ─────────────────────────────────────── */
.mac-unknown-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.55);
}

/* ── Custom scrollbar (global thin variant) ───────────────────────────────── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

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

::-webkit-scrollbar-thumb {
    background-color: rgba(100, 116, 139, 0.3);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background-color: rgba(100, 116, 139, 0.55);
}

/* ── Footer ───────────────────────────────────────────────────────────────── */
.footer {
    font-size: 0.72rem;
    background-color: var(--bs-body-bg);
    color: var(--bs-secondary-color);
    width: 100%;
    padding: 0.4rem 1rem;
    border-top: 1px solid var(--bs-border-color);
    position: sticky;
    bottom: 0;
    z-index: 1030;
    flex-shrink: 0;
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.sidebar {
    flex: 0 0 240px;
    width: 240px;
    max-height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    padding-top: 0.75rem;
    padding-bottom: 1rem;
    border-right: 1px solid var(--bs-border-color);
    box-shadow: inset -1px 0 0 rgba(0, 0, 0, 0.04);
    transition: width 0.25s ease, transform 0.25s ease;
    scrollbar-width: none;
    background-color: var(--bs-body-bg);
    z-index: 900;
}

.sidebar::-webkit-scrollbar {
    width: 0;
    background: transparent;
}

/* Sidebar links */
.sidebar .nav-link {
    color: var(--bs-body-color);
    padding: 0.45rem 0.75rem 0.45rem 1.5rem;
    border-radius: 6px;
    margin: 1px 8px;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.55rem;
    transition: background-color 0.15s ease, color 0.15s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar .nav-link i {
    font-size: 1rem;
    flex-shrink: 0;
    width: 1.2rem;
    text-align: center;
}

.sidebar .nav-link:hover {
    background-color: var(--bs-tertiary-bg);
    color: var(--bs-emphasis-color);
}

.sidebar .nav-link.active {
    background-color: var(--bs-primary);
    color: #fff !important;
    font-weight: 600;
}

.sidebar .nav-link.active i {
    color: #fff;
}

/* Section titles */
.sidebar .section-title {
    padding: 0 0.75rem 0.25rem 1.5rem;
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--bs-secondary-color);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-top: 1.25rem;
    margin-bottom: 0.25rem;
}

/* Disabled / not-yet-implemented links */
.sidebar .nav-link.disabled-link {
    background-color: rgba(220, 53, 69, 0.08);
    color: #842029 !important;
    cursor: not-allowed;
    pointer-events: none;
    opacity: 0.8;
}

.sidebar .nav-link.disabled-link:hover {
    background-color: rgba(220, 53, 69, 0.12);
}

/* Testing / WIP links */
.sidebar .nav-link.testing-link {
    background-color: rgba(13, 202, 240, 0.1);
    color: #055160 !important;
}

.sidebar .nav-link.testing-link:hover {
    background-color: rgba(13, 202, 240, 0.16);
}

/* Mobile sidebar overlay behaviour */
@media (max-width: 767.98px) {
    .sidebar {
        position: fixed;
        top: 56px;
        left: 0;
        bottom: 0;
        z-index: 1035;
        box-shadow: 4px 0 16px rgba(0, 0, 0, 0.15);
    }

    .sidebar-toggle-btn {
        display: inline-flex !important;
    }
}

@media (min-width: 768px) {
    .sidebar-toggle-btn {
        display: none !important;
    }
}

/* Alpine.js cloak — hide elements before Alpine initialises */
[x-cloak] { display: none !important; }

/* ── Navbar tweaks ────────────────────────────────────────────────────────── */
.navbar-brand img {
    border-radius: 4px;
}

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
    transition: box-shadow 0.2s ease, transform 0.15s ease;
}

.card:hover {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1) !important;
}

/* Stat cards on dashboard */
.stat-card {
    border-radius: 12px;
    overflow: hidden;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12) !important;
}

.stat-icon {
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
    border-radius: 10px;
}

.stat-value {
    line-height: 1.1;
}

.stat-label {
    font-size: 0.78rem;
    margin-top: 2px;
}

/* ── Toast styles ─────────────────────────────────────────────────────────── */
.toast {
    opacity: 0;
    transition: opacity 0.35s ease-in-out;
    font-size: 0.875rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 8px;
    min-width: 260px;
    max-width: 380px;
}

.toast.showing { opacity: 0; }
.toast.show    { opacity: 1; }

.toast-pastel-success {
    background-color: #d1e7dd !important;
    color: #0a3622 !important;
    border-color: #a3cfbb !important;
}

.toast-pastel-danger {
    background-color: #f8d7da !important;
    color: #58151c !important;
    border-color: #f1aeb5 !important;
}

.toast-pastel-warning {
    background-color: #fff3cd !important;
    color: #664d03 !important;
    border-color: #ffe69c !important;
}

.toast-pastel-info {
    background-color: #cff4fc !important;
    color: #055160 !important;
    border-color: #9eeaf9 !important;
}

.toast-pastel-error {
    background-color: #f8d7da !important;
    color: #58151c !important;
    border-color: #f1aeb5 !important;
}

/* ── AJAX Loader overlay ──────────────────────────────────────────────────── */
#ajaxLoader {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.65);
    z-index: 9999;
    justify-content: center;
    align-items: center;
}

[data-bs-theme="dark"] #ajaxLoader {
    background: rgba(13, 17, 23, 0.7);
}

.loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    display: grid;
}

.loader::before,
.loader::after {
    content: "";
    grid-area: 1/1;
    --c: no-repeat radial-gradient(farthest-side, #25b09b 92%, #0000);
    background:
        var(--c) 50%   0,
        var(--c) 50%   100%,
        var(--c) 100%  50%,
        var(--c) 0     50%;
    background-size: 11px 11px;
    animation: loaderSpin 1s infinite;
}

.loader::before {
    margin: 4px;
    filter: hue-rotate(45deg);
    background-size: 7px 7px;
    animation-timing-function: linear;
}

@keyframes loaderSpin {
    100% { transform: rotate(0.5turn); }
}

/* ── Dark mode overrides ──────────────────────────────────────────────────── */
[data-bs-theme="dark"] .sidebar {
    background-color: #161b22;
    border-right-color: #30363d;
}

[data-bs-theme="dark"] .sidebar .nav-link {
    color: #c9d1d9;
}

[data-bs-theme="dark"] .sidebar .nav-link:hover {
    background-color: #21262d;
    color: #e6edf3;
}

[data-bs-theme="dark"] .sidebar .nav-link.active {
    background-color: #1f6feb;
    color: #fff !important;
}

[data-bs-theme="dark"] .sidebar .section-title {
    color: #6e7681;
}

[data-bs-theme="dark"] .card {
    border-color: #30363d;
    background-color: #161b22;
}

[data-bs-theme="dark"] .card:hover {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4) !important;
}

[data-bs-theme="dark"] .table-light th {
    background-color: #21262d;
    color: #c9d1d9;
    border-color: #30363d;
}

[data-bs-theme="dark"] .footer {
    background-color: #161b22;
    border-top-color: #30363d;
}

[data-bs-theme="dark"] .list-group-item {
    background-color: #161b22;
    border-color: #30363d;
    color: #c9d1d9;
}

[data-bs-theme="dark"] .card-header {
    background-color: #161b22;
    border-bottom-color: #30363d;
}

[data-bs-theme="dark"] .card-footer {
    background-color: #161b22;
    border-top-color: #30363d;
}

[data-bs-theme="dark"] .table {
    --bs-table-bg: transparent;
    --bs-table-striped-bg: rgba(255, 255, 255, 0.03);
    --bs-table-hover-bg: rgba(255, 255, 255, 0.05);
    color: #c9d1d9;
    border-color: #30363d;
}

[data-bs-theme="dark"] .table > :not(caption) > * > * {
    border-bottom-color: #30363d;
}

/* ── DataTables overrides ─────────────────────────────────────────────────── */
.dataTables_wrapper .dataTables_filter input {
    border-radius: 6px;
    font-size: 0.875rem;
}

.dataTables_wrapper .dataTables_length select {
    border-radius: 6px;
    font-size: 0.875rem;
}

[data-bs-theme="dark"] .dataTables_wrapper .dataTables_filter input,
[data-bs-theme="dark"] .dataTables_wrapper .dataTables_length select {
    background-color: #0d1117;
    border-color: #30363d;
    color: #c9d1d9;
}

[data-bs-theme="dark"] .dataTables_wrapper .dataTables_info,
[data-bs-theme="dark"] .dataTables_wrapper .dataTables_paginate .paginate_button {
    color: #8b949e !important;
}

[data-bs-theme="dark"] .dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: #1f6feb !important;
    border-color: #1f6feb !important;
    color: #fff !important;
}

/* ── Utility helpers ──────────────────────────────────────────────────────── */
.bg-purple {
    background-color: #6f42c1 !important;
    color: #fff;
}

.bg-teal {
    background-color: #20c997 !important;
    color: #fff;
}

.text-purple { color: #6f42c1 !important; }
.text-teal   { color: #20c997 !important; }

/* Rotation for chevrons in collapsible panels */
.rotate {
    transition: transform 0.25s ease;
}

.rotate.down {
    transform: rotate(180deg);
}

/* Table danger row */
.table-danger {
    background-color: rgba(220, 53, 69, 0.08) !important;
}

[data-bs-theme="dark"] .table-danger {
    background-color: rgba(220, 53, 69, 0.18) !important;
}

/* ── Form helpers ─────────────────────────────────────────────────────────── */
.form-control:focus,
.form-select:focus {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.18);
}

/* ── Badges ───────────────────────────────────────────────────────────────── */
.badge {
    font-weight: 600;
    letter-spacing: 0.02em;
}

/* ── Code elements ────────────────────────────────────────────────────────── */
code {
    font-size: 0.82em;
    color: #d63384;
    background: rgba(214, 51, 132, 0.08);
    padding: 0.1em 0.35em;
    border-radius: 3px;
}

[data-bs-theme="dark"] code {
    color: #f78166;
    background: rgba(247, 129, 102, 0.1);
}

/* ── Alert tweaks ─────────────────────────────────────────────────────────── */
.alert {
    border-radius: 8px;
    font-size: 0.875rem;
}

/* ── Print styles (for labels / stickers) ────────────────────────────────── */
@media print {
    /* Hide everything except the printable label area */
    body > *:not(.print-area) {
        display: none !important;
    }

    .print-area {
        display: block !important;
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
    }

    .sidebar,
    nav.navbar,
    footer.footer,
    #ajaxLoader,
    #toastContainer,
    .btn,
    .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_info,
    .dataTables_wrapper .dataTables_paginate {
        display: none !important;
    }

    main {
        overflow: visible !important;
        height: auto !important;
    }

    /* Label card reset for clean printing */
    .label-card {
        border: 1px solid #000 !important;
        break-inside: avoid;
        page-break-inside: avoid;
        box-shadow: none !important;
    }

    /* Sticker page layout */
    .sticker-grid {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 4mm;
    }

    .sticker-item {
        border: 0.5pt solid #ccc;
        padding: 3mm;
        font-size: 8pt;
        break-inside: avoid;
    }

    /* Barcode / QR code */
    .barcode-container {
        display: flex;
        justify-content: center;
        margin: 2mm 0;
    }

    @page {
        margin: 10mm;
    }
}

/* ── Misc: intro.js / tooltip overrides ──────────────────────────────────── */
.customTooltip {
    background-color: #343a40;
    color: #fff;
    font-size: 0.9rem;
}

.customHighlight {
    box-shadow: 0 0 0 4px rgba(31, 122, 236, 0.5);
    border-radius: 6px;
}

/* ── Map card (scoped to .map-card, preserved from original) ──────────────── */
.map-card {
    --card-bg:     #e6edf4;
    --card-border: #bcc7d4;
    --shadow:      0 6px 20px rgba(15, 23, 42, 0.12);
    --radius:      12px;
    --accent:      #1e40af;
    --muted:       #5b6b80;
    --text:        #0f172a;
    --map-height:  78vh;

    position: relative;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin: 20px 12px 28px;
}

.map-card-header {
    padding: 10px 14px;
    border-bottom: 1px solid var(--card-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.map-card-header h3 {
    margin: 0;
    font: 600 14px/1.2 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--text);
}

.map-card-header .toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.map-card select {
    appearance: none;
    background: #fff;
    min-width: 170px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    padding: 6px 34px 6px 10px;
    font-size: 0.9rem;
    color: #111827;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.02);
    text-align: center;
    text-align-last: center;
}

.map-card select:focus {
    outline: none;
    border-color: #93c5fd;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}

#map.map-theme {
    height: var(--map-height);
    width: 100%;
    background: #eef2f6;
}

/* ── Leaflet pin styles (scoped) ─────────────────────────────────────────── */
.leaflet-div-icon,
.leaflet-marker-icon {
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
}

.mk {
    position: relative;
    width: 28px;
    height: 40px;
    transform: translate(-50%, -100%);
}

.mk.mk-pin::before {
    content: "";
    position: absolute;
    width: 24px;
    height: 24px;
    left: 2px;
    top: 2px;
    background: var(--c, #2563eb);
    border: 2px solid #fff;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
}

.mk.mk-pin.badged::after {
    content: attr(data-badge);
    position: absolute;
    left: 50%;
    top: 14px;
    transform: translate(-50%, -50%);
    font: 700 12px/1 system-ui, -apple-system, sans-serif;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
    background: none !important;
    border: none !important;
}

.mk.selected.mk-pin::before {
    box-shadow:
        0 0 0 3px rgba(245, 158, 11, 0.9),
        0 4px 12px rgba(0, 0, 0, 0.25);
}
