/**
 * CSS cho frontend
 */

/* Container */
.fptb-table-container {
    margin-bottom: 20px;
    overflow-x: auto;
}

/* Table Title and Description */
.fptb-table-title {
    margin-bottom: 15px;
    font-size: 1.5em;
    font-weight: bold;
    color: #333;
}

.fptb-table-description {
    margin-bottom: 20px;
    color: #666;
    line-height: 1.6;
}

/* Base Table Styles */
.fptb-table {
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
    margin-bottom: 20px;
    background-color: #fff;
}

.fptb-table th,
.fptb-table td {
    padding: 12px;
    text-align: left;
    vertical-align: top;
}

.fptb-table th {
    font-weight: bold;
    background-color: #f8f9fa;
    color: #333;
}

/* Basic Style */
.fptb-style-basic {
    border: none;
}

.fptb-style-basic th,
.fptb-style-basic td {
    border-bottom: 1px solid #dee2e6;
}

.fptb-style-basic th {
    border-bottom: 2px solid #dee2e6;
}

/* Striped Style */
.fptb-style-striped th,
.fptb-style-striped td {
    border-bottom: 1px solid #dee2e6;
}

.fptb-style-striped th {
    border-bottom: 2px solid #dee2e6;
}

.fptb-style-striped tbody tr:nth-child(odd) {
    background-color: #f8f9fa;
}

/* Bordered Style */
.fptb-style-bordered {
    border: 1px solid #dee2e6;
}

.fptb-style-bordered th,
.fptb-style-bordered td {
    border: 1px solid #dee2e6;
}

/* Hover Style */
.fptb-style-hover th,
.fptb-style-hover td {
    border-bottom: 1px solid #dee2e6;
}

.fptb-style-hover th {
    border-bottom: 2px solid #dee2e6;
}

.fptb-style-hover tbody tr:hover {
    background-color: #f5f5f5;
    transition: background-color 0.15s ease-in-out;
}

/* Product Cells */
.fptb-cell-type-product {
    vertical-align: top;
    text-align: center;
}

.fptb-product {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    max-width: 200px;
    margin: 0 auto;
}

.fptb-product-image {
    margin-bottom: 10px;
}

.fptb-product-image a {
    display: block;
    text-decoration: none;
}

.fptb-product-image img {
    max-width: 100px;
    height: auto;
    border-radius: 4px;
    transition: transform 0.2s ease-in-out;
}

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

.fptb-product-title {
    font-weight: bold;
    margin-bottom: 8px;
    line-height: 1.3;
}

.fptb-product-title a {
    color: #333;
    text-decoration: none;
    transition: color 0.2s ease-in-out;
}

.fptb-product-title a:hover {
    color: #0073aa;
}

.fptb-product-price {
    margin-bottom: 8px;
    font-weight: bold;
    font-size: 1.1em;
}

.fptb-product-price .amount {
    color: #77a464;
}

.fptb-product-price del {
    color: #999;
    font-weight: normal;
    margin-right: 5px;
}

.fptb-product-rating {
    margin-bottom: 8px;
}

.fptb-product-rating .star-rating {
    float: none;
    display: inline-block;
    margin: 0;
}

.fptb-product-sku,
.fptb-product-stock {
    margin-bottom: 5px;
    font-size: 0.9em;
}

.fptb-product-sku-label {
    font-weight: bold;
    color: #666;
}

.fptb-product-sku-value {
    color: #333;
}

.fptb-product-stock-in-stock {
    color: #7ad03a;
    font-weight: bold;
}

.fptb-product-stock-out-of-stock {
    color: #d63638;
    font-weight: bold;
}

.fptb-product-stock-onbackorder {
    color: #ffba00;
    font-weight: bold;
}

.fptb-product-short-description {
    margin-top: 10px;
    font-size: 0.9em;
    color: #666;
    line-height: 1.4;
    text-align: left;
}

.fptb-product-add-to-cart {
    margin-top: 10px;
}

.fptb-product-add-to-cart .button {
    padding: 8px 16px;
    font-size: 0.9em;
    border-radius: 4px;
    transition: all 0.2s ease-in-out;
}

.fptb-product-add-to-cart .button:hover {
    transform: translateY(-1px);
}

/* Image Cells */
.fptb-cell-type-image {
    text-align: center;
}

.fptb-cell-type-image img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}

/* Text Cells */
.fptb-cell-type-text {
    line-height: 1.6;
}

/* Error Messages */
.fptb-error {
    color: #d63638;
    background-color: #ffeaea;
    border: 1px solid #d63638;
    border-radius: 4px;
    padding: 10px;
    margin: 10px 0;
    text-align: center;
}

/* Responsive Table */
@media screen and (max-width: 768px) {
    .fptb-responsive {
        font-size: 0.9em;
    }
    
    .fptb-responsive th,
    .fptb-responsive td {
        padding: 8px;
    }
    
    .fptb-product {
        max-width: 150px;
    }
    
    .fptb-product-image img {
        max-width: 80px;
    }
    
    .fptb-product-title {
        font-size: 0.9em;
    }
    
    .fptb-product-price {
        font-size: 1em;
    }
}

@media screen and (max-width: 600px) {
    .fptb-responsive {
        display: block;
        width: 100%;
        overflow-x: auto;
        white-space: nowrap;
    }
    
    .fptb-responsive table {
        width: 100%;
        min-width: 600px;
    }
}

/* Alternative responsive approach for very small screens */
@media screen and (max-width: 480px) {
    .fptb-responsive.fptb-stack-mobile {
        display: block;
        width: 100%;
        overflow-x: visible;
        white-space: normal;
    }
    
    .fptb-responsive.fptb-stack-mobile table,
    .fptb-responsive.fptb-stack-mobile thead,
    .fptb-responsive.fptb-stack-mobile tbody,
    .fptb-responsive.fptb-stack-mobile th,
    .fptb-responsive.fptb-stack-mobile td,
    .fptb-responsive.fptb-stack-mobile tr {
        display: block;
    }
    
    .fptb-responsive.fptb-stack-mobile thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }
    
    .fptb-responsive.fptb-stack-mobile tr {
        border: 1px solid #ccc;
        margin-bottom: 10px;
        padding: 10px;
        border-radius: 4px;
        background: #fff;
    }
    
    .fptb-responsive.fptb-stack-mobile td {
        border: none;
        border-bottom: 1px solid #eee;
        position: relative;
        padding-left: 50%;
        white-space: normal;
        text-align: left;
        padding-top: 10px;
        padding-bottom: 10px;
    }
    
    .fptb-responsive.fptb-stack-mobile td:before {
        content: attr(data-label);
        position: absolute;
        left: 6px;
        width: 45%;
        padding-right: 10px;
        white-space: nowrap;
        text-align: left;
        font-weight: bold;
        color: #333;
    }
    
    .fptb-responsive.fptb-stack-mobile .fptb-product {
        align-items: flex-start;
        text-align: left;
        max-width: none;
    }
    
    .fptb-responsive.fptb-stack-mobile .fptb-product-image {
        margin-bottom: 5px;
    }
    
    .fptb-responsive.fptb-stack-mobile .fptb-product-image img {
        max-width: 60px;
    }
}

/* Loading States */
.fptb-loading {
    text-align: center;
    padding: 20px;
    color: #666;
}

.fptb-loading:before {
    content: "";
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #0073aa;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 10px;
    vertical-align: middle;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Print Styles */
@media print {
    .fptb-table-container {
        overflow: visible;
    }
    
    .fptb-table {
        border-collapse: collapse;
        width: 100%;
    }
    
    .fptb-table th,
    .fptb-table td {
        border: 1px solid #000;
        padding: 8px;
    }
    
    .fptb-product-add-to-cart {
        display: none;
    }
    
    .fptb-product-image img {
        max-width: 50px;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .fptb-table {
        background-color: #1a1a1a;
        color: #e0e0e0;
    }
    
    .fptb-table th {
        background-color: #2d2d2d;
        color: #e0e0e0;
    }
    
    .fptb-style-basic th,
    .fptb-style-basic td,
    .fptb-style-striped th,
    .fptb-style-striped td,
    .fptb-style-hover th,
    .fptb-style-hover td {
        border-color: #444;
    }
    
    .fptb-style-bordered {
        border-color: #444;
    }
    
    .fptb-style-bordered th,
    .fptb-style-bordered td {
        border-color: #444;
    }
    
    .fptb-style-striped tbody tr:nth-child(odd) {
        background-color: #2d2d2d;
    }
    
    .fptb-style-hover tbody tr:hover {
        background-color: #333;
    }
    
    .fptb-product-title a {
        color: #e0e0e0;
    }
    
    .fptb-product-title a:hover {
        color: #4a9eff;
    }
}

/* Accessibility */
.fptb-table:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

.fptb-table th {
    position: relative;
}

.fptb-table th[scope="col"]:after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background-color: #0073aa;
    opacity: 0;
    transition: opacity 0.2s;
}

.fptb-table th[scope="col"]:focus:after {
    opacity: 1;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .fptb-table {
        border: 2px solid #000;
    }
    
    .fptb-table th,
    .fptb-table td {
        border: 1px solid #000;
    }
    
    .fptb-product-title a {
        text-decoration: underline;
    }
}

