.product-table-section {
    padding: .8rem 1rem;
}
.products-table {
    display: none; /* Hide the table view by default */
}
.product-cards {
    display: grid; /* Display cards as a grid on small screens */
    grid-template-columns: 1fr;
    gap: 1rem;
}
.product-card {
    background-color: var(--card-bg); /* Match the dark card background color */
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.card-header {
    display: flex;
    align-items: center;
    margin-bottom: 1rem; 
}

.card-header img {
    width: 26px; /* Make the icon larger */
    height: auto;
    margin-right: 0.75rem;
}

.card-header h3 {
    margin: 0;
    font-size: 1.1rem; /* Adjust font size */
    font-weight: 500;
    color: var(--text-white);
}

.product-details {
    display: grid;
    grid-template-columns: 1fr; /* Two columns for details */
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.product-details .detail-row-lrg {
    display: none;
    flex-direction: row;
}
.product-details .detail-row-sm {
    display: flex;
    flex-direction: row;
}
.product-details .detail-column {
    margin: 0;
    display: flex;
    flex-direction: column;
    color: var(--text-light-gray);
    font-size: 0.9rem;
}
.product-details .detail-row-sm:last-child .detail-column {
    display: flex;
    flex-direction: row;
    padding-right: 25px;
}
.product-details .detail-row-sm:last-child .detail-column span:last-child {
    padding-left: 10px;
}
.product-details p:nth-of-type(3),
.product-details p:nth-of-type(4) {
    grid-column: span 1; /* Ensure these also take one column */
}

.product-details span {
    color: var(--text-white); /* Match the bright text color for values */
    font-weight: 900;
}

.btns-row {
    display: grid;
    grid-template-columns: 1fr;
    grid-gap: 10px;
    margin-top: 10px;
}
.buy-card-btn {
    border: none;
    border-radius: 20px;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    cursor: pointer;
    align-self: flex-start; /* Align button to the left */
}
.stick-button {
    /* Button styling based on the image */
    background-color: #272727;
    color: #d1d1d1;
    padding: 0.75rem .3rem;
    border-radius: 25px; /* Creates the pill shape */
    border: none;
    box-shadow: none;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
}
/* Media Queries */


a.product-permalink {
    color: var(--text-white);
    text-decoration: none;
}
/* Tablet view (769px to 1024px) */
@media (min-width: 591px) {
    .product-details .detail-row-sm:last-child .detail-column {
        padding-right: 50px;
    }
}

/* Tablet view (769px to 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    .product-cards {
        grid-template-columns: 1fr 1fr; /* Two columns for tablet view */
        gap: 20px;
        padding: 0;
    }
    .product-details .detail-row-sm:last-child .detail-column {
        padding-right: 25px;
    }
}

/* Phone view (up to 768px) */
@media (max-width: 768px) {
    .product-cards {
        grid-template-columns: 1fr; /* One column for phone view */
        padding: 0;
    }
}
@media (min-width: 1025px) {
    .product-details .detail-row-sm {
        display: none;
    }
    .product-details .detail-row-lrg {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 1rem;
    }
}
/* This media query ensures the table is only shown on desktop */
@media (min-width: 1225px) {
    .product-table-section {
        padding: 2rem 3rem;
    }
    .table-container {
        background-color: var(--card-bg);
        border-radius: 20px;
        padding: 1.5rem;
    }
    .products-table {
        display: flex; 
        flex-flow: column nowrap;
        width: 100%;
    }
    .product-cards {
        display: none;
    }
    .table-container {
        background-color: var(--card-bg);
        border-radius: 20px;
        padding: 1rem 1.5rem;
    }
    .grid-header {
        display: grid; 
        grid-template-columns: 1.5fr 1.5fr 1fr 1fr 1fr 1fr;
        font-weight: 500;
        color: var(--text-light-gray); /* Light gray for headers */
        border-bottom: 1px solid var(--table-border); /* Darker border for separation */
        padding-bottom: 1rem;
    }
    .grid-header .grid-cell {
        padding: 1rem 0;
    }
    .product-row {
        display: grid; 
        grid-template-columns: 1.5fr 1.5fr 1fr 1fr 1fr 1fr;
        border-bottom: 1px solid var(--table-border);
        color: var(--text-white); /* Light text color for rows */
    }
    .product-row:hover {
        background-color: var(--table-row-hover-bg);
        color: var(--card-text);
    }

    .product-row:last-child {
        border-bottom: none;
    }
    .grid-header .column {
        display: flex;
        align-items: center;
        padding: 1rem .8rem;
        box-sizing: border-box;
    }
    .product-row .column {
        display: flex;
        align-items: center;
        padding: 1rem .8rem;
        box-sizing: border-box;
    }
    
    /* Center the buy button */
    .buy-col {
        justify-content: flex-end; /* Align button to the end of the cell */
    }

    .buy-btn {
        border: none;
        border-radius: 20px;
        padding: 0.5rem 1.5rem;
        cursor: pointer;
        font-weight: 600;
        float: none; /* Remove float */
    }
    .in-stock-col .stock-text {
        display: block; /* Show the text on desktop */
    }

    .in-stock-col .stock-btn {
        display: none; /* Hide the button on desktop */
    }
    

    .product-icon {
        width: 1.2rem;
        height: 1.2rem;
        margin-right: 0.5rem;
        vertical-align: middle;
    }
}

html {
    scroll-behavior: smooth;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--modal-backdrop-bg, rgba(0, 0, 0, 0.8));
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: opacity 0.3s ease-in-out;
    opacity: 0;
    pointer-events: none;
    padding: 16px;
    box-sizing: border-box;
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background-color: var(--card-bg, #1a1a1a);    
    color: var(--modal-text, #e0e0e0);
    box-shadow: rgba(0, 0, 0, 0.3) 0px 0.5rem 2rem;
    border: 1px solid var(--modal-border, rgba(255, 255, 255, 0.1));
    border-radius: var(--modal-border-radius, 12px);
    width: 100%;
    max-width: 420px;
    max-height: calc(100vh - 32px);
    padding: 20px;
    position: relative;
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
    overflow-y: auto;
    box-sizing: border-box;
}

.modal-content h2 {
    font-size: 1.1rem !important;
    color: inherit;
    font-weight: 700 !important;
    margin-bottom: 0 !important;
}

.modal-overlay.open .modal-content {
    transform: scale(1);
}

.btn-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    color: var(--text-white, #fff);
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    padding: 4px;
    transition: color 0.2s ease-in-out;
    z-index: 10;
}

.btn-close:hover {
    color: #F5F5F5;
}

#confirmPurchaseButton {
    padding: 0.6rem 1.2rem;
    border-radius: 25px;
    cursor: pointer;
    transition: background-color 0.3s ease, color 0.3s ease;
    width: 100%;
    border: none;
    margin-bottom: 0 !important;
    font-size: 0.95rem;
    background-color: var(--primary-green, #4CAF50);
    color: white;
    text-decoration: none;
    display: block;
    text-align: center;
}

#confirmPurchaseButton:hover {
    opacity: 0.9;
}

.form-input-div {
    margin-bottom: 0.8rem !important;
}

.label-wrapper {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.4rem !important;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-light-gray, #757575);
}

.form-input {
    width: 100%;
    background-color: var(--bg-dark, #2a2a2a);
    border: 1px solid var(--bg-dark, #2a2a2a);
    color: #E0E0E0;
    padding: 8px 12px;
    border-radius: 25px;
    outline: none;
    transition: border-color 0.2s;
    text-align: left;
    font-size: 0.9rem;
    box-sizing: border-box;
}

.form-input:focus {
    border-color: var(--primary-green, #4CAF50);
}

.product-info-display {
    background-color: var(--bg-dark, #2a2a2a);
    border-radius: 25px;
    padding: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.product-icon {
    width: 36px;
    height: 36px;
    border-radius: 4px;
    object-fit: cover;
}

.purchase-summary-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
    font-size: 0.85rem;
}

.purchase-summary-row span:last-child {
    font-weight: 500;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-right: 20px;
}

.modal-header h2 {
    font-size: 1.1rem;
    font-weight: bold;
    color: #F5F5F5;
    margin: 0;
}

.quantity-section {
    margin-bottom: 12px;
}

.quantity-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.price-summary-section {
    margin-bottom: 12px;
    padding-top: 8px;
    border-top: 1px solid #424242;
}

.total-row {
    font-weight: bold;
    font-size: 0.9rem;
    padding-top: 6px;
    border-top: 1px solid #555;
    margin-top: 4px;
}

/* Coupon styles - compacted */
.coupon-input-wrapper {
    display: grid; 
    grid-template-columns: 1fr 120px; 
    grid-gap: 10px;
}
.want-coupon-link {
    display: flex;
    justify-content: space-between;
    margin-top: 4px;
    margin-left: 6px;
    gap: 10px;
}

.btn-coupon-apply {
    width: 120px;
    padding: 8px 10px;
    font-size: 0.8rem;
    margin-bottom: 0;
    border-radius: 25px;
    background-color: var(--primary-green, #4CAF50);
    color: white;
    border: none;
    cursor: pointer;
}

.want-coupon-link {
    color: var(--btn-primary-bg, #4CAF50);
    text-decoration: none;
    font-size: 0.75rem;
    font-weight: 500;
    text-align: left;
}

.want-coupon-link:hover {
    text-decoration: underline;
}

.coupon-message {
    margin-top: 6px;
    padding: 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    display: none;
}

.coupon-message.success {
    background: rgba(46, 204, 113, 0.2);
    color: #2ecc71;
    border: 1px solid #2ecc71;
}

.coupon-message.error {
    background: rgba(231, 76, 60, 0.2);
    color: #e74c3c;
    border: 1px solid #e74c3c;
}

#couponDiscountRow {
    color: var(--primary-green, #4CAF50);
}

/* Payment method styles - compacted */
.payment-method-header {
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-white, #fff);
}

.payment-method-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.payment-option-card {
    flex: 1;
    background-color: var(--card-bg, #1a1a1a);
    color: var(--text-white, #fff);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 10px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
}

.payment-option-card.active {
    border-color: var(--primary-green, #4CAF50);
    box-shadow: 0 0 0 1px var(--primary-green, #4CAF50), 0 0 15px rgba(76, 175, 80, 0.2);
}

.payment-option-card:hover {
    transform: translateY(-1px);
    border-color: rgba(255, 255, 255, 0.2);
}

.payment-option-card:hover.active {
    border-color: var(--primary-green, #4CAF50);
}

.payment-option-icon {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.payment-option-card p {
    font-size: 0.85rem;
    margin: 0;
    font-weight: 500;
    color: var(--text-white, #fff);
    line-height: 1.2;
}

/* Selection indicator */
.payment-option-card::after {
    content: '';
    position: absolute;
    top: 6px;
    right: 6px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
    transition: all 0.2s ease-in-out;
}

.payment-option-card.active::after {
    background-color: var(--primary-green, #4CAF50);
    border-color: var(--primary-green, #4CAF50);
    box-shadow: inset 0 0 0 2px var(--card-bg, #1a1a1a);
}

/* Error message styles */
.stock-warning,
.email-warning {
    color: #e74c3c;
    font-size: 0.75rem;
    margin-top: 4px;
    padding: 4px 6px;
    /* background: rgba(231, 76, 60, 0.1);
    border: 1px solid rgba(231, 76, 60, 0.3); */
    border-radius: 4px;
    display: none;
}

/* Mobile optimizations */
@media (max-width: 640px) {
    .modal-overlay {
        padding: 8px;
        align-items: center;
        justify-content: center;
    }
    
    .modal-content {
        max-width: 100%;
        padding: 12px;
        max-height: calc(100vh - 20px);
        border-radius: 8px;
        min-height: auto;
    }

    .modal-header {
        margin-bottom: 8px;
        padding-right: 16px;
    }

    .modal-header h2 {
        font-size: 0.9rem !important;
    }

    .btn-close {
        font-size: 1.1rem;
        top: 6px;
        right: 6px;
    }

    .form-input-div {
        margin-bottom: 0.5rem !important;
    }

    .label-wrapper {
        margin-bottom: 0.25rem !important;
        font-size: 0.7rem;
    }

    .form-input {
        padding: 6px 10px;
        font-size: 0.8rem;
        height: auto;
    }

    .product-info-display {
        padding: 6px 8px;
        margin-bottom: 8px;
    }

    .product-icon {
        width: 28px;
        height: 28px;
    }

    .purchase-summary-row {
        font-size: 0.75rem;
        margin-bottom: 2px;
    }

    .total-row {
        font-size: 0.8rem;
        margin-top: 2px;
        padding-top: 4px;
    }

    .price-summary-section {
        margin-bottom: 8px;
        padding-top: 6px;
    }

    .payment-method-header {
        margin-top: 0.6rem;
        margin-bottom: 0.4rem;
        font-size: 0.8rem;
    }

    #confirmPurchaseButton {
        padding: 0.6rem 0.8rem;
        font-size: 0.85rem;
    }

    .coupon-input-wrapper {
        grid-template-columns: 1fr 100px; 
    }

    .coupon-actions {
        margin-top: 2px;
    }

    .btn-coupon-apply {
        width: 100px;
        font-size: 0.75rem;
        padding: 6px 8px;
    }

    .want-coupon-link {
        font-size: 0.7rem;
        margin-top: 2px;
    }

    .payment-method-options {
        gap: 4px;
    }

    .payment-option-card {
        padding: 6px 8px;
        gap: 6px;
    }

    .payment-option-icon {
        width: 24px;
        height: 24px;
    }

    .payment-option-card p {
        font-size: 0.75rem;
        line-height: 1.1;
    }

    .coupon-message {
        margin-top: 4px;
        padding: 4px;
        font-size: 0.7rem;
    }

    .stock-warning,
    .email-warning {
        font-size: 0.7rem !important;
        margin-top: 3px !important;
        padding: 3px 5px !important;
    }
}

/* Tablet optimizations */
@media (min-width: 641px) and (max-width: 1024px) {
    .modal-content {
        max-width: 460px;
        padding: 24px;
    }
    
    .payment-method-options {
        flex-direction: row;
        gap: 12px;
    }
}

/* Desktop optimizations */
@media (min-width: 1025px) {     
    .modal-content {
        max-width: 480px;
        padding: 28px;
    }
    
    .payment-method-options {
        flex-direction: row;
        justify-content: space-between;
        gap: 16px;
    }
}

/* Ensure scrollbar is styled on webkit browsers */
.modal-content::-webkit-scrollbar {
    width: 6px;
}

.modal-content::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.modal-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

.modal-content::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}
