/**
 * Phase 4: Responsive & Accessibility Styles
 * Mobile-first responsive design for all Phase 3 & 4 features
 */

/* ===== Bulk Actions - Mobile Responsive ===== */
.bulk-actions-toolbar {
    flex-wrap: wrap;
    gap: 0.5rem;
}

@media (max-width: 640px) {
    .bulk-actions-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .bulk-actions-toolbar .action-btn {
        width: 100%;
        justify-content: center;
    }
    
    .bulk-selection-info {
        font-size: 0.875rem;
    }
}

/* ===== Advanced Filters - Mobile Responsive ===== */
.advanced-filters-panel {
    max-width: 100%;
    margin-bottom: 0.25rem !important;
}

/* Orders advanced filters - Reduce spacing below */
#orders-advanced-filters,
#orders-advanced-filters .advanced-filters-panel {
    margin-bottom: 0.25rem !important;
}

@media (max-width: 768px) {
    .filters-grid {
        grid-template-columns: 1fr !important;
    }
    
    .filter-chips-container {
        flex-wrap: wrap;
    }
    
    .filter-actions {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .filter-actions button {
        width: 100%;
    }
}

/* ===== Quick Actions Menu - Touch Friendly ===== */
.quick-actions-trigger {
    min-width: 44px;
    min-height: 44px;
    touch-action: manipulation;
}

@media (max-width: 640px) {
    .quick-actions-menu {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        transform: none;
        border-radius: 1rem 1rem 0 0;
        max-height: 60vh;
        overflow-y: auto;
    }
    
    .action-item {
        padding: 1rem;
        font-size: 1rem;
    }
}

/* ===== Export Button - Mobile ===== */
@media (max-width: 640px) {
    .export-dropdown {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        border-radius: 1rem 1rem 0 0;
    }
}

/* ===== Dashboard Widgets - Responsive Grid ===== */
.stat-grid {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

@media (max-width: 640px) {
    .stat-grid {
        grid-template-columns: 1fr;
    }
    
    .stat-card {
        padding: 1rem;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
}

/* ===== Tables - Horizontal Scroll on Mobile ===== */
@media (max-width: 768px) {
    .overflow-x-auto {
        -webkit-overflow-scrolling: touch;
    }
    
    table {
        min-width: 600px;
    }
    
    /* Sticky first column for better UX */
    table th:first-child,
    table td:first-child {
        position: sticky;
        left: 0;
        background-color: white;
        z-index: 10;
    }
    
    table th:first-child {
        background-color: rgb(249, 250, 251);
    }
}

/* ===== Focus Indicators for Keyboard Navigation ===== */
button:focus-visible,
input:focus-visible,
select:focus-visible,
.row-checkbox:focus-visible {
    outline: 3px solid #3b82f6;
    outline-offset: 2px;
}

.quick-actions-trigger:focus-visible {
    outline: 3px solid #3b82f6;
    outline-offset: 2px;
    border-radius: 0.375rem;
}

/* ===== High Contrast Mode Support ===== */
@media (prefers-contrast: high) {
    .action-btn,
    .filter-chip,
    .stat-card {
        border: 2px solid currentColor;
    }
}

/* ===== Reduced Motion Support ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===== Print Styles ===== */
@media print {
    .bulk-actions-toolbar,
    .advanced-filters-panel,
    .quick-actions-trigger,
    .export-btn,
    .no-print {
        display: none !important;
    }
    
    /* ✅ Fixed table header row height for quotation */
    body.printing-quotation-v2 #quotation-v2-print-area .invoice-items-table thead th {
        height: 8mm !important;
        max-height: 8mm !important;
        min-height: 8mm !important;
        padding: 1.5mm 2mm !important;
        overflow: hidden !important;
        vertical-align: middle !important;
    }
    
    table {
        page-break-inside: avoid;
    }
    
    tr {
        page-break-inside: avoid;
        page-break-after: auto;
    }
}

/* ===== Touch Device Optimizations ===== */
@media (hover: none) and (pointer: coarse) {
    /* Larger tap targets for touch devices */
    button,
    .action-item,
    .filter-chip {
        min-height: 44px;
        padding: 0.75rem 1rem;
    }
    
    /* Remove hover effects on touch devices */
    .hover\:bg-gray-50:hover,
    .hover\:bg-gray-100:hover {
        background-color: inherit;
    }
}

/* ===== Dark Mode Support (Optional) ===== */
@media (prefers-color-scheme: dark) {
    .stat-card {
        background-color: #1f2937;
        color: #f9fafb;
    }
    
    .filter-chip {
        background-color: #374151;
        color: #f9fafb;
    }
}

/* ===== Screen Reader Only Content ===== */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ===== Skip to Content Link ===== */
.skip-to-content {
    position: absolute;
    top: -40px;
    left: 0;
    background: #3b82f6;
    color: white;
    padding: 8px;
    text-decoration: none;
    z-index: 100;
}

.skip-to-content:focus {
    top: 0;
}

/* ===== QUOTATION TAB - MOBILE RESPONSIVE ===== */
/* Mobile-first approach - only affects mobile screens, preserves desktop & print */

@media (max-width: 768px) {
    /* Header buttons - Stack vertically on mobile */
    #quotation-create-view .flex.justify-between.items-center.mb-6 {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }
    
    #quotation-create-view .flex.flex-wrap.gap-2 {
        flex-direction: column;
        width: 100%;
    }
    
    #quotation-create-view .flex.flex-wrap.gap-2 > * {
        width: 100%;
        justify-content: center;
    }
    
    /* Date picker - Full width on mobile */
    #quotation-create-view .flex.items-center.gap-2.bg-gray-50 {
        width: 100%;
        justify-content: space-between;
    }
    
    /* Quotation print area - Reduce padding on mobile */
    #quotation-print-area {
        padding: 1rem !important;
        max-width: 100% !important;
    }
    
    /* Customer name section - Better mobile layout */
    .quotation-details-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.75rem;
    }
    
    .quotation-details-header > div {
        width: 100% !important;
    }
    
    .quotation-details-header .text-right {
        text-align: left !important;
        justify-content: flex-start !important;
    }
    
    /* Table - Remove horizontal scroll, make it fit screen */
    .quotation-table-section .table-container {
        overflow-x: visible;
        margin: 0;
        padding: 0;
    }
    
    .invoice-items-table {
        width: 100% !important;
        min-width: auto !important;
        table-layout: fixed !important;
        font-size: 0.65rem !important;
    }
    
    /* Adjust column widths for mobile - NO column */
    .invoice-items-table th:nth-child(1),
    .invoice-items-table td:nth-child(1) {
        width: 8% !important;
    }
    
    /* DESCRIPTION column - Allow text wrapping */
    .invoice-items-table th:nth-child(2),
    .invoice-items-table td:nth-child(2) {
        width: 35% !important;
        max-width: none !important;
        white-space: normal !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
        line-height: 1.3 !important;
        padding: 0.3rem 0.2rem !important;
    }
    
    /* DESCRIPTION input - Better sizing and wrapping */
    .invoice-items-table td:nth-child(2) input[type="text"],
    .invoice-items-table td:nth-child(2) .item-autocomplete-wrapper {
        width: 100% !important;
        min-width: 0 !important;
    }
    
    .invoice-items-table td:nth-child(2) input[type="text"] {
        white-space: normal !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
        height: auto !important;
        min-height: 2rem !important;
        line-height: 1.3 !important;
    }
    
    /* DESCRIPTION cell - Stack layout for mobile: Description on top, ft/in|Width|Height below */
    .invoice-items-table td:nth-child(2) > div {
        display: flex !important;
        flex-direction: column !important;
        gap: 0.25rem !important;
        width: 100% !important;
    }
    
    /* Description input - Full width on first line */
    .invoice-items-table td:nth-child(2) .quotation-desc-input {
        width: 100% !important;
        order: 1 !important;
    }
    
    /* Width/Height container - Second line with ft/in button */
    .invoice-items-table td:nth-child(2) .unit-toggle-btn,
    .invoice-items-table td:nth-child(2) .quotation-width-input,
    .invoice-items-table td:nth-child(2) .quotation-height-input {
        order: 2 !important;
    }
    
    /* Unit toggle button - Smaller for mobile */
    .invoice-items-table td:nth-child(2) .unit-toggle-btn {
        font-size: 0.65rem !important;
        padding: 0.25rem 0.4rem !important;
        flex-shrink: 0 !important;
    }
    
    /* Width and Height inputs - Equal width */
    .invoice-items-table td:nth-child(2) .quotation-width-input,
    .invoice-items-table td:nth-child(2) .quotation-height-input {
        flex: 1 !important;
        min-width: 0 !important;
        font-size: 0.75rem !important;
        padding: 0.25rem !important;
    }
    
    /* QTY column */
    .invoice-items-table th:nth-child(3),
    .invoice-items-table td:nth-child(3) {
        width: 10% !important;
    }
    
    /* SQFT column - Stack layout: Lock icon on top, input below */
    .invoice-items-table th:nth-child(4),
    .invoice-items-table td:nth-child(4) {
        width: 10% !important;
    }
    
    /* SQFT cell - Vertical stacking */
    .invoice-items-table td:nth-child(4) {
        padding: 0.3rem 0.2rem !important;
    }
    
    .invoice-items-table td:nth-child(4) > div {
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.25rem !important;
        width: 100% !important;
    }
    
    /* Lock icon - On top, clickable */
    .invoice-items-table td:nth-child(4) .fa-lock {
        font-size: 0.7rem !important;
        color: #9ca3af !important;
        cursor: pointer !important;
        padding: 0.1rem !important;
    }
    
    /* SQFT input - Below lock icon, full width */
    .invoice-items-table td:nth-child(4) input {
        width: 100% !important;
        padding: 0.25rem 0.3rem !important;
        box-sizing: border-box !important;
        font-size: 0.65rem !important;
    }
    
    /* PRICE column */
    .invoice-items-table th:nth-child(5),
    .invoice-items-table td:nth-child(5) {
        width: 17% !important;
    }
    
    /* Input fields in table - Better sizing */
    .invoice-items-table input[type="text"],
    .invoice-items-table input[type="number"] {
        width: 100% !important;
        min-width: 0 !important;
        font-size: 0.65rem !important;
        padding: 0.25rem 0.15rem !important;
        border: 1px solid #d1d5db !important;
        border-radius: 0.25rem !important;
        box-sizing: border-box !important;
    }
    
    /* QTY input - Center align */
    .invoice-items-table td:nth-child(3) input {
        text-align: center !important;
    }
    
    /* PRICE and TOTAL inputs - Right align */
    .invoice-items-table td:nth-child(5) input,
    .invoice-items-table td:nth-child(6) input {
        text-align: right !important;
    }
    
    /* TOTAL column */
    .invoice-items-table th:nth-child(6),
    .invoice-items-table td:nth-child(6) {
        width: 17% !important;
    }
    
    /* Delete button column (no-print) */
    .invoice-items-table th:nth-child(7),
    .invoice-items-table td:nth-child(7) {
        width: 3% !important;
        padding: 0.2rem !important;
    }
    
    .invoice-items-table td:nth-child(7) button {
        padding: 0.2rem 0.3rem !important;
        font-size: 0.7rem !important;
        min-width: auto !important;
        width: 100% !important;
    }
    
    /* Remove sticky column behavior - causes layout issues */
    .invoice-items-table th:first-child,
    .invoice-items-table td:first-child {
        position: static;
        box-shadow: none;
    }
    
    .invoice-items-table thead th:first-child {
        background-color: #f0b21b;
    }
    
    /* Material Row Groups - Better spacing and visual separation */
    .quotation-material-row td {
        font-weight: 600 !important;
        background-color: #f9fafb !important;
        border-top: 2px solid #e5e7eb !important;
        padding-top: 0.5rem !important;
        padding-bottom: 0.5rem !important;
    }
    
    /* Sub-item rows - Indentation and spacing */
    .quotation-subitem-row td {
        padding-left: 0.3rem !important;
        padding-right: 0.15rem !important;
        padding-top: 0.3rem !important;
        padding-bottom: 0.3rem !important;
        background-color: #ffffff !important;
        border-bottom: 1px solid #f3f4f6 !important;
        vertical-align: middle !important;
    }
    
    /* Sub-item first column (NO) - Add visual indent */
    .quotation-subitem-row td:first-child {
        padding-left: 1rem !important;
        color: #9ca3af !important;
        font-size: 0.6rem !important;
    }
    
    /* Sub-item inputs - Prevent overflow */
    .quotation-subitem-row input {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
    }
    
    /* Add button row - Spacing */
    .quotation-add-btn-row td {
        padding: 0.3rem !important;
        background-color: #fefefe !important;
        border-bottom: 2px solid #e5e7eb !important;
    }
    
    .quotation-add-btn-row button {
        font-size: 0.65rem !important;
        padding: 0.3rem 0.5rem !important;
        white-space: nowrap !important;
    }
    
    /* Simple item rows - Visual distinction */
    .quotation-simple-row td {
        background-color: #f0fdf4 !important;
        border-top: 1px solid #d1fae5 !important;
        border-bottom: 1px solid #d1fae5 !important;
        padding-top: 0.5rem !important;
        padding-bottom: 0.5rem !important;
    }
    
    /* Total section - Better mobile fit */
    .quotation-footer-section .flex.justify-end {
        justify-content: center !important;
    }
    
    .quotation-footer-section .w-5\/12 {
        width: 100% !important;
        max-width: 320px;
    }
    
    /* Signature section - Stack on mobile */
    .quotation-footer-section .flex.justify-between.mt-8 {
        flex-direction: column;
        gap: 2rem;
    }
    
    .quotation-footer-section .w-1\/3 {
        width: 100% !important;
    }
    
    /* Floating action buttons - Adjust position */
    .quotation-fab {
        right: 1rem !important;
        bottom: 1rem !important;
        min-width: 3rem !important;
        height: 3rem !important;
        font-size: 0.875rem;
    }
    
    #add-quotation-row-btn {
        bottom: 5rem !important;
    }
    
    /* Hide button text on mobile, show only icon */
    .quotation-fab span {
        display: none;
    }
    
    /* Sub-navigation tabs - Scrollable */
    #quotation-sub-nav {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
    }
    
    .sub-nav-btn {
        white-space: nowrap;
        flex-shrink: 0;
    }
}

/* Extra small devices - Further optimization */
@media (max-width: 480px) {
    #quotation-print-area {
        padding: 0.5rem !important;
    }
    
    .invoice-items-table {
        font-size: 0.6rem !important;
    }
    
    .invoice-items-table th,
    .invoice-items-table td {
        padding: 0.3rem 0.15rem !important;
        font-size: 0.6rem !important;
    }
    
    /* Material Row - Even more prominent on small screens */
    .quotation-material-row td {
        padding-top: 0.4rem !important;
        padding-bottom: 0.4rem !important;
        border-top: 2px solid #d1d5db !important;
    }
    
    /* Sub-item rows - Tighter spacing */
    .quotation-subitem-row td {
        padding-top: 0.25rem !important;
        padding-bottom: 0.25rem !important;
        padding-left: 0.2rem !important;
        padding-right: 0.1rem !important;
        vertical-align: middle !important;
    }
    
    .quotation-subitem-row td:first-child {
        padding-left: 0.8rem !important;
        font-size: 0.55rem !important;
    }
    
    /* Sub-item inputs - Tighter */
    .quotation-subitem-row input {
        font-size: 0.6rem !important;
        padding: 0.2rem 0.1rem !important;
    }
    
    /* Add button row - Smaller */
    .quotation-add-btn-row td {
        padding: 0.2rem !important;
    }
    
    .quotation-add-btn-row button {
        font-size: 0.6rem !important;
        padding: 0.2rem 0.4rem !important;
    }
    
    /* Simple item rows - Compact */
    .quotation-simple-row td {
        padding-top: 0.4rem !important;
        padding-bottom: 0.4rem !important;
    }
    
    /* Tighter column widths for very small screens */
    .invoice-items-table th:nth-child(1),
    .invoice-items-table td:nth-child(1) {
        width: 7% !important;
    }
    
    .invoice-items-table th:nth-child(2),
    .invoice-items-table td:nth-child(2) {
        width: 38% !important;
    }
    
    .invoice-items-table th:nth-child(3),
    .invoice-items-table td:nth-child(3),
    .invoice-items-table th:nth-child(4),
    .invoice-items-table td:nth-child(4) {
        width: 9% !important;
    }
    
    .invoice-items-table th:nth-child(5),
    .invoice-items-table td:nth-child(5),
    .invoice-items-table th:nth-child(6),
    .invoice-items-table td:nth-child(6) {
        width: 16% !important;
    }
    
    /* Header image smaller */
    #quotation-header-img {
        max-height: 80px !important;
    }
    
    /* Customer name and date section more compact */
    .quotation-details-header {
        font-size: 0.75rem !important;
        padding: 0 0.5rem !important;
    }
    
    #quotation-customer-name,
    #quotation-date-display {
        font-size: 0.75rem !important;
    }
    
    /* Footer total section */
    .quotation-footer-section .text-lg {
        font-size: 0.875rem !important;
    }
    
    /* Floating buttons even smaller */
    .quotation-fab {
        min-width: 2.5rem !important;
        height: 2.5rem !important;
        font-size: 0.75rem !important;
    }
    
    #add-quotation-row-btn {
        bottom: 4rem !important;
    }
    
    /* Header image - Responsive */
    #quotation-header-img {
        max-height: 80px;
        object-fit: contain;
    }
    
    /* Reduce total box size */
    .quotation-footer-section .w-5\/12 {
        max-width: 100%;
    }
    
    #quotation-calc-toggle-btn {
        margin-left: 0.5rem !important;
    }
}

/* Tablet landscape - Optimize for medium screens */
@media (min-width: 769px) and (max-width: 1024px) {
    #quotation-print-area {
        padding: 1.5rem !important;
    }
    
    .invoice-items-table {
        font-size: 0.875rem !important;
    }
    
    /* === DESCRIPTION COLUMN (td:nth-child(2)) - Stack Layout like Mobile === */
    #quotation .invoice-items-table td:nth-child(2) {
        vertical-align: top !important;
        padding: 0.5rem 0.3rem !important;
    }
    
    /* Description cell - Stack layout: Description on top, dimensions below */
    #quotation .invoice-items-table td:nth-child(2) > div {
        display: flex !important;
        flex-direction: column !important;
        gap: 0.3rem !important;
        width: 100% !important;
    }
    
    /* Description input - Full width on first line */
    #quotation .invoice-items-table td:nth-child(2) .quotation-desc-input {
        width: 100% !important;
        order: 1 !important;
        box-sizing: border-box !important;
    }
    
    /* Unit toggle button (ft/in) - Order 2, same row with width/height */
    #quotation .invoice-items-table td:nth-child(2) .unit-toggle-btn {
        order: 2 !important;
        flex-shrink: 0 !important;
        width: auto !important;
        padding: 0.3rem 0.5rem !important;
        font-size: 0.75rem !important;
        white-space: nowrap !important;
        box-sizing: border-box !important;
    }
    
    /* Width input - Order 2, flexible width */
    #quotation .invoice-items-table td:nth-child(2) .quotation-width-input {
        order: 2 !important;
        flex: 1 !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
    }
    
    /* Height input - Order 2, flexible width */
    #quotation .invoice-items-table td:nth-child(2) .quotation-height-input {
        order: 2 !important;
        flex: 1 !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
    }
    
    /* === SQFT COLUMN (td:nth-child(4)) - Stack Layout like Mobile === */
    #quotation .invoice-items-table td:nth-child(4) {
        vertical-align: top !important;
        padding: 0.5rem 0.3rem !important;
    }
    
    /* SQFT cell content wrapper - Stack vertically */
    #quotation .invoice-items-table td:nth-child(4) > div {
        display: flex !important;
        flex-direction: column !important;
        gap: 0.3rem !important;
        align-items: center !important;
        width: 100% !important;
    }
    
    /* Lock/Unlock button - Top position (Order 1) */
    #quotation .invoice-items-table td:nth-child(4) .sqft-lock-btn {
        order: 1 !important;
        width: auto !important;
        padding: 0.25rem 0.5rem !important;
        font-size: 0.75rem !important;
        margin: 0 !important;
        flex-shrink: 0 !important;
    }
    
    /* SQFT input - Bottom position (Order 2) */
    #quotation .invoice-items-table td:nth-child(4) input[type="text"],
    #quotation .invoice-items-table td:nth-child(4) .subitem-sqft {
        order: 2 !important;
        width: 100% !important;
        max-width: 100% !important;
        text-align: center !important;
        box-sizing: border-box !important;
    }
    
    /* === GENERAL INPUT FIELD CONSTRAINTS === */
    #quotation .invoice-items-table input[type="text"],
    #quotation .invoice-items-table input[type="number"],
    #quotation .invoice-items-table textarea,
    #quotation .invoice-items-table select {
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
    
    /* Table cells - Auto height for stacked content */
    #quotation-view .invoice-items-table tbody tr {
        height: auto !important;
        min-height: 60px !important;
    }
    
    #quotation-view .invoice-items-table tbody td {
        height: auto !important;
        min-height: 60px !important;
    }
}

/* ===== Saved Quotations List - Mobile Responsive ===== */
@media (max-width: 768px) {
    /* Quotation list table - Optimize column widths */
    #quotation-list-view table {
        font-size: 0.75rem !important;
    }
    
    #quotation-list-view thead th {
        padding: 0.5rem 0.3rem !important;
        font-size: 0.65rem !important;
        line-height: 1.2 !important;
    }
    
    #quotation-list-view tbody td {
        padding: 0.5rem 0.3rem !important;
        font-size: 0.75rem !important;
        line-height: 1.3 !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
    }
    
    /* Column 1: Date - 25% */
    #quotation-list-view th:nth-child(1),
    #quotation-list-view td:nth-child(1) {
        width: 25% !important;
        max-width: 25% !important;
    }
    
    /* Column 2: Customer Name - 35% */
    #quotation-list-view th:nth-child(2),
    #quotation-list-view td:nth-child(2) {
        width: 35% !important;
        max-width: 35% !important;
    }
    
    /* Column 3: Total Amount - 25% */
    #quotation-list-view th:nth-child(3),
    #quotation-list-view td:nth-child(3) {
        width: 25% !important;
        max-width: 25% !important;
    }
    
    /* Column 4: Actions - 15% */
    #quotation-list-view th:nth-child(4),
    #quotation-list-view td:nth-child(4) {
        width: 15% !important;
        max-width: 15% !important;
        text-align: center !important;
    }
    
    /* Action buttons - Stack vertically and reduce size */
    #quotation-list-view td:nth-child(4) .flex {
        flex-direction: column !important;
        gap: 0.2rem !important;
        align-items: stretch !important;
    }
    
    #quotation-list-view td:nth-child(4) button,
    #quotation-list-view td:nth-child(4) .action-btn {
        font-size: 0.6rem !important;
        padding: 0.2rem 0.3rem !important;
        white-space: nowrap !important;
        line-height: 1.2 !important;
    }
    
    #quotation-list-view td:nth-child(4) i {
        font-size: 0.65rem !important;
        margin-right: 0.15rem !important;
    }
    
    /* Remove horizontal scroll */
    #quotation-list-view .overflow-x-auto {
        overflow-x: visible !important;
    }
    
    /* Title spacing */
    #quotation-list-view h2 {
        font-size: 1.25rem !important;
        margin-bottom: 0.75rem !important;
    }
}

/* Extra small mobile devices */
@media (max-width: 480px) {
    #quotation-list-view table {
        font-size: 0.7rem !important;
    }
    
    #quotation-list-view thead th {
        font-size: 0.6rem !important;
        padding: 0.4rem 0.2rem !important;
    }
    
    #quotation-list-view tbody td {
        font-size: 0.7rem !important;
        padding: 0.4rem 0.2rem !important;
    }
    
    /* Adjust column widths for very small screens */
    #quotation-list-view th:nth-child(1),
    #quotation-list-view td:nth-child(1) {
        width: 22% !important;
    }
    
    #quotation-list-view th:nth-child(2),
    #quotation-list-view td:nth-child(2) {
        width: 38% !important;
    }
    
    #quotation-list-view th:nth-child(3),
    #quotation-list-view td:nth-child(3) {
        width: 23% !important;
        font-size: 0.65rem !important;
    }
    
    #quotation-list-view th:nth-child(4),
    #quotation-list-view td:nth-child(4) {
        width: 17% !important;
    }
    
    #quotation-list-view td:nth-child(4) button {
        font-size: 0.6rem !important;
        padding: 0.2rem 0.3rem !important;
    }
    
    #quotation-list-view h2 {
        font-size: 1.1rem !important;
    }
}

/* ===== INVOICE TAB - MOBILE RESPONSIVE ===== */
/* Mobile-first approach - Desktop & Print layouts preserved */
/* CRITICAL: Only apply on screen, NOT in print mode */

@media screen and (max-width: 768px) {
    /* Header controls - Stack vertically */
    #invoice .no-print.grid {
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
    }
    
    #invoice .flex.flex-wrap.gap-2.items-center.justify-end {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.5rem !important;
    }
    
    #invoice .flex.flex-wrap.gap-2.items-center.justify-end > * {
        width: 100% !important;
    }
    
    /* Date picker - Full width */
    #invoice .flex.items-center.gap-2 {
        width: 100%;
        justify-content: space-between;
    }
    
    /* Invoice print area - Reduce padding */
    #invoice-print-area {
        padding: 1rem !important;
        max-width: 100% !important;
    }
    
    /* Header image - Responsive */
    #invoice-print-area img {
        max-height: 120px;
        object-fit: contain;
    }
    
    /* Invoice header details - Better mobile layout */
    #invoice-print-area .flex.justify-between.mt-1 {
        flex-direction: column !important;
        gap: 0.5rem;
        padding: 0 0.5rem !important;
    }
    
    #invoice-print-area .flex.justify-between.mt-1 > div {
        width: 100% !important;
    }
    
    #invoice-print-area .text-right {
        text-align: left !important;
    }
    
    /* Invoice items table - Fit to screen */
    .invoice-items-table {
        width: 100% !important;
        table-layout: fixed !important;
        font-size: 0.7rem !important;
    }
    
    .invoice-items-table thead th {
        padding: 0.4rem 0.2rem !important;
        font-size: 0.65rem !important;
        line-height: 1.2 !important;
    }
    
    .invoice-items-table tbody td {
        padding: 0.4rem 0.2rem !important;
        font-size: 0.7rem !important;
        line-height: 1.3 !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
        vertical-align: middle !important;
    }
    
    /* Column widths optimization */
    /* NO column */
    .invoice-items-table th:nth-child(1),
    .invoice-items-table td:nth-child(1) {
        width: 8% !important;
        padding-left: 0.3rem !important;
        padding-right: 0.1rem !important;
    }
    
    /* DESCRIPTION column */
    .invoice-items-table th:nth-child(2),
    .invoice-items-table td:nth-child(2) {
        width: 40% !important;
        max-width: none !important;
        white-space: normal !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
    }
    
    /* QTY column */
    .invoice-items-table th:nth-child(3),
    .invoice-items-table td:nth-child(3) {
        width: 10% !important;
        text-align: center !important;
    }
    
    /* SQFT column */
    .invoice-items-table th:nth-child(4),
    .invoice-items-table td:nth-child(4) {
        width: 10% !important;
        text-align: center !important;
    }
    
    /* PRICE column */
    .invoice-items-table th:nth-child(5),
    .invoice-items-table td:nth-child(5) {
        width: 16% !important;
        text-align: right !important;
        font-size: 0.65rem !important;
    }
    
    /* TOTAL column */
    .invoice-items-table th:nth-child(6),
    .invoice-items-table td:nth-child(6) {
        width: 16% !important;
        text-align: right !important;
        font-size: 0.65rem !important;
        padding-right: 0.3rem !important;
    }
    
    /* Footer totals section - Better mobile fit */
    #invoice-print-area .flex.justify-end {
        justify-content: center !important;
        margin-top: 0.5rem !important;
    }
    
    #invoice-print-area .w-4\/12 {
        width: 100% !important;
        max-width: 280px !important;
    }
    
    /* Total boxes - Adjust sizing */
    #invoice-print-area .flex.justify-between.items-center {
        padding: 0.3rem 0.4rem !important;
    }
    
    #invoice-print-area .flex.justify-between.items-center strong,
    #invoice-print-area .flex.justify-between.items-center span {
        font-size: 0.75rem !important;
    }
    
    /* Signature section - Stack */
    #invoice-print-area .flex.justify-between.mt-6 {
        flex-direction: column !important;
        gap: 1.5rem;
        margin-top: 1.5rem !important;
    }
    
    #invoice-print-area .w-1\/3 {
        width: 100% !important;
    }
    
    /* Title */
    #invoice h2 {
        font-size: 1.25rem !important;
    }
    
    /* Payment Info section - Reduce font sizes */
    .invoice-payment-info {
        font-size: 0.65rem !important;
    }
    
    .invoice-payment-info p {
        font-size: 0.7rem !important;
    }
    
    .invoice-payment-info .grid.grid-cols-2 {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
    
    .invoice-payment-info .grid.grid-cols-\[max-content_1fr\] {
        gap: 0.5rem !important;
    }
    
    .invoice-payment-info strong {
        font-size: 0.65rem !important;
    }
    
    .invoice-payment-info span {
        font-size: 0.65rem !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
    }
}

/* Extra small devices - Further optimization */
@media screen and (max-width: 480px) {
    #invoice-print-area {
        padding: 0.5rem !important;
    }
    
    #invoice-print-area img {
        max-height: 100px;
    }
    
    .invoice-items-table {
        font-size: 0.65rem !important;
    }
    
    .invoice-items-table thead th {
        padding: 0.3rem 0.15rem !important;
        font-size: 0.6rem !important;
    }
    
    .invoice-items-table tbody td {
        padding: 0.3rem 0.15rem !important;
        font-size: 0.65rem !important;
    }
    
    /* Tighter column widths */
    .invoice-items-table th:nth-child(1),
    .invoice-items-table td:nth-child(1) {
        width: 7% !important;
    }
    
    .invoice-items-table th:nth-child(2),
    .invoice-items-table td:nth-child(2) {
        width: 42% !important;
    }
    
    .invoice-items-table th:nth-child(3),
    .invoice-items-table td:nth-child(3),
    .invoice-items-table th:nth-child(4),
    .invoice-items-table td:nth-child(4) {
        width: 9% !important;
    }
    
    .invoice-items-table th:nth-child(5),
    .invoice-items-table td:nth-child(5),
    .invoice-items-table th:nth-child(6),
    .invoice-items-table td:nth-child(6) {
        width: 15.5% !important;
        font-size: 0.6rem !important;
    }
    
    /* Footer totals - Smaller */
    #invoice-print-area .w-4\/12 {
        max-width: 100% !important;
    }
    
    #invoice-print-area .flex.justify-between.items-center {
        padding: 0.25rem 0.3rem !important;
    }
    
    #invoice-print-area .flex.justify-between.items-center strong,
    #invoice-print-area .flex.justify-between.items-center span {
        font-size: 0.7rem !important;
    }
    
    #invoice h2 {
        font-size: 1.1rem !important;
    }
    
    /* Payment Info section - Even smaller for extra small screens */
    .invoice-payment-info {
        font-size: 0.6rem !important;
    }
    
    .invoice-payment-info p {
        font-size: 0.65rem !important;
    }
    
    .invoice-payment-info strong {
        font-size: 0.6rem !important;
    }
    
    .invoice-payment-info span {
        font-size: 0.6rem !important;
    }
}

/* ===== Customer Table Checkbox Column Hide (Non-Admin) ===== */
/* This class will be added by JavaScript for non-admin users */
.hide-checkbox-column .customer-checkbox-cell {
    display: none !important;
}

/* Also hide the header checkbox column */
.hide-checkbox-column th:has(#customers-select-all) {
    display: none !important;
}
