/* =========================
   TABLES & PAGINATION
   ========================= */

.table-light {
    border-radius: 1rem !important;
}

.table-clickable-rows tbody tr {
    transition: box-shadow 0.2s ease, background-color 0.2s ease;
}

    .table-clickable-rows tbody tr:hover {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
        background-color: var(--color-bg-hover);
    }

.table {
    border-radius: 1rem;
    box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.15), 0 8px 20px -8px rgba(0, 0, 0, 0.1);
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: none;
    /* Coins arrondis - nécessite border-collapse: separate */
    overflow: visible;
    border-collapse: separate;
    border-spacing: 0;
}

/* Allow dropdown menus to overflow table containers */
.table-responsive,
.table-responsive-md,
.table-responsive-lg,
.table-container-fixed {
    overflow: visible !important;
}

/* Dropdown positioning in tables - ensure menus are visible */
.table .dropdown-menu {
    position: absolute;
    z-index: 1050;
}

/* For tables with few rows, open dropdown upward if near bottom */
.table tbody tr:last-child .dropdown-menu,
.table tbody tr:nth-last-child(2) .dropdown-menu {
    top: auto !important;
    bottom: 100% !important;
    margin-bottom: 0.125rem;
    margin-top: 0;
}

    /* Coins arrondis sur les cellules */
    .table thead th:first-child {
        border-top-left-radius: 1rem;
        padding-left: 1.5rem;
    }
    
    .table thead th:last-child {
        border-top-right-radius: 1rem;
        padding-right: 1.5rem;
    }
    
    .table tbody tr:last-child td:first-child {
        border-bottom-left-radius: 1rem;
    }
    
    .table tbody tr:last-child td:last-child {
        border-bottom-right-radius: 1rem;
    }

    /* Espacement première et dernière colonne */
    .table tbody td:first-child {
        padding-left: 1.5rem;
    }
    
    .table tbody td:last-child {
        padding-right: 1.5rem;
    }

    .table thead {
        border-radius: 1rem 1rem 0 0 !important;
    }

        .table thead th {
            background: rgba(255, 255, 255, 0.5);
            color: var(--color-primary);
            font-weight: 600;
            border: none;
            border-bottom: 1px solid rgba(241, 245, 249, 0.5);
            padding: 1rem 1.25rem;
            text-transform: uppercase;
            font-size: 0.875rem;
            letter-spacing: 0.05em;
        }

    .table tbody tr {
        transition: all 0.2s ease;
        border-bottom: 1px solid rgba(241, 245, 249, 0.5);
        background: transparent;
    }

        .table tbody tr:hover {
            background: rgba(255, 255, 255, 0.5);
        }

        .table tbody tr:last-child {
            border-bottom: none;
        }

    .table tbody td {
        padding: 1rem 1.25rem;
        vertical-align: middle;
        border: none;
        background: transparent;
    }

.table-clickable-rows tbody tr {
    cursor: pointer;
}

    .table-clickable-rows tbody tr:hover {
        background: linear-gradient(135deg, #eff6ff, #dbeafe);
    }

/*Tablet*/
@media (max-width: 768px) {
    .table-clickable-rows tbody tr {
        cursor: pointer;
    }

    .table td,
    .table th {
        padding: 1rem 0.75rem !important;
        line-height: 1.7 !important;
        vertical-align: middle !important;
    }

    .table-clickable-rows tbody tr {
        min-height: 70px !important;
    }

        .table-clickable-rows tbody tr:hover {
            background-color: #f8fafc !important;
            border-left: 4px solid var(--color-primary) !important;
        }    
        
        .table .dropdown button {
        padding: 0.75rem !important;
        min-width: 44px !important;
        min-height: 44px !important;
    }

    .table {
        font-size: 1rem !important;
    }

        .table thead th {
            padding: 1.25rem 0.75rem !important;
            font-weight: 600 !important;
            background: #f8fafc;
        }
}

/*Mobile*/
@media (max-width: 576px) {
    .table td, .table th {
        padding: 2rem 0.5rem !important;
        font-size: 1rem !important;
    }

    .table-clickable-rows tbody tr {
        min-height: 80px !important;
    }

    /* Round buttons - ensure transparent background in corners */
    .table .dropdown {
        background: transparent !important;
    }

    .table .dropdown button {
        padding: 1rem !important;
        min-width: 48px !important;
        min-height: 48px !important;
        border-radius: 50% !important;
        background-color: transparent !important;
    }

    .table .dropdown button.btn-outline-secondary,
    .table .dropdown button.btn-outline-primary,
    .table .dropdown button.btn-outline-danger {
        background-color: transparent !important;
    }

    .table td {
        border-right: 1px solid var(--color-border-light-gray);
    }

        .table td:last-child {
            border-right: none;
        }

    /* Fix white corners on table-responsive wrapper */
    .table-responsive {
        background: transparent !important;
        border-radius: 1rem;
        overflow: visible !important; /* Allow dropdowns to overflow */
    }

    /* Ensure table has no white corners showing through */
    .table {
        background: rgba(255, 255, 255, 0.85) !important;
        border-radius: 1rem !important;
        overflow: visible !important; /* Allow dropdowns to overflow */
    }

    .table thead th:first-child {
        border-top-left-radius: 1rem;
    }

    .table thead th:last-child {
        border-top-right-radius: 1rem;
    }

    .table tbody tr:last-child td:first-child {
        border-bottom-left-radius: 1rem;
    }

    .table tbody tr:last-child td:last-child {
        border-bottom-right-radius: 1rem;
    }
}

/* =========================
   PAGINATION STYLES
   ========================= */
.page-item.active .page-link {
    z-index: 3;
    color: var(--color-white);
    background-color: var(--color-primary);
    border-color: var(--color-primary);
}

.pagination {
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
}

    .pagination .page-item {
        margin: 2px;
    }

/*Mobile*/
@media (max-width: 576px) {
    .pagination {
        font-size: 14px;
    }

        .pagination .page-link {
            padding: 6px 10px;
        }
}

.page-link {
    border: 2px solid var(--color-border-gray);
    border-radius: 0.75rem;
    color: var(--color-text-muted);
    font-weight: 600;
    padding: 0.75rem 1rem;
    margin: 0;
    transition: all 0.3s ease;
}

    .page-link:hover {
        background: linear-gradient(135deg, var(--color-bg-light), var(--color-bg-secondary));
        border-color: var(--color-primary);
        color: var(--color-primary);
        transform: translateY(-2px);
    }

.page-item.active .page-link {
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-secondary));
    border-color: var(--color-primary);
    color: white;
}

.border-primary {
    border-color: var(--color-primary) !important;
}

/* =========================
   MOBILE TABLE TO CARDS CONVERSION
   ========================= */

/* Hide tables on mobile, show cards */
@media (max-width: 767.98px) {
    .table-responsive {
        display: none !important;
    }
    
    .mobile-line-items {
        display: block !important;
    }
}

/* Show tables on desktop, hide cards */
@media (min-width: 768px) {
    .mobile-line-items { 
        display: none !important; 
    }
}

/* Mobile line items styling */
.mobile-line-items {
    display: none; /* Hidden by default, shown on mobile */
}

.mobile-line-item {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 0.75rem;
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.mobile-line-item:last-child {
    margin-bottom: 0;
}

.mobile-line-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--color-border-light-gray, #f3f4f6);
}

.mobile-line-item-description {
    font-weight: 600;
    color: var(--color-text-dark, #1e293b);
    flex: 1;
    margin-right: 1rem;
}

.mobile-line-item-actions {
    display: flex;
    gap: 0.5rem;
}

/* Ensure buttons in mobile actions have transparent backgrounds */
.mobile-line-item-actions .btn-outline-primary,
.mobile-line-item-actions .btn-outline-secondary,
.mobile-line-item-actions .btn-outline-danger {
    background-color: transparent !important;
}

.mobile-line-item-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.mobile-line-item-field {
    display: flex;
    flex-direction: column;
}

.mobile-line-item-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-text-muted, #6b7280);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.mobile-line-item-value {
    font-size: 0.9rem;
    color: var(--color-text-dark, #1e293b);
    font-weight: 500;
}

.mobile-line-item-total {
    grid-column: 1 / -1;
    text-align: center;
    padding-top: 0.5rem;
    border-top: 1px solid var(--color-border-light-gray, #f3f4f6);
    margin-top: 0.5rem;
}

.mobile-line-item-total .mobile-line-item-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-primary, #086973);
}

/* =========================
   TRANSACTIONS MOBILE LAYOUT (INVOICE-STYLE)
   ========================= */

/* Badge small size for mobile */
.badge-sm {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
}

/* Enlarge transaction amounts on mobile */
@media (max-width: 767.98px) {
    #transactions-table tbody td:nth-child(2) strong {
        font-size: 1rem;
    }
    
    #transactions-table tbody td:nth-child(2) .badge {
        font-size: 0.75rem;
    }
    
    /* Make amount column larger and bold on mobile */
    #transactions-table tbody td:last-child strong {
        font-size: 1.25rem !important;
        font-weight: 700 !important;
    }
    
    /* Date below amount should be smaller */
    #transactions-table tbody td:last-child small {
        font-size: 0.875rem;
        margin-top: 0.25rem;
    }
}

/* =========================
   TABLE FILTER ROW
   ========================= */

.table-filter-row th {
    background: rgba(248, 249, 250, 0.9) !important;
    padding: 0.5rem !important;
    border-bottom: 2px solid var(--color-primary-light, #e2e8f0) !important;
}

.table-filter-row .form-control,
.table-filter-row .form-select {
    font-size: 0.8125rem;
    border-radius: 0.375rem;
    border-color: #dee2e6;
    background-color: #fff;
}

.table-filter-row .form-control:focus,
.table-filter-row .form-select:focus {
    border-color: var(--color-primary, #0d6efd);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15);
}

.table-filter-row .form-control::placeholder {
    color: #adb5bd;
    font-style: italic;
}

.table-filter-row .btn-outline-secondary {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

/* Prevent filter row from sorting */
.table-filter-row th {
    cursor: default !important;
    user-select: auto !important;
}