/* Global dark theme. Loaded after app.scss so it also covers legacy custom styles. */

.theme-toggle-button {
    min-width: 118px;
    justify-content: center;
    font-weight: 600;
}

/*
 * Order list typography is intentionally increased by exactly one pixel.
 * Keep the existing paddings, widths and control heights so the denser table
 * layout does not grow unless the browser actually needs an extra text line.
 */
#orders-table-body {
    .order-id-badge { font-size: calc(0.88rem + 1px); }
    .order-date { font-size: calc(0.74rem + 1px); }
    .order-customer-name { font-size: calc(0.9rem + 1px); }

    .order-customer-phone,
    .order-marketplace-login { font-size: calc(0.76rem + 1px); }

    .allegro-login-copy-icon { font-size: calc(0.68rem + 1px); }
    .order-shipping-method { font-size: calc(0.78rem + 1px); }

    .order-delivery-type-badge,
    .order-smart-inline-badge,
    .order-payment-cell .badge { font-size: calc(0.85rem + 1px); }

    .order-payment-method { font-size: calc(0.77rem + 1px); }
    .order-payment-cell small { font-size: calc(0.875rem + 1px); }
    .order-status-cell .status-badge { font-size: calc(0.72rem + 1px); }
    .order-total-price { font-size: calc(1rem + 1px); }
    .product-stock-badge { font-size: calc(0.8rem + 1px) !important; }
    .order-shipping-cell .small { font-size: calc(0.875rem + 1px); }
}

html[data-bs-theme="dark"] {
    color-scheme: dark;
    --bs-body-bg: #111827;
    --bs-body-color: #e5e7eb;
    --bs-emphasis-color: #f8fafc;
    --bs-secondary-color: #a8b3c4;
    --bs-secondary-bg: #1f2937;
    --bs-tertiary-bg: #263246;
    --bs-border-color: #3b475a;
    --bs-link-color: #76a9fa;
    --bs-link-hover-color: #a8c7fa;

    body,
    #mainContent,
    .container,
    .container-fluid {
        background-color: var(--bs-body-bg);
        color: var(--bs-body-color);
    }

    .navbar.bg-dark,
    .mobile-header {
        background-color: #0b1220 !important;
        border-bottom: 1px solid #334155;
    }

    #sidebarMenu.bg-light {
        background-color: #151d2b !important;
        border-right: 1px solid #334155;
    }

    #sidebarMenu .nav-link {
        color: #cbd5e1;

        &:hover,
        &:focus,
        &.active {
            color: #fff;
            background-color: #263b5c;
        }
    }

    #sidebarMenu #integracjeSubmenu {
        background-color: #111827;
    }

    #sidebarToggle.bg-white,
    .bg-white,
    .bg-light {
        background-color: #1f2937 !important;
        color: #e5e7eb !important;
    }

    .card,
    .modal-content,
    .dropdown-menu,
    .popover,
    .toast,
    .list-group-item,
    .accordion-item {
        background-color: #182235;
        color: #e5e7eb;
        border-color: #3b475a;
    }

    .card-header,
    .card-footer,
    .modal-header,
    .modal-footer,
    .accordion-button {
        background-color: #1f2b3d;
        color: #f1f5f9;
        border-color: #3b475a;
    }

    .dropdown-item,
    .nav-tabs .nav-link {
        color: #dbe4f0;
    }

    .dropdown-item:hover,
    .dropdown-item:focus,
    .dropdown-item.active,
    .dropdown-item:active,
    .nav-tabs .nav-link:hover,
    .nav-tabs .nav-link.active {
        color: #fff;
        background-color: #2d4265;
        border-color: #50627a;
    }

    .table {
        --bs-table-color: #e5e7eb;
        --bs-table-bg: transparent;
        --bs-table-border-color: #3b475a;
        --bs-table-striped-color: #e5e7eb;
        --bs-table-striped-bg: rgba(255, 255, 255, 0.035);
        --bs-table-hover-color: #fff;
        --bs-table-hover-bg: rgba(118, 169, 250, 0.12);
    }

    .table-light {
        --bs-table-color: #f1f5f9;
        --bs-table-bg: #243147;
        --bs-table-border-color: #46556c;
    }

    /* Order state palette requested for the dark theme. */
    #orders-table-body tr.order-row-shipped {
        --bs-emphasis-color: #102f3a;
        --bs-secondary-color: #355867;
        --bs-body-color: #102f3a;

        > td {
            background-color: #70d3ef !important;
            color: #102f3a;
            border-color: rgba(16, 47, 58, 0.18);
        }

        .text-muted {
            color: #355867 !important;
        }

        &:hover {
            filter: brightness(0.94);
        }
    }

    #orders-table-body tr.order-row-paid {
        --bs-emphasis-color: #17351d;
        --bs-secondary-color: #46634a;
        --bs-body-color: #17351d;

        > td {
            background-color: #96d283 !important;
            color: #17351d;
            border-color: rgba(23, 53, 29, 0.18);
        }

        .text-muted {
            color: #46634a !important;
        }

        &:hover {
            filter: brightness(0.94);
        }
    }

    #orders-table-body tr.order-row-default,
    #orders-table-body tr.order-row-out-of-stock {
        --bs-emphasis-color: #f8fafc;
        --bs-secondary-color: #b8c0cc;
        --bs-body-color: #f1f5f9;

        > td {
            background-color: #4b5563 !important;
            color: #f1f5f9;
            border-color: #454c57;
        }

        .text-muted {
            color: #b8c0cc !important;
        }

        &:hover {
            filter: brightness(1.16);
        }
    }

    #orders-table-body .order-smart-inline-badge,
    #orders-table-body .order-smart-inline-badge i {
        color: #fff !important;
    }

    #orders-table-body .order-smart-inline-badge {
        background-color: #4b5563 !important;
        border-color: #fff !important;
        box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
    }

    #orders-table-body [id^="order-notes-"] .bg-danger-subtle {
        background-color: #4b5563 !important;
        border-color: #fff !important;
        color: #fff !important;
    }

    #orders-table-body [id^="order-notes-"] .text-danger {
        color: #fff !important;
    }


    .form-control,
    .form-select,
    .form-check-input,
    .input-group-text,
    .status-message-editor,
    .ts-control,
    .ts-dropdown {
        background-color: #111a2a !important;
        color: #eef2f7 !important;
        border-color: #46556c !important;
    }

    .form-control:focus,
    .form-select:focus,
    .form-check-input:focus,
    .status-message-editor:focus,
    .ts-control:focus-within {
        border-color: #76a9fa !important;
        box-shadow: 0 0 0 0.2rem rgba(59, 130, 246, 0.25);
    }

    .form-check-input:checked {
        background-color: #3b82f6 !important;
        border-color: #3b82f6 !important;
    }

    .form-control::placeholder,
    .status-message-editor:empty::before {
        color: #8795aa;
        opacity: 1;
    }

    .form-control:disabled,
    .form-select:disabled,
    .form-control[readonly] {
        background-color: #263246 !important;
        color: #a8b3c4 !important;
    }

    .ts-dropdown .option,
    .ts-dropdown .create {
        color: #e5e7eb;
    }

    .ts-dropdown .active {
        background-color: #2d4265;
        color: #fff;
    }

    .page-link {
        color: #9cc2ff;
        background-color: #182235;
        border-color: #3b475a;
    }

    .page-link:hover,
    .page-item.active .page-link {
        color: #fff;
        background-color: #2d4265;
        border-color: #6382ad;
    }


    .btn-light,
    .btn-outline-dark {
        --bs-btn-color: #e5e7eb;
        --bs-btn-bg: #263246;
        --bs-btn-border-color: #50627a;
        --bs-btn-hover-color: #fff;
        --bs-btn-hover-bg: #34445c;
        --bs-btn-hover-border-color: #6382ad;
    }

    .text-bg-light {
        color: #e5e7eb !important;
        background-color: #263246 !important;
    }

    .order-card,
    .order-card-body,
    .detail-section .table,
    .product-search-dropdown,
    .available-products-container,
    .selected-products-container,
    .customer-suggestions-dropdown {
        background-color: #182235 !important;
        color: #e5e7eb;
        border-color: #3b475a !important;
    }

    .order-card {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);

        &:hover {
            border-color: #6382ad;
            box-shadow: 0 5px 16px rgba(0, 0, 0, 0.5);
        }
    }

    .order-card-header:hover,
    .order-card-header[aria-expanded="true"],
    .product-search-dropdown .list-group-item:hover,
    .customer-suggestions-dropdown .list-group-item:hover,
    .available-products-container tbody tr:hover {
        background-color: #243147 !important;
    }

    .products-table tbody tr:hover {
        background-color: #453713 !important;
    }

    .detail-section h5,
    .detail-section .product-info h6,
    .order-form-container h5,
    .statistics-page .page-header h1,
    .statistics-page .chart-container h4,
    .statistics-page .product-table h4,
    .statistics-page .product-name {
        color: #f1f5f9 !important;
    }

    .cost-summary,
    .chart-container,
    .product-table,
    .period-filter-container,
    .period-btn {
        background-color: #182235 !important;
        color: #e5e7eb !important;
        border-color: #3b475a !important;
    }

    .product-item {
        border-bottom-color: #3b475a;

        &:hover {
            background-color: #243147;
        }
    }

    .period-btn:hover,
    .period-btn.active {
        color: #fff !important;
        border-color: #76a9fa !important;
        background-color: #2d4265 !important;
    }

    .auction-popover-custom .popover-header {
        background-color: #243147;
        color: #f1f5f9;
        border-bottom-color: #46556c;
    }


    .alert-light,
    .list-group-item-light {
        background-color: #243147;
        color: #e5e7eb;
        border-color: #46556c;
    }

    .image-placeholder,
    pre,
    code {
        background-color: #0b1220;
        color: #dbeafe;
    }

    .card.bg-success-subtle {
        background-color: #133a2d !important;
        border-color: #287457 !important;

        .card-header {
            background-color: #194b39 !important;
            border-bottom-color: #287457 !important;
        }
    }

    .card.bg-info-subtle {
        background-color: #123747 !important;
        border-color: #28718c !important;

        .card-header {
            background-color: #17485d !important;
            border-bottom-color: #28718c !important;
        }
    }

    .card.bg-warning-subtle {
        background-color: #453713 !important;
        border-color: #80651e !important;

        .card-header {
            background-color: #594719 !important;
            border-bottom-color: #80651e !important;
        }
    }

    .card.bg-white {
        background-color: #182235 !important;
        border-color: #3b475a !important;

        .card-header {
            background-color: #1f2b3d !important;
            border-bottom-color: #3b475a !important;
        }
    }

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

    ::-webkit-scrollbar-track {
        background: #0b1220;
    }

    ::-webkit-scrollbar-thumb {
        background: #475569;
        border: 2px solid #0b1220;
        border-radius: 8px;
    }

    ::-webkit-scrollbar-thumb:hover {
        background: #64748b;
    }
}

@media (min-width: 768px) and (max-width: 992px) {
    .theme-toggle-button {
        min-width: auto;

        i {
            margin-right: 0 !important;
        }

        span {
            display: none;
        }
    }
}
