/**
 * Frontend Styles for WooCommerce Price Breakdown
 */

/* Quick Calculator */
.wpb-quick-calculator {
    flex: 1;
    padding: 20px;
    background: #f8f9fa;
    border: 1px solid #d1d5db;
    border-radius: 6px;
}

.wpb-quick-calculator label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #24292e;
    margin-bottom: 12px;
}

.wpb-calculator-form {
    display: flex;
    gap: 10px;
    align-items: center;
}

.wpb-qty-input {
    flex: 1;
    max-width: 200px;
    padding: 12px 14px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 14px;
    background: #fff;
    color: #333;
    transition: border-color 0.2s ease;
    height: 46px;
}

.wpb-qty-input::placeholder {
    color: #9ca3af;
}

.wpb-qty-input:hover {
    border-color: #9ca3af;
}

.wpb-qty-input:focus {
    border-color: #2563eb;
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.wpb-calculate-btn {
    padding: 12px 28px !important;
    background: #1f2937 !important;
    color: #fff !important;
    border: none !important;
    border-radius: 6px !important;
    font-size: 15px !important;
    font-weight: 700 !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    white-space: nowrap !important;
    position: relative !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25) !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    height: 46px !important;
}

.wpb-calculate-btn:hover {
    background: #111827 !important;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35) !important;
    transform: translateY(-2px) !important;
}

.wpb-calculate-btn:active {
    background: #030712 !important;
    transform: translateY(0) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3) !important;
}

.wpb-calculate-btn:disabled,
.wpb-calculate-btn.wpb-loading {
    background: #6b7280 !important;
    cursor: not-allowed !important;
    opacity: 0.8 !important;
    box-shadow: 0 2px 8px rgba(107, 114, 128, 0.3) !important;
}

.wpb-calculate-btn.wpb-loading:hover {
    background: #6b7280 !important;
    transform: translateY(0) !important;
    box-shadow: 0 2px 8px rgba(107, 114, 128, 0.3) !important;
}

/* Loading Spinner */
.wpb-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: wpb-spin 0.6s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}

@keyframes wpb-spin {
    to {
        transform: rotate(360deg);
    }
}

.wpb-calc-result {
    margin-top: 20px;
    margin-bottom: 30px;
    padding: 0;
    border-radius: 6px;
    animation: slideDown 0.4s ease;
    overflow: hidden;
    width: 100%;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.wpb-calc-success {
    background: #fff;
    border: 2px solid #10b981;
}

.wpb-calc-success .wpb-result-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: #10b981;
    color: #fff;
}

.wpb-calc-success .wpb-result-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.wpb-calc-success .wpb-result-header strong {
    font-size: 14px;
    font-weight: 600;
    margin: 0;
}

.wpb-calc-success .wpb-result-details {
    padding: 16px;
    background: #f0fdf4;
}

.wpb-calc-success .wpb-result-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
}

.wpb-calc-success .wpb-result-row:not(:last-child) {
    border-bottom: 1px solid #d1fae5;
}

.wpb-calc-success .wpb-result-label {
    font-size: 13px;
    color: #065f46;
    font-weight: 500;
}

.wpb-calc-success .wpb-result-value {
    font-size: 14px;
    color: #064e3b;
    font-weight: 600;
}

.wpb-calc-success .wpb-result-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    background: #fff;
    border-top: 2px solid #10b981;
}

.wpb-calc-success .wpb-result-total .wpb-result-label {
    font-size: 15px;
    color: #064e3b;
    font-weight: 700;
}

.wpb-calc-success .wpb-result-total .wpb-result-value {
    font-size: 18px;
    color: #10b981;
    font-weight: 700;
}

.wpb-calc-error {
    background: #fef2f2;
    border: 2px solid #ef4444;
    color: #991b1b;
    padding: 16px;
}

/* OR Separator */
.wpb-separator {
    display: flex;
    align-items: center;
    justify-content: center;
}

.wpb-separator span {
    display: inline-block;
    padding: 8px 12px;
    font-weight: 700;
    font-size: 12px;
    color: #6b7280;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* Common Table Styles */
.wpb-table-wrapper {
    margin: 20px 0;
}

.wpb-price-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    overflow: hidden;
}

.wpb-price-table thead {
    background: #f7f7f7;
}

.wpb-price-table thead th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    font-size: 14px;
    color: #333;
    border-bottom: 2px solid #e0e0e0;
}

.wpb-price-table tbody tr {
    transition: background-color 0.2s ease;
}

.wpb-price-table tbody tr:hover {
    background-color: #f9f9f9;
}

.wpb-price-table tbody tr:not(:last-child) {
    border-bottom: 1px solid #e0e0e0;
}

.wpb-price-table tbody td {
    padding: 12px 15px;
    font-size: 14px;
    color: #555;
}

.wpb-price-table tbody td .woocommerce-Price-amount {
    font-weight: 600;
    color: #333;
}

.wpb-table-note {
    margin-top: 15px;
    padding: 12px 15px;
    background: #f9f9f9;
    border-left: 4px solid #2c3e50;
    border-radius: 4px;
}

.wpb-table-note p {
    margin: 0;
    font-size: 13px;
    color: #666;
    line-height: 1.6;
}

.wpb-table-note::before {
    content: "* ";
    font-weight: 600;
}

/* Popup Trigger Container */
.wpb-popup-trigger-container {
    margin: 20px 0 60px 0;
}

.wpb-popup-trigger-wrapper {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 40px;
}

.wpb-popup-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    background: #fff;
    color: #333;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: 2px solid #333;
    border-radius: 6px;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.wpb-popup-trigger svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.wpb-expandable-trigger svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.wpb-popup-trigger:hover {
    background: #333;
    border-color: #333;
    color: #fff;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.wpb-popup-trigger:active {
    background: #1a1a1a;
    border-color: #1a1a1a;
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

/* Popup Modal */
.wpb-popup-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wpb-popup-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
}

.wpb-popup-content {
    position: relative;
    width: 90%;
    max-width: 700px;
    max-height: 80vh;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    animation: wpbSlideIn 0.3s ease-out;
}

@keyframes wpbSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.wpb-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 25px;
    border-bottom: 1px solid #e0e0e0;
    background: #f7f7f7;
}

.wpb-popup-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #333;
}

.wpb-popup-close {
    background: none;
    border: none;
    font-size: 32px;
    line-height: 1;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s ease, transform 0.2s ease;
    border-radius: 4px;
}

.wpb-popup-close:hover {
    color: #333;
    background: #e0e0e0;
    transform: rotate(90deg);
}

.wpb-popup-body {
    padding: 25px;
    max-height: calc(80vh - 80px);
    overflow-y: auto;
}

/* Expandable */
.wpb-expandable-wrapper {
    margin: 20px 0 60px 0;
}

.wpb-expandable-row {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 40px;
}

.wpb-expandable-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    background: #fff;
    color: #333;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: 2px solid #333;
    border-radius: 6px;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.wpb-expandable-trigger:hover {
    background: #333;
    border-color: #333;
    color: #fff;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.wpb-expandable-trigger:hover .wpb-toggle-icon {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.wpb-expandable-trigger:active {
    background: #1a1a1a;
    border-color: #1a1a1a;
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.wpb-toggle-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    background: #333;
    color: #fff;
    border-radius: 50%;
    font-size: 14px;
    font-weight: 700;
    transition: all 0.3s ease;
    line-height: 1;
}

.wpb-expandable-trigger.active {
    background: #333;
    border-color: #333;
    color: #fff;
}

.wpb-expandable-trigger.active .wpb-toggle-icon {
    transform: rotate(45deg);
    background: rgba(255, 255, 255, 0.3);
}

.wpb-expandable-content {
    overflow: hidden;
    transition: max-height 0.4s ease, opacity 0.3s ease;
    max-height: 0;
    opacity: 0;
}

.wpb-expandable-content.active {
    max-height: 2000px;
    opacity: 1;
}

/* Always Visible */
.wpb-always-visible-wrapper {
    margin: 25px 0 60px 0;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.wpb-always-visible-wrapper .wpb-quick-calculator {
    margin-bottom: 25px;
    background: #fff;
}

.wpb-always-visible-wrapper .wpb-table-title {
    margin: 0 0 15px 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

/* Ensure SKU and Product Meta are Always Visible */
.product_meta,
.sku_wrapper,
.product .sku_wrapper,
.woocommerce div.product .product_meta {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.product_meta .sku,
.sku_wrapper .sku {
    display: inline !important;
    visibility: visible !important;
}

/* Custom Price Display */
.wpb-custom-price {
    margin: 10px 0;
    display: block;
    clear: both;
}

.wpb-custom-price .wpb-lowest-price {
    font-size: 28px;
    font-weight: 700;
    color: #2c3e50;
    display: inline-block;
}

.wpb-custom-price .wpb-qty-info {
    font-size: 16px;
    color: #666;
    margin-left: 5px;
    display: inline-block;
}

.wpb-custom-price .wpb-min-qty {
    margin-top: 8px;
    font-size: 14px;
    color: #666;
    display: block;
    clear: both;
}

.wpb-custom-price .wpb-min-qty-value,
.wpb-custom-price .wpb-min-qty-price {
    font-weight: 600;
    color: #333;
}

/* Spacing between price and product meta */
.woocommerce div.product .wpb-custom-price + .product_meta,
.woocommerce div.product p.price:has(.wpb-custom-price) + .product_meta {
    margin-top: 20px;
}

/* Ensure SKU on Archive/Loop Products */
.woocommerce ul.products li.product .sku_wrapper,
.woocommerce-loop-product .sku_wrapper {
    display: block !important;
    visibility: visible !important;
    margin: 5px 0;
}

/* Custom Price on Archive Pages (Shop/Category) */
.woocommerce-loop-product__title + .price .wpb-custom-price,
.woocommerce ul.products li.product .price .wpb-custom-price {
    margin: 5px 0;
    display: block;
}

.woocommerce ul.products li.product .price .wpb-custom-price .wpb-lowest-price {
    font-size: 20px;
    display: block;
}

.woocommerce ul.products li.product .price .wpb-custom-price .wpb-qty-info {
    font-size: 13px;
    color: #888;
}

.woocommerce ul.products li.product .price .wpb-custom-price .wpb-min-qty {
    margin-top: 6px;
    font-size: 12px;
    color: #888;
    line-height: 1.4;
}

.woocommerce ul.products li.product .price .wpb-custom-price .wpb-min-qty-value,
.woocommerce ul.products li.product .price .wpb-custom-price .wpb-min-qty-price {
    font-weight: 600;
    color: #555;
}

/* Responsive */
@media screen and (max-width: 768px) {
    .wpb-popup-trigger-wrapper,
    .wpb-expandable-row {
        flex-direction: column;
        gap: 15px;
    }

    .wpb-separator {
        display: none;
    }

    .wpb-quick-calculator {
        padding: 16px;
        width: 100%;
    }

    .wpb-popup-trigger,
    .wpb-expandable-trigger {
        width: 100%;
        justify-content: center;
    }

    .wpb-quick-calculator label {
        font-size: 13px;
        margin-bottom: 10px;
    }

    .wpb-calculator-form {
        flex-direction: column;
        gap: 8px;
    }

    .wpb-qty-input {
        max-width: 100%;
        padding: 10px 12px;
    }

    .wpb-calculate-btn {
        width: 100%;
        padding: 10px 20px !important;
    }

    .wpb-calc-result {
        margin-top: 15px;
    }

    .wpb-calc-success .wpb-result-header {
        padding: 12px 14px;
    }

    .wpb-calc-success .wpb-result-header strong {
        font-size: 13px;
    }

    .wpb-calc-success .wpb-result-details {
        padding: 14px;
    }

    .wpb-calc-success .wpb-result-label {
        font-size: 12px;
    }

    .wpb-calc-success .wpb-result-value {
        font-size: 13px;
    }

    .wpb-calc-success .wpb-result-total {
        padding: 12px 14px;
    }

    .wpb-calc-success .wpb-result-total .wpb-result-label {
        font-size: 14px;
    }

    .wpb-calc-success .wpb-result-total .wpb-result-value {
        font-size: 16px;
    }

    .wpb-popup-content {
        width: 95%;
        max-height: 90vh;
    }

    .wpb-popup-header {
        padding: 15px 20px;
    }

    .wpb-popup-header h3 {
        font-size: 18px;
    }

    .wpb-popup-body {
        padding: 20px;
    }

    .wpb-price-table {
        font-size: 13px;
    }

    .wpb-price-table thead th {
        padding: 10px;
        font-size: 13px;
    }

    .wpb-price-table tbody td {
        padding: 10px;
        font-size: 13px;
    }

    .wpb-always-visible-wrapper {
        padding: 15px;
    }
}

@media screen and (max-width: 480px) {
    .wpb-price-table {
        font-size: 12px;
    }

    .wpb-price-table thead th,
    .wpb-price-table tbody td {
        padding: 8px;
    }

    .wpb-custom-price .wpb-lowest-price {
        font-size: 24px;
    }
}

/* Accessibility */
.wpb-popup-modal:focus-within .wpb-popup-close {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .wpb-popup-modal {
        position: static;
    }

    .wpb-popup-overlay {
        display: none;
    }

    .wpb-popup-content {
        max-width: 100%;
        box-shadow: none;
    }

    .wpb-popup-close {
        display: none;
    }
}
