:root {
    /* Set primary color to $blue-300 (#93c5fd) */
    --bs-primary: #93c5fd;
    --bs-primary-rgb: 147, 197, 253;
}

html {
    max-width: 100%;
    overflow-x: hidden;
    overflow-x: clip;
    scroll-behavior: smooth;
}

body {
    max-width: 100%;
    overflow-x: hidden;
    overflow-x: clip;
    -webkit-text-size-adjust: 100%;
}

body.sidebar-open {
    overflow: hidden;
}

img,
svg,
video,
canvas {
    max-width: 100%;
}

button,
.btn,
.form-control,
.form-select {
    touch-action: manipulation;
}

/* Ensure text on primary buttons is readable (dark text on light blue) */
.btn-primary {
    --bs-btn-color: #1e3a8a; /* Darker blue text for contrast */
    --bs-btn-bg: #93c5fd;
    --bs-btn-border-color: #93c5fd;
    --bs-btn-hover-color: #1e3a8a;
    --bs-btn-hover-bg: #bfdbfe; /* $blue-200 for hover */
    --bs-btn-hover-border-color: #bfdbfe;
    --bs-btn-focus-shadow-rgb: 147, 197, 253;
    --bs-btn-active-color: #1e3a8a;
    --bs-btn-active-bg: #bfdbfe;
    --bs-btn-active-border-color: #bfdbfe;
}

.btn-outline-primary {
    --bs-btn-color: #93c5fd;
    --bs-btn-border-color: #93c5fd;
    --bs-btn-hover-color: #1e3a8a;
    --bs-btn-hover-bg: #93c5fd;
    --bs-btn-hover-border-color: #93c5fd;
    --bs-btn-focus-shadow-rgb: 147, 197, 253;
    --bs-btn-active-color: #1e3a8a;
    --bs-btn-active-bg: #93c5fd;
    --bs-btn-active-border-color: #93c5fd;
}

.text-primary {
    color: #60a5fa !important; /* Slightly darker $blue-400 for text to ensure readability on white */
}

.bg-primary {
    background-color: #93c5fd !important;
}

/* Custom background for subtle components */
.bg-primary-subtle {
    background-color: #eff6ff !important; /* $blue-50 */
}

.border-primary-subtle {
    border-color: #bfdbfe !important; /* $blue-200 */
}

/* Custom Inputs Focus */
.form-control:focus, .form-select:focus {
    border-color: #93c5fd;
    box-shadow: 0 0 0 0.25rem rgba(147, 197, 253, 0.25);
}

/* Hover Lift Effect */
.hover-lift {
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}
.hover-lift:hover {
    transform: translateY(-4px);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.1) !important;
}

/* Responsive Table to Cards for Mobile */
@media (max-width: 767.98px) {
    .todo-page {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    .todo-page .todo-section-card,
    .todo-page .todo-table-wrap,
    .todo-page .todo-table {
        width: 100%;
        max-width: 100%;
    }

    .todo-page .todo-table-wrap {
        overflow: visible;
    }

    .todo-page .table-responsive-cards tr {
        grid-template-columns: minmax(0, 1fr) minmax(0, auto);
        width: 100%;
        max-width: 100%;
    }

    .todo-page .table-responsive-cards td {
        max-width: 100%;
        white-space: normal !important;
        overflow-wrap: anywhere;
    }

    .todo-page .table-responsive-cards td.mobile-proof-cell,
    .todo-page .table-responsive-cards td.mobile-action-cell {
        grid-column: 1 / -1;
        width: 100%;
        text-align: left !important;
    }

    .todo-page .table-responsive-cards td.mobile-action-cell > form,
    .todo-page .table-responsive-cards td.mobile-action-cell > .btn {
        display: inline-block;
        width: auto;
        max-width: 100%;
    }

    .todo-page .pagination {
        margin-bottom: 0;
    }

    .table-responsive-cards thead {
        display: none;
    }
    .table-responsive-cards,
    .table-responsive-cards tbody {
        display: block;
        width: 100%;
    }
    .table-responsive-cards tbody {
        padding: 0;
        background: transparent;
    }
    .table-responsive-cards tr {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        width: auto;
        margin: 0 0 0.6rem;
        background-color: #fff;
        border-radius: 0.875rem;
        border: 1px solid #e2e8f0;
        border-left: 3px solid #93c5fd;
        padding: 0.5rem 0.6rem;
        box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
        overflow: hidden;
    }
    .table-responsive-cards td {
        display: block;
        min-width: 0;
        border: none !important;
        padding: 0.32rem 0.35rem !important;
        font-size: 0.875rem;
        line-height: 1.35;
        text-align: left !important;
    }
    .table-responsive-cards td.mobile-wide-cell,
    .table-responsive-cards td[colspan] {
        grid-column: 1 / -1;
    }
    .table-responsive-cards td.mobile-date-cell {
        grid-column: 1;
        grid-row: 1;
    }
    .table-responsive-cards td.mobile-status-cell {
        grid-column: 2;
        grid-row: 1;
        text-align: right !important;
    }
    .table-responsive-cards td::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 0.15rem;
        color: #64748b;
        font-size: 0.68rem;
        font-weight: 700;
        line-height: 1.15;
        letter-spacing: 0.02em;
        text-align: left;
    }
    .table-responsive-cards td > * {
        min-width: 0;
        max-width: 100%;
    }
    .table-responsive-cards td.mobile-wide-cell {
        grid-row: auto;
        padding-top: 0.5rem !important;
        padding-bottom: 0.5rem !important;
    }
    .table-responsive-cards td.mobile-amount-cell {
        grid-column: 1;
        align-self: end;
    }
    .table-responsive-cards td.mobile-proof-cell,
    .table-responsive-cards td.mobile-action-cell {
        grid-column: 2;
        align-self: end;
        text-align: right !important;
    }
    .table-responsive-cards td.mobile-action-cell::before {
        display: none;
    }
    .table-responsive-cards td.mobile-action-cell .btn {
        min-height: 36px;
        margin: 0.125rem 0 0.125rem 0.25rem;
    }
    .table-responsive-cards td[colspan] {
        display: block !important;
        padding: 1.25rem 0.75rem !important;
        text-align: center !important;
    }
    .table-responsive-cards td[colspan]::before {
        display: none;
    }
}
/* Sidebar Layout Styles */
:root {
    --sidebar-width: 252px;
    --header-height: 64px;
    --sidebar-bg: #1e293b; /* Slate 800 */
    --sidebar-text: #cbd5e1; /* Slate 300 */
    --sidebar-hover-bg: #334155; /* Slate 700 */
    --sidebar-active-bg: #93c5fd; /* Blue 300 */
    --sidebar-active-text: #1e3a8a; /* Dark blue */
}

body {
    background-color: #f8fafc;
    min-height: 100vh;
}

.layout-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Styling */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #172033 0%, var(--sidebar-bg) 55%, #172033 100%);
    color: var(--sidebar-text);
    transition: all 0.3s ease;
    z-index: 1000;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    max-width: 100vw;
    box-shadow: 0 0 0 rgba(15, 23, 42, 0);
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-brand {
    min-width: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: #fff;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    white-space: nowrap;
}

.sidebar-logo {
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    object-fit: contain;
}

.sidebar-close {
    display: none;
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 0.75rem;
    background: rgba(255, 255, 255, 0.08);
    color: #e2e8f0;
}

.sidebar-close:hover,
.sidebar-close:focus-visible {
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
}

.sidebar-content {
    padding: 1rem 0.65rem 1.5rem;
    overflow-y: auto;
    height: calc(100vh - var(--header-height));
}

.nav-label {
    list-style: none;
    padding: 0 0.75rem;
    margin: 0 0 0.4rem;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #8291a8;
}

.sidebar-nav {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-item {
    margin-bottom: 0.15rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    min-height: 42px;
    padding: 0.58rem 0.75rem;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 0.7rem;
    transition: all 0.2s ease;
    position: relative;
    font-size: 0.92rem;
    line-height: 1.3;
}

.sidebar-link i {
    width: 22px;
    margin-right: 0.55rem;
    font-size: 1rem;
    text-align: center;
}

.sidebar-link:hover {
    background-color: var(--sidebar-hover-bg);
    color: #fff;
}

.sidebar-link.active {
    background: linear-gradient(135deg, #bfdbfe 0%, var(--sidebar-active-bg) 100%);
    color: var(--sidebar-active-text);
    font-weight: 700;
    box-shadow: 0 6px 14px rgba(96, 165, 250, 0.16);
}

.sidebar-link.active::before {
    content: '';
    position: absolute;
    left: -0.15rem;
    top: 50%;
    width: 3px;
    height: 20px;
    border-radius: 999px;
    background: #2563eb;
    transform: translateY(-50%);
}

/* Main Content Area */
.main-container {
    min-width: 0;
    flex: 1;
    margin-left: var(--sidebar-width);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    width: calc(100% - var(--sidebar-width));
    overflow: visible;
}

.top-header {
    height: var(--header-height);
    background-color: #fff;
    border-bottom: 1px solid #e8edf4;
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 950;
    gap: 1rem;
    flex: 0 0 auto;
    isolation: isolate;
    transition: box-shadow 0.2s ease, background-color 0.2s ease;
    will-change: box-shadow;
}

.top-header.is-scrolled {
    background-color: rgba(255, 255, 255, 0.94);
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.1);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.top-header > * {
    min-width: 0;
}

.app-page-title {
    max-width: min(52vw, 680px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.top-user-button {
    min-height: 42px;
    background: #fff;
    border-color: #e2e8f0 !important;
}

.top-user-button:hover,
.top-user-button:focus-visible {
    background: #f8fafc;
    border-color: #bfdbfe !important;
}

.content-wrapper {
    padding: 2rem;
    flex: 1;
    width: 100%;
    min-width: 0;
}

.content-wrapper > *,
.content-wrapper .row > *,
.content-wrapper .card,
.content-wrapper .card-body,
.content-wrapper form {
    min-width: 0;
}

.content-wrapper h1,
.content-wrapper h2,
.content-wrapper h3,
.content-wrapper h4,
.content-wrapper h5,
.content-wrapper h6,
.content-wrapper p,
.content-wrapper td,
.content-wrapper th {
    overflow-wrap: anywhere;
}

.content-wrapper h2 {
    font-size: clamp(1.4rem, 2.6vw, 2rem);
}

.content-wrapper .page-header,
.content-wrapper .responsive-toolbar,
.content-wrapper .responsive-filter,
.content-wrapper .responsive-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}

.content-wrapper .page-header,
.content-wrapper .responsive-toolbar {
    justify-content: space-between;
}

.content-wrapper .table-responsive {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #94a3b8 #e2e8f0;
}

.content-wrapper .table-responsive > .table {
    margin-bottom: 0;
}

.content-wrapper .table-responsive th {
    white-space: nowrap;
}

.content-wrapper .table-responsive td:last-child,
.content-wrapper .table-responsive th:last-child {
    white-space: nowrap;
}

.content-wrapper .table-responsive::-webkit-scrollbar {
    height: 8px;
}

.content-wrapper .table-responsive::-webkit-scrollbar-track {
    background: #e2e8f0;
}

.content-wrapper .table-responsive::-webkit-scrollbar-thumb {
    background: #94a3b8;
    border-radius: 999px;
}

.content-wrapper .form-control,
.content-wrapper .form-select,
.modal .form-control,
.modal .form-select {
    max-width: 100%;
}

.content-wrapper .input-group,
.modal .input-group {
    flex-wrap: nowrap;
}

.content-wrapper .pagination {
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.2rem;
}

.modal-dialog {
    width: auto;
}

.modal-content {
    max-height: calc(100dvh - 2rem);
}

.modal-body {
    overflow-y: auto;
    overscroll-behavior: contain;
}

@media (max-width: 1199.98px) {
    .content-wrapper {
        padding: 1.5rem;
    }
}

/* Mobile Responsiveness */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
        width: min(264px, 82vw);
        box-shadow: 12px 0 30px rgba(15, 23, 42, 0.18);
    }
    
    .sidebar.show {
        transform: translateX(0);
    }

    .sidebar-close {
        display: inline-flex;
    }
    
    .main-container {
        margin-left: 0;
        width: 100%;
    }
    
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background-color: rgba(15, 23, 42, 0.48);
        backdrop-filter: blur(2px);
        z-index: 999;
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition: opacity 0.2s ease, visibility 0.2s ease;
    }
    
    .sidebar-overlay.show {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }
    
    .content-wrapper {
        padding: 1rem;
    }
}

.menu-toggle {
    display: none;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border: none;
    font-size: 1.5rem;
    color: #1e293b;
    padding: 0;
    margin-right: 0.7rem;
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    align-items: center;
    justify-content: center;
    border-radius: 0.75rem;
}

.menu-toggle:hover,
.menu-toggle:focus-visible {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #2563eb;
}

@media (max-width: 991.98px) {
    .menu-toggle {
        display: inline-flex;
    }
}

@media (max-width: 767.98px) {
    .top-header {
        min-height: 60px;
        height: auto;
        padding: 0.5rem 0.75rem;
        padding-top: max(0.5rem, env(safe-area-inset-top));
    }

    .top-header .dropdown-toggle {
        min-width: 44px;
        min-height: 44px;
        padding-inline: 0.8rem !important;
    }

    .app-page-title {
        max-width: calc(100vw - 145px);
        font-size: 1rem;
    }

    .content-wrapper {
        padding: 0.875rem;
    }

    .content-wrapper > .d-flex.justify-content-between,
    .content-wrapper .page-header,
    .content-wrapper .mobile-stack {
        align-items: stretch !important;
        flex-direction: column;
        gap: 0.875rem;
    }

    .content-wrapper > .d-flex.justify-content-between > .btn,
    .content-wrapper > .d-flex.justify-content-between > a.btn,
    .content-wrapper .page-header > .btn,
    .content-wrapper .page-header > a.btn {
        width: 100%;
    }

    .content-wrapper .responsive-filter,
    .content-wrapper form.d-flex:not(.d-inline):not(.d-inline-block) {
        width: 100%;
        align-items: stretch !important;
    }

    .content-wrapper .responsive-filter > *,
    .content-wrapper form.d-flex:not(.d-inline):not(.d-inline-block) > * {
        min-width: 0;
    }

    .content-wrapper .responsive-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .content-wrapper .responsive-actions > .btn,
    .content-wrapper .responsive-actions > a.btn,
    .content-wrapper .responsive-actions > form,
    .content-wrapper .responsive-actions > form > .btn {
        width: 100%;
    }

    .content-wrapper .card.p-4,
    .content-wrapper .card-body.p-4,
    .content-wrapper .card-header.p-4,
    .content-wrapper .alert.p-4,
    .modal-body.p-4,
    .modal-header.p-4,
    .modal-footer.p-4 {
        padding: 1rem !important;
    }

    .content-wrapper .card.rounded-4,
    .content-wrapper .alert.rounded-4,
    .modal-content.rounded-4 {
        border-radius: 1rem !important;
    }

    .content-wrapper .table-responsive > .table {
        min-width: 680px;
    }

    .content-wrapper .table-responsive > .table.table-responsive-cards {
        min-width: 0;
    }

    .content-wrapper .card:has(> .table-responsive-cards),
    .content-wrapper .card:has(> .table-responsive > .table-responsive-cards),
    .content-wrapper .card:has(> .card-body > .table-responsive > .table-responsive-cards) {
        overflow: visible !important;
        background: transparent;
        border: 0 !important;
        box-shadow: none !important;
    }

    .content-wrapper .table-responsive .btn-sm {
        min-width: 38px;
        min-height: 38px;
    }

    .content-wrapper .alert.d-flex {
        align-items: flex-start !important;
        flex-wrap: wrap;
    }

    .content-wrapper .alert.d-flex > .ms-3 {
        width: 100%;
        margin-left: 0 !important;
    }

    .content-wrapper .alert.d-flex > .ms-3 .btn {
        width: 100%;
    }

    .modal-dialog,
    .modal-dialog.modal-lg,
    .modal-dialog.modal-xl {
        max-width: calc(100vw - 1rem);
        margin: 0.5rem auto;
    }

    .modal-content {
        max-height: calc(100dvh - 1rem);
        border-radius: 1rem !important;
    }

    .modal-footer {
        align-items: stretch;
        flex-direction: column-reverse;
    }

    .modal-footer > .btn,
    .modal-footer > form,
    .modal-footer > form > .btn {
        width: 100%;
        margin: 0 !important;
    }

    .form-control,
    .form-select {
        font-size: 16px;
        min-height: 44px;
    }

    textarea.form-control {
        min-height: 96px;
    }

    .btn:not(.btn-sm):not(.btn-close) {
        min-height: 44px;
    }

    .hover-lift:hover {
        transform: none;
    }
}

@media (max-width: 575.98px) {
    .content-wrapper {
        padding: 0.75rem;
    }

    .content-wrapper h2 {
        font-size: 1.35rem;
    }

    .content-wrapper .responsive-filter {
        flex-direction: column;
        align-items: stretch !important;
    }

    .content-wrapper .responsive-filter > .d-flex {
        width: 100%;
    }

    .content-wrapper .responsive-filter > .d-flex .form-select,
    .content-wrapper .responsive-filter > .form-control,
    .content-wrapper .responsive-filter > .form-select,
    .content-wrapper .responsive-filter > .btn {
        width: 100%;
    }

    .content-wrapper .responsive-filter > span {
        display: none;
    }

    .content-wrapper .row {
        --bs-gutter-x: 1rem;
    }

    .dashboard-summary-grid {
        --bs-gutter-x: 0.65rem !important;
        --bs-gutter-y: 0.65rem !important;
    }

    .dashboard-stat-card {
        min-height: 100% !important;
        border-radius: 0.875rem !important;
    }

    .dashboard-stat-card .card-body {
        padding: 0.75rem !important;
    }

    .dashboard-stat-card .card-body > .d-flex {
        align-items: flex-start !important;
        margin-bottom: 0 !important;
    }

    .dashboard-stat-card .card-body > .d-flex > div:first-child {
        padding: 0.55rem !important;
        margin-right: 0.5rem !important;
        border-radius: 0.65rem !important;
    }

    .dashboard-stat-card .card-body > .d-flex > div:last-child,
    .dashboard-stat-card .card-body > div:last-child {
        min-width: 0;
    }

    .dashboard-stat-card h6 {
        font-size: 0.66rem;
        line-height: 1.2;
    }

    .dashboard-stat-card h4 {
        font-size: 1rem;
        line-height: 1.3;
    }

    .content-wrapper .table-responsive > .table {
        min-width: 640px;
    }

    .content-wrapper .display-4,
    .content-wrapper .display-5 {
        font-size: 2rem;
    }

    .login-page {
        align-items: flex-start !important;
        padding-block: 1rem;
    }

    .login-page .login-card {
        width: 100%;
        padding: 1.25rem !important;
        border-radius: 1rem !important;
    }

    .error-container {
        width: 100%;
        padding: 1.25rem !important;
    }

    .error-code {
        font-size: 4rem !important;
    }

    .error-message {
        font-size: 1.2rem !important;
    }
}

/* Scrollbar Styling for Sidebar */
.sidebar-content::-webkit-scrollbar {
    width: 4px;
}
.sidebar-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}
.sidebar-content:hover::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
}
