/* Root font size control */
:root {
    font-size: calc(0.7rem + .25vw);
}

/* Universal margin reset */
* {
    margin-bottom: 0 !important;
  }

body, html {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.table td {
    white-space: nowrap;
    word-wrap: break-word;
    max-width: 250px;
}

.pointer {
    cursor: pointer;
}

.card-header {
    position: relative;
    display: flex;
    align-items: center;
}

.sidebar {
    width: 200px;
    height: 100vh;
    transition: width 0.3s;
    overflow-y: auto;
    background-clip: padding-box;
    position: fixed;
    top: 0;
    bottom: 0;
    background-color: var(--bs-light);
}

.sidebar:before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    right: 0;
    width: 5px;
    background: linear-gradient(to bottom, transparent, #ccc 30%, #ccc 70%, transparent);
}

.sidebar.collapsed {
    width: 55px;
}

.sidebar .nav-item {
    padding: 5px 10px;
    list-style-type: none;
}

.sidebar .nav-item ul {
    padding-left: 0;
}

.sidebar .sidebar-header, .sidebar .nav-link {
    display: flex;
    align-items: center;
    padding: 2px 0;
}

.sidebar .sidebar-header span, .sidebar .nav-link span {
    display: inline-block;
    margin-left: 10px;
}

.sidebar.collapsed .sidebar-header span, .sidebar.collapsed .nav-link span {
    display: none;
}

.sidebar.collapsed .collapse .nav-link span {
    display: none;
}

.sidebar.collapsed ~ .content-wrapper {
    margin-left: 55px;
}

.sidebar-toggle {
    display: inline-block;
    cursor: pointer;
    width: 25px;
    height: 30px;
}

.navbar {
    width: 100%;
    border-bottom: 1px solid #ddd;
    background-color: var(--bs-light);
}

.navbar div {
    margin-left: 5px;
    margin-right: 5px;
}

.profile-toggle {
    cursor: pointer;
}

.bar1, .bar2, .bar3 {
    width: 25px;
    height: 2px;
    background-color: var(--bs-dark);
    margin: 6px 0;
    transition: 0.4s;
}

.change .bar1 {
    transform: translate(0, 8px) rotate(-45deg);
}

.change .bar2 {
    opacity: 0;
}

.change .bar3 {
    transform: translate(0, -8px) rotate(45deg);
}

.right-sidebar {
    display:none; 
    position:fixed; 
    top:50px; 
    bottom:0; 
    right:0; 
    width:250px; 
    overflow-y:auto;
    background-color: var(--bs-light);
}

.content-wrapper {
    margin-left: 200px;
    flex: 1;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s;
}

.content {
    flex: 1;
    overflow-y: auto;
}

.expand-button {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.expand-button:hover {
    background-color: #e9ecef;
}

.expand-button i {
    transition: transform 0.3s ease;
}

.expand-button.expanded i {
    transform: rotate(180deg);
}

.message-preview {
    white-space: normal;
    cursor: pointer;
    display: block;
}

.trim-description {
    cursor: pointer;
    white-space: nowrap; /* Prevent wrapping initially */
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px; /* Adjust as needed */
}

.trim-description.expanded {
    white-space: normal; /* Allow wrapping when expanded */
    max-width: none;
}

.carousel-item img {
    max-height: 500px;
    object-fit: contain;
}

#sortableGallery .thumbnail-item {
    cursor: move;
}

.footer {
    position: fixed;
    bottom: 0;
    width: 100%;
    text-align: center;
    height: 25px;
    line-height: 1.2rem;
    border-top: 1px solid #ddd;
    background-color: var(--bs-light);
}

[data-bs-theme="dark"] {
    --bs-body-bg: #121212;
    --bs-body-color: #f8f9fa;
    --bs-light: #333;
    --bs-dark: #f8f9fa;
}

[data-bs-theme="light"] {
    --bs-body-bg: #f8f9fa;
    --bs-body-color: #212529;
    --bs-light: #f8f9fa;
    --bs-dark: #212529;
}

@media (max-width: 1200px) {
    .container, .container-fluid, .container-lg, .container-md, .container-sm, .container-xl, .container-xxl {
        padding-right: 0 !important;
        padding-left: 0 !important;
    }
}

@media print {
    /* Hide navigation, sidebar, header, and footer */
    #sidebar, .navbar, .content-header, .right-sidebar, .footer, .d-print-none {
        display: none !important;
    }

    /* Expand the content area to full width */
    .content-wrapper {
        margin: 0;
        padding: 0;
        width: 100%;
        overflow: visible !important; /* Ensure content can flow across pages */
    }

    /* Compact font size for printing */
    body {
        font-size: 10px;
        line-height: 1.2;
    }

    h4, h5 {
        font-size: 12px;
        margin-bottom: 4px;
        font-weight: bold;
    }

    /* Condense table formatting */
    .table {
        width: 100%;
        border-collapse: collapse;
        font-size: 10px;
        margin-bottom: 2px; /* Ensure some space between tables */
    }

    th, td {
        padding: 2px 4px; /* Override the padding here */
        text-align: left;
        white-space: nowrap;
    }

    th {
        background-color: #f2f2f2;
        font-weight: bold;
    }

    /* Override any padding set by .table class */
    .table>:not(caption)>*>* {
        padding: 2px 4px !important; /* Ensure this padding takes precedence */
    }

    /* Remove unnecessary spacing */
    .mb-4, .mb-2, .py-1, tr, .btn, .container-fluid {
        margin: 0;
        padding: 0;
    }

    /* Ensure cards maintain structure */
    .card {
        border: 1px solid #000;
        margin-bottom: 10px;
        page-break-inside: avoid; /* Prevent page breaks inside cards */
    }


    .card-header h4 {
        font-size: 12px;
        padding: 1px;
        margin: 0;
        font-weight: bold;
    }

    .card-body h5 {
        font-size: 10px;
        padding: 1px;
        margin: 0;
        font-weight: normal;
    }

    /* Ensure table rows don't split across pages */
    tr {
        page-break-inside: avoid;
    }

    /* Hide scrollbars */
    ::-webkit-scrollbar {
        display: none;
    }
    
    * {
        -ms-overflow-style: none;  /* Internet Explorer 10+ */
        scrollbar-width: none;  /* Firefox */
    }
    
    /* Allow content to flow onto the next page */
    * {
        overflow: visible !important;
        page-break-inside: auto; /* Allow page breaks within elements */
        page-break-before: auto; /* Allow breaks before elements if necessary */
        page-break-after: auto;  /* Allow breaks after elements if necessary */
    }

    /* Ensure body height doesn't restrict content */
    html, body {
        height: auto !important;
    }
}
