/* ==========================================================================
   Admin Dashboard & Layout Styles (Separated from Blade Layout)
   ========================================================================== */

/* Journey Line & Utilities */
.journey-line {
    height: 2px;
    background: #e0e0e0;
    position: relative;
    margin: 10px 0;
    flex-grow: 1;
}

.journey-line::after {
    content: '\F1AF';
    font-family: "bootstrap-icons";
    position: absolute;
    top: -10px;
    left: 45%;
    background: #f8f9fa;
    padding: 0 8px;
    color: #066ac9;
    font-size: 14px;
}

.w-40px {
    width: 40px;
}

.nav-tabs-line .nav-link {
    border-bottom: 2px solid transparent;
}

.nav-tabs-line .nav-link.active {
    border-bottom-color: #066ac9;
    color: #066ac9;
    background: transparent;
}

/* ================= DARK MODE STYLES & AUTO THEME SUPPORT ================= */
[data-bs-theme="dark"] body {
    background-color: #121417;
    color: #e2e8f0;
}

[data-bs-theme="dark"] .top-bar {
    background-color: #1b1e22 !important;
    border-bottom-color: rgba(255, 255, 255, 0.08) !important;
}

[data-bs-theme="dark"] .top-bar .nav-link {
    color: #adb5bd;
}

[data-bs-theme="dark"] .top-bar .nav-link:hover,
[data-bs-theme="dark"] .top-bar .nav-link.active {
    color: #fff;
}

[data-bs-theme="dark"] .sidebar {
    background-color: #16181b;
    border-right-color: rgba(255, 255, 255, 0.08) !important;
}

[data-bs-theme="dark"] .sidebar .offcanvas {
    background-color: #16181b;
}

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

[data-bs-theme="dark"] .sidebar .nav-link:hover,
[data-bs-theme="dark"] .sidebar .nav-link.active {
    color: #6ea8fe;
    background-color: rgba(13, 110, 253, 0.15);
}

[data-bs-theme="dark"] .page-content-wrapper {
    background: transparent !important;
}

/* Cards & Container Surfaces (Turn white/light backgrounds dark in dark mode) */
[data-bs-theme="dark"] .card {
    background-color: #1e2227;
    border-color: rgba(255, 255, 255, 0.08);
    color: #e2e8f0;
}

[data-bs-theme="dark"] .card .card-header,
[data-bs-theme="dark"] .card .card-footer {
    background-color: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.08);
}

[data-bs-theme="dark"] .bg-white {
    background-color: #1e2227 !important;
    color: #f1f3f5 !important;
}

[data-bs-theme="dark"] .bg-light {
    background-color: #16181b !important;
    color: #f1f3f5 !important;
}

/* Ensure All Dark Text Turns White / Crisp in Dark Mode */
[data-bs-theme="dark"] .text-dark,
[data-bs-theme="dark"] .text-black,
[data-bs-theme="dark"] h1.text-dark,
[data-bs-theme="dark"] h2.text-dark,
[data-bs-theme="dark"] h3.text-dark,
[data-bs-theme="dark"] h4.text-dark,
[data-bs-theme="dark"] h5.text-dark,
[data-bs-theme="dark"] h6.text-dark,
[data-bs-theme="dark"] p.text-dark,
[data-bs-theme="dark"] span.text-dark,
[data-bs-theme="dark"] div.text-dark,
[data-bs-theme="dark"] a.text-dark,
[data-bs-theme="dark"] b.text-dark,
[data-bs-theme="dark"] strong.text-dark,
[data-bs-theme="dark"] .modal-title,
[data-bs-theme="dark"] .dropdown-header {
    color: #f8fafc !important;
}

[data-bs-theme="dark"] h1,
[data-bs-theme="dark"] h2,
[data-bs-theme="dark"] h3,
[data-bs-theme="dark"] h4,
[data-bs-theme="dark"] h5,
[data-bs-theme="dark"] h6 {
    color: #f8fafc;
}

[data-bs-theme="dark"] .text-muted,
[data-bs-theme="dark"] .text-secondary {
    color: #94a3b8 !important;
}

[data-bs-theme="dark"] .border,
[data-bs-theme="dark"] .border-top,
[data-bs-theme="dark"] .border-bottom,
[data-bs-theme="dark"] .border-start,
[data-bs-theme="dark"] .border-end {
    border-color: rgba(255, 255, 255, 0.08) !important;
}

/* Buttons in Dark Mode */
[data-bs-theme="dark"] .btn-white {
    background-color: #1e2227 !important;
    border-color: rgba(255, 255, 255, 0.12) !important;
    color: #f1f3f5 !important;
}

[data-bs-theme="dark"] .btn-white:hover,
[data-bs-theme="dark"] .btn-white:focus,
[data-bs-theme="dark"] .btn-white:active {
    background-color: #272c33 !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
    color: #ffffff !important;
}

[data-bs-theme="dark"] .btn-white .text-dark,
[data-bs-theme="dark"] .btn-white i.text-dark {
    color: #f1f3f5 !important;
}

[data-bs-theme="dark"] .btn-light {
    background-color: #252930 !important;
    border-color: rgba(255, 255, 255, 0.12) !important;
    color: #f1f3f5 !important;
}

[data-bs-theme="dark"] .btn-light:hover {
    background-color: #2f343d !important;
    color: #ffffff !important;
}

[data-bs-theme="dark"] .btn-secondary-subtle {
    background-color: rgba(255, 255, 255, 0.08) !important;
    color: #94a3b8 !important;
    border-color: rgba(255, 255, 255, 0.12) !important;
}

[data-bs-theme="dark"] .btn-success-subtle {
    background-color: rgba(25, 135, 84, 0.18) !important;
    color: #4ade80 !important;
    border-color: rgba(74, 222, 128, 0.3) !important;
}

/* Navigation & Supplier Portal Menu in Dark Mode */
[data-bs-theme="dark"] .navbar-offcanvas-menu .nav-link,
[data-bs-theme="dark"] .navbar-nav .nav-link.text-dark {
    color: #cbd5e1 !important;
}

[data-bs-theme="dark"] .navbar-offcanvas-menu .nav-link:hover,
[data-bs-theme="dark"] .navbar-nav .nav-link.hover-bg-light:hover {
    background-color: rgba(255, 255, 255, 0.08) !important;
    color: #ffffff !important;
}

[data-bs-theme="dark"] .navbar-offcanvas-menu .nav-link.active,
[data-bs-theme="dark"] .navbar-nav .nav-link.active {
    background-color: #0d6efd !important;
    color: #ffffff !important;
}

[data-bs-theme="dark"] .hover-bg-light:hover {
    background-color: rgba(255, 255, 255, 0.08) !important;
    color: #ffffff !important;
}

/* Modals & Dialogs (Auto reflect in all admin & supplier pages) */
[data-bs-theme="dark"] .modal-content {
    background-color: #1e2227 !important;
    border-color: rgba(255, 255, 255, 0.12) !important;
    color: #dee2e6 !important;
    box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.6) !important;
}

[data-bs-theme="dark"] .modal-header {
    border-bottom-color: rgba(255, 255, 255, 0.08) !important;
}

[data-bs-theme="dark"] .modal-header.bg-light {
    background-color: #141619 !important;
}

[data-bs-theme="dark"] .modal-footer {
    border-top-color: rgba(255, 255, 255, 0.08) !important;
}

[data-bs-theme="dark"] .modal-footer.bg-light {
    background-color: #141619 !important;
}

[data-bs-theme="dark"] .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

/* Form Inputs & Selects */
[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
    background-color: #16181b !important;
    border-color: rgba(255, 255, 255, 0.12) !important;
    color: #f1f3f5 !important;
}

[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
    background-color: #16181b !important;
    border-color: #0d6efd !important;
    color: #fff !important;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25) !important;
}

[data-bs-theme="dark"] .form-control::placeholder {
    color: #64748b !important;
}

[data-bs-theme="dark"] .form-label {
    color: #cbd5e1 !important;
}

[data-bs-theme="dark"] .form-check-label {
    color: #f1f3f5 !important;
}

[data-bs-theme="dark"] .form-check.form-switch.bg-light {
    background-color: #141619 !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
}

[data-bs-theme="dark"] .input-group-text,
[data-bs-theme="dark"] .input-group-text.bg-light {
    background-color: #141619 !important;
    border-color: rgba(255, 255, 255, 0.12) !important;
    color: #cbd5e1 !important;
}

/* Dropdowns */
[data-bs-theme="dark"] .dropdown-menu {
    background-color: #1e2227 !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
    color: #dee2e6 !important;
    box-shadow: 0 .5rem 1.5rem rgba(0, 0, 0, 0.5) !important;
}

[data-bs-theme="dark"] .dropdown-item,
[data-bs-theme="dark"] .dropdown-item.text-dark {
    color: #cbd5e1 !important;
}

[data-bs-theme="dark"] .dropdown-item:hover,
[data-bs-theme="dark"] .dropdown-item:focus {
    background-color: rgba(255, 255, 255, 0.08) !important;
    color: #fff !important;
}

[data-bs-theme="dark"] .dropdown-item.active,
[data-bs-theme="dark"] .dropdown-item.bg-light {
    background-color: rgba(13, 110, 253, 0.2) !important;
    color: #6ea8fe !important;
}

[data-bs-theme="dark"] .dropdown-divider {
    border-color: rgba(255, 255, 255, 0.08) !important;
}

/* Tables */
[data-bs-theme="dark"] .table {
    --bs-table-color: #f1f3f5;
    --bs-table-bg: transparent;
    --bs-table-border-color: rgba(255, 255, 255, 0.08);
    --bs-table-striped-bg: rgba(255, 255, 255, 0.02);
    --bs-table-hover-bg: rgba(255, 255, 255, 0.04);
    color: #f1f3f5 !important;
}

[data-bs-theme="dark"] .table td,
[data-bs-theme="dark"] .table th {
    color: #f1f3f5 !important;
    border-color: rgba(255, 255, 255, 0.08) !important;
}

[data-bs-theme="dark"] .table thead.table-light th,
[data-bs-theme="dark"] .table thead th,
[data-bs-theme="dark"] .table-light {
    background-color: #141619 !important;
    color: #94a3b8 !important;
    border-color: rgba(255, 255, 255, 0.08) !important;
}

[data-bs-theme="dark"] .table-hover tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.04) !important;
}

[data-bs-theme="dark"] .table-hover tbody tr:hover td {
    color: #ffffff !important;
}

/* Offcanvas in Dark Mode */
[data-bs-theme="dark"] .offcanvas,
[data-bs-theme="dark"] .offcanvas-xl {
    background-color: #1e2227 !important;
    color: #f1f3f5 !important;
}

[data-bs-theme="dark"] .offcanvas-header {
    border-bottom-color: rgba(255, 255, 255, 0.08) !important;
}

[data-bs-theme="dark"] .journey-line::after {
    background: #1b1e22;
}

/* Admin Sidebar Close & Expand Styles */
.sidebar {
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1), left 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.page-content {
    transition: margin-left 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (min-width: 1200px) {
    html.admin-sidebar-collapsed .sidebar,
    body.admin-sidebar-collapsed .sidebar {
        transform: translateX(-100%) !important;
    }

    html.admin-sidebar-collapsed .page-content,
    body.admin-sidebar-collapsed .page-content {
        margin-left: 0 !important;
    }
}

.extra-small {
    font-size: 10px;
    font-weight: 600;
}

/* ==========================================================================
   Universal Modal Pinned Footer & Small-Screen Responsiveness
   ========================================================================== */
.modal-dialog-scrollable {
    max-height: calc(100% - 1rem);
}

.modal-dialog-scrollable .modal-content {
    max-height: calc(100dvh - 1.5rem) !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
}

/* Ensure forms inside scrollable modals flex correctly and don't push footer offscreen */
.modal-dialog-scrollable form,
.modal-dialog-scrollable .modal-content > form {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    max-height: 100% !important;
    overflow: hidden !important;
}

.modal-dialog-scrollable .modal-header {
    flex-shrink: 0 !important;
}

.modal-dialog-scrollable .modal-body,
.modal-dialog-scrollable form .modal-body {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    -webkit-overflow-scrolling: touch;
}

.modal-dialog-scrollable .modal-footer,
.modal-dialog-scrollable form .modal-footer {
    flex-shrink: 0 !important;
    margin-top: auto !important;
    position: sticky !important;
    bottom: 0 !important;
    z-index: 1055 !important;
    background: #f8fafc !important;
    border-top: 1px solid #e2e8f0 !important;
}

[data-bs-theme="dark"] .modal-dialog-scrollable .modal-footer,
[data-bs-theme="dark"] .modal-dialog-scrollable form .modal-footer {
    background: #1b1e22 !important;
    border-top-color: rgba(255, 255, 255, 0.1) !important;
}

/* Mobile & Small Tablet Viewport Adjustments (<= 768px) */
@media (max-width: 768px) {
    .modal-dialog {
        margin: 0.5rem auto !important;
        max-width: calc(100% - 1rem) !important;
    }

    .modal-dialog-scrollable .modal-content,
    .modal-dialog:not(.modal-dialog-scrollable) .modal-content {
        max-height: calc(100dvh - 1rem) !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
    }

    .modal-dialog form,
    .modal-dialog .modal-content > form {
        display: flex !important;
        flex-direction: column !important;
        flex: 1 1 auto !important;
        min-height: 0 !important;
        overflow: hidden !important;
    }

    .modal-dialog .modal-body,
    .modal-dialog form .modal-body {
        overflow-y: auto !important;
        flex: 1 1 auto !important;
        min-height: 0 !important;
        padding: 1rem !important;
        -webkit-overflow-scrolling: touch;
    }

    .modal-dialog .modal-footer,
    .modal-dialog form .modal-footer {
        flex-shrink: 0 !important;
        position: sticky !important;
        bottom: 0 !important;
        z-index: 1055 !important;
        background: #f8fafc !important;
        border-top: 1px solid #e2e8f0 !important;
        padding: 0.75rem 1rem !important;
        box-shadow: 0 -3px 12px rgba(0, 0, 0, 0.08) !important;
    }

    [data-bs-theme="dark"] .modal-dialog .modal-footer,
    [data-bs-theme="dark"] .modal-dialog form .modal-footer {
        background: #1b1e22 !important;
        border-top-color: rgba(255, 255, 255, 0.1) !important;
        box-shadow: 0 -3px 12px rgba(0, 0, 0, 0.3) !important;
    }
}

