/**
 * KB Quantity Discount Table - Frontend Styles
 *
 * @author    Starter
 * @copyright 2024
 * @license   http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */

/* Discount Table Wrapper */
.kbqd-discount-table-wrapper {
    margin: 20px 0;
    padding: 0;
}

.kbqd-discount-table-wrapper.kbqd-tab-content {
    margin: 0;
    padding: 15px 0;
}

.kbqd-title {
    margin: 0 0 10px 0;
    padding: 0;
    font-size: 1rem;
    font-weight: 600;
    color: #232323;
}

/* Main Discount Table */
.kbqd-table {
    width: 100%;
    border-collapse: collapse;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    font-size: 0.9rem;
}

.kbqd-table thead th {
    background-color: var(--kbqd-header-bg, #2ecc71);
    color: var(--kbqd-header-text, #ffffff);
    padding: 12px 15px;
    text-align: center;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kbqd-table tbody td {
    padding: 10px 15px;
    text-align: center;
    border-bottom: 1px solid #eee;
}

.kbqd-table tbody tr.odd {
    background-color: var(--kbqd-row-odd, #ffffff);
}

.kbqd-table tbody tr.even {
    background-color: var(--kbqd-row-even, #f9f9f9);
}

.kbqd-table tbody tr:last-child td {
    border-bottom: none;
}

.kbqd-table tbody tr:hover {
    background-color: #f0f8ff;
}

/* Cell Specific Styles */
.kbqd-quantity {
    font-weight: 600;
    color: #333;
}

.kbqd-discount {
    font-weight: 700;
    color: #e74c3c;
}

.kbqd-savings {
    color: #27ae60;
    font-weight: 500;
}

/* ================================
   Listing Page Styles
   ================================ */

.kbqd-listing-wrapper {
    position: relative;
    margin-top: 8px;
    text-align: center;
}

.kbqd-view-discounts-btn {
    display: inline-block;
    padding: 6px 12px;
    background-color: #2ecc71;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.kbqd-view-discounts-btn:hover {
    background-color: #27ae60;
    transform: translateY(-1px);
}

.kbqd-view-discounts-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(46, 204, 113, 0.3);
}

/* Popup Styles */
.kbqd-popup {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    margin-bottom: 10px;
}

.kbqd-popup-content {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    min-width: 200px;
    overflow: hidden;
}

.kbqd-popup-content::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid #fff;
}

.kbqd-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background-color: var(--kbqd-header-bg, #2ecc71);
    color: var(--kbqd-header-text, #ffffff);
}

.kbqd-popup-title {
    font-weight: 600;
    font-size: 0.85rem;
}

.kbqd-popup-close {
    background: none;
    border: none;
    color: inherit;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    opacity: 0.8;
}

.kbqd-popup-close:hover {
    opacity: 1;
}

/* Mini Table in Popup */
.kbqd-table-mini {
    font-size: 0.8rem;
    box-shadow: none;
    border-radius: 0;
}

.kbqd-table-mini thead th {
    padding: 8px 12px;
    font-size: 0.75rem;
}

.kbqd-table-mini tbody td {
    padding: 6px 12px;
}

/* ================================
   Responsive Styles
   ================================ */

@media (max-width: 767px) {
    .kbqd-table thead th,
    .kbqd-table tbody td {
        padding: 8px 10px;
        font-size: 0.8rem;
    }

    .kbqd-popup {
        left: 0;
        right: 0;
        transform: none;
    }

    .kbqd-popup-content {
        min-width: 100%;
    }
}

@media (max-width: 480px) {
    .kbqd-table {
        font-size: 0.8rem;
    }

    .kbqd-table thead th {
        padding: 8px 6px;
        font-size: 0.7rem;
    }

    .kbqd-table tbody td {
        padding: 8px 6px;
    }
}

/* ================================
   Animation
   ================================ */

.kbqd-popup {
    animation: kbqdFadeIn 0.2s ease;
}

@keyframes kbqdFadeIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* Active State for Listing Button */
.kbqd-view-discounts-btn.active {
    background-color: #27ae60;
}
