/**
 * ManageMyTrust - Main Stylesheet
 * Version: 1.0.0
 * 
 * This stylesheet contains all custom styles for the ManageMyTrust application.
 * It follows a modular approach with clear sections for different components.
 */

/* ============================================
   1. BASE & LAYOUT
   ============================================ */

html {
    height: 100%;
}

body {
    height: 100%;
    margin: 0 !important;
    padding: 0 !important;
}

div.wrapper {
    min-height: 100vh !important;
    display: flex !important;
    flex-direction: column !important;
}

div.content-wrapper {
    flex: 1 0 auto !important;
}

footer.footer {
    flex-shrink: 0 !important;
    width: 100%;
}

/* ============================================
   2. NAVIGATION
   ============================================ */

/* Logout button in dropdown - styled as dropdown item */
.logout-form {
    display: inline;
    width: 100%;
}

.logout-button {
    border: none;
    background: none;
    cursor: pointer;
    text-align: left;
    width: 100%;
}

/* Language switcher forms */
.language-form {
    display: inline;
}

/* Top navbar for non-authenticated users only */
.navbar .navbar-brand img {
    max-height: 60px;
    width: auto;
    transition: opacity 0.2s ease;
}

.navbar .navbar-brand:hover img {
    opacity: 0.9;
}

.navbar .navbar-brand {
    display: flex !important;
    align-items: center !important;
    text-decoration: none !important;
    padding: 0.25rem 0 !important;
    margin-right: 1rem !important;
}

.navbar {
    padding-top: 0.25rem !important;
    padding-bottom: 0.25rem !important;
}

/* ============================================
   3. FORMS & INPUTS
   ============================================ */

/* Scrollable permission containers */
.permission-container {
    height: 400px !important;
    max-height: 400px !important;
    overflow-y: auto !important;
}

/* Scrollable group selection in user forms */
.group-selection-container {
    max-height: 300px;
    overflow-y: auto;
}

/* Permission items in group forms */
.permission-item {
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.2s ease;
    border-left: 3px solid transparent;
}

.permission-item.hidden {
    display: none !important;
}

.permission-item.hidden {
    display: none !important;
}

.permission-item:hover {
    background-color: #f8f9fa;
}

.available-item:hover {
    border-left-color: #28a745;
    background-color: #f0f9f4;
}

.selected-item:hover {
    border-left-color: #dc3545;
    background-color: #fff5f5;
}

/* Hidden checkboxes for permission selection */
.permission-checkbox-hidden {
    display: none !important;
    visibility: hidden !important;
}

/* Dependent dropdown functionality */
.dependent-field-help {
    font-size: 0.70875rem;
    color: #6c757d;
    margin-top: 0.25rem;
}

/* Loading state for dropdowns */
select.loading {
    background-image: url('data:image/svg+xml;charset=utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><circle cx="8" cy="8" r="7" fill="none" stroke="%23007bff" stroke-width="2" stroke-dasharray="31.416" stroke-dashoffset="31.416"><animate attributeName="stroke-dasharray" dur="2s" values="0 31.416;15.708 15.708;0 31.416" repeatCount="indefinite"/><animate attributeName="stroke-dashoffset" dur="2s" values="0;-15.708;-31.416" repeatCount="indefinite"/></circle></svg>');
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px 16px;
}

/* Error state for dropdowns */
select.error {
    border-color: #dc3545;
    background-color: #fff5f5;
}

/* Other state input field - initially hidden */
#id_other_state {
    display: none;
}

/* ============================================
   4. TABLES
   ============================================ */

/* Ensure tables are responsive */
.table-responsive {
    overflow-x: auto;
    border-radius: 0.375rem;
}

/* Number and currency formatting */
.table .number-cell,
.table .currency-cell,
.table .amount-cell,
.table .decimal-cell,
.table .integer-cell {
    text-align: right !important;
    font-family: 'Courier New', Courier, monospace;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.table .currency-cell {
    font-weight: 600;
}

/* Specific styling for different number types */
.table .percentage-cell {
    text-align: right !important;
    font-variant-numeric: tabular-nums;
}

.table .id-cell,
.table .count-cell {
    text-align: right !important;
    font-variant-numeric: tabular-nums;
    font-weight: 500;
}

/* Enhanced table styling */
.table {
    margin-bottom: 0;
    border-collapse: separate;
    border-spacing: 0;
}

.table th {
    background-color: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
    font-weight: 600;
    font-size: 0.7875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #495057;
    padding: 0.75rem;
    vertical-align: middle;
    position: relative;
}

.table td {
    padding: 0.75rem;
    vertical-align: middle;
    border-bottom: 1px solid #dee2e6;
    transition: background-color 0.2s ease;
}

/* Table hover effects - enhanced */
.table-hover tbody tr:hover {
    background-color: rgba(13, 110, 253, 0.05);
    transition: background-color 0.2s ease;
}

.table-hover tbody tr:hover td {
    background-color: transparent;
}

/* Striped table enhancement */
.table-striped > tbody > tr:nth-of-type(odd) > td {
    background-color: rgba(0, 0, 0, 0.02);
}

/* Table borders */
.table-bordered {
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    overflow: hidden;
}

.table-bordered th,
.table-bordered td {
    border: 1px solid #dee2e6;
}

/* Action buttons in tables */
.table .btn-group {
    display: flex;
    gap: 0.25rem;
}

.table .btn-sm {
    font-size: 0.675rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    transition: all 0.2s ease;
}

.table .btn-sm:hover {
    transform: translateY(-1px);
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.15);
}

/* ============================================
   4.1. TABLE ENHANCEMENTS
   ============================================ */

/* Enhanced table container */
.enhanced-table-container {
    background: #fff;
    border-radius: 0.5rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    overflow: hidden;
}

/* Table filter section */
.table-filter-section {
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    padding: 1rem;
}

.table-filter-form {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: end;
}

.table-filter-group {
    display: flex;
    flex-direction: column;
    min-width: 200px;
    flex: 1;
}

.table-filter-group label {
    font-size: 0.7875rem;
    font-weight: 600;
    color: #495057;
    margin-bottom: 0.25rem;
}

.table-filter-group .form-control,
.table-filter-group .form-select {
    font-size: 0.7875rem;
    padding: 0.375rem 0.75rem;
    border-radius: 0.375rem;
    transition: all 0.2s ease;
}

.table-filter-group .form-control:focus,
.table-filter-group .form-select:focus {
    border-color: #0d6efd;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

.table-search-input {
    position: relative;
}

.table-search-input .form-control {
    padding-left: 2.5rem;
}

.table-search-input::before {
    content: "🔍";
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
    z-index: 2;
    pointer-events: none;
}

.table-filter-actions {
    display: flex;
    gap: 0.5rem;
    align-items: end;
}

.table-filter-actions .btn {
    font-size: 0.7875rem;
    padding: 0.375rem 0.75rem;
    white-space: nowrap;
}

/* Active filters display */
.active-filters {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #dee2e6;
}

.active-filters-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0;
}

/* Date range filtering styles */
.date-filter-group {
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    padding: 0.75rem;
    background-color: #f8f9fa;
    margin-bottom: 0.5rem;
}

.date-preset-select {
    margin-bottom: 0.5rem;
}

.date-range-inputs {
    transition: all 0.3s ease;
}

.date-range-inputs input[type="date"] {
    font-size: 0.875rem;
}

.date-range-inputs input[type="date"]:focus {
    border-color: #0d6efd;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

.date-range-inputs input[type="date"].is-invalid {
    border-color: #dc3545;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
}

.date-filter-error {
    font-size: 0.75rem;
    color: #dc3545;
    margin-top: 0.25rem;
    display: none;
}

/* Date filter badges in active filters */
.badge.bg-info {
    background-color: #0dcaf0 !important;
}

.badge a {
    text-decoration: none;
}

.badge a:hover {
    opacity: 0.8;
}

/* Mobile responsive date filters */
@media (max-width: 768px) {
    .date-filter-group {
        margin-bottom: 1rem;
    }
    
    .date-range-inputs .col-6 {
        margin-bottom: 0.5rem;
    }
    
    .date-preset-select {
        font-size: 0.875rem;
    }
}

.filter-tag {
    display: inline-flex;
    align-items: center;
    background-color: #e7f3ff;
    color: #0d6efd;
    padding: 0.25rem 0.5rem;
    border-radius: 1rem;
    font-size: 0.675rem;
    font-weight: 500;
    border: 1px solid #b8daff;
}

.filter-tag .filter-remove {
    background: none;
    border: none;
    color: #0d6efd;
    margin-left: 0.25rem;
    padding: 0;
    font-size: 0.75rem;
    cursor: pointer;
    border-radius: 50%;
    width: 1rem;
    height: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.filter-tag .filter-remove:hover {
    background-color: #0d6efd;
    color: white;
}

/* Sortable table headers */
.sortable-header {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 1.5rem !important;
    transition: all 0.2s ease;
}

.sortable-header .sort-link {
    color: inherit;
    display: flex;
    align-items: center;
    justify-content: between;
    width: 100%;
    padding: 0.5rem;
    margin: -0.5rem;
    text-decoration: none;
}

.sortable-header .sort-link:hover {
    background-color: rgba(0, 0, 0, 0.05);
    border-radius: 0.25rem;
    color: inherit;
    text-decoration: none;
}

.sortable-header .sort-indicators {
    font-size: 0.875rem;
    min-width: 1rem;
    text-align: center;
}

.sortable-header:hover .sort-indicators .opacity-50 {
    opacity: 1 !important;
}

.sortable-header:hover {
    background-color: rgba(13, 110, 253, 0.1);
    color: #0d6efd;
}

.sortable-header.active {
    background-color: rgba(13, 110, 253, 0.15);
    color: #0d6efd;
    font-weight: 600;
}

.sort-indicator {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.75rem;
    opacity: 0.6;
    transition: all 0.2s ease;
}

.sortable-header:hover .sort-indicator {
    opacity: 1;
}

.sortable-header.active .sort-indicator {
    opacity: 1;
    color: #0d6efd;
}

.sort-indicator.asc::before {
    content: "▲";
}

.sort-indicator.desc::before {
    content: "▼";
}

.sort-indicator.none::before {
    content: "⇅";
}

/* Enhanced pagination */
.table-pagination-wrapper {
    background-color: #f8f9fa;
    border-top: 1px solid #dee2e6;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.table-info {
    font-size: 0.7875rem;
    color: #6c757d;
    margin: 0;
}

.table-info strong {
    color: #495057;
    font-weight: 600;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.page-size-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.7875rem;
    color: #6c757d;
}

.page-size-selector select {
    font-size: 0.7875rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    border: 1px solid #ced4da;
    background-color: white;
}

/* Enhanced pagination navigation */
.pagination {
    margin: 0;
    font-size: 0.7875rem;
}

.pagination .page-link {
    padding: 0.375rem 0.75rem;
    border-radius: 0.375rem;
    margin: 0 0.125rem;
    transition: all 0.2s ease;
    border: 1px solid #dee2e6;
    color: #6c757d;
}

.pagination .page-link:hover {
    background-color: #e9ecef;
    border-color: #adb5bd;
    color: #495057;
    transform: translateY(-1px);
}

.pagination .page-item.active .page-link {
    background-color: #0d6efd;
    border-color: #0d6efd;
    color: white;
    font-weight: 600;
}

.pagination .page-item.disabled .page-link {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Date range filter styling */
.date-range-filter {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.date-range-filter input[type="date"] {
    font-size: 0.7875rem;
    padding: 0.375rem 0.5rem;
    border-radius: 0.375rem;
    border: 1px solid #ced4da;
    width: 140px;
}

.date-range-presets {
    display: flex;
    gap: 0.25rem;
    margin-top: 0.5rem;
}

.date-preset-btn {
    font-size: 0.675rem;
    padding: 0.25rem 0.5rem;
    border: 1px solid #dee2e6;
    background-color: white;
    color: #6c757d;
    border-radius: 0.25rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.date-preset-btn:hover {
    background-color: #e9ecef;
    border-color: #adb5bd;
    color: #495057;
}

.date-preset-btn.active {
    background-color: #0d6efd;
    border-color: #0d6efd;
    color: white;
}

/* ============================================
   ENHANCED MOBILE RESPONSIVENESS & TOUCH SUPPORT
   ============================================ */

/* Mobile responsive table enhancements */
@media (max-width: 768px) {
    .enhanced-table-container {
        margin: 0 -0.75rem;
        border-radius: 0;
        box-shadow: none;
        border-left: none;
        border-right: none;
    }
    
    .table-filter-section {
        padding: 0.75rem;
        background-color: #f8f9fa;
        border-bottom: 1px solid #dee2e6;
        position: sticky;
        top: 0;
        z-index: 10;
    }
    
    /* Collapsible filter components for mobile */
    .table-filter-form {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .table-filter-group {
        min-width: auto;
        width: 100%;
    }
    
    .table-filter-actions {
        width: 100%;
        justify-content: stretch;
        gap: 0.5rem;
    }
    
    .table-filter-actions .btn {
        flex: 1;
        min-height: 44px; /* Touch-friendly minimum height */
        font-size: 0.875rem;
        font-weight: 500;
    }
    
    /* Collapsible filter toggle */
    .mobile-filter-toggle {
        display: block;
        width: 100%;
        background: linear-gradient(135deg, #0d6efd, #0b5ed7);
        color: white;
        border: none;
        padding: 0.75rem 1rem;
        border-radius: 0.5rem;
        font-size: 0.875rem;
        font-weight: 600;
        margin-bottom: 1rem;
        transition: all 0.3s ease;
        box-shadow: 0 0.125rem 0.25rem rgba(13, 110, 253, 0.25);
        min-height: 48px; /* Touch-friendly */
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
    
    .mobile-filter-toggle:hover {
        background: linear-gradient(135deg, #0b5ed7, #0a58ca);
        transform: translateY(-1px);
        box-shadow: 0 0.25rem 0.5rem rgba(13, 110, 253, 0.3);
    }
    
    .mobile-filter-toggle:active {
        transform: translateY(0);
    }
    
    .mobile-filter-toggle .toggle-icon {
        transition: transform 0.3s ease;
        font-size: 1rem;
    }
    
    .mobile-filter-toggle.collapsed .toggle-icon {
        transform: rotate(180deg);
    }
    
    .mobile-filter-content {
        transition: all 0.3s ease;
        overflow: hidden;
    }
    
    .mobile-filter-content.collapsed {
        max-height: 0;
        opacity: 0;
        margin-bottom: 0;
    }
    
    .mobile-filter-content:not(.collapsed) {
        max-height: 500px;
        opacity: 1;
        margin-bottom: 1rem;
    }
    
    .active-filters-list {
        justify-content: flex-start;
        gap: 0.5rem;
        margin-top: 1rem;
    }
    
    /* Enhanced mobile table scrolling with sticky columns */
    .table-responsive {
        border-radius: 0;
        border-left: 0;
        border-right: 0;
        position: relative;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        scrollbar-color: rgba(13, 110, 253, 0.3) transparent;
    }
    
    .table-responsive::-webkit-scrollbar {
        height: 8px;
    }
    
    .table-responsive::-webkit-scrollbar-track {
        background: rgba(0, 0, 0, 0.05);
        border-radius: 4px;
    }
    
    .table-responsive::-webkit-scrollbar-thumb {
        background: rgba(13, 110, 253, 0.3);
        border-radius: 4px;
    }
    
    .table-responsive::-webkit-scrollbar-thumb:hover {
        background: rgba(13, 110, 253, 0.5);
    }
    
    .table-responsive .table {
        font-size: 0.75rem;
        margin-bottom: 0;
        min-width: 600px; /* Ensure horizontal scrolling */
    }
    
    .table-responsive .table th,
    .table-responsive .table td {
        padding: 0.75rem 0.5rem;
        white-space: nowrap;
        vertical-align: middle;
    }
    
    /* Sticky first column for better navigation */
    .table-responsive .table th:first-child,
    .table-responsive .table td:first-child {
        position: sticky;
        left: 0;
        background-color: white;
        border-right: 2px solid #dee2e6;
        z-index: 2;
        box-shadow: 2px 0 4px rgba(0, 0, 0, 0.1);
        min-width: 120px;
        max-width: 150px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .table-responsive .table th:first-child {
        background-color: #f8f9fa;
        font-weight: 600;
    }
    
    /* Sticky action column */
    .table-responsive .table .actions-column {
        position: sticky;
        right: 0;
        background-color: white;
        border-left: 2px solid #dee2e6;
        z-index: 2;
        min-width: 140px;
        box-shadow: -2px 0 4px rgba(0, 0, 0, 0.1);
    }
    
    .table-responsive .table .actions-column.th {
        background-color: #f8f9fa;
    }
    
    .table-responsive .table .actions-column .btn {
        font-size: 0.75rem;
        padding: 0.375rem 0.75rem;
        margin: 0.125rem;
        display: inline-block;
        min-width: 60px;
        min-height: 36px; /* Touch-friendly */
        border-radius: 0.375rem;
        transition: all 0.2s ease;
    }
    
    .table-responsive .table .actions-column .btn:hover {
        transform: translateY(-1px);
        box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.15);
    }
    
    .table-responsive .table .actions-column .btn:active {
        transform: translateY(0);
    }
    
    /* Mobile pagination enhancements */
    .table-pagination-wrapper {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
        padding: 1rem 0.75rem;
        background-color: #f8f9fa;
        border-top: 1px solid #dee2e6;
        position: sticky;
        bottom: 0;
        z-index: 5;
    }
    
    .pagination-controls {
        flex-direction: column;
        gap: 1rem;
        width: 100%;
    }
    
    .pagination {
        justify-content: center;
        flex-wrap: wrap;
        gap: 0.25rem;
    }
    
    .pagination .page-link {
        padding: 0.75rem 1rem;
        margin: 0;
        min-width: 44px; /* Touch-friendly minimum */
        min-height: 44px;
        text-align: center;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 0.5rem;
        font-weight: 500;
        transition: all 0.2s ease;
    }
    
    .pagination .page-link:hover {
        transform: translateY(-1px);
        box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.15);
    }
    
    .pagination .page-link:active {
        transform: translateY(0);
    }
    
    /* Compact pagination for very small screens */
    .pagination-compact {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 1rem;
    }
    
    .pagination-compact .page-info {
        font-size: 0.875rem;
        color: #6c757d;
        font-weight: 500;
    }
    
    .pagination-compact .page-nav {
        display: flex;
        gap: 0.5rem;
    }
    
    .pagination-compact .page-nav .btn {
        min-width: 44px;
        min-height: 44px;
        padding: 0.75rem;
        border-radius: 0.5rem;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Enhanced mobile sort headers */
    .sortable-header {
        font-size: 0.75rem;
        padding: 0.75rem 0.5rem !important;
        min-height: 48px; /* Touch-friendly */
        display: flex;
        align-items: center;
        position: relative;
    }
    
    .sortable-header .sort-link {
        min-height: 44px;
        padding: 0.5rem;
        border-radius: 0.375rem;
        transition: all 0.2s ease;
    }
    
    .sortable-header .sort-link:hover {
        background-color: rgba(13, 110, 253, 0.1);
        transform: scale(1.02);
    }
    
    .sortable-header .sort-link:active {
        transform: scale(0.98);
    }
    
    .sort-indicator {
        right: 0.5rem;
        font-size: 0.875rem;
        min-width: 20px;
        min-height: 20px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Enhanced mobile date filters */
    .date-range-filter {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    
    .date-range-filter input[type="date"] {
        width: 100%;
        min-height: 44px; /* Touch-friendly */
        padding: 0.75rem;
        font-size: 0.875rem;
        border-radius: 0.5rem;
        border: 2px solid #dee2e6;
        transition: all 0.2s ease;
    }
    
    .date-range-filter input[type="date"]:focus {
        border-color: #0d6efd;
        box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
        transform: scale(1.02);
    }
    
    .date-range-presets {
        justify-content: center;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .date-preset-btn {
        min-height: 40px;
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
        border-radius: 0.5rem;
        transition: all 0.2s ease;
        border: 2px solid #dee2e6;
        background-color: white;
        color: #495057;
        font-weight: 500;
    }
    
    .date-preset-btn:hover {
        border-color: #0d6efd;
        background-color: #e7f3ff;
        color: #0d6efd;
        transform: translateY(-1px);
    }
    
    .date-preset-btn:active {
        transform: translateY(0);
    }
    
    .date-preset-btn.active {
        background-color: #0d6efd;
        border-color: #0d6efd;
        color: white;
        box-shadow: 0 0.125rem 0.25rem rgba(13, 110, 253, 0.25);
    }
    
    /* Mobile search input enhancements */
    .table-search-input .form-control {
        min-height: 44px;
        padding: 0.75rem 0.75rem 0.75rem 3rem;
        font-size: 0.875rem;
        border-radius: 0.5rem;
        border: 2px solid #dee2e6;
        transition: all 0.2s ease;
    }
    
    .table-search-input .form-control:focus {
        border-color: #0d6efd;
        box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
        transform: scale(1.02);
    }
    
    .table-search-input::before {
        font-size: 1.125rem;
        left: 1rem;
        z-index: 3;
    }
    
    /* Mobile filter tags */
    .filter-tag {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
        border-radius: 1.5rem;
        margin: 0.25rem;
        display: inline-flex;
        align-items: center;
        gap: 0.5rem;
        min-height: 36px;
    }
    
    .filter-tag .filter-remove {
        min-width: 24px;
        min-height: 24px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 0.875rem;
        transition: all 0.2s ease;
    }
    
    .filter-tag .filter-remove:hover {
        transform: scale(1.1);
    }
    
    .filter-tag .filter-remove:active {
        transform: scale(0.9);
    }
}

/* Tablet responsive adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
    .enhanced-table-container {
        border-radius: 0.5rem;
        margin: 0 -0.5rem;
    }
    
    .table-filter-form {
        gap: 1rem;
    }
    
    .table-filter-group {
        min-width: 180px;
        flex: 1;
    }
    
    .table-filter-actions .btn {
        min-height: 40px;
        padding: 0.5rem 1rem;
    }
    
    .pagination .page-link {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
        min-height: 40px;
        min-width: 40px;
    }
    
    .sortable-header {
        font-size: 0.875rem;
        min-height: 44px;
    }
    
    .table-responsive .table th,
    .table-responsive .table td {
        padding: 0.75rem 0.5rem;
    }
    
    /* Tablet sticky columns */
    .table-responsive .table .actions-column {
        min-width: 160px;
    }
    
    .table-responsive .table .actions-column .btn {
        font-size: 0.875rem;
        padding: 0.375rem 0.75rem;
        min-height: 36px;
    }
}

/* Touch-friendly enhancements for all touch devices */
@media (hover: none) and (pointer: coarse) {
    /* Ensure all interactive elements meet minimum touch target size */
    .sortable-header {
        min-height: 44px;
        display: flex;
        align-items: center;
        touch-action: manipulation;
    }
    
    .sortable-header .sort-link {
        min-height: 44px;
        min-width: 44px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0.75rem;
        border-radius: 0.5rem;
        transition: all 0.2s ease;
    }
    
    .sortable-header .sort-link:active {
        background-color: rgba(13, 110, 253, 0.2);
        transform: scale(0.98);
    }
    
    .pagination .page-link {
        min-height: 44px;
        min-width: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        touch-action: manipulation;
        border-radius: 0.5rem;
        transition: all 0.2s ease;
    }
    
    .pagination .page-link:active {
        transform: scale(0.95);
        background-color: rgba(13, 110, 253, 0.2);
    }
    
    .filter-tag .filter-remove {
        min-width: 32px;
        min-height: 32px;
        border-radius: 50%;
        touch-action: manipulation;
    }
    
    .filter-tag .filter-remove:active {
        transform: scale(0.9);
        background-color: rgba(220, 53, 69, 0.2);
    }
    
    .date-preset-btn {
        min-height: 44px;
        padding: 0.75rem 1rem;
        touch-action: manipulation;
        border-radius: 0.5rem;
    }
    
    .date-preset-btn:active {
        transform: scale(0.98);
    }
    
    /* Enhanced touch scrolling */
    .table-responsive {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
        overscroll-behavior-x: contain;
    }
    
    /* Touch-friendly form controls */
    .table-filter-group .form-control,
    .table-filter-group .form-select {
        min-height: 44px;
        padding: 0.75rem;
        font-size: 16px; /* Prevents zoom on iOS */
        touch-action: manipulation;
    }
    
    .table-filter-actions .btn {
        min-height: 44px;
        min-width: 44px;
        padding: 0.75rem 1rem;
        touch-action: manipulation;
        border-radius: 0.5rem;
    }
    
    .table-filter-actions .btn:active {
        transform: scale(0.98);
    }
    
    /* Touch-friendly table actions */
    .table .btn {
        min-height: 36px;
        min-width: 60px;
        touch-action: manipulation;
        border-radius: 0.375rem;
    }
    
    .table .btn:active {
        transform: scale(0.95);
    }
    
    /* Improved touch feedback for interactive elements */
    .sortable-header:active,
    .pagination .page-link:active,
    .filter-tag:active,
    .date-preset-btn:active,
    .table-filter-actions .btn:active {
        transition: transform 0.1s ease;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .sortable-header:hover,
    .sortable-header.active {
        background-color: #000;
        color: #fff;
    }
    
    .filter-tag {
        border: 2px solid #000;
        background-color: #fff;
        color: #000;
    }
    
    .pagination .page-item.active .page-link {
        background-color: #000;
        border-color: #000;
        color: #fff;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .sortable-header,
    .sort-indicator,
    .pagination .page-link,
    .filter-tag .filter-remove,
    .date-preset-btn {
        transition: none;
    }
    
    .pagination .page-link:hover {
        transform: none;
    }
}

/* Print styles for tables */
@media print {
    .table-filter-section,
    .table-pagination-wrapper {
        display: none !important;
    }
    
    .enhanced-table-container {
        box-shadow: none;
        border: 1px solid #000;
    }
    
    .table {
        font-size: 8pt;
    }
    
    .table th,
    .table td {
        padding: 0.25rem;
        border: 1px solid #000;
    }
    
    .sortable-header .sort-indicator {
        display: none;
    }
}

/* Loading states for table enhancements */
.table-loading {
    position: relative;
    opacity: 0.7;
    pointer-events: none;
}

.table-loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 2rem;
    height: 2rem;
    margin: -1rem 0 0 -1rem;
    border: 0.25rem solid #f3f3f3;
    border-top: 0.25rem solid #0d6efd;
    border-radius: 50%;
    animation: table-spinner 1s linear infinite;
    z-index: 1000;
}

@keyframes table-spinner {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Empty state for filtered tables */
.table-empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #6c757d;
}

.table-empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.table-empty-state h5 {
    color: #495057;
    margin-bottom: 0.5rem;
}

.table-empty-state p {
    margin-bottom: 1rem;
    font-size: 0.7875rem;
}

.table-empty-state .btn {
    font-size: 0.7875rem;
}

/* ============================================
   5. CARDS & PANELS
   ============================================ */

/* Card styling consistency */
.card {
    border-radius: 0.5rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

.card-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid rgba(0, 0, 0, 0.125);
    font-weight: 600;
}

/* ============================================
   6. BUTTONS
   ============================================ */

/* Button spacing in action columns */
.btn-sm {
    margin-right: 0.25rem;
}

.btn-sm:last-child {
    margin-right: 0;
}

/* Button group spacing */
.btn-group .btn {
    margin-right: 0;
}

/* ============================================
   7. BADGES & LABELS
   ============================================ */

/* Badge spacing */
.badge {
    margin-right: 0.25rem;
}

.badge:last-child {
    margin-right: 0;
}

/* ============================================
   8. ALERTS & MESSAGES
   ============================================ */

/* Alert positioning and animation */
.alert {
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   9. EMPTY STATES
   ============================================ */

/* Empty state styling for lists */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #6c757d;
}

.empty-state-icon {
    font-size: 2.43rem;
    margin-bottom: 1rem;
}

/* Empty message in permission selector */
.empty-message {
    text-align: center;
    padding: 3rem 1rem;
    color: #6c757d;
}

.empty-message i {
    font-size: 2.43rem;
}

/* Card header search inputs */
.card-header input.form-control {
    background-color: rgba(255, 255, 255, 0.9);
}

/* ============================================
   10. UTILITY CLASSES
   ============================================ */

/* Visibility utilities */
.hidden {
    display: none !important;
}

/* Text utilities */
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Currency and number formatting utilities */
.currency-cell,
.number-cell,
.amount-cell,
.decimal-cell,
.integer-cell {
    text-align: right;
    font-family: 'Courier New', Courier, monospace;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.currency-cell {
    font-weight: 600;
}

.percentage-cell {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Spacing utilities */
.mt-6 {
    margin-top: 4rem;
}

.mb-6 {
    margin-bottom: 4rem;
}

/* ============================================
   11. RESPONSIVE ADJUSTMENTS
   ============================================ */

/* Mobile optimizations */
@media (max-width: 768px) {
    /* Stack buttons vertically on mobile */
    .btn-sm {
        display: block;
        width: 100%;
        margin-bottom: 0.25rem;
        margin-right: 0;
    }
    
    /* Adjust table font size */
    .table {
        font-size: 0.70875rem;
    }
    
    /* Reduce permission container height on mobile */
    .permission-container {
        height: 300px;
    }
    
    .group-selection-container {
        max-height: 200px;
    }
}

/* Tablet adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
    .container {
        max-width: 95%;
    }
}

/* ============================================
   12. PRINT STYLES
   ============================================ */

@media print {
    /* Hide navigation and footer when printing */
    .navbar,
    .footer,
    .btn,
    .alert {
        display: none !important;
    }
    
    /* Ensure tables print properly */
    .table {
        border-collapse: collapse !important;
    }
    
    .table td,
    .table th {
        border: 1px solid #dee2e6 !important;
    }
}

/* ============================================
   13. ACCESSIBILITY ENHANCEMENTS
   ============================================ */

/* Focus styles for keyboard navigation */
a:focus,
button:focus,
input:focus,
select:focus,
textarea:focus {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
}

/* Skip to main content link (for screen readers) */
.skip-to-main {
    position: absolute;
    left: -9999px;
    z-index: 999;
}

.skip-to-main:focus {
    left: 50%;
    transform: translateX(-50%);
    top: 10px;
    background: #0d6efd;
    color: white;
    padding: 0.5rem 1rem;
    text-decoration: none;
    border-radius: 0.25rem;
}

/* ============================================
   14. LOADING STATES
   ============================================ */

/* Loading spinner */
.spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

/* ============================================
   15. CUSTOM COMPONENTS
   ============================================ */

/* Document Upload Integration */
.document-upload-section {
    margin-bottom: 1rem;
}

.document-upload-section .current-document {
    background-color: #f8fff9;
    border: 1px solid #d1e7dd;
    border-radius: 0.375rem;
    padding: 1rem;
}

.document-upload-section .no-document {
    padding: 0.5rem 0;
}

/* Document management buttons */
.document-actions .btn {
    transition: all 0.2s ease;
}

.document-actions .btn:hover {
    transform: translateY(-1px);
}

/* File type indicators */
.file-type-pdf { color: #dc3545; }
.file-type-doc, .file-type-docx { color: #0d6efd; }
.file-type-image { color: #198754; }

/* Document status badges */
.document-status .badge {
    margin-right: 0.25rem;
    margin-bottom: 0.25rem;
}

/* Dashboard welcome section */
.dashboard-welcome {
    text-align: center;
    padding: 3rem 1rem;
}

/* Admin panel cards */
.admin-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* Video gallery components */
.video-thumbnail-preview {
    max-height: 300px;
    object-fit: cover;
    border-radius: 0.375rem;
}

.video-icon-large {
    font-size: 3rem;
}


.admin-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

/* Footer links */
.footer a {
    color: #6c757d;
    transition: color 0.2s ease;
}

.footer a:hover {
    color: #0d6efd;
}

/* Cookie consent banner */
.cookie-consent {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1.5rem;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1050;
}

.cookie-consent.hidden {
    display: none !important;
}

.cookie-consent:not(.hidden) {
    animation: slideUp 0.5s ease-out;
}

.cookie-consent-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.cookie-consent p {
    margin: 0;
    color: white;
}

.cookie-consent strong {
    font-size: 0.891rem;
}

.cookie-consent .btn {
    min-width: 150px;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Responsive cookie consent */
@media (min-width: 768px) {
    .cookie-consent-content {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        text-align: left;
    }
    
    .cookie-consent-content > div {
        flex: 1;
        margin-right: 2rem;
    }
    
    .cookie-consent .btn {
        flex-shrink: 0;
    }
}

/* ============================================
   16. DOCUMENT VIEWER MODAL
   ============================================ */

/* Document viewer modal styling */
#documentViewerModal .modal-dialog {
    max-width: 90vw;
    width: 90vw;
    height: 90vh;
    margin: 1rem auto;
}

#documentViewerModal .modal-content {
    height: 100%;
    display: flex;
    flex-direction: column;
}

#documentViewerModal .modal-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 1rem;
}

/* Loading state */
.document-viewer-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    text-align: center;
    padding: 2rem;
}

.document-viewer-loading .spinner-border {
    width: 3rem;
    height: 3rem;
    margin-bottom: 1rem;
}

.document-viewer-loading .progress {
    margin-top: 1rem;
}

/* Enhanced error state */
.document-viewer-error {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    padding: 2rem;
}

.document-viewer-error .alert {
    margin: 0;
    max-width: 500px;
    text-align: center;
}

.document-viewer-error .alert i {
    font-size: 1.215rem;
    margin-bottom: 0.5rem;
}

/* Warning state for file size warnings */
.document-viewer-warning {
    padding: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
}

.document-viewer-warning .alert {
    margin: 0;
    max-width: 500px;
    text-align: center;
    border-color: #ffc107;
    background-color: #fff3cd;
}

/* Modal loading animation */
.modal.loading .modal-content {
    position: relative;
}

.modal.loading .modal-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, #007bff, transparent);
    animation: loading-bar 2s infinite;
    z-index: 1000;
}

@keyframes loading-bar {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Error state modal styling */
.modal.error-state .modal-header {
    border-bottom-color: #dc3545;
}

.modal.error-state .modal-title {
    color: #dc3545;
}

/* PDF loading placeholder */
.pdf-loading-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    background-color: #f8f9fa;
    border: 2px dashed #dee2e6;
    border-radius: 0.375rem;
}

/* Image loading state */
.image-loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    background-color: #f8f9fa;
    border: 2px dashed #dee2e6;
    border-radius: 0.375rem;
}

/* Text loading state */
.text-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
}

/* Progress bar enhancements */
.progress-bar {
    transition: width 0.3s ease;
    font-size: 0.6075rem;
    font-weight: 600;
}

/* Retry button countdown styling */
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Network status indicator */
.network-status {
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 9999;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    font-size: 0.7875rem;
    font-weight: 600;
}

.network-status.offline {
    background-color: #dc3545;
    color: white;
}

.network-status.online {
    background-color: #198754;
    color: white;
}

/* Content area */
.document-viewer-content {
    flex: 1;
    overflow: auto;
    display: flex;
    flex-direction: column;
}

/* PDF viewer */
.document-viewer-pdf {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.document-viewer-pdf iframe {
    flex: 1;
    min-height: 600px;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
}

/* Image viewer */
.document-viewer-image {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 400px;
    background-color: #f8f9fa;
    border-radius: 0.375rem;
    padding: 1rem;
}

.document-viewer-image img {
    max-height: 70vh;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    border-radius: 0.375rem;
}

/* Text viewer */
.document-viewer-text {
    flex: 1;
}

.document-viewer-text pre {
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.70875rem;
    line-height: 1.4;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Document info */
.document-viewer-info {
    border-top: 1px solid #dee2e6;
    padding-top: 1rem;
    margin-top: 1rem;
}

.document-viewer-info .card {
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
}

.document-viewer-info dl {
    margin-bottom: 0;
}

.document-viewer-info dt {
    font-weight: 600;
    color: #495057;
}

.document-viewer-info dd {
    color: #6c757d;
}

/* Fullscreen styles */
.document-viewer-content:fullscreen {
    background: white;
    padding: 1rem;
}

.document-viewer-content:-webkit-full-screen {
    background: white;
    padding: 1rem;
}

.document-viewer-content:-moz-full-screen {
    background: white;
    padding: 1rem;
}

/* Responsive adjustments for document viewer */
@media (max-width: 768px) {
    #documentViewerModal .modal-dialog {
        max-width: 98vw;
        width: 98vw;
        height: 98vh;
        margin: 1vh auto;
    }
    
    #documentViewerModal .modal-body {
        padding: 0.75rem;
    }
    
    #documentViewerModal .modal-header {
        padding: 0.75rem;
        flex-wrap: wrap;
    }
    
    #documentViewerModal .modal-footer {
        padding: 0.75rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    #documentViewerModal .modal-title {
        font-size: 0.81rem;
        flex: 1;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    .document-viewer-pdf iframe {
        min-height: 400px;
    }
    
    .document-viewer-image {
        min-height: 300px;
    }
    
    .document-viewer-image img {
        max-height: 50vh;
    }
    
    .document-viewer-info dt,
    .document-viewer-info dd {
        font-size: 0.70875rem;
    }
    
    /* Mobile-optimized controls */
    .document-viewer-image .image-controls {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.25rem;
    }
    
    .document-viewer-image .image-controls .btn {
        min-width: 2.75rem;
        padding: 0.5rem;
    }
    
    .document-viewer-text .text-controls,
    .document-viewer-csv .text-controls,
    .document-viewer-json .text-controls,
    .document-viewer-markup .text-controls {
        flex-wrap: wrap;
        gap: 0.25rem;
    }
}

/* Tablet adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
    #documentViewerModal .modal-dialog {
        max-width: 95vw;
        width: 95vw;
        height: 95vh;
        margin: 2.5vh auto;
    }
    
    .document-viewer-image img {
        max-height: 65vh;
    }
    
    .document-viewer-pdf iframe {
        min-height: 500px;
    }
}

/* Large screen optimizations */
@media (min-width: 1200px) {
    #documentViewerModal .modal-dialog {
        max-width: 85vw;
        width: 85vw;
        height: 85vh;
    }
    
    .document-viewer-image img {
        max-height: 75vh;
    }
    
    .document-viewer-pdf iframe {
        min-height: 700px;
    }
}

/* Ultra-wide screen adjustments */
@media (min-width: 1600px) {
    #documentViewerModal .modal-dialog {
        max-width: 80vw;
        width: 80vw;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .document-viewer-image img {
        /* Enable pinch-to-zoom on touch devices */
        touch-action: pinch-zoom;
    }
    
    .document-viewer-text pre {
        /* Better scrolling on touch devices */
        -webkit-overflow-scrolling: touch;
    }
    
    /* Larger touch targets for mobile */
    .document-viewer-image .image-controls .btn,
    .document-viewer-text .text-controls .btn,
    .document-viewer-csv .text-controls .btn,
    .document-viewer-json .text-controls .btn,
    .document-viewer-markup .text-controls .btn {
        min-height: 44px;
        min-width: 44px;
        padding: 0.75rem;
    }
    
    /* Touch-friendly scrollbars */
    .document-viewer-content {
        scrollbar-width: thick;
    }
    
    .document-viewer-content::-webkit-scrollbar {
        width: 12px;
        height: 12px;
    }
    
    .document-viewer-content::-webkit-scrollbar-thumb {
        background-color: rgba(0, 0, 0, 0.3);
        border-radius: 6px;
    }
    
    .document-viewer-content::-webkit-scrollbar-track {
        background-color: rgba(0, 0, 0, 0.1);
    }
    
    /* Improve touch interaction for image panning */
    .document-viewer-image .image-container {
        touch-action: pan-x pan-y pinch-zoom;
        user-select: none;
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
    }
    
    /* Better touch feedback */
    .btn:active {
        transform: scale(0.95);
        transition: transform 0.1s ease;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .document-viewer-loading,
    .document-viewer-error {
        background-color: white;
        color: black;
    }
    
    .document-viewer-image {
        background-color: white;
        border: 2px solid black;
    }
    
    .document-viewer-text pre {
        background-color: white;
        border: 2px solid black;
        color: black;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .document-viewer-loading .spinner-border {
        animation: none;
    }
    
    .progress-bar-animated {
        animation: none;
    }
}

/* ============================================
   17. FILE TYPE HANDLER STYLES
   ============================================ */

/* PDF Handler Styles */
.document-viewer-pdf {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.document-viewer-pdf .pdf-iframe {
    width: 100%;
    min-height: 600px;
    height: 70vh; /* Use viewport height for better sizing */
    border: none;
    border-radius: 0.375rem;
    background-color: #f8f9fa; /* Light background to show iframe boundaries */
    flex: 1; /* Take up available space */
}

.document-viewer-pdf .pdf-loading-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    text-align: center;
}

/* Ensure modal content has proper height for PDF viewing */
#documentViewerModal .modal-body {
    min-height: 70vh;
    padding: 1rem;
}

#documentViewerModal .modal-dialog {
    max-width: 90vw;
    width: 90vw;
    height: 90vh;
    max-height: 90vh;
}

#documentViewerModal .modal-content {
    height: 100%;
    display: flex;
    flex-direction: column;
}

#documentViewerModal .modal-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Image Handler Styles */
.document-viewer-image {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.document-viewer-image .image-container {
    position: relative;
    overflow: hidden;
    border-radius: 0.375rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    max-height: 70vh;
    max-width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #f8f9fa;
    touch-action: pan-x pan-y pinch-zoom;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.document-viewer-image .viewer-image {
    max-width: 100%;
    max-height: 100%;
    transition: transform 0.2s ease;
    cursor: default;
    touch-action: none;
}

.document-viewer-image .image-container[style*="cursor: grab"] .viewer-image {
    cursor: grab;
}

.document-viewer-image .image-container[style*="cursor: grabbing"] .viewer-image {
    cursor: grabbing;
}

.document-viewer-image .image-controls {
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem;
    background-color: rgba(0, 0, 0, 0.05);
    border-radius: 0.375rem;
    flex-wrap: wrap;
    justify-content: center;
}

.document-viewer-image .image-controls .btn {
    min-width: 2.5rem;
    transition: all 0.2s ease;
}

.document-viewer-image .image-controls .btn:active {
    transform: scale(0.95);
}

/* Text Handler Styles */
.document-viewer-text,
.document-viewer-csv,
.document-viewer-json,
.document-viewer-markup {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.document-viewer-text .text-controls,
.document-viewer-csv .text-controls,
.document-viewer-json .text-controls,
.document-viewer-markup .text-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.document-viewer-text .text-controls .btn,
.document-viewer-csv .text-controls .btn,
.document-viewer-json .text-controls .btn,
.document-viewer-markup .text-controls .btn {
    transition: all 0.2s ease;
}

.document-viewer-text .text-controls .btn:active,
.document-viewer-csv .text-controls .btn:active,
.document-viewer-json .text-controls .btn:active,
.document-viewer-markup .text-controls .btn:active {
    transform: scale(0.95);
}

.document-viewer-text .text-content,
.document-viewer-json .json-content,
.document-viewer-markup .markup-content {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    padding: 1rem;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.70875rem;
    line-height: 1.5;
    max-height: 600px;
    overflow: auto;
    white-space: pre;
    margin: 0;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y pinch-zoom;
}

.document-viewer-text .text-content.text-wrap {
    white-space: pre-wrap;
    word-wrap: break-word;
}

.document-viewer-csv .table-responsive {
    max-height: 600px;
    overflow: auto;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
}

.document-viewer-csv .table {
    margin-bottom: 0;
    font-size: 0.70875rem;
}

.document-viewer-csv .table th {
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: #212529 !important;
}

.text-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: #6c757d;
}

/* Fallback Handler Styles */
.document-viewer-fallback {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 1rem;
}

.document-viewer-fallback .file-type-info {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    padding: 1.5rem;
}

.document-viewer-fallback .file-type-info h6 {
    color: #495057;
    margin-bottom: 1rem;
    font-weight: 600;
}

.document-viewer-fallback .file-type-info dl {
    margin-bottom: 0;
}

.document-viewer-fallback .file-type-info dt {
    font-weight: 600;
    color: #495057;
}

.document-viewer-fallback .file-type-info dd {
    color: #6c757d;
}

.document-viewer-fallback .supported-formats {
    background-color: #e7f3ff;
    border: 1px solid #b8daff;
    border-radius: 0.375rem;
    padding: 1.5rem;
}

.document-viewer-fallback .supported-formats h6 {
    color: #004085;
    margin-bottom: 1rem;
    font-weight: 600;
}

.document-viewer-fallback .supported-formats ul {
    margin-bottom: 0;
    color: #004085;
}

/* Responsive adjustments for file type handlers */
@media (max-width: 768px) {
    .document-viewer-image .image-container {
        max-height: 50vh;
    }
    
    .document-viewer-image .image-controls {
        justify-content: center;
    }
    
    .document-viewer-text .text-content,
    .document-viewer-json .json-content,
    .document-viewer-markup .markup-content {
        font-size: 0.6075rem;
        max-height: 400px;
    }
    
    .document-viewer-csv .table-responsive {
        max-height: 400px;
    }
    
    .document-viewer-fallback .file-type-info,
    .document-viewer-fallback .supported-formats {
        padding: 1rem;
    }
}

/* Touch device optimizations for handlers */
@media (hover: none) and (pointer: coarse) {
    .document-viewer-image .viewer-image {
        touch-action: pinch-zoom;
    }
    
    .document-viewer-text .text-content,
    .document-viewer-json .json-content,
    .document-viewer-markup .markup-content {
        -webkit-overflow-scrolling: touch;
    }
    
    .document-viewer-csv .table-responsive {
        -webkit-overflow-scrolling: touch;
    }
}

/* High contrast mode support for handlers */
@media (prefers-contrast: high) {
    .document-viewer-text .text-content,
    .document-viewer-json .json-content,
    .document-viewer-markup .markup-content {
        background-color: white;
        border: 2px solid black;
        color: black;
    }
    
    .document-viewer-fallback .file-type-info,
    .document-viewer-fallback .supported-formats {
        background-color: white;
        border: 2px solid black;
        color: black;
    }
}

/* Print styles for document viewer */
@media print {
    #documentViewerModal {
        display: none !important;
    }
}

/* ============================================
   17. PASSWORD TOGGLE WITH BOOTSTRAP INPUT-GROUP
   ============================================ */

/* Password toggle button styling */
.password-toggle-btn {
    border-left: 0 !important;
    background: transparent !important;
    border-color: #ced4da !important;
    color: #6c757d !important;
    padding: 0.375rem 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.password-toggle-btn:hover {
    background: rgba(0, 0, 0, 0.05) !important;
    border-color: #ced4da !important;
    color: #495057 !important;
}

.password-toggle-btn:focus {
    background: rgba(13, 110, 253, 0.1) !important;
    border-color: #86b7fe !important;
    color: #0d6efd !important;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25) !important;
}

.password-toggle-btn:active {
    background: rgba(13, 110, 253, 0.2) !important;
    border-color: #86b7fe !important;
    color: #0d6efd !important;
}

/* Material Icons styling for password toggle */
.password-toggle-btn .material-symbols-outlined {
    font-family: 'Material Symbols Outlined';
    font-weight: normal;
    font-style: normal;
    font-size: 14.58px;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    display: inline-block;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    -webkit-font-feature-settings: 'liga';
    -webkit-font-smoothing: antialiased;
    color: inherit;
}

/* Ensure input-group has proper focus states */
.input-group:focus-within .password-toggle-btn {
    border-color: #86b7fe !important;
}

/* ============================================
   18. DEPENDENT DROPDOWN FUNCTIONALITY
   ============================================ */

/* Loading state for dropdowns */
select.loading {
    background-image: url("data:image/svg+xml,%3csvg width='16' height='16' viewBox='0 0 16 16' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0zM8 2a6 6 0 1 0 0 12A6 6 0 0 0 8 2z' fill='%236c757d'/%3e%3cpath d='M8 2a6 6 0 0 1 6 6h-2a4 4 0 0 0-4-4V2z' fill='%230d6efd'%3e%3canimateTransform attributeName='transform' type='rotate' values='0 8 8;360 8 8' dur='1s' repeatCount='indefinite'/%3e%3c/path%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px;
    padding-right: 2.5rem !important;
}

/* Error state for dropdowns */
select.error {
    border-color: #dc3545 !important;
    background-color: #f8d7da !important;
}

select.error:focus {
    border-color: #dc3545 !important;
    box-shadow: 0 0 0 0.25rem rgba(220, 53, 69, 0.25) !important;
}

/* Disabled state styling */
select:disabled {
    background-color: #e9ecef !important;
    opacity: 1 !important;
}

/* Country-State form group styling */
.country-state-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 576px) {
    .country-state-group {
        grid-template-columns: 1fr;
    }
}

/* Help text for dependent fields */
.dependent-field-help {
    font-size: 0.70875rem;
    color: #6c757d;
    margin-top: 0.25rem;
}

/* Loading indicator for AJAX requests */
.dropdown-loading {
    position: relative;
}

.dropdown-loading::after {
    content: '';
    position: absolute;
    right: 2rem;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #0d6efd;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: translateY(-50%) rotate(0deg); }
    100% { transform: translateY(-50%) rotate(360deg); }
}

/* Accessibility improvements */
select[aria-busy="true"] {
    cursor: wait;
}

select[aria-invalid="true"] {
    border-color: #dc3545 !important;
}

/* Focus management for dependent dropdowns */
.form-control:focus + .dependent-field-help {
    color: #0d6efd;
}

/* Form fieldset styling */
fieldset {
    border: none;
    padding: 0;
    margin: 0;
}

fieldset legend {
    font-weight: 600;
    font-size: 0.81rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #dee2e6;
    width: 100%;
}

/* Form section spacing */
.card-body fieldset + fieldset {
    margin-top: 2rem;
}

/* ============================================
   19. DOCUMENT VIEWER CONTROLS
   ============================================ */

/* Viewer controls layout */
.viewer-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.viewer-controls .btn-group {
    flex-shrink: 0;
}

.viewer-controls .btn {
    transition: all 0.2s ease;
}

.viewer-controls .btn:hover:not(:disabled) {
    transform: translateY(-1px);
}

.viewer-controls .btn:active:not(:disabled) {
    transform: translateY(0);
}

.viewer-controls .btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Page navigation info */
#pageInfo {
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.70875rem;
    font-weight: 600;
    min-width: 80px;
    text-align: center;
    cursor: default;
}

/* Action buttons layout */
.action-buttons {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
}

/* Modal footer responsive layout */
#documentViewerModal .modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 1rem;
}

/* Responsive adjustments for viewer controls */
@media (max-width: 768px) {
    #documentViewerModal .modal-footer {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    
    .viewer-controls {
        justify-content: center;
        order: 1;
    }
    
    .action-buttons {
        justify-content: center;
        margin-left: 0;
        order: 2;
    }
    
    .viewer-controls .btn-group {
        margin-bottom: 0.25rem;
    }
    
    .viewer-controls .btn {
        min-width: 2.5rem;
        padding: 0.5rem;
    }
    
    .action-buttons .btn {
        flex: 1;
        min-width: 0;
    }
    
    #pageInfo {
        min-width: 70px;
        font-size: 0.6075rem;
    }
}

/* Tablet adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
    .viewer-controls .btn {
        padding: 0.375rem 0.5rem;
        font-size: 0.70875rem;
    }
    
    #pageInfo {
        min-width: 75px;
        font-size: 0.658125rem;
    }
}

/* Touch device optimizations for controls */
@media (hover: none) and (pointer: coarse) {
    .viewer-controls .btn,
    .action-buttons .btn {
        min-height: 44px;
        min-width: 44px;
        padding: 0.75rem;
    }
    
    .viewer-controls .btn-group .btn {
        border-radius: 0.375rem !important;
        margin-right: 0.25rem;
    }
    
    .viewer-controls .btn-group .btn:last-child {
        margin-right: 0;
    }
    
    #pageInfo {
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0.75rem 0.5rem;
    }
}

/* High contrast mode support for controls */
@media (prefers-contrast: high) {
    .viewer-controls .btn,
    .action-buttons .btn {
        border: 2px solid;
    }
    
    .viewer-controls .btn:disabled,
    .action-buttons .btn:disabled {
        opacity: 0.7;
        background-color: #f8f9fa;
        color: #6c757d;
        border-color: #6c757d;
    }
}

/* Reduced motion support for controls */
@media (prefers-reduced-motion: reduce) {
    .viewer-controls .btn,
    .action-buttons .btn {
        transition: none;
    }
    
    .viewer-controls .btn:hover:not(:disabled) {
        transform: none;
    }
}

/* Focus styles for keyboard navigation */
.viewer-controls .btn:focus,
.action-buttons .btn:focus {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
    z-index: 1;
}

/* Button group focus management */
.viewer-controls .btn-group .btn:focus {
    z-index: 2;
}

/* Info toggle button states */
#documentInfoToggle.active {
    background-color: #0d6efd;
    border-color: #0d6efd;
    color: white;
}

/* Fullscreen button enhancement */
#documentViewerFullscreen {
    position: relative;
}

#documentViewerFullscreen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 30%, rgba(255,255,255,0.1) 50%, transparent 70%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

#documentViewerFullscreen:hover::before {
    opacity: 1;
}

/* Control tooltips enhancement */
.viewer-controls .btn[title],
.action-buttons .btn[title] {
    position: relative;
}

/* Print styles for controls */
@media print {
    .viewer-controls,
    .action-buttons,
    #documentViewerModal .modal-footer {
        display: none !important;
    }
}

/* Performance Optimization Styles */

/* Network Status Indicator */
.network-status {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    color: white;
    font-size: 0.70875rem;
    font-weight: 500;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    transition: all 0.3s ease;
}

.network-status.online {
    background-color: #198754;
}

.network-status.offline {
    background-color: #dc3545;
}

/* Progressive Loading Indicators */
.progressive-loading-indicator {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.675rem;
    z-index: 10;
}

/* Cache Status Indicator */
.cache-status {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(40, 167, 69, 0.9);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.675rem;
    z-index: 10;
}

/* Memory Usage Warning */
.memory-warning {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: rgba(255, 193, 7, 0.95);
    color: #212529;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    font-size: 0.7875rem;
    z-index: 9998;
    max-width: 300px;
}

/* Loading Animation Enhancements */
.modal.loading .modal-content {
    position: relative;
    overflow: hidden;
}

.modal.loading .modal-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, #007bff, transparent);
    animation: loading-shimmer 2s infinite;
    z-index: 1000;
}

@keyframes loading-shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* Error State Styling */
.modal.error-state .modal-header {
    background-color: #f8d7da;
    border-bottom-color: #f5c6cb;
}

.modal.error-state .modal-title {
    color: #721c24;
}

/* Performance Metrics Display (for debugging) */
.performance-metrics {
    position: fixed;
    bottom: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.675rem;
    font-family: monospace;
    z-index: 9997;
    display: none; /* Hidden by default, can be shown for debugging */
}

.performance-metrics.show {
    display: block;
}

/* Lazy Loading Placeholder */
.document-lazy-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    background: #f8f9fa;
    border: 2px dashed #dee2e6;
    border-radius: 0.375rem;
    color: #6c757d;
    font-size: 0.7875rem;
}

.document-lazy-placeholder i {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
}

/* Progressive Loading Progress Bar Enhancement */
.progress-bar.progressive {
    background: linear-gradient(45deg, #007bff 25%, transparent 25%, transparent 50%, #007bff 50%, #007bff 75%, transparent 75%, transparent);
    background-size: 1rem 1rem;
    animation: progress-bar-stripes 1s linear infinite;
}

@keyframes progress-bar-stripes {
    0% { background-position: 1rem 0; }
    100% { background-position: 0 0; }
}

/* Mobile Performance Optimizations */
@media (max-width: 768px) {
    .network-status {
        top: 10px;
        right: 10px;
        font-size: 0.675rem;
        padding: 0.25rem 0.5rem;
    }
    
    .progressive-loading-indicator,
    .cache-status {
        font-size: 0.5625rem;
        padding: 0.125rem 0.25rem;
    }
    
    .memory-warning {
        bottom: 10px;
        left: 10px;
        font-size: 0.675rem;
        padding: 0.25rem 0.5rem;
        max-width: 250px;
    }
}

/* ============================================
   20. ENHANCED DOCUMENT VIEWER UI POLISH
   ============================================ */

/* Smooth transitions for all interactive elements */
.document-viewer-btn,
.document-viewer-link {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.document-viewer-btn:hover,
.document-viewer-link:hover {
    transform: translateY(-1px);
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.15);
}

.document-viewer-btn:active,
.document-viewer-link:active {
    transform: translateY(0);
    transition-duration: 0.1s;
}

/* Ripple effect for buttons */
.document-viewer-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.3s ease, height 0.3s ease;
    pointer-events: none;
}

.document-viewer-btn:active::before {
    width: 300px;
    height: 300px;
}

/* Enhanced loading animations */
.document-viewer-loading {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    position: relative;
}

.document-viewer-loading::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* Pulse animation for loading states */
.document-viewer-loading .spinner-border {
    animation: pulse-scale 1.5s ease-in-out infinite alternate;
}

@keyframes pulse-scale {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(1.1); opacity: 0.7; }
}

/* Enhanced progress bar with gradient */
.document-viewer-progress .progress-bar {
    background: linear-gradient(45deg, #007bff, #0056b3);
    position: relative;
    overflow: hidden;
}

.document-viewer-progress .progress-bar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.2) 50%, transparent 70%);
    animation: progress-shine 2s infinite;
}

@keyframes progress-shine {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Modal entrance animations */
#documentViewerModal.fade .modal-dialog {
    transform: scale(0.9) translateY(-50px);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#documentViewerModal.show .modal-dialog {
    transform: scale(1) translateY(0);
}

/* Content fade-in animation */
.document-viewer-content {
    opacity: 0;
    animation: fadeInUp 0.5s ease-out forwards;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Enhanced error state with icon animation */
.document-viewer-error .alert i {
    animation: errorPulse 2s ease-in-out infinite;
}

@keyframes errorPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Success state animation */
.document-viewer-success {
    animation: successSlide 0.5s ease-out;
}

@keyframes successSlide {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Interactive hover states for document cards */
.document-card {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 0.5rem;
    overflow: hidden;
    position: relative;
}

.document-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(13, 110, 253, 0.05) 0%, rgba(13, 110, 253, 0.1) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.document-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.document-card:hover::before {
    opacity: 1;
}

/* Enhanced file type icons with animations */
.file-type-icon {
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 0.375rem;
    margin-right: 0.5rem;
}

.file-type-icon:hover {
    transform: rotate(5deg) scale(1.1);
}

.file-type-pdf .file-type-icon {
    background: linear-gradient(135deg, #dc3545, #c82333);
    color: white;
}

.file-type-image .file-type-icon {
    background: linear-gradient(135deg, #198754, #157347);
    color: white;
}

.file-type-doc .file-type-icon,
.file-type-docx .file-type-icon {
    background: linear-gradient(135deg, #0d6efd, #0b5ed7);
    color: white;
}

.file-type-text .file-type-icon {
    background: linear-gradient(135deg, #6c757d, #5c636a);
    color: white;
}

/* Enhanced zoom controls with better feedback */
.zoom-controls {
    background: rgba(0, 0, 0, 0.8);
    border-radius: 0.5rem;
    padding: 0.5rem;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.zoom-controls .btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    transition: all 0.2s ease;
}

.zoom-controls .btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.zoom-controls .btn:active {
    transform: scale(0.95);
}

/* Enhanced fullscreen transition */
.document-viewer-content.entering-fullscreen {
    animation: enterFullscreen 0.3s ease-out;
}

.document-viewer-content.exiting-fullscreen {
    animation: exitFullscreen 0.3s ease-out;
}

@keyframes enterFullscreen {
    from {
        transform: scale(0.95);
        opacity: 0.8;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes exitFullscreen {
    from {
        transform: scale(1.05);
        opacity: 0.8;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Enhanced responsive breakpoints */
@media (max-width: 480px) {
    #documentViewerModal .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100vw - 1rem);
        height: calc(100vh - 1rem);
    }
    
    .document-viewer-content {
        padding: 0.5rem;
    }
    
    .zoom-controls {
        padding: 0.25rem;
    }
    
    .zoom-controls .btn {
        min-width: 2rem;
        min-height: 2rem;
        padding: 0.25rem;
        font-size: 0.675rem;
    }
}

@media (min-width: 481px) and (max-width: 768px) {
    #documentViewerModal .modal-dialog {
        margin: 1rem;
        max-width: calc(100vw - 2rem);
        height: calc(100vh - 2rem);
    }
}

@media (min-width: 1400px) {
    #documentViewerModal .modal-dialog {
        max-width: 75vw;
        width: 75vw;
    }
}

/* Enhanced accessibility features */
@media (prefers-reduced-motion: reduce) {
    .document-viewer-btn,
    .document-viewer-link,
    .document-card,
    .file-type-icon,
    .zoom-controls .btn {
        transition: none;
        animation: none;
    }
    
    .document-viewer-btn:hover,
    .document-viewer-link:hover,
    .document-card:hover,
    .file-type-icon:hover,
    .zoom-controls .btn:hover {
        transform: none;
    }
    
    .document-viewer-loading::before,
    .document-viewer-progress .progress-bar::before {
        animation: none;
    }
}

/* High contrast mode enhancements */
@media (prefers-contrast: high) {
    .document-card {
        border: 2px solid;
    }
    
    .zoom-controls {
        background: black;
        border: 2px solid white;
    }
    
    .zoom-controls .btn {
        background: white;
        color: black;
        border: 1px solid black;
    }
    
    .file-type-icon {
        border: 2px solid;
    }
}

/* Dark mode support (if implemented) */
@media (prefers-color-scheme: dark) {
    .document-viewer-loading {
        background: linear-gradient(135deg, #343a40 0%, #495057 100%);
    }
    
    .document-card::before {
        background: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.1) 100%);
    }
    
    .document-viewer-content {
        background-color: #212529;
        color: #f8f9fa;
    }
}

/* Enhanced focus indicators for better accessibility */
.document-viewer-btn:focus-visible,
.document-viewer-link:focus-visible {
    outline: 3px solid #0d6efd;
    outline-offset: 2px;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

.zoom-controls .btn:focus-visible {
    outline: 2px solid white;
    outline-offset: 2px;
}

/* Loading skeleton for better perceived performance */
.document-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 0.375rem;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.document-skeleton.skeleton-text {
    height: 1rem;
    margin-bottom: 0.5rem;
}

.document-skeleton.skeleton-text:last-child {
    width: 60%;
}

.document-skeleton.skeleton-image {
    height: 200px;
    width: 100%;
}

/* Enhanced tooltip styling */
.tooltip {
    font-size: 0.675rem;
}

.tooltip-inner {
    background-color: rgba(0, 0, 0, 0.9);
    border-radius: 0.375rem;
    padding: 0.5rem 0.75rem;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* Performance indicator styling */
.performance-indicator {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.5625rem;
    font-family: monospace;
    z-index: 10;
}

.performance-indicator.good {
    background: rgba(25, 135, 84, 0.8);
}

.performance-indicator.warning {
    background: rgba(255, 193, 7, 0.8);
    color: #212529;
}

.performance-indicator.poor {
    background: rgba(220, 53, 69, 0.8);
}

/* Enhanced print styles */
@media print {
    .document-viewer-content {
        background: white !important;
        color: black !important;
        box-shadow: none !important;
    }
    
    .document-viewer-image img {
        max-width: 100% !important;
        height: auto !important;
    }
    
    .document-viewer-text pre {
        white-space: pre-wrap !important;
        font-size: 9pt !important;
        line-height: 1.2 !important;
    }
}

/* ============================================
   21. DOCUMENT CARD COMPONENT STYLES
   ============================================ */

/* Document card base styles */
.document-card .card {
    border: 1px solid #dee2e6;
    border-radius: 0.5rem;
    transition: all 0.2s ease;
    position: relative;
}

.document-card .card:hover {
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.1);
    border-color: #0d6efd;
}

/* Document info styles */
.document-info .document-title {
    color: #495057;
    font-weight: 600;
}

.document-info .document-filename {
    font-weight: 500;
    color: #212529;
    word-break: break-word;
}

.document-info .document-meta {
    margin-top: 0.25rem;
}

/* Document actions */
.document-actions .btn {
    transition: all 0.2s ease;
}

.document-actions .btn:hover {
    transform: translateY(-1px);
}

/* Document status badges */
.document-status .badge {
    margin-right: 0.25rem;
    margin-bottom: 0.25rem;
    animation: fadeInUp 0.3s ease-out;
}

/* Loading state for document cards */
.document-card.loading {
    opacity: 0.7;
    pointer-events: none;
    position: relative;
}

.document-card.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 1.5rem;
    height: 1.5rem;
    margin: -0.75rem 0 0 -0.75rem;
    border: 0.2rem solid #f3f3f3;
    border-top: 0.2rem solid #0d6efd;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 1000;
}

/* Responsive adjustments for document cards */
@media (max-width: 768px) {
    .document-card .row {
        text-align: center;
    }
    
    .document-card .col-auto:first-child {
        margin-bottom: 1rem;
    }
    
    .document-actions {
        margin-top: 1rem;
    }
    
    .document-actions .btn {
        margin-bottom: 0.25rem;
    }
}

/* ============================================
   22. DOCUMENT GALLERY COMPONENT STYLES
   ============================================ */

/* Document gallery grid layout */
.document-gallery {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

.document-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, auto));
    gap: 1rem;
    width: 100%;
    max-width: 100%;
}

.document-gallery-item .card {
    transition: all 0.2s ease;
    height: 100%;
}

.document-gallery-item .card:hover {
    transform: translateY(-2px);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

/* Document preview styles */
.document-preview {
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.375rem;
    overflow: hidden;
}

.image-preview {
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 0.375rem;
    cursor: pointer;
    position: relative;
    transition: transform 0.2s ease;
}

.image-preview:hover {
    transform: scale(1.05);
}

.image-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
    color: white;
    font-size: 1.35rem;
}

.image-preview:hover .image-overlay {
    opacity: 1;
}

.file-preview {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.7rem;
    color: white;
    border-radius: 0.375rem;
}

.file-preview.file-type-pdf { 
    background: linear-gradient(135deg, #dc3545, #c82333); 
}

.file-preview.file-type-doc, 
.file-preview.file-type-docx { 
    background: linear-gradient(135deg, #0d6efd, #0b5ed7); 
}

.file-preview.file-type-default { 
    background: linear-gradient(135deg, #6c757d, #5c636a); 
}

.empty-document-preview {
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f8f9fa;
    border: 2px dashed #dee2e6;
    border-radius: 0.375rem;
    font-size: 1.8rem;
    color: #6c757d;
    transition: all 0.2s ease;
}

.empty-document-preview:hover {
    border-color: #0d6efd;
    color: #0d6efd;
}

/* Gallery item animations */
.document-gallery-item {
    animation: fadeInUp 0.3s ease-out;
}

/* View toggle animations */
.document-gallery-grid.fade-out,
.document-gallery-list.fade-out {
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.2s ease;
}

.document-gallery-grid.fade-in,
.document-gallery-list.fade-in {
    opacity: 1;
    transform: translateY(0);
    transition: all 0.2s ease;
}

/* Responsive adjustments for document gallery */
@media (max-width: 768px) {
    .document-gallery-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
        width: 100%;
        max-width: 100%;
    }
    
    .document-preview {
        height: 100px;
    }
    
    .empty-document-preview {
        height: 100px;
        font-size: 1.35rem;
    }
}

@media (max-width: 576px) {
    .document-gallery-grid {
        grid-template-columns: 1fr;
        width: 100%;
        max-width: 100%;
    }
}

/* ============================================
   23. SIDEBAR NAVIGATION STYLES
   ============================================ */

/* Sidebar container */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 200px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    box-shadow: 0 0.125rem 0.25rem var(--sidebar-shadow);
    z-index: 1040;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Collapsed sidebar state */
.sidebar.collapsed {
    width: 80px;
}

/* Sidebar header */
.sidebar-header {
    padding: 1rem;
    border-bottom: 1px solid var(--sidebar-header-border);
    background-color: var(--sidebar-header-bg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 70px;
    flex-shrink: 0;
}

.sidebar-header .navbar-brand {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: var(--sidebar-text);
    font-weight: 600;
    font-size: 1.0125rem;
    margin: 0;
    padding: 0;
    transition: opacity 0.3s ease;
}

.sidebar-header .navbar-brand img {
    max-height: 40px;
    width: auto;
    margin-right: 0.75rem;
    transition: margin 0.3s ease;
}

/* Logo visibility control */
.sidebar-header .navbar-brand .logo-full {
    display: block;
}

.sidebar-header .navbar-brand .logo-icon {
    display: none;
    max-height: 32px;
    width: 32px;
}

.sidebar.collapsed .sidebar-header .navbar-brand .logo-full {
    display: none;
}

.sidebar.collapsed .sidebar-header .navbar-brand .logo-icon {
    display: block;
    margin-right: 0;
}

.sidebar.collapsed .sidebar-header .navbar-brand span {
    opacity: 0;
    width: 0;
    overflow: hidden;
    transition: all 0.3s ease;
}

.sidebar.collapsed .sidebar-header .navbar-brand img {
    margin-right: 0;
}

/* Sidebar toggle button */
.sidebar-toggle {
    background: none;
    border: none;
    color: var(--sidebar-toggle-color);
    font-size: 1.125rem;
    padding: 0.5rem;
    border-radius: 0.375rem;
    transition: all 0.2s ease;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
}

.sidebar-toggle:hover {
    background-color: var(--sidebar-toggle-hover-bg);
    color: var(--sidebar-toggle-hover-color);
}

.sidebar-toggle:focus {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
}

/* Collapsed sidebar toggle button positioning */
.sidebar.collapsed .sidebar-header {
    padding: 1rem 0.5rem;
    justify-content: flex-start;
    position: relative;
}

.sidebar.collapsed .sidebar-header .navbar-brand {
    margin-right: auto;
    padding-left: 0.25rem;
}

.sidebar.collapsed .sidebar-toggle {
    position: absolute;
    top: 50%;
    right: 0.5rem;
    transform: translateY(-50%);
    width: 2rem;
    height: 2rem;
    padding: 0.25rem;
    font-size: 0.9rem;
    background-color: var(--sidebar-toggle-collapsed-bg);
    border-radius: 0.25rem;
    border: 1px solid var(--sidebar-toggle-collapsed-border);
}

.sidebar.collapsed .sidebar-toggle:hover {
    background-color: var(--sidebar-toggle-hover-bg);
    border-color: var(--sidebar-toggle-collapsed-border);
    color: var(--sidebar-toggle-hover-color);
}

.sidebar.collapsed .sidebar-toggle:focus {
    background-color: rgba(77, 171, 247, 0.1);
    border-color: var(--sidebar-link-active-border);
    color: var(--sidebar-text-hover);
}

/* Sidebar navigation */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem 0;
}

.sidebar-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.sidebar-nav li {
    margin-bottom: 0.25rem;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: all 0.2s ease;
    border-radius: 0;
    position: relative;
    white-space: nowrap;
}

.sidebar-nav a:hover {
    background-color: var(--sidebar-link-hover-bg);
    color: var(--sidebar-text-hover);
    text-decoration: none;
}

.sidebar-nav a:focus {
    outline: 2px solid #0d6efd;
    outline-offset: -2px;
    background-color: var(--sidebar-link-hover-bg);
    color: var(--sidebar-text-hover);
    text-decoration: none;
}

.sidebar-nav a.active {
    background-color: var(--sidebar-link-active-bg);
    color: var(--sidebar-text-hover);
    border-right: 3px solid var(--sidebar-link-active-border);
    font-weight: 500;
}

.sidebar-nav a.active:hover {
    background-color: var(--sidebar-link-active-bg);
    opacity: 0.9;
}

.sidebar-nav a i {
    width: 1.5rem;
    height: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 0.75rem;
    font-size: 1.0125rem;
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.sidebar.collapsed .sidebar-nav a {
    padding: 0.75rem;
    justify-content: center;
    position: relative;
}

.sidebar.collapsed .sidebar-nav a i {
    margin-right: 0;
    font-size: 1.125rem; /* Slightly larger icons when collapsed */
}

.sidebar.collapsed .sidebar-nav a span {
    opacity: 0;
    width: 0;
    overflow: hidden;
    transition: all 0.3s ease;
}

/* Tooltip for collapsed sidebar */
.sidebar.collapsed .sidebar-nav a {
    position: relative;
}

.sidebar.collapsed .sidebar-nav a:hover::after {
    content: attr(title);
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    background-color: var(--sidebar-tooltip-bg);
    color: var(--sidebar-tooltip-text);
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.7875rem;
    white-space: nowrap;
    z-index: 1050;
    margin-left: 0.5rem;
    opacity: 0;
    animation: tooltipFadeIn 0.2s ease forwards;
    pointer-events: none;
}

.sidebar.collapsed .sidebar-nav a:hover::before {
    content: '';
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    border: 5px solid transparent;
    border-right-color: var(--sidebar-tooltip-bg);
    z-index: 1050;
    margin-left: 0.25rem;
    opacity: 0;
    animation: tooltipFadeIn 0.2s ease forwards;
    pointer-events: none;
}

@keyframes tooltipFadeIn {
    from {
        opacity: 0;
        transform: translateY(-50%) translateX(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(-50%) translateX(0);
    }
}

/* Icon consistency across states */
.sidebar-nav a i.bi-speedometer2,
.sidebar-nav a i.bi-building,
.sidebar-nav a i.bi-people,
.sidebar-nav a i.bi-gear {
    font-size: 1.0125rem;
}

.sidebar.collapsed .sidebar-nav a i.bi-speedometer2,
.sidebar.collapsed .sidebar-nav a i.bi-building,
.sidebar.collapsed .sidebar-nav a i.bi-people,
.sidebar.collapsed .sidebar-nav a i.bi-gear {
    font-size: 1.125rem;
}

/* Active state enhancements */
.sidebar-nav a.active i {
    color: var(--sidebar-text-hover);
}

.sidebar.collapsed .sidebar-nav a.active {
    border-right: none;
    border-left: 3px solid var(--sidebar-link-active-border);
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    .sidebar-nav a,
    .sidebar-nav a i,
    .sidebar.collapsed .sidebar-nav a span {
        transition: none;
    }
    
    .sidebar.collapsed .sidebar-nav a:hover::after,
    .sidebar.collapsed .sidebar-nav a:hover::before {
        animation: none;
        opacity: 1;
        transform: translateY(-50%) translateX(0);
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .sidebar-nav a {
        border: 1px solid transparent;
    }
    
    .sidebar-nav a:hover,
    .sidebar-nav a:focus {
        border-color: currentColor;
    }
    
    .sidebar-nav a.active {
        border: 2px solid currentColor;
    }
}

/* Sidebar user section */
.sidebar-user {
    border-top: 1px solid var(--sidebar-user-border);
    padding: 1rem;
    background-color: var(--sidebar-user-bg);
    flex-shrink: 0;
}

.sidebar-user .dropdown {
    width: 100%;
}

.sidebar-user .dropdown-toggle {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 0.75rem;
    background: none;
    border: none;
    color: var(--sidebar-text);
    text-align: left;
    border-radius: 0.375rem;
    transition: all 0.2s ease;
    text-decoration: none;
}

.sidebar-user .dropdown-toggle:hover {
    background-color: var(--sidebar-user-hover-bg);
}

.sidebar-user .dropdown-toggle::after {
    margin-left: auto;
}

.sidebar-user .user-avatar {
    width: 2rem;
    height: 2rem;
    background-color: var(--sidebar-link-active-border);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 0.75rem;
    font-weight: 600;
    flex-shrink: 0;
    transition: margin 0.3s ease;
}

.sidebar.collapsed .sidebar-user .dropdown-toggle {
    justify-content: center;
    padding: 0.75rem 0.5rem;
}

.sidebar.collapsed .sidebar-user .user-avatar {
    margin-right: 0;
}

.sidebar.collapsed .sidebar-user .user-info {
    opacity: 0;
    width: 0;
    overflow: hidden;
    transition: all 0.3s ease;
}

.sidebar.collapsed .sidebar-user .dropdown-toggle::after {
    display: none;
}

/* Fix dropdown positioning in collapsed state */
.sidebar.collapsed .sidebar-user .dropdown-menu {
    position: fixed !important;
    left: 80px !important;
    bottom: 1rem !important;
    top: auto !important;
    right: auto !important;
    transform: none !important;
    z-index: 1060 !important;
    min-width: 200px !important;
    margin: 0 !important;
}

/* Ensure collapsed dropdown items align left */
.sidebar.collapsed .dropdown-item {
    text-align: left !important;
    justify-content: flex-start !important;
}

.sidebar.collapsed .dropdown-item button,
.sidebar.collapsed .language-form button {
    text-align: left !important;
    justify-content: flex-start !important;
    display: flex !important;
    align-items: center !important;
}

/* Ensure all sidebar dropdown menus have proper z-index */
.sidebar .dropdown-menu {
    position: fixed !important;
    z-index: 10000 !important;
}

/* Fix submenu positioning */
.sidebar .dropdown-submenu .dropdown-menu {
    position: fixed !important;
    z-index: 10001 !important;
}

/* Main content wrapper adjustments */
.main-wrapper {
    margin-left: 200px;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.main-wrapper.sidebar-collapsed {
    margin-left: 80px;
}

/* No sidebar case (for non-authenticated users) */
.main-wrapper.no-sidebar {
    margin-left: 0;
}

/* Mobile responsive behavior */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: 200px;
        box-shadow: none;
    }
    
    .sidebar.show {
        transform: translateX(0);
        box-shadow: 0.5rem 0 1rem rgba(0, 0, 0, 0.15);
    }
    
    .sidebar.collapsed {
        width: 200px;
        transform: translateX(-100%);
    }
    
    .sidebar.collapsed.show {
        transform: translateX(0);
    }
    
    .main-wrapper {
        margin-left: 0;
    }
    
    .main-wrapper.sidebar-collapsed {
        margin-left: 0;
    }
    
    .main-wrapper.no-sidebar {
        margin-left: 0;
    }
    
    /* Mobile backdrop */
    .sidebar-backdrop {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background-color: var(--sidebar-backdrop);
        z-index: 1039;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
    }
    
    .sidebar-backdrop.show {
        opacity: 1;
        visibility: visible;
    }
}

/* Tablet adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
    .sidebar {
        width: 230px;
    }
    
    .sidebar.collapsed {
        width: 75px;
    }
    
    .main-wrapper {
        margin-left: 230px;
    }
    
    .main-wrapper.sidebar-collapsed {
        margin-left: 75px;
    }
    
    .main-wrapper.no-sidebar {
        margin-left: 0;
    }
}

/* Large screen optimizations */
@media (min-width: 1200px) {
    .sidebar {
        width: 270px;
    }
    
    .main-wrapper {
        margin-left: 270px;
    }
    
    .main-wrapper.no-sidebar {
        margin-left: 0;
    }
}

/* Sidebar animations */
@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
    }
    to {
        transform: translateX(0);
    }
}

@keyframes slideOutLeft {
    from {
        transform: translateX(0);
    }
    to {
        transform: translateX(-100%);
    }
}

/* Accessibility enhancements */
.sidebar-nav a:focus {
    outline: 2px solid #0d6efd;
    outline-offset: -2px;
    background-color: #e7f3ff;
}

.sidebar-user .dropdown-toggle:focus {
    outline: 2px solid #0d6efd;
    outline-offset: -2px;
    background-color: #e9ecef;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .sidebar {
        border-right: 2px solid #000;
    }
    
    .sidebar-nav a.active {
        border-right: 4px solid #000;
        background-color: #fff;
        color: #000;
    }
    
    .sidebar-header,
    .sidebar-user {
        border-color: #000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .sidebar,
    .main-wrapper,
    .sidebar-nav a,
    .sidebar-toggle,
    .sidebar-user .dropdown-toggle,
    .sidebar-backdrop {
        transition: none;
    }
    
    .sidebar-nav a i,
    .sidebar-nav a span,
    .sidebar-user .user-avatar,
    .sidebar-user .user-info {
        transition: none;
    }
}

/* Print styles */
@media print {
    .sidebar {
        display: none !important;
    }
    
    .main-wrapper {
        margin-left: 0 !important;
    }
}

/* Dropdown submenu styles for language switcher */
.dropdown-submenu {
    position: relative;
}

.dropdown-submenu .dropdown-menu {
    top: 0;
    left: 100%;
    margin-top: -1px;
    border-radius: 0.375rem;
}

.dropdown-submenu:hover .dropdown-menu {
    display: block;
}

.dropdown-submenu .dropdown-toggle::after {
    transform: rotate(-90deg);
    float: right;
    margin-top: 0.5rem;
}

/* Mobile dropdown submenu adjustments */
@media (max-width: 768px) {
    .dropdown-submenu .dropdown-menu {
        position: static;
        float: none;
        width: auto;
        margin-top: 0;
        background-color: transparent;
        border: 0;
        box-shadow: none;
    }
    
    .dropdown-submenu .dropdown-item {
        padding-left: 2rem;
    }
}

/* ============================================
   24. DARK MODE SIDEBAR (PERMANENT)
   ============================================ */

/* CSS Custom Properties for dark sidebar */
:root {
    /* Dark sidebar colors (always applied) */
    --sidebar-bg: #1a1a1a;
    --sidebar-border: #404040;
    --sidebar-shadow: rgba(0, 0, 0, 0.3);
    --sidebar-header-bg: #2d2d2d;
    --sidebar-header-border: #404040;
    --sidebar-text: #e0e0e0;
    --sidebar-text-hover: #4dabf7;
    --sidebar-link-hover-bg: #2d2d2d;
    --sidebar-link-active-bg: #1e3a5f;
    --sidebar-link-active-border: #4dabf7;
    --sidebar-toggle-color: #b0b0b0;
    --sidebar-toggle-hover-bg: #404040;
    --sidebar-toggle-hover-color: #e0e0e0;
    --sidebar-toggle-collapsed-bg: rgba(176, 176, 176, 0.1);
    --sidebar-toggle-collapsed-border: rgba(176, 176, 176, 0.2);
    --sidebar-user-bg: #2d2d2d;
    --sidebar-user-border: #404040;
    --sidebar-user-hover-bg: #404040;
    --sidebar-tooltip-bg: #f8f9fa;
    --sidebar-tooltip-text: #212529;
    --sidebar-backdrop: rgba(0, 0, 0, 0.7);
}

/* Apply CSS variables to sidebar components */
.sidebar {
    background-color: var(--sidebar-bg);
    border-right-color: var(--sidebar-border);
    box-shadow: 0 0.125rem 0.25rem var(--sidebar-shadow);
}

.sidebar-header {
    background-color: var(--sidebar-header-bg);
    border-bottom-color: var(--sidebar-header-border);
}

.sidebar-header .navbar-brand {
    color: var(--sidebar-text);
}

.sidebar-toggle {
    color: var(--sidebar-toggle-color);
}

.sidebar-toggle:hover {
    background-color: var(--sidebar-toggle-hover-bg);
    color: var(--sidebar-toggle-hover-color);
}

.sidebar.collapsed .sidebar-toggle {
    background-color: var(--sidebar-toggle-collapsed-bg);
    border-color: var(--sidebar-toggle-collapsed-border);
}

.sidebar.collapsed .sidebar-toggle:hover {
    background-color: var(--sidebar-toggle-hover-bg);
    border-color: var(--sidebar-toggle-collapsed-border);
    color: var(--sidebar-toggle-hover-color);
}

.sidebar.collapsed .sidebar-toggle:focus {
    background-color: rgba(77, 171, 247, 0.1);
    border-color: var(--sidebar-link-active-border);
    color: var(--sidebar-text-hover);
}

.sidebar-nav a {
    color: var(--sidebar-text);
}

.sidebar-nav a:hover {
    background-color: var(--sidebar-link-hover-bg);
    color: var(--sidebar-text-hover);
}

.sidebar-nav a:focus {
    background-color: var(--sidebar-link-hover-bg);
    color: var(--sidebar-text-hover);
}

.sidebar-nav a.active {
    background-color: var(--sidebar-link-active-bg);
    color: var(--sidebar-text-hover);
    border-right-color: var(--sidebar-link-active-border);
}

.sidebar-nav a.active:hover {
    background-color: var(--sidebar-link-active-bg);
    opacity: 0.9;
}

.sidebar.collapsed .sidebar-nav a.active {
    border-left-color: var(--sidebar-link-active-border);
}

.sidebar.collapsed .sidebar-nav a:hover::after {
    background-color: var(--sidebar-tooltip-bg);
    color: var(--sidebar-tooltip-text);
}

.sidebar.collapsed .sidebar-nav a:hover::before {
    border-right-color: var(--sidebar-tooltip-bg);
}

.sidebar-user {
    background-color: var(--sidebar-user-bg);
    border-top-color: var(--sidebar-user-border);
}

.sidebar-user .dropdown-toggle {
    color: var(--sidebar-text);
}

.sidebar-user .dropdown-toggle:hover {
    background-color: var(--sidebar-user-hover-bg);
}

.sidebar-backdrop {
    background-color: var(--sidebar-backdrop);
}

/* Dark mode specific adjustments */
.sidebar-nav a.active i {
    color: var(--sidebar-text-hover);
}

.sidebar-user .user-avatar {
    background-color: var(--sidebar-link-active-border);
}

/* Ensure dropdown menus also follow dark theme */
.sidebar .dropdown-menu {
    background-color: var(--sidebar-header-bg);
    border-color: var(--sidebar-border);
}

.sidebar .dropdown-item {
    color: var(--sidebar-text);
    text-align: left !important;
}

.sidebar .dropdown-item:hover,
.sidebar .dropdown-item:focus {
    background-color: var(--sidebar-link-hover-bg);
    color: var(--sidebar-text-hover);
}

/* Ensure dropdown form buttons align left */
.sidebar .dropdown-item button,
.sidebar .language-form button {
    text-align: left !important;
    width: 100%;
    border: none;
    background: none;
    padding: 0.375rem 1rem;
}

.sidebar .dropdown-divider {
    border-color: var(--sidebar-border);
}

/* Smooth transitions for sidebar elements */
.sidebar,
.sidebar-header,
.sidebar-nav a,
.sidebar-toggle,
.sidebar-user,
.sidebar-user .dropdown-toggle {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* Override Bootstrap text-muted class in sidebar for dark theme */
.sidebar .text-muted {
    color: #a0a0a0 !important;
}

.sidebar .user-info small.text-muted {
    color: #a0a0a0 !important;
}

/* Print mode - force light theme for readability */
@media print {
    .sidebar {
        background-color: #ffffff !important;
        color: #000000 !important;
        border-color: #000000 !important;
    }
    
    .sidebar * {
        background-color: transparent !important;
        color: #000000 !important;
    }
}

/* ============================================
   16. FORM VALIDATION STYLES
   ============================================ */

/* Import form validation styles */
@import url('form-validation.css');

/* Additional form validation styles specific to main.css */
.form-validation-enhanced {
    /* Enhanced form validation container */
    position: relative;
}

.form-validation-enhanced .form-control,
.form-validation-enhanced .form-select {
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-validation-enhanced .form-control:focus,
.form-validation-enhanced .form-select:focus {
    border-color: #86b7fe;
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* Form validation summary styling */
.form-validation-summary {
    background-color: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 0.375rem;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.form-validation-summary .alert-heading {
    color: #856404;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.form-validation-summary ul {
    margin-bottom: 0;
    padding-left: 1.5rem;
}

.form-validation-summary li {
    color: #856404;
    margin-bottom: 0.25rem;
}

/* Fieldset error highlighting */
fieldset.has-validation-errors {
    border-left: 4px solid #dc3545;
    padding-left: 15px;
    background-color: rgba(248, 215, 218, 0.1);
    margin-bottom: 1.5rem;
}

fieldset.has-validation-errors legend {
    color: #dc3545;
    font-weight: 600;
}

fieldset.has-validation-errors legend .error-icon {
    color: #dc3545;
    margin-right: 0.5rem;
}

/* Real-time validation feedback */
.form-control.validating {
    border-color: #ffc107;
    box-shadow: 0 0 0 0.2rem rgba(255, 193, 7, 0.25);
}

.form-control.validation-success {
    border-color: #198754;
    box-shadow: 0 0 0 0.2rem rgba(25, 135, 84, 0.25);
}

.form-control.validation-error {
    border-color: #dc3545;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
}

/* Placeholder enhancement */
.form-control.has-placeholder-warning {
    border-color: #ffc107 !important;
    box-shadow: 0 0 0 0.2rem rgba(255, 193, 7, 0.25) !important;
}

.form-control.has-placeholder-warning::after {
    content: "⚠️";
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #ffc107;
}

/* Conditional field animations */
.conditional-field {
    transition: opacity 0.3s ease, transform 0.3s ease, height 0.3s ease;
}

.conditional-field.hiding {
    opacity: 0;
    transform: translateY(-10px);
    height: 0;
    overflow: hidden;
}

.conditional-field.showing {
    opacity: 1;
    transform: translateY(0);
    height: auto;
}

/* Form field group styling for better organization */
.form-field-group {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.form-field-group .form-field-group-title {
    font-weight: 600;
    color: #495057;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #dee2e6;
}

/* Enhanced error message styling */
.field-error-message {
    display: block;
    width: 100%;
    margin-top: 0.25rem;
    font-size: 0.7875rem;
    color: #dc3545;
    font-weight: 500;
}

.field-error-message::before {
    content: "⚠️ ";
    margin-right: 0.25rem;
}

/* Success message styling */
.field-success-message {
    display: block;
    width: 100%;
    margin-top: 0.25rem;
    font-size: 0.7875rem;
    color: #198754;
    font-weight: 500;
}

.field-success-message::before {
    content: "✓ ";
    margin-right: 0.25rem;
}

/* Form validation loading states */
.form-field-loading {
    position: relative;
}

.form-field-loading::after {
    content: "";
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: translateY(-50%) rotate(0deg); }
    100% { transform: translateY(-50%) rotate(360deg); }
}

/* Enhanced accessibility for form validation */
.form-validation-live-region {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* Form validation tooltip styling */
.form-validation-tooltip {
    position: absolute;
    z-index: 1070;
    display: block;
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-style: normal;
    font-weight: 400;
    line-height: 1.5;
    text-align: left;
    text-decoration: none;
    text-shadow: none;
    text-transform: none;
    letter-spacing: normal;
    word-break: normal;
    word-spacing: normal;
    white-space: normal;
    line-break: auto;
    font-size: 0.7875rem;
    word-wrap: break-word;
    opacity: 0.9;
}

.form-validation-tooltip .tooltip-inner {
    max-width: 200px;
    padding: 0.25rem 0.5rem;
    color: #fff;
    text-align: center;
    background-color: #dc3545;
    border-radius: 0.25rem;
}

/* Form validation progress indicator */
.form-validation-progress {
    height: 4px;
    background-color: #e9ecef;
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.form-validation-progress-bar {
    height: 100%;
    background-color: #007bff;
    transition: width 0.3s ease;
}

.form-validation-progress-bar.success {
    background-color: #198754;
}

.form-validation-progress-bar.error {
    background-color: #dc3545;
}

/* Mobile-specific form validation styles */
@media (max-width: 767.98px) {
    .form-validation-enhanced .form-control,
    .form-validation-enhanced .form-select {
        font-size: 14.4px; /* Prevent zoom on iOS */
    }
    
    .form-validation-tooltip {
        font-size: 0.72rem;
    }
    
    .form-validation-tooltip .tooltip-inner {
        max-width: 150px;
        padding: 0.2rem 0.4rem;
    }
    
    .form-field-group {
        padding: 1rem;
        margin-bottom: 1rem;
    }
}

/* Print styles for forms */
@media print {
    .form-validation-enhanced .form-control,
    .form-validation-enhanced .form-select {
        border: 1px solid #000 !important;
        box-shadow: none !important;
    }
    
    .form-validation-enhanced .is-invalid {
        border-color: #000 !important;
    }
    
    .form-validation-enhanced .is-valid {
        border-color: #000 !important;
    }
    
    .field-error-message,
    .field-success-message {
        color: #000 !important;
    }
    
    .form-validation-tooltip {
        display: none !important;
    }
}

/* Enhanced accessibility for keyboard navigation */
@media (hover: hover) and (pointer: fine) {
    .sortable-header:focus-within {
        outline: 2px solid #0d6efd;
        outline-offset: 2px;
        border-radius: 0.375rem;
    }
    
    .pagination .page-link:focus {
        outline: 2px solid #0d6efd;
        outline-offset: 2px;
        z-index: 3;
    }
    
    .filter-tag .filter-remove:focus {
        outline: 2px solid #0d6efd;
        outline-offset: 2px;
    }
    
    .date-preset-btn:focus {
        outline: 2px solid #0d6efd;
        outline-offset: 2px;
    }
    
    .table-filter-actions .btn:focus {
        outline: 2px solid #0d6efd;
        outline-offset: 2px;
    }
}

/* Small mobile devices (phones in portrait) */
@media (max-width: 480px) {
    .enhanced-table-container {
        margin: 0 -1rem;
        border-radius: 0;
    }
    
    .table-filter-section {
        padding: 0.5rem;
    }
    
    .mobile-filter-toggle {
        font-size: 0.875rem;
        padding: 0.75rem;
        margin-bottom: 0.75rem;
    }
    
    .table-filter-group .form-control,
    .table-filter-group .form-select {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 0.75rem 0.5rem;
    }
    
    .table-responsive .table {
        min-width: 500px;
        font-size: 0.75rem;
    }
    
    .table-responsive .table th:first-child,
    .table-responsive .table td:first-child {
        min-width: 100px;
        max-width: 120px;
    }
    
    .table-responsive .table .actions-column {
        min-width: 120px;
    }
    
    .table-responsive .table .actions-column .btn {
        font-size: 0.75rem;
        padding: 0.375rem 0.5rem;
        margin: 0.125rem;
        min-width: 50px;
        min-height: 32px;
    }
    
    .pagination .page-link {
        padding: 0.5rem;
        font-size: 0.875rem;
        min-width: 40px;
        min-height: 40px;
    }
    
    .pagination-compact .page-nav .btn {
        min-width: 40px;
        min-height: 40px;
        padding: 0.5rem;
    }
    
    .filter-tag {
        font-size: 0.75rem;
        padding: 0.375rem 0.5rem;
        margin: 0.125rem;
    }
    
    .filter-tag .filter-remove {
        min-width: 20px;
        min-height: 20px;
        font-size: 0.75rem;
    }
}

/* Large tablets and small desktops */
@media (min-width: 1025px) and (max-width: 1199px) {
    .enhanced-table-container {
        border-radius: 0.5rem;
    }
    
    .table-filter-section {
        padding: 1rem;
    }
    
    .table-filter-form {
        gap: 1rem;
    }
    
    .table-filter-group {
        min-width: 200px;
    }
    
    .pagination .page-link {
        padding: 0.5rem 0.75rem;
        min-height: 38px;
        min-width: 38px;
    }
    
    .sortable-header {
        min-height: 40px;
    }
}

/* Ultra-wide screens */
@media (min-width: 1400px) {
    .enhanced-table-container {
        border-radius: 0.75rem;
        box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.1);
    }
    
    .table-filter-section {
        padding: 1.5rem;
    }
    
    .table-filter-form {
        gap: 1.5rem;
    }
    
    .table-filter-group {
        min-width: 250px;
    }
    
    .table-responsive .table {
        font-size: 0.875rem;
    }
    
    .table-responsive .table th,
    .table-responsive .table td {
        padding: 1rem 0.75rem;
    }
    
    .pagination .page-link {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }
}

/* Mobile filter toggle JavaScript support */
.mobile-filter-toggle {
    display: none; /* Hidden by default, shown via JavaScript on mobile */
}

@media (max-width: 768px) {
    .mobile-filter-toggle {
        display: block;
    }
}

/* Enhanced mobile table scrolling indicators */
@media (max-width: 768px) {
    .table-responsive::before,
    .table-responsive::after {
        content: '';
        position: absolute;
        top: 0;
        bottom: 0;
        width: 20px;
        pointer-events: none;
        z-index: 1;
        transition: opacity 0.3s ease;
    }
    
    .table-responsive::before {
        left: 0;
        background: linear-gradient(to right, rgba(248, 249, 250, 0.8), transparent);
        opacity: 0;
    }
    
    .table-responsive::after {
        right: 0;
        background: linear-gradient(to left, rgba(248, 249, 250, 0.8), transparent);
        opacity: 1;
    }
    
    .table-responsive.scrolled-left::before {
        opacity: 1;
    }
    
    .table-responsive.scrolled-right::after {
        opacity: 0;
    }
}

/* Performance optimizations for mobile */
@media (max-width: 768px) {
    .table-responsive .table {
        will-change: scroll-position;
    }
    
    .sortable-header .sort-link,
    .pagination .page-link,
    .filter-tag .filter-remove {
        will-change: transform;
    }
}

/* Reduced motion support for mobile enhancements */
@media (prefers-reduced-motion: reduce) {
    .mobile-filter-content {
        transition: none;
    }
    
    .mobile-filter-toggle .toggle-icon {
        transition: none;
    }
    
    .sortable-header .sort-link:active,
    .pagination .page-link:active,
    .filter-tag .filter-remove:active,
    .date-preset-btn:active,
    .table-filter-actions .btn:active {
        transform: none;
        transition: none;
    }
}

/* ============================================
   16. RECEIPT MANAGEMENT STYLES
   ============================================ */

/* Receipt Form Layout Enhancements */
.conditional-required {
    display: none;
}

/* Ensure proper spacing for fieldsets */
fieldset {
    border: none;
    padding: 0;
    margin: 0;
}

fieldset legend {
    font-weight: 600;
    color: #6c757d;
    margin-bottom: 1rem;
}

/* Enhanced conditional field animations */
[data-conditional="true"] {
    transition: opacity 300ms ease, transform 300ms ease;
}

[data-conditional="true"].hiding {
    opacity: 0;
    transform: translateY(-10px);
}

/* 80G conditional section styling */
#tax-info-section {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    padding: 1.5rem;
    margin-top: 1rem;
    transition: all 0.3s ease;
}

#tax-info-section.show {
    display: block !important;
}

#tax-info-section h5 {
    color: #495057;
    margin-bottom: 1rem;
    font-weight: 600;
}

/* Void section styling */
#void-section {
    background-color: #fff5f5;
    border: 1px solid #fecaca;
    border-radius: 0.375rem;
    padding: 1.5rem;
    margin-top: 1rem;
    transition: all 0.3s ease;
}

#void-section.show {
    display: block !important;
}

#void-section h5 {
    color: #dc2626;
    margin-bottom: 1rem;
    font-weight: 600;
}

/* Status badge styling */
.status-badge {
    font-size: 0.875rem;
    padding: 0.375rem 0.75rem;
    border-radius: 0.25rem;
    font-weight: 500;
}

.status-draft {
    background-color: #e9ecef;
    color: #495057;
}

.status-issued {
    background-color: #d1ecf1;
    color: #0c5460;
}

.status-sent {
    background-color: #d4edda;
    color: #155724;
}

.status-void {
    background-color: #f8d7da;
    color: #721c24;
}

/* Receipt type badge styling */
.receipt-type-badge {
    font-size: 0.875rem;
    padding: 0.375rem 0.75rem;
    border-radius: 0.25rem;
    font-weight: 500;
}

.receipt-type-80g {
    background-color: #d1ecf1;
    color: #0c5460;
}

.receipt-type-non80g {
    background-color: #e2e3e5;
    color: #383d41;
}

/* Receipt form responsive adjustments */
@media (max-width: 767.98px) {
    .receipt-form .col-md-6 {
        margin-bottom: 1rem;
    }
    
    /* Stack form elements vertically on mobile */
    .receipt-form .row > .col-md-6:not(:last-child) {
        margin-bottom: 1.5rem;
    }
}

/* Receipt list enhancements */
.receipt-list-filters {
    background-color: #f8f9fa;
    border-radius: 0.375rem;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.receipt-summary-stats {
    background-color: #e7f3ff;
    border-left: 4px solid #0d6efd;
    padding: 1rem;
    margin-bottom: 1rem;
}

/* Receipt detail view enhancements */
.receipt-detail-section {
    margin-bottom: 2rem;
}

.receipt-detail-section .card-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

.receipt-detail-section .card-header h5 {
    margin-bottom: 0;
    color: #495057;
    font-weight: 600;
}

/* Receipt confirmation dialog enhancements */
.receipt-delete-warning {
    border-left: 4px solid #dc3545;
    background-color: #f8d7da;
    padding: 1rem;
    margin-bottom: 1rem;
}

.receipt-delete-info {
    border-left: 4px solid #0dcaf0;
    background-color: #cff4fc;
    padding: 1rem;
    margin-bottom: 1rem;
}

/* ============================================
   20. CLIPBOARD FUNCTIONALITY
   ============================================ */

/* Copy button states and transitions */
.copy-url-btn {
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.copy-url-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.copy-url-btn.btn-success {
    animation: copySuccess 0.3s ease;
}

@keyframes copySuccess {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* Copy status messages */
.copy-status {
    min-height: 1.5rem;
    transition: all 0.3s ease;
}

.copy-status .alert-sm {
    padding: 0.5rem 0.75rem;
    margin-bottom: 0;
    font-size: 0.70875rem;
    border-radius: 0.25rem;
}

/* URL input field enhancements */
.print-url-input {
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.70875rem;
    background-color: #f8f9fa;
    border-color: #dee2e6;
    cursor: text;
}

.print-url-input:focus {
    background-color: #fff;
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

.print-url-input:read-only {
    background-color: #e9ecef;
    cursor: default;
}

/* Input group focus states */
.input-group:focus-within .copy-url-btn {
    border-color: #86b7fe;
}

/* Accessibility enhancements */
.copy-url-btn:focus {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
    z-index: 3;
}

/* Keyboard navigation indicators */
.copy-url-btn[aria-pressed="true"] {
    background-color: #0d6efd;
    border-color: #0d6efd;
    color: white;
}

/* Manual copy instructions styling */
.manual-copy-instructions {
    background-color: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 0.375rem;
    padding: 0.75rem;
    margin-top: 0.5rem;
    font-size: 0.70875rem;
}

.manual-copy-instructions kbd {
    background-color: #212529;
    color: #fff;
    padding: 0.1875rem 0.375rem;
    border-radius: 0.25rem;
    font-size: 0.6075rem;
    font-family: 'Courier New', Courier, monospace;
}

/* Copy feedback animations */
.copy-feedback-enter {
    opacity: 0;
    transform: translateY(-10px);
    animation: copyFeedbackEnter 0.3s ease forwards;
}

@keyframes copyFeedbackEnter {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.copy-feedback-exit {
    animation: copyFeedbackExit 0.3s ease forwards;
}

@keyframes copyFeedbackExit {
    to {
        opacity: 0;
        transform: translateY(-10px);
    }
}

/* URL selection highlighting */
.print-url-input::selection {
    background-color: #0d6efd;
    color: white;
}

.print-url-input::-moz-selection {
    background-color: #0d6efd;
    color: white;
}

/* Responsive adjustments for clipboard functionality */
@media (max-width: 768px) {
    .print-url-input {
        font-size: 0.6075rem;
    }
    
    .copy-status .alert-sm {
        font-size: 0.658125rem;
        padding: 0.375rem 0.5rem;
    }
    
    .manual-copy-instructions {
        font-size: 0.658125rem;
        padding: 0.5rem;
    }
    
    .manual-copy-instructions kbd {
        font-size: 0.5625rem;
        padding: 0.125rem 0.25rem;
    }
    
    .copy-url-btn {
        min-width: 60px;
        padding: 0.375rem 0.5rem;
        font-size: 0.70875rem;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .copy-url-btn {
        min-height: 44px;
        min-width: 44px;
        padding: 0.75rem;
    }
    
    .print-url-input {
        min-height: 44px;
        padding: 0.75rem;
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    /* Better touch feedback */
    .copy-url-btn:active {
        transform: scale(0.95);
        transition: transform 0.1s ease;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .print-url-input {
        background-color: white;
        border: 2px solid black;
        color: black;
    }
    
    .copy-url-btn {
        border: 2px solid black;
        background-color: white;
        color: black;
    }
    
    .copy-url-btn:hover {
        background-color: black;
        color: white;
    }
    
    .manual-copy-instructions {
        background-color: white;
        border: 2px solid black;
        color: black;
    }
    
    .manual-copy-instructions kbd {
        background-color: black;
        color: white;
        border: 1px solid white;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .copy-url-btn,
    .copy-status,
    .copy-feedback-enter,
    .copy-feedback-exit {
        animation: none;
        transition: none;
    }
    
    .copy-url-btn:active {
        transform: none;
    }
}

/* Print styles - hide clipboard functionality */
@media print {
    .input-group,
    .copy-status,
    .manual-copy-instructions {
        display: none !important;
    }
}

/* Focus management for screen readers */
.copy-url-btn[aria-describedby] {
    position: relative;
}

/* Status message live region */
.copy-status[role="status"] {
    position: relative;
}

/* Clipboard API not supported fallback styling */
.clipboard-not-supported .copy-url-btn {
    background-color: #ffc107;
    border-color: #ffc107;
    color: #000;
}

.clipboard-not-supported .copy-url-btn:hover {
    background-color: #ffca2c;
    border-color: #ffc720;
}

/* Success state persistence */
.copy-success-persistent {
    background-color: #d1e7dd !important;
    border-color: #badbcc !important;
    color: #0f5132 !important;
}

/* Error state styling */
.copy-error {
    background-color: #f8d7da !important;
    border-color: #f5c2c7 !important;
    color: #842029 !important;
}

/* Loading state for URL generation */
.url-generating .print-url-input {
    background-image: url("data:image/svg+xml,%3csvg width='16' height='16' viewBox='0 0 16 16' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0zM8 2a6 6 0 1 0 0 12A6 6 0 0 0 8 2z' fill='%236c757d'/%3e%3cpath d='M8 2a6 6 0 0 1 6 6h-2a4 4 0 0 0-4-4V2z' fill='%230d6efd'%3e%3canimateTransform attributeName='transform' type='rotate' values='0 8 8;360 8 8' dur='1s' repeatCount='indefinite'/%3e%3c/path%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px;
    padding-right: 2.5rem !important;
}

/* URL ready state */
.url-ready .print-url-input {
    background-color: #d1e7dd;
    border-color: #badbcc;
}

/* Copy button icon transitions */
.copy-url-btn .bi {
    transition: transform 0.2s ease;
}

.copy-url-btn:hover .bi {
    transform: scale(1.1);
}

.copy-url-btn:active .bi {
    transform: scale(0.9);
}

/* ============================================
   20. LOGO RESIZE TOOL STYLES
   ============================================ */

/* Logo resize tool container */
.logo-resize-tool {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    padding: 1.5rem;
    margin-top: 1rem;
}

/* Resize workspace */
.resize-workspace {
    background-color: white;
    border-radius: 0.375rem;
    padding: 1rem;
    border: 1px solid #e9ecef;
}

/* Canvas container */
.canvas-container {
    position: relative;
    display: inline-block;
    border: 2px solid #dee2e6;
    border-radius: 0.375rem;
    background-color: #f8f9fa;
    margin-bottom: 1rem;
}

.resize-canvas {
    display: block;
    max-width: 100%;
    height: auto;
    cursor: crosshair;
}

/* Resize handles */
.resize-handles {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.resize-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background-color: #007bff;
    border: 2px solid white;
    border-radius: 50%;
    pointer-events: all;
    cursor: pointer;
    z-index: 10;
    transform: translate(-50%, -50%);
}

.resize-handle.nw {
    top: 0;
    left: 0;
    cursor: nw-resize;
}

.resize-handle.ne {
    top: 0;
    right: 0;
    cursor: ne-resize;
}

.resize-handle.sw {
    bottom: 0;
    left: 0;
    cursor: sw-resize;
}

.resize-handle.se {
    bottom: 0;
    right: 0;
    cursor: se-resize;
}

.resize-handle:hover {
    background-color: #0056b3;
    transform: translate(-50%, -50%) scale(1.2);
}

/* Resize controls */
.resize-controls .form-control {
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.875rem;
}

.resize-controls .form-check {
    margin-top: 0.75rem;
}

/* Receipt preview */
.receipt-preview {
    background-color: white;
    border-radius: 0.375rem;
    padding: 1rem;
    border: 1px solid #e9ecef;
}

.receipt-mockup {
    background-color: white;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    padding: 1rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    max-width: 300px;
    margin: 0 auto;
}

.receipt-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #dee2e6;
    margin-bottom: 1rem;
}

.preview-canvas {
    border: 1px solid #dee2e6;
    border-radius: 0.25rem;
    background-color: #f8f9fa;
    max-width: 100px;
    max-height: 50px;
}

.organization-name {
    font-weight: 600;
    color: #495057;
    font-size: 1rem;
}

.receipt-body {
    font-size: 0.875rem;
    color: #6c757d;
}

.receipt-body hr {
    margin: 0.75rem 0;
    border-color: #dee2e6;
}

/* Resize actions */
.resize-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
    padding-top: 1rem;
    border-top: 1px solid #dee2e6;
}

.resize-actions .btn {
    min-width: 120px;
    transition: all 0.2s ease;
}

.resize-actions .btn:hover {
    transform: translateY(-1px);
}

/* Loading states */
.logo-resize-tool.loading {
    opacity: 0.7;
    pointer-events: none;
}

.logo-resize-tool.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 1000;
}

/* Success/error states */
.logo-resize-success {
    background-color: #d4edda;
    border-color: #c3e6cb;
    color: #155724;
    padding: 0.75rem 1rem;
    border-radius: 0.375rem;
    margin-top: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo-resize-error {
    background-color: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
    padding: 0.75rem 1rem;
    border-radius: 0.375rem;
    margin-top: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .logo-resize-tool {
        padding: 1rem;
    }
    
    .logo-resize-tool .row {
        flex-direction: column;
    }
    
    .resize-workspace,
    .receipt-preview {
        margin-bottom: 1.5rem;
    }
    
    .canvas-container {
        max-width: 100%;
        overflow-x: auto;
    }
    
    .resize-canvas {
        min-width: 300px;
    }
    
    .receipt-mockup {
        max-width: 250px;
    }
    
    .resize-actions {
        flex-direction: column;
        align-items: stretch;
    }
    
    .resize-actions .btn {
        min-width: auto;
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .resize-controls .row {
        flex-direction: column;
    }
    
    .resize-controls .col-md-6 {
        margin-bottom: 1rem;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .resize-handle {
        width: 20px;
        height: 20px;
        border-width: 3px;
    }
    
    .resize-canvas {
        cursor: default;
    }
    
    .resize-actions .btn {
        min-height: 44px;
        padding: 0.75rem 1rem;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .logo-resize-tool {
        border: 2px solid #000;
    }
    
    .resize-handle {
        background-color: #000;
        border-color: #fff;
    }
    
    .canvas-container {
        border-color: #000;
    }
    
    .receipt-mockup {
        border-color: #000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .resize-handle {
        transition: none;
    }
    
    .resize-handle:hover {
        transform: translate(-50%, -50%);
    }
    
    .resize-actions .btn:hover {
        transform: none;
    }
    
    .logo-resize-tool.loading::after {
        animation: none;
    }
}

/* Print styles */
@media print {
    .logo-resize-tool {
        display: none !important;
    }
}

/* ============================================
   LOGO LAZY LOADING STYLES
   ============================================ */

/* Logo lazy loading placeholders */
.logo-loading-placeholder {
    background: rgba(248, 249, 250, 0.9);
    border-radius: inherit;
}

.logo-error-placeholder {
    background: rgba(248, 249, 250, 0.95);
    border: 1px dashed #dc3545;
    border-radius: inherit;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.logo-error-placeholder:hover {
    background: rgba(220, 53, 69, 0.1);
}

.logo-loaded {
    transition: opacity 0.3s ease;
}

/* Logo container positioning for placeholders */
.logo-container {
    position: relative;
}

.organization-logo-thumbnail {
    position: relative;
}

/* Loading spinner for logo placeholders */
.logo-loading-placeholder .spinner-border-sm {
    width: 1rem;
    height: 1rem;
}

/* Fade-in animation for loaded logos */
.logo-thumbnail.logo-loaded,
.organization-logo.logo-loaded {
    animation: logoFadeIn 0.3s ease-in-out;
}

@keyframes logoFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Error state styling */
.logo-error-placeholder small {
    font-size: 0.6rem;
    line-height: 1;
}

.logo-error-placeholder i {
    font-size: 0.8rem;
}

/* Responsive adjustments for lazy loading */
@media (max-width: 767.98px) {
    .logo-loading-placeholder .spinner-border-sm {
        width: 0.8rem;
        height: 0.8rem;
    }
    
    .logo-error-placeholder i {
        font-size: 0.7rem;
    }
    
    .logo-error-placeholder small {
        font-size: 0.5rem;
    }
}


/* ============================================
   16. VIDEO PLAYER STYLES
   ============================================ */

/* Video player element styling */
.video-player-element {
    background-color: #000;
    width: 100%;
    height: auto;
    display: block;
}

/* Video player card - 50% smaller */
.video-player-card {
    max-width: 50%;
    margin-left: auto;
    margin-right: auto;
}

/* Video placeholder container for loading/error states */
.video-placeholder-container {
    background-color: #000;
    width: 100%;
    height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Video placeholder icon sizing */
.video-placeholder-container .bi {
    font-size: 3rem;
}

/* Responsive video player height on mobile */
@media (max-width: 767.98px) {
    .video-player-card {
        max-width: 100%;
    }
    
    .video-placeholder-container {
        height: 250px;
    }
    
    .video-placeholder-container .bi {
        font-size: 2rem;
    }
}
