.hidden {
    display: none;
}

.dt-buttons.btn-group.flex-wrap {
    gap: 10px;
}

.placeholder-box {
    background-color: #ffffff;
    border: 1px solid #ccc;
    border-radius: 6px;
    height: 180px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 0.95rem;
    color: #666;
    margin-bottom: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.placeholder-box canvas {
    flex: 1;
    width: 100% !important;
    height: auto !important;
    height: 100% !important;
    max-height: none !important;
    margin-top: 0;
}

.chart-box {
    position: relative;
}

.chart-loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.7);
    opacity: 0;
    pointer-events: none;
    z-index: 2;
    transition: opacity 0.2s ease;
}

.chart-loading.active {
    opacity: 1;
    pointer-events: auto;
}

.chart-empty-state {
    position: absolute;
    top: 28px;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem;
    text-align: center;
    background: rgba(255, 255, 255, 0.88);
    z-index: 1;
}

.chart-empty-state.hidden {
    display: none !important;
}

.loading-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid #cfe5d8;
    border-top-color: #218838;
    border-radius: 50%;
    animation: chart-spin 0.8s linear infinite;
}

.loading-text {
    font-size: 0.75rem;
    color: #218838;
    font-weight: 600;
}

@keyframes chart-spin {
    to {
        transform: rotate(360deg);
    }
}

@media print {
    .doh-footer {
        display: none !important;
    }

    .region-info-line {
        font-size: 0.95rem !important;
    }

    .print-hide {
        display: none !important;
    }

    body,
    #page-content {
        margin: 0 !important;
        padding: 0 !important;
    }

    #page-content > div {
        margin: 0 !important;
        padding: 0 !important;
    }

    .container-fluid {
        padding-top: 0 !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    .card {
        margin: 0 !important;
    }

    .stock-box {
        padding: 0.1rem 0.25rem !important;
        min-height: auto !important;
        width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        display: block !important;
    }

    .stock-box .dataTables_scroll,
    #stockDataTable_wrapper,
    #stockDataTable {
        width: 100% !important;
        max-width: none !important;
    }

    .stock-box .dataTables_scroll {
        overflow: visible !important;
    }

    .stock-box .dataTables_scrollHeadInner,
    .stock-box .dataTables_scrollHead table,
    .stock-box .dataTables_scrollBody table,
    .stock-box table {
        width: 100% !important;
        table-layout: auto !important;
    }

    #stockDataTable {
        font-size: 0.6rem !important;
    }

    .stock-box .dataTables_scrollBody {
        overflow: visible !important;
        height: auto !important;
    }

    .stock-box .dataTables_scrollHead {
        overflow: visible !important;
    }

    .stock-box th,
    .stock-box td {
        white-space: normal !important;
        padding: 0.35rem 0.4rem !important;
    }

    .foreign-stack-row {
        flex-direction: row !important;
        gap: 0.75rem !important;
    }

    .foreign-stack-row .placeholder-box {
        width: 50% !important;
        min-height: 260px !important;
        padding: 0.25rem 0.5rem !important;
    }

    .ownership-foreign-col {
        width: 100% !important;
        max-width: 100% !important;
        flex: 0 0 100% !important;
        display: block !important;
    }

    #foreignTrainedBarChart,
    #foreignBornBarChart {
        width: 100% !important;
        height: 260px !important;
        max-width: 100% !important;
    }

    /* Match MD pie size to foreign charts in print */
    #mdPieChart {
        width: 100% !important;
        height: 260px !important;
        max-width: 100% !important;
    }

    .pt-0.mt-0 {
        margin-bottom: 0 !important;
        margin-top: 0 !important;
    }

    .placeholder-box,
    .placeholder-tall,
    .chart-box {
        height: auto !important;
        min-height: 250px;
        break-inside: avoid;
        margin-bottom: 1.5rem !important;
    }

    #stockDataTable,
    #stockDataTable_wrapper {
        overflow: visible !important;
    }

    .placeholder-box canvas {
        height: 250px !important;
        max-height: none !important;
        width: 100% !important;
    }

    .placeholder-box.placeholder-tall.chart-box {
        height: 350px !important;
        min-height: 350px !important;
    }

    .dt-buttons {
        display: none !important;
    }

    #region-map {
        height: 200px !important;
        break-after: avoid;
    }
}

.placeholder-tall {
    height: 300px;
    margin-bottom: 1rem;
}

.filter-box {
    border: 1px solid #1e7e34;
    background-color: #fff;
    border-radius: 6px;
    padding: 0.25rem 0.75rem;
    width: 100%;
    font-size: 0.8rem;
    color: #155724;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.filter-box h6 {
    font-weight: 700;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
}

.filter-box .form-check {
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filter-box .form-check-input {
    width: 18px !important;
    height: 18px !important;
    margin: 0 !important;
    cursor: pointer !important;
    flex-shrink: 0 !important;
    -webkit-appearance: checkbox !important;
    -moz-appearance: checkbox !important;
    appearance: checkbox !important;
    accent-color: #1e7e34 !important;
    border: 2px solid #1e7e34 !important;
    border-radius: 3px !important;
    background-color: white !important;
    opacity: 1 !important;
    visibility: visible !important;
    display: inline-block !important;
    position: relative !important;
}

.filter-box .form-check-input:checked {
    background-color: #1e7e34 !important;
    border-color: #1e7e34 !important;
    opacity: 1 !important;
}

.filter-box .form-check-label {
    flex-grow: 1;
    white-space: normal;
    cursor: pointer;
    line-height: 1.1;
    font-size: 0.75rem;
}

.filter-box::-webkit-scrollbar {
    width: 8px;
}

.filter-box::-webkit-scrollbar-thumb {
    background-color: #1e7e34;
    border-radius: 4px;
}

.region-info-line {
    display: flex;
    justify-content: space-between;
    font-size: 0.80rem;
    margin-bottom: 0.3rem;
}

.region-info-line .label {
    color: #218838;
}

.region-info-line .value {
    color: #dc3545;
}

#stockDataTable thead th {
    color: #fff !important;
    font-size: 0.70rem !important;
}

#stockDataTable tfoot {
    color: #000 !important;
    font-size: 0.70rem !important;
}

#stockDataTable {
    font-size: 0.70rem !important;
}

.chart-box {
    flex-direction: column;
    justify-content: flex-start;
    padding: 0.5rem 0.75rem;
    overflow: hidden;
}

.chart-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: #1e7e34;
    text-align: center;
    margin-bottom: 0.3rem;
    line-height: 1.2;
    white-space: normal;
}

.scrollable-checkbox-list {
    max-height: 150px;
    overflow-y: auto;
    padding-right: 4px;
}

.scrollable-checkbox-list::-webkit-scrollbar {
    width: 6px;
}

.scrollable-checkbox-list::-webkit-scrollbar-thumb {
    background-color: #1e7e34;
    border-radius: 3px;
}

.modal-dialog {
    margin: auto !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    position: relative !important;
}

.modal-content1.nhwr-reg-selector-modal-content {
    left: -193%;
}

.modal-content {
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

body.modal-open {
    overflow: hidden !important;
}

.modal-backdrop.show {
    position: fixed !important;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1050;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(16px);
    background-color: rgba(0, 0, 0, 0.3);
}

.modal-body {
    flex-grow: 1;
    overflow-y: auto;
    max-height: none;
}

.modal {
    z-index: 1055 !important;
}

body.modal-open #page-content {
    filter: blur(2px);
    transition: filter 0.3s ease;
}

.custom-modal {
    width: 85vw !important;
    max-width: 1400px !important;
    height: 75vh !important;
    margin: auto !important;
    display: flex !important;
    align-items: center !important;
}

.custom-modal .modal-content {
    width: 100% !important;
    max-width: 95vw !important;
    height: auto;
}

.custom-modal .modal-body {
    padding: 1.5rem;
    overflow-x: auto;
}

#consolidatedDataTable {
    min-width: 100%;
    table-layout: auto;
}

#chartModal .modal-body {
    padding: 1.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
}

#expandedChart {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: contain;
}

.modal-title {
    color: #1e7e34 !important;
    font-weight: 600 !important;
    font-size: 1.2rem !important;
    margin: 0 auto;
}

.modal-close-x {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    font-weight: bold;
    color: inherit;
    cursor: pointer;
    padding: 0 0.5rem;
}

.list-group-item {
    font-size: 0.85rem;
    font-weight: 600;
    color: #1e7e34 !important;
    text-align: center;
}

.list-group-item:hover {
    background-color: #f0f0f0;
}

@media (max-width: 991.98px) {
    .col-lg-6 {
        margin-bottom: 1.5rem;
    }

    .d-flex.w-100.mb-3 {
        flex-direction: column;
        gap: 1.5rem;
    }

    .region-info-box {
        margin-right: 0 !important;
    }

    .placeholder-box.chart-box {
        height: 300px !important;
        min-height: 300px !important;
    }

    .placeholder-tall {
        height: 300px;
        margin-bottom: 1rem;
    }

    .filter-box {
        border: 1px solid #1e7e34;
        background-color: #fff;
        border-radius: 6px;
        padding: 0.25rem 0.75rem;
        width: 100%;
        font-size: 0.8rem;
        color: #155724;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }

    .filter-box h6 {
        font-weight: 700;
        margin-bottom: 0.5rem;
        font-size: 0.85rem;
    }

    .filter-box .form-check {
        margin-bottom: 0.5rem;
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }

    .filter-box .form-check-input {
        width: 18px !important;
        height: 18px !important;
        margin: 0 !important;
        cursor: pointer !important;
        flex-shrink: 0 !important;
        -webkit-appearance: checkbox !important;
        -moz-appearance: checkbox !important;
        appearance: checkbox !important;
        accent-color: #1e7e34 !important;
        border: 2px solid #1e7e34 !important;
        border-radius: 3px !important;
        background-color: white !important;
        opacity: 1 !important;
        visibility: visible !important;
        display: inline-block !important;
        position: relative !important;
    }

    .filter-box .form-check-input:checked {
        background-color: #1e7e34 !important;
        border-color: #1e7e34 !important;
        opacity: 1 !important;
    }

    .filter-box .form-check-label {
        flex-grow: 1;
        white-space: normal;
        cursor: pointer;
        line-height: 1.1;
        font-size: 0.75rem;
    }

    .filter-box::-webkit-scrollbar {
        width: 8px;
    }

    .filter-box::-webkit-scrollbar-thumb {
        background-color: #1e7e34;
        border-radius: 4px;
    }

    .region-info-line {
        display: flex;
        justify-content: space-between;
        font-size: 0.80rem;
        margin-bottom: 0.3rem;
    }

    .region-info-line .label {
        color: #218838;
    }

    .region-info-line .value {
        color: #dc3545;
    }

    #stockDataTable thead th {
        color: #fff !important;
        font-size: 0.70rem !important;
    }

    #stockDataTable tfoot {
        color: #000 !important;
        font-size: 0.70rem !important;
    }

    #stockDataTable {
        font-size: 0.70rem !important;
    }

    .chart-box {
        flex-direction: column;
        justify-content: flex-start;
        padding: 0.5rem 0.75rem;
        overflow: hidden;
    }

    .chart-title {
        font-size: 0.75rem;
        font-weight: 600;
        color: #1e7e34;
        text-align: center;
        margin-bottom: 0.3rem;
        line-height: 1.2;
        white-space: normal;
    }

    .scrollable-checkbox-list {
        max-height: 150px;
        overflow-y: auto;
        padding-right: 4px;
    }

    .scrollable-checkbox-list::-webkit-scrollbar {
        width: 6px;
    }

    .scrollable-checkbox-list::-webkit-scrollbar-thumb {
        background-color: #1e7e34;
        border-radius: 3px;
    }

    .modal-dialog {
        margin: auto !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
        position: relative !important;
    }

    .modal-content {
        max-height: 90vh;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    body.modal-open {
        overflow: hidden !important;
    }

    .modal-backdrop.show {
        position: fixed !important;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        z-index: 1050;
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(16px);
        background-color: rgba(0, 0, 0, 0.3);
    }

    .modal-body {
        flex-grow: 1;
        overflow-y: auto;
        max-height: none;
    }

    .modal {
        z-index: 1055 !important;
    }

    body.modal-open #page-content {
        filter: blur(2px);
        transition: filter 0.3s ease;
    }

    .custom-modal {
        width: 85vw !important;
        max-width: 1400px !important;
        height: 75vh !important;
        margin: auto !important;
        display: flex !important;
        align-items: center !important;
    }

    .custom-modal .modal-content {
        width: 100% !important;
        max-width: 95vw !important;
        height: auto;
    }

    .custom-modal .modal-body {
        padding: 1.5rem;
        overflow-x: auto;
    }

    #consolidatedDataTable {
        min-width: 100%;
        table-layout: auto;
    }

    #chartModal .modal-body {
        padding: 1.5rem;
        display: flex;
        justify-content: center;
        align-items: center;
        height: 100%;
    }

    #expandedChart {
        width: 100% !important;
        height: 100% !important;
        max-width: 100% !important;
        max-height: 100% !important;
        object-fit: contain;
    }

    .modal-title {
        color: #1e7e34 !important;
        font-weight: 600 !important;
        font-size: 1.2rem !important;
        margin: 0 auto;
    }

    .modal-close-x {
        background: none;
        border: none;
        font-size: 1.5rem;
        line-height: 1;
        font-weight: bold;
        color: inherit;
        cursor: pointer;
        padding: 0 0.5rem;
    }

    .list-group-item {
        font-size: 0.85rem;
        font-weight: 600;
        color: #1e7e34 !important;
        text-align: center;
    }

    .list-group-item:hover {
        background-color: #f0f0f0;
    }
}
