/**
 * Table Component Styles
 * Styling for all tables across the application
 */

/* Base Table Styles */
.table {
    width: 100%;
    margin-bottom: 1rem;
    color: #212529;
    vertical-align: top;
    border-color: #dee2e6;
}

.table > :not(caption) > * > * {
    padding: 0.5rem 0.5rem;
    background-color: var(--bs-table-bg);
    border-bottom-width: 1px;
    box-shadow: inset 0 0 0 9999px var(--bs-table-accent-bg);
}

.table > tbody {
    vertical-align: inherit;
}

.table > thead {
    vertical-align: bottom;
}

/* Striped Tables */
.table-striped > tbody > tr:nth-of-type(odd) {
    --bs-table-accent-bg: var(--bs-table-striped-bg);
    color: var(--bs-table-striped-color);
}

/* Bordered Tables */
.table-bordered > :not(caption) > * {
    border-width: 1px 0;
}

.table-bordered > :not(caption) > * > * {
    border-width: 0 1px;
}

/* Borderless Tables */
.table-borderless > :not(caption) > * > * {
    border-bottom-width: 0;
}

/* Hover Tables */
.table-hover > tbody > tr:hover {
    --bs-table-accent-bg: var(--bs-table-hover-bg);
    color: var(--bs-table-hover-color);
}

/* Table Variants */
.table-primary {
    --bs-table-bg: #cfe2ff;
    --bs-table-striped-bg: #c5d7f2;
    --bs-table-striped-color: #000;
    --bs-table-active-bg: #bacbe6;
    --bs-table-active-color: #000;
    --bs-table-hover-bg: #bfd1ec;
    --bs-table-hover-color: #000;
    color: #000;
    border-color: #bacbe6;
}

.table-success {
    --bs-table-bg: #d1e7dd;
    --bs-table-striped-bg: #c7dbd2;
    --bs-table-striped-color: #000;
    --bs-table-active-bg: #bcd0c7;
    --bs-table-active-color: #000;
    --bs-table-hover-bg: #c1d6cc;
    --bs-table-hover-color: #000;
    color: #000;
    border-color: #bcd0c7;
}

.table-info {
    --bs-table-bg: #cff4fc;
    --bs-table-striped-bg: #c5e8ef;
    --bs-table-striped-color: #000;
    --bs-table-active-bg: #badce3;
    --bs-table-active-color: #000;
    --bs-table-hover-bg: #bfe2e9;
    --bs-table-hover-color: #000;
    color: #000;
    border-color: #badce3;
}

.table-warning {
    --bs-table-bg: #fff3cd;
    --bs-table-striped-bg: #f2e7c3;
    --bs-table-striped-color: #000;
    --bs-table-active-bg: #e6dbb9;
    --bs-table-active-color: #000;
    --bs-table-hover-bg: #ece1be;
    --bs-table-hover-color: #000;
    color: #000;
    border-color: #e6dbb9;
}

.table-danger {
    --bs-table-bg: #f8d7da;
    --bs-table-striped-bg: #eccccf;
    --bs-table-striped-color: #000;
    --bs-table-active-bg: #dfc2c4;
    --bs-table-active-color: #000;
    --bs-table-hover-bg: #e5c7ca;
    --bs-table-hover-color: #000;
    color: #000;
    border-color: #dfc2c4;
}

.table-light {
    --bs-table-bg: #f8f9fa;
    --bs-table-striped-bg: #ecedee;
    --bs-table-striped-color: #000;
    --bs-table-active-bg: #dfe0e1;
    --bs-table-active-color: #000;
    --bs-table-hover-bg: #e5e6e7;
    --bs-table-hover-color: #000;
    color: #000;
    border-color: #dfe0e1;
}

.table-dark {
    --bs-table-bg: #212529;
    --bs-table-striped-bg: #2c3034;
    --bs-table-striped-color: #fff;
    --bs-table-active-bg: #373b3e;
    --bs-table-active-color: #fff;
    --bs-table-hover-bg: #323539;
    --bs-table-hover-color: #fff;
    color: #fff;
    border-color: #373b3e;
}

/* Small Tables */
.table-sm > :not(caption) > * > * {
    padding: 0.25rem 0.25rem;
}

/* Responsive Tables */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Admin Panel Tables */
.admin-table th {
    font-weight: 600;
    vertical-align: middle;
    border-bottom-width: 2px;
    background-color: #f8f9fc;
}

.admin-table td {
    vertical-align: middle;
}

.admin-table-hover tbody tr:hover {
    background-color: rgba(78, 115, 223, 0.05);
    cursor: pointer;
}

/* Inventory Table */
.inventory-table td,
.inventory-table th {
    padding: 0.75rem;
}

.inventory-row.low-stock {
    background-color: rgba(246, 194, 62, 0.1) !important;
}

.inventory-row.out-of-stock {
    background-color: rgba(255, 99, 132, 0.1) !important;
}

/* Enquiry Table */
.enquiry-table tbody tr:hover {
    background-color: rgba(78, 115, 223, 0.05);
    transform: translateY(-2px);
}

.enquiry-table tbody tr.unreplied {
    background-color: rgba(246, 194, 62, 0.05);
}

.enquiry-table tbody tr.unreplied:hover {
    background-color: rgba(246, 194, 62, 0.1);
}

/* Product Table */
.product-table td {
    vertical-align: middle;
}

.product-thumbnail {
    transition: transform 0.2s ease;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.1);
    object-fit: cover;
    width: 50px;
    height: 50px;
}

.product-thumbnail:hover {
    transform: scale(1.1);
    box-shadow: 0 0 10px rgba(0,0,0,0.2);
}

.no-image-placeholder {
    box-shadow: 0 0 0 1px rgba(0,0,0,0.1);
    transition: all 0.2s ease;
    width: 50px;
    height: 50px;
    background-color: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6c757d;
}

.no-image-placeholder:hover {
    background-color: #e9ecef !important;
}

/* Featured and seasonal row indicators */
tr.featured td:nth-child(3) {
    border-left: 3px solid #1cc88a;
}

tr.seasonal td:nth-child(3) {
    border-left: 3px solid #36b9cc;
}

tr.featured.seasonal td:nth-child(3) {
    border-left: 3px solid #4e73df;
}

/* Order Items Table */
.order-items-table td {
    padding: 1.25rem 1.5rem;
    vertical-align: middle;
    border-top: 1px solid #eef1f5;
}

.order-items-table thead th {
    background-color: #f8fafd;
    font-weight: 600;
    color: #333;
    padding: 1rem 1.5rem;
    border-top: none;
    letter-spacing: 0.03em;
}

.product-image-container {
    width: 70px;
    height: 70px;
    overflow: hidden;
    border-radius: 10px;
    border: 1px solid #eef1f5;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f8fafd;
}

.product-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.product-image:hover {
    transform: scale(1.05);
}

/* Cart Table */
.cart-table th {
    padding: 1rem;
    background-color: #f8f9fa;
    font-weight: 600;
}

.cart-table td {
    padding: 1.5rem 1rem;
    vertical-align: middle;
}

.cart-table .product-info {
    display: flex;
    align-items: center;
}

.cart-table .product-thumbnail {
    width: 80px;
    height: 80px;
    margin-right: 1rem;
}

.cart-table .product-title {
    font-weight: 600;
    color: #333;
    text-decoration: none;
}

.cart-table .product-title:hover {
    color: #3D7A67;
}

/* DataTables Custom Styling */
.dataTables_wrapper .dataTables_paginate .paginate_button {
    padding: 0.25rem 0.5rem;
    margin-left: 2px;
    border-radius: 0.25rem;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: #3D7A67;
    border-color: #3D7A67;
    color: white !important;
}

.dataTables_wrapper .dataTables_info {
    color: #6c757d;
}

.dataTables_wrapper .dataTables_filter input {
    border: 1px solid #ced4da;
    border-radius: 0.25rem;
    padding: 0.375rem 0.75rem;
}

.dataTables_wrapper .dataTables_length select {
    border: 1px solid #ced4da;
    border-radius: 0.25rem;
    padding: 0.375rem 0.75rem;
}

/* Animation for new items */
@keyframes highlightNew {
    from { background-color: rgba(61, 122, 103, 0.2); }
    to { background-color: transparent; }
}

.new-item {
    animation: highlightNew 2s ease-out;
}

/* Responsive Adjustments */
@media (max-width: 992px) {
    .product-table th:nth-child(7),
    .product-table th:nth-child(8),
    .product-table td:nth-child(7),
    .product-table td:nth-child(8) {
        display: none;
    }
}

@media (max-width: 768px) {
    .product-table th:nth-child(6),
    .product-table td:nth-child(6) {
        display: none;
    }

    .admin-table thead {
        display: none;
    }

    .admin-table tbody tr {
        display: block;
        border-bottom: 2px solid #dee2e6;
        margin-bottom: 1rem;
    }

    .admin-table tbody td {
        display: block;
        text-align: right;
        position: relative;
        padding-left: 50%;
        white-space: normal;
    }

    .admin-table tbody td:before {
        content: attr(data-title);
        position: absolute;
        left: 0.75rem;
        font-weight: 600;
        text-align: left;
    }
}

@media (max-width: 576px) {
    .table {
        font-size: 0.875rem;
    }

    .product-thumbnail,
    .no-image-placeholder {
        width: 40px;
        height: 40px;
    }

    .admin-table tbody td {
        padding: 0.5rem 0.5rem 0.5rem 50%;
    }

    .cart-table .product-info {
        flex-direction: column;
        align-items: flex-start;
    }

    .cart-table .product-thumbnail {
        margin-bottom: 0.5rem;
    }
}