/* Responsive Table Styles - Shared across all table components */

/* CSS Custom Properties for maintainable responsive design */
:root {
    /* Header and offset heights for different screen sizes */
    --header-offset-xxl: 200px;
    --header-offset-xl: 210px;
    --header-offset-lg: 215px;
    --header-offset-md: 220px;
    --header-offset-sm: 250px;
    --header-offset-xs: 270px;
    --header-offset-ipad: 400px;

    /* Spacing values */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.3rem;
    --spacing-md: 0.5rem;

    /* Touch target minimum size */
    --touch-target-min: 44px;
}

/* Accessibility: Respect user's motion preferences */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Prevent page scroll - make hangline fit viewport on larger screens */
@media (min-width: 768px) {
    body:has(.hangline-container) {
        overflow: hidden;
        height: 100vh;
    }
}

/* Allow scrolling on smaller screens */
@media (max-width: 767px) {
    body:has(.hangline-container) {
        overflow-y: auto;
        overflow-x: hidden;
    }
}

/* Responsive padding for page containers */
.hangline-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    padding: var(--spacing-md);
    min-height: 100vh;
    padding-bottom: 70px; /* Reduced space for fixed legend */
}

/* Desktop and large tablets - fixed viewport */
@media (min-width: 768px) {
    .hangline-container {
        height: 100vh;
        max-height: 100vh;
        overflow: hidden;
        padding-bottom: 70px; /* Reduced space for fixed legend */
    }
}

/* Adjust padding for medium screens */
@media (min-width: 1024px) {
    .hangline-container {
        padding: var(--spacing-md);
    }
}

/* Smaller tablets - reduced padding */
@media (min-width: 768px) and (max-width: 1023px) {
    .hangline-container {
        padding: var(--spacing-sm);
    }
}

/* Small mobile - natural scrolling */
@media (min-width: 600px) and (max-width: 767px) {
    .hangline-container {
        min-height: 100vh;
        overflow-y: auto;
        overflow-x: hidden;
        padding: 0.4rem;
    }
}

/* Extra small mobile - natural scrolling */
@media (max-width: 599px) {
    .hangline-container {
        min-height: 100vh;
        overflow-y: auto;
        overflow-x: hidden;
        padding: var(--spacing-xs);
    }
}

/* Hangline Page Layout */
.hangline-paper {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

@media (max-width: 767px) {
    .hangline-paper {
        min-height: auto;
        overflow: visible;
    }
}

.hangline-grid {
    flex: 1 1 0;
    margin: 0;
    min-height: 0;
    overflow: hidden;
    width: 100%;
    height: 100%;
}

@media (max-width: 767px) {
    .hangline-grid {
        min-height: auto;
        overflow: visible;
        height: auto;
    }
}

/* Filter Column */
.hangline-filter-item {
    display: flex;
    flex-direction: column;
    padding: 8px;
    min-height: 0;
    max-width: 100%;
    height: 100%;
}

@media (min-width: 768px) and (max-width: 959px) {
    .hangline-filter-item {
        padding: 6px;
    }
}

@media (max-width: 767px) {
    .hangline-filter-item {
        min-height: auto;
        padding: 6px;
        margin-bottom: 1rem;
    }
}

@media (max-width: 599px) {
    .hangline-filter-item {
        padding: 4px;
    }
}

.hangline-filter-paper {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

@media (max-width: 959px) {
    .hangline-filter-paper {
        height: auto;
        min-height: 250px;
    }
}

@media (max-width: 599px) {
    .hangline-filter-paper {
        min-height: 200px;
    }
}

.hangline-filter-title {
    font-weight: bold;
    margin-bottom: 8px;
    flex-shrink: 0;
}

@media (max-width: 959px) {
    .hangline-filter-title {
        margin-bottom: 6px;
        font-size: 0.95rem;
    }
}

@media (max-width: 599px) {
    .hangline-filter-title {
        font-size: 0.9rem;
    }
}

.hangline-filter-controls {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex-shrink: 0;
    margin-bottom: 4px;
}

@media (max-width: 959px) {
    .hangline-filter-controls {
        gap: 2px;
        margin-bottom: 4px;
        flex-wrap: wrap; 
    }

        .hangline-filter-controls .past-due-btn {
            width: auto;
            min-width: 96px; 
        }
}
.hangline-filter-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

@media (max-width: 959px) {
    .hangline-filter-scroll {
        max-height: 200px;
    }
}

@media (max-width: 599px) {
    .hangline-filter-scroll {
        max-height: 150px;
    }
}

/* Main Content Column */
.hangline-main-item {
    display: flex;
    flex-direction: column;
    padding: 8px;
    min-height: 0;
    overflow: hidden;
    max-width: 100%;
    width: 100%;
    height: 100%;
}

@media (min-width: 768px) {
    .hangline-main-item {
        flex: 1 1 0;
        min-height: 0;
    }
}

@media (min-width: 768px) and (max-width: 1023px) {
    .hangline-main-item {
        padding: 6px;
        overflow: hidden;
    }
}

@media (max-width: 767px) {
    .hangline-main-item {
        min-height: auto;
        overflow: visible;
        padding: 6px;
    }
}

@media (max-width: 599px) {
    .hangline-main-item {
        padding: 4px;
    }
}

/* Actions Row */
.hangline-actions-row {
    display: flex;
    gap: 12px;
    flex-shrink: 0;
    margin-bottom: 8px;
    width: 100%;
}

@media (max-width: 1023px) {
    .hangline-actions-row {
        gap: 10px;
        margin-bottom: 6px;
    }
}

@media (max-width: 767px) {
    .hangline-actions-row {
        gap: 8px;
        margin-bottom: 8px;
        flex-wrap: wrap;
    }
}

@media (max-width: 599px) {
    .hangline-actions-row {
        gap: 6px;
        margin-bottom: 6px;
        flex-direction: column;
    }
    
    .hangline-block-selector,
    .hangline-hang-actions {
        width: 100% !important;
        margin-left: 0 !important;
    }
}

/* Table Card */
.hangline-table-card {
    flex: 1 1 0;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* Desktop - max-height constraints - Optimized for maximum table space */
@media (min-width: 1920px) {
    .hangline-table-card {
        max-height: calc(100vh - 240px);
    }
}

@media (min-width: 1440px) and (max-width: 1919px) {
    .hangline-table-card {
        max-height: calc(100vh - 250px);
    }
}

@media (min-width: 1280px) and (max-width: 1439px) {
    .hangline-table-card {
        max-height: calc(100vh - 260px);
    }
}

@media (min-width: 1024px) and (max-width: 1279px) {
    .hangline-table-card {
        max-height: calc(100vh - 265px);
    }
}

/* Tablet */
@media (min-width: 834px) and (max-width: 1023px) {
    .hangline-table-card {
        max-height: calc(100vh - 280px);
    }
}

@media (min-width: 768px) and (max-width: 833px) {
    .hangline-table-card {
        max-height: calc(100vh - 290px);
    }
}

/* iPad portrait screens (768x1024 and 820x1180) - specific handling */
@media (min-width: 768px) and (max-width: 834px) and (min-height: 1000px) {
    .hangline-container {
        max-height: 100vh;
        overflow: hidden;
        padding-bottom: 0;
    }

    .hangline-table-card {
        max-height: calc(100vh - var(--header-offset-ipad));
    }

    .hangline-filter-paper {
        max-height: calc(100vh - 150px);
    }

    .hangline-main-item {
        padding-bottom: 0;
        overflow: hidden;
    }

    .hangline-legend {
        margin-top: 4px;
        margin-bottom: 0;
        padding-bottom: 0;
        flex-shrink: 0;
        position: relative;
    }

    .hangline-legend-content {
        padding: 6px 10px;
    }
}

@media (max-width: 767px) {
    .hangline-table-card {
        height: auto;
        min-height: 400px;
        max-height: 60vh;
    }
}

@media (max-width: 599px) {
    .hangline-table-card {
        min-height: 350px;
        max-height: 55vh;
    }
}

/* Table Content */
.hangline-table-content {
    width: 100%;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: visible;
}

@media (max-width: 767px) {
    .hangline-table-content {
        min-height: 400px;
    }
}

@media (max-width: 599px) {
    .hangline-table-content {
        min-height: 350px;
    }
}

/* Past Due Empty State */
.hangline-past-due-empty {
    background-color: #f9f9f9;
    text-align: center;
    margin: 16px;
}

@media (max-width: 767px) {
    .hangline-past-due-empty {
        margin: 12px;
        padding: 1.5rem !important;
    }
}

@media (max-width: 599px) {
    .hangline-past-due-empty {
        margin: 8px;
        padding: 1rem !important;
    }
    
    .hangline-past-due-empty .mud-icon-root {
        font-size: 48px !important;
    }
}

/* Past Due Scroll Container */
.hangline-past-due-scroll {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
    flex: 1;
    min-height: 0;
    max-height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 4px;
}

@media (max-width: 1023px) {
    .hangline-past-due-scroll {
        gap: 12px;
    }
}

@media (max-width: 767px) {
    .hangline-past-due-scroll {
        gap: 12px;
        padding: 2px;
    }
}

@media (max-width: 599px) {
    .hangline-past-due-scroll {
        gap: 10px;
        padding: 2px;
    }
}

/* Past Due Item */
.hangline-past-due-item {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    width: 100%;
    max-width: 100%;
}
    .hangline-past-due-item .main-hang-table {
        margin-top: 0 !important;
    }

    .hangline-past-due-item > :last-child {
        margin-top: 0 !important;
    }

    .hangline-past-due-item .mud-table {
        margin-top: 0 !important;
    }
.hangline-past-due-header {
    background-color: #953204 !important; /*light-#74adfc*/
    padding: 8px;
    margin: 6px 0px 0px 0px;
    border-radius: 8px 8px 0 0;
    margin-bottom: 0 !important;
}

@media (max-width: 767px) {
    .hangline-past-due-header {
        background-color: #953204;
        padding: 6px;
        margin: 4px 4px 6px 4px;
        border-radius: 8px 8px 0 0;
    }
}

@media (max-width: 599px) {
    .hangline-past-due-header {
        background-color: #953204;
        padding: 4px 6px;
        margin: 2px 2px 4px 2px;
        border-radius: 8px 8px 0 0;
    }
    
    .hangline-past-due-header .mud-typography {
        font-size: 0.85rem !important;
    }
}

/* Legend - Fixed at bottom of page */
.hangline-legend-fixed {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 1000;
    background-color: white;
    border-top: 1px solid rgba(0, 0, 0, 0.12);
    margin: 0;
    box-shadow: 0px -2px 8px rgba(0, 0, 0, 0.1);
}

/* Desktop and tablets - ensure legend is always visible */
@media (min-width: 768px) {
    .hangline-legend-fixed {
        flex-shrink: 0 !important;
        min-height: fit-content;
    }
}

/* Large desktops */
@media (min-width: 1920px) {
    .hangline-legend-fixed {
        padding: 0 16px;
    }
}

/* Tablets and smaller - ensure visibility */
@media (max-width: 1023px) {
    .hangline-legend-fixed {
        padding: 0 8px;
    }
}

/* Old legend class - hide it since we're using fixed now */
.hangline-legend {
    display: none;
}

/* Touch Target Improvements */
@media (max-width: 767px) {
    .hangline-filter-controls .mud-button,
    .hangline-filter-controls .mud-icon-button,
    .hangline-hang-actions .mud-button,
    .hangline-hang-actions .mud-icon-button {
        min-width: var(--touch-target-min);
        min-height: var(--touch-target-min);
    }

    .past-due-btn {
        min-width: 96px !important;
        min-height: var(--touch-target-min);
    }
}

/* Scroll to Top Button */
.hangline-scroll-top {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 2000;
    cursor: pointer;
}

@media (min-width: 768px) and (max-width: 1023px) {
    .hangline-scroll-top {
        right: 20px;
        bottom: 20px;
    }
}

@media (max-width: 767px) {
    .hangline-scroll-top {
        right: 16px;
        bottom: 16px;
    }
}

@media (max-width: 599px) {
    .hangline-scroll-top {
        right: 12px;
        bottom: 12px;
    }
    
    .hangline-scroll-top .mud-avatar {
        width: 40px !important;
        height: 40px !important;
    }
}

/* Ensure hangline-legend-item has proper horizontal flex layout with row direction and aligned items */
.hangline-legend-content {
    padding: 8px 12px;
}

@media (min-width: 1920px) {
    .hangline-legend-content {
        padding: 10px 16px;
    }
}

@media (min-width: 1440px) and (max-width: 1919px) {
    .hangline-legend-content {
        padding: 8px 14px;
    }
}

/* Tablets - consolidated */
@media (min-width: 768px) and (max-width: 1023px) {
    .hangline-legend-content {
        padding: 6px 10px;
    }
}

@media (max-width: 767px) {
    .hangline-legend-content {
        padding: 6px 8px;
    }
}

@media (max-width: 599px) {
    .hangline-legend-content {
        padding: 4px 6px;
    }
}

.hangline-legend-title {
    font-weight: 600;
    margin-bottom: 6px;
}

@media (min-width: 1920px) {
    .hangline-legend-title {
        margin-bottom: 8px;
        font-size: 0.95rem;
    }
}

/* Tablets and mobile - consolidated */
@media (max-width: 1023px) {
    .hangline-legend-title {
        font-size: 0.85rem;
        margin-bottom: 2px;
    }
}

@media (max-width: 599px) {
    .hangline-legend-title {
        font-size: 0.8rem;
    }
}

.hangline-legend-item {
    display: flex;
    flex-direction: row;
    gap: 6px;
    align-items: center;
    min-width: fit-content;
    white-space: nowrap;
}

@media (min-width: 1920px) {
    .hangline-legend-item {
        gap: 8px;
    }
}

/* Tablets - consolidated */
@media (min-width: 768px) and (max-width: 1023px) {
    .hangline-legend-item {
        gap: 4px;
    }

    .hangline-legend-item .mud-icon-root {
        font-size: 1.2rem;
    }

    .hangline-legend-item .mud-typography {
        font-size: 0.8rem;
    }
}

/* Small mobile */
@media (max-width: 599px) {
    .hangline-legend-item {
        gap: 2px;
    }

    .hangline-legend-item .mud-icon-root {
        font-size: 1rem;
    }

    .hangline-legend-item .mud-typography {
        font-size: 0.7rem;
    }
}
