/* assets/css/tables.css */

/* ===== TABLE STYLES - RESPONSIVE ===== */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 20px 0;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.table-container {
    width: 100%;
    margin: 0 auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    background-color: #ffffff;
    min-width: 100%;
}

/* For very wide tables that need horizontal scroll */
.table-responsive.wide-table {
    overflow-x: auto;
}

.table-responsive.wide-table table {
    min-width: 1200px;
}

/* For full-width tables outside container */
.full-width-table {
    width: 100vw;
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw;
    margin-right: -50vw;
}

.full-width-table .table-responsive {
    border-radius: 0;
    box-shadow: none;
}

/* Table text transformation - sentence case with 11px font */
table td,
table th {
    /* font-size: 11px; */
    text-transform: lowercase;
}

table td::first-letter,
table th::first-letter {
    text-transform: uppercase;
}

/* Ensure links and buttons inside tables maintain readability */
table td a,
table td button,
table td .btn,
table td .action-button {
    /* font-size: 11px; */
    text-transform: none;
}

/* Preserve original case for file icons and special characters */
table td .file-icon,
table td [class*="icon"],
table td .badge {
    text-transform: none !important;
}

th {
    padding: 16px 20px;
    text-align: left;
    color: white;
    font-weight: 600;
    font-size: 0.95rem;
    text-transform: none;
}

th::first-letter {
    text-transform: uppercase;
}

td {
    padding: 16px 20px;
    vertical-align: middle;
    border-bottom: 1px solid #e9ecef;
}

/* Align action buttons column to the right */
td:last-child,
th:last-child {
    text-align: right;
}

/* Action buttons container */
.action-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    width: 100%;
}

.action-buttons a,
.action-buttons button {
    display: inline-block;
    padding: 8px 16px;
    color: #ffffff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    /* font-size: 11px; */
    text-decoration: none;
    text-align: center;
    transition: all 0.2s;
    min-width: 80px;
}

.action-buttons a:first-child,
.action-buttons button:first-child {
    background-color: #EA580C;
}

.action-buttons a:first-child:hover,
.action-buttons button:first-child:hover {
    background-color: #c2410c;
}

.action-buttons a:last-child,
.action-buttons button:last-child {
    background-color: #15803D;
}

.action-buttons a:last-child:hover,
.action-buttons button:last-child:hover {
    background-color: #0e6c2d;
}

/* Zebra striping for better readability */
tbody tr:nth-child(even) {
    background-color: #f9f9f9;
}

/* Hover effect for rows */
tbody tr:hover {
    background-color: #f5f5f5;
}

/* Responsive font size for different screen sizes */
@media (min-width: 769px) and (max-width: 992px) {
    table td,
    table th {
        font-size: 10px;
    }
    
    th, td {
        padding: 12px 16px;
    }
    
    .action-buttons a,
    .action-buttons button {
        font-size: 10px;
        padding: 6px 12px;
        min-width: 70px;
    }
}

/* Mobile table styles - Card Layout */
@media (max-width: 768px) {
    .table-responsive {
        overflow-x: visible;
        background-color: transparent;
        box-shadow: none;
        margin: 10px 0;
    }
    
    table {
        min-width: 100%;
        border: none;
        display: block;
    }
    
    thead {
        display: none;
    }
    
    tbody {
        display: block;
    }
    
    tr {
        display: block;
        margin-bottom: 20px;
        background-color: #ffffff;
        border-radius: 8px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
        padding: 15px;
        border: 1px solid #e5e5e5;
    }
    
    td {
        display: flex;
        align-items: center;
        padding: 10px 0;
        border: none;
        border-bottom: 1px solid #f0f0f0;
        text-align: left;
        font-size: 11px;
        text-transform: lowercase;
    }
    
    td::first-letter {
        text-transform: uppercase;
    }
    
    td:last-child {
        border-bottom: none;
        text-align: left; /* Reset right alignment on mobile */
    }
    
    /* Show labels for all columns EXCEPT Title */
    td:before {
        content: attr(data-label);
        font-weight: 600;
        width: 120px;
        min-width: 120px;
        color: #15803D;
        font-size: 11px;
        text-transform: lowercase;
    }
    
    td:before::first-letter {
        text-transform: uppercase;
    }
    
    /* Special handling for Title column */
    td:first-child {
        display: flex;
        align-items: center;
        font-weight: 500;
        color: #000000;
    }
    
    td:first-child:before {
        display: none;
    }
    
    td:first-child div {
        flex: 1;
        display: flex;
        align-items: center;
        gap: 10px;
    }
    
    td:first-child .file-icon {
        text-transform: none !important;
    }
    
    /* Action buttons container on mobile */
    .action-buttons {
        display: flex;
        gap: 10px;
        width: 100%;
        justify-content: flex-start; /* Left align on mobile */
    }
    
    .action-buttons a,
    .action-buttons button {
        flex: 1;
        text-align: center;
        padding: 12px !important;
        font-size: 11px !important;
        text-transform: none;
        min-width: 0; /* Remove min-width on mobile */
    }
}

/* Small phones */
@media (max-width: 480px) {
    tr {
        padding: 12px;
    }
    
    td {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
        font-size: 10px;
    }
    
    td:before {
        width: 100%;
        margin-bottom: 5px;
        font-size: 10px;
    }
    
    td:first-child {
        flex-direction: row;
        align-items: center;
    }
    
    td:first-child div {
        flex: 1;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .action-buttons a,
    .action-buttons button {
        width: 100%;
        font-size: 10px !important;
        padding: 10px !important;
    }
}

/* Print styles for tables */
@media print {
    .table-responsive {
        box-shadow: none;
        margin: 10px 0;
        overflow-x: visible;
    }
    
    table {
        min-width: 100%;
        border: 1px solid #000;
    }
    
    table td,
    table th {
        font-size: 10pt;
        text-transform: lowercase;
        border: 1px solid #000;
        padding: 8px;
    }
    
    table td::first-letter,
    table th::first-letter {
        text-transform: uppercase;
    }
    
    td:last-child,
    th:last-child {
        text-align: right;
    }
    
    table td a,
    table td button,
    table td .btn {
        text-transform: none;
        text-decoration: none;
        color: #000;
    }
    
    .action-buttons {
        justify-content: flex-end;
    }
    
    thead {
        display: table-header-group;
    }
    
    tbody {
        display: table-row-group;
    }
    
    tr {
        page-break-inside: avoid;
        page-break-after: auto;
    }
    
    tbody tr:nth-child(even) {
        background-color: #f0f0f0 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}