/* Responsive Table Styles for Document Manager */

/* Mobile-first approach */
@media screen and (max-width: 768px) {
    /* Hide table header on mobile */
    .responsive-table thead {
        display: none;
    }
    
    /* Make table rows display as cards */
    .responsive-table tbody tr {
        display: block;
        margin-bottom: 1rem;
        border: 1px solid #e5e7eb;
        border-radius: 0.5rem;
        padding: 1rem;
        background: white;
        box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    }
    
    /* Dark mode styles for cards */
    .dark .responsive-table tbody tr {
        background: #1f2937;
        border-color: #374151;
    }
    
    /* Make table cells display as block */
    .responsive-table td {
        display: block;
        text-align: left;
        padding: 0.5rem 0;
        border: none;
        position: relative;
        padding-left: 40%;
    }
    
    /* Add labels before each cell */
    .responsive-table td:before {
        content: attr(data-label);
        position: absolute;
        left: 0;
        width: 35%;
        padding-right: 10px;
        white-space: nowrap;
        font-weight: 600;
        color: #6b7280;
    }
    
    /* Dark mode label color */
    .dark .responsive-table td:before {
        color: #9ca3af;
    }
    
    /* Special handling for actions */
    .responsive-table td:last-child {
        padding-left: 0;
        text-align: center;
        border-top: 1px solid #e5e7eb;
        margin-top: 0.5rem;
        padding-top: 0.75rem;
    }
    
    .dark .responsive-table td:last-child {
        border-top-color: #374151;
    }
    
    .responsive-table td:last-child:before {
        content: none;
    }
    
    /* Make action buttons larger on mobile */
    .responsive-table td:last-child button,
    .responsive-table td:last-child a {
        padding: 0.5rem;
        font-size: 1.125rem;
    }
    
    /* Fix overflow for long text */
    .responsive-table td {
        word-break: break-word;
        overflow-wrap: break-word;
    }
    
    /* Hide pagination text, show only buttons */
    .pagination span.relative {
        display: none;
    }
    
    /* Make filter grid single column on mobile */
    .filter-grid-mobile {
        grid-template-columns: 1fr !important;
    }
}

/* Tablet styles */
@media screen and (min-width: 769px) and (max-width: 1024px) {
    /* Make table scrollable horizontally */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Reduce font size slightly */
    .responsive-table {
        font-size: 0.875rem;
    }
    
    /* Reduce padding */
    .responsive-table th,
    .responsive-table td {
        padding: 0.5rem;
    }
    
    /* Make certain columns narrower */
    .responsive-table th:first-child,
    .responsive-table td:first-child {
        width: 50px;
    }
}

/* General improvements */
.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Prevent text overflow in cells */
.responsive-table td {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Except for the title column which can wrap */
.responsive-table td.title-cell {
    white-space: normal;
    word-break: break-word;
}

/* Mobile menu improvements */
@media screen and (max-width: 640px) {
    /* Stack buttons vertically on very small screens */
    .mobile-actions {
        flex-direction: column;
        width: 100%;
    }
    
    .mobile-actions button {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    /* Make modals full screen on mobile */
    .mobile-modal {
        width: 100% !important;
        height: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        top: 0 !important;
        border-radius: 0 !important;
    }
    
    .mobile-modal .modal-content {
        height: calc(100vh - 100px);
        overflow-y: auto;
    }
}

/* Improve button spacing on mobile */
.action-buttons-mobile {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}

.action-buttons-mobile button,
.action-buttons-mobile a {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Persian/Arabic text alignment fix */
.rtl-support {
    direction: rtl;
    text-align: right;
}

/* Improve scroll indicator */
.scroll-indicator {
    display: none;
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    background: linear-gradient(to right, transparent, white);
    padding: 1rem;
    pointer-events: none;
}

.dark .scroll-indicator {
    background: linear-gradient(to right, transparent, #1f2937);
}

@media screen and (max-width: 768px) {
    .table-container.scrollable .scroll-indicator {
        display: block;
    }
}

/* Loading skeleton for better UX */
.skeleton {
    animation: skeleton-loading 1s linear infinite alternate;
}

@keyframes skeleton-loading {
    0% {
        background-color: #f3f4f6;
    }
    100% {
        background-color: #e5e7eb;
    }
}

.dark .skeleton {
    animation: skeleton-loading-dark 1s linear infinite alternate;
}

@keyframes skeleton-loading-dark {
    0% {
        background-color: #374151;
    }
    100% {
        background-color: #4b5563;
    }
}