/* Custom CSS for Frontend Shop Pages */

/* Product Grid Layout */
.cs-products-grid {
    display: grid;
    /* This uses a CSS variable --grid-columns set in cs-shortcodes.php via inline style */
    grid-template-columns: repeat(var(--grid-columns, 3), 1fr); /* Default to 3 columns if variable not set */
    gap: 20px;
    margin-bottom: 30px;
}

/* Product Card Styling */
.cs-product-card {
    border: 1px solid #eee;
    padding: 15px;
    text-align: center;
    background-color: #fff;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
}
.cs-product-card img {
    max-width: 100%;
    height: 200px; /* Fixed height for consistency */
    object-fit: contain; /* Ensure image fits without cropping */
    margin-bottom: 10px;
}
.cs-product-card h2 { /* Changed from h3 to h2 as per shortcode output */
    font-size: 1.2em;
    margin-bottom: 5px;
    min-height: 2.4em; /* Consistent height for titles */
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.cs-product-card p.price {
    font-size: 1.1em;
    font-weight: bold;
    color: #28a745;
    margin-bottom: 10px;
}
.cs-product-card .cs-actions {
    margin-top: auto; /* Push buttons to the bottom */
}
.cs-product-card .cs-actions button {
    background-color: #007bff; /* Changed from #49ce69 to #007bff for consistency */
    color: white;
    border: none;
    padding: 10px 15px;
    cursor: pointer;
    border-radius: 4px;
    font-size: 0.9em;
    width: 100%;
    margin-bottom: 5px;
    transition: background-color 0.3s ease;
}
.cs-product-card .cs-actions button.add-to-cart {
    background-color: #28a745;
}
.cs-product-card .cs-actions button:hover {
    opacity: 0.9;
}


/* Pagination */
.cs-pagination {
    text-align: center;
    margin-top: 20px;
}
.cs-pagination a, .cs-pagination span {
    display: inline-block;
    padding: 8px 12px;
    margin: 0 5px;
    border: 1px solid #ccc;
    text-decoration: none;
    color: #333;
    border-radius: 4px;
}
.cs-pagination span.current {
    background-color: #007bff;
    color: white;
    border-color: #007bff;
}


/* Single Product Detail Page Styling (from cs-single-product.php) */
.cs-single-product-container {
    display: flex;
    flex-wrap: wrap; /* Allows wrapping on smaller screens */
    gap: 30px;
    padding: 20px;
    background-color: #fff;
    border: 1px solid #eee;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.cs-single-product-image {
    flex: 1; /* Takes equal space */
    min-width: 300px; /* Minimum width before wrapping */
    max-width: 500px;
    text-align: center;
}
.cs-single-product-image img {
    max-width: 100%;
    height: auto;
    border: 1px solid #ddd;
    padding: 5px;
}
.cs-single-product-details {
    flex: 2; /* Takes more space */
    min-width: 300px; /* Minimum width before wrapping */
}
.cs-single-product-details h2 {
    font-size: 2em;
    margin-top: 0;
    margin-bottom: 15px;
}
.cs-single-product-details .price {
    font-size: 1.8em;
    font-weight: bold;
    color: #28a745;
    margin-bottom: 20px;
}
.cs-single-product-details .description {
    font-size: 1.1em;
    line-height: 1.6;
    margin-bottom: 20px;
}
.cs-single-product-details .cs-actions button {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 12px 25px;
    cursor: pointer;
    border-radius: 5px;
    font-size: 1.1em;
    margin-right: 10px;
    transition: background-color 0.3s ease;
}
.cs-single-product-details .cs-actions button.add-to-cart {
    background-color: #28a745;
}
.cs-single-product-details .cs-actions button:hover {
    opacity: 0.9;
}


/* Cart Button in Header (from previous instructions) */
.cs-cart-button-wrapper {
    display: inline-block;
    vertical-align: middle;
    margin-left: 60px;
    margin-top: 17px;
}
.cs-cart-button {
    display: flex;
    align-items: center;
    background-color: #f0f0f0; /* Light gray background */
    border: 1px solid #ccc;
    padding: 8px 15px;
    border-radius: 25px; /* Pill shape */
    text-decoration: none;
    color: #333;
    font-size: 1em;
    transition: background-color 0.3s ease;
    padding: 7px 35px 15px 35px;
}
.cs-cart-button:hover {
    background-color: #e0e0e0;
}
.cs-cart-button .dashicons-cart {
    font-size: 1.5em;
    margin-right: 8px;
    color: #28a745;
}
.cs-cart-count {
    background-color: #dc3545; /* Red badge */
    color: white;
    font-size: 0.75em;
    padding: 3px 7px;
    border-radius: 50%;
    margin-right: 10px;
    line-height: 1; /* For vertical alignment */
}
.cs-cart-text {
    font-weight: bold;
    padding: 7px 0px 0px 20px;
}

/* Loading state for cart button */
.cs-cart-button-wrapper.loading .cs-cart-button {
    opacity: 0.7;
    cursor: progress;
}

/* --- Checkout Page Specific Styles --- */
.cs-checkout-page-container {
    background-color: #fff;
    border: 1px solid #eee;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    padding: 30px;
    margin-bottom: 30px;
}

.cs-checkout-page-container h1 {
    font-size: 2.5em;
    margin-bottom: 25px;
    text-align: center;
    color: #333;
}

.cs-checkout-section {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid #eee;
}

.cs-checkout-section h2 {
    font-size: 1.8em;
    margin-top: 0;
    margin-bottom: 15px;
    color: #555;
}

.cs-checkout-cart-table, .cs-checkout-profile-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.cs-checkout-cart-table th, .cs-checkout-cart-table td,
.cs-checkout-profile-table th, .cs-checkout-profile-table td {
    border: 1px solid #ddd;
    padding: 12px;
    text-align: left;
    vertical-align: top;
}

.cs-checkout-cart-table th {
    background-color: #f9f9f9;
    font-weight: bold;
}

.cs-checkout-cart-table tfoot td {
    background-color: #f2f2f2;
    font-weight: bold;
}

.cs-checkout-cart-table .text-right {
    text-align: right;
}

.cs-checkout-profile-table th {
    width: 30%;
    background-color: #f9f9f9;
    font-weight: normal;
    color: #666;
}

.cs-profile-note {
    font-size: 0.9em;
    color: #777;
    margin-top: 15px;
}

.cs-checkout-actions {
    text-align: center;
    padding-top: 20px;
}

.cs-checkout-actions .button {
    padding: 15px 40px;
    font-size: 1.2em;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    background-color: #28a745; /* Green for checkout */
    border-color: #28a745;
    color: white;
}

.cs-checkout-actions .button:hover {
    background-color: #218838; /* Darker green on hover */
    border-color: #1e7e34;
}

/* Warning/Notice for incomplete profile */
.notice.notice-warning {
    border-left-color: #ffb300;
    margin-top: 20px;
    padding: 10px 15px;
    background-color: #fffbe6;
    border: 1px solid #ffeb3b;
    color: #616161;
}
.notice.notice-warning ul {
    list-style: disc;
    margin-left: 20px;
    margin-bottom: 10px;
}
.notice.notice-warning p {
    margin: 0 0 5px 0;
}


/* Basic styling for the cart page table */
.cs-cart-page-wrapper {
    max-width: 960px;
    margin: 20px auto;
    padding: 20px;
    background-color: #fff;
}


.cs-cart-page-wrapper h2 {
    text-align: center;
    margin-bottom: 25px;
    color: #333;
}

.cs-cart-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.cs-cart-table th,
.cs-cart-table td {
    border: 1px solid #eee;
    padding: 12px 15px;
    text-align: left;
}

.cs-cart-table th {
    background-color: #f5f5f5;
    font-weight: bold;
    color: #555;
}

.cs-cart-table tbody tr:nth-child(even) {
    background-color: #f9f9f9;
}

.cs-cart-product-name {
    width: 40%;
}

.cs-cart-product-price,
.cs-cart-product-subtotal {
    width: 15%;
    white-space: nowrap; /* Prevents wrapping for prices */
}

.cs-cart-product-quantity {
    width: 20%;
}

.cs-cart-quantity-input {
    width: 60px;
    padding: 5px;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-align: center;
}

.cs-cart-product-remove {
    width: 10%;
    text-align: center;
}

.cs-remove-from-cart-btn {
    background-color: #dc3545;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85em;
    transition: background-color 0.2s ease;
}

.cs-remove-from-cart-btn:hover {
    background-color: #c82333;
}

.cs-cart-totals {
    text-align: right;
    font-size: 1.2em;
    margin-bottom: 20px;
    padding-top: 10px;
    border-top: 1px solid #eee;
}

.cs-cart-actions {
    text-align: right;
}

.cs-cart-actions .button {
    margin-left: 10px;
    padding: 10px 20px;
    border-radius: 4px;
    text-decoration: none;
    display: inline-block;
}

.cs-continue-shopping-btn {
    background-color: #6c757d;
    color: white;
    border: none;
}

.cs-continue-shopping-btn:hover {
    background-color: #5a6268;
}

#cs-proceed-to-checkout-btn {
    background-color: #007bff;
    color: white;
    border: none;
}

#cs-proceed-to-checkout-btn:hover {
    background-color: #0056b3;
}

/* Loading state for cart button */
.cs-cart-button-wrapper.loading .dashicons-cart {
    animation: spin 1s infinite linear;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.cs-cart-button {
    display: flex;
    align-items: center;
    color: inherit; /* Inherit color from theme for better integration */
    text-decoration: none;
}

.cs-cart-button .dashicons-cart {
    font-size: 1.5em; /* Adjust size as needed */
    margin-right: 5px;
}

.cs-cart-count {
    background-color: red; /* Example styling */
    color: white;
    border-radius: 50%;
    padding: 2px 6px;
    font-size: 0.8em;
    margin-left: 3px;
    min-width: 20px;
    text-align: center;
}

/* Basic styling for disabled buttons */
.button[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
}


/* Responsive adjustments */
@media (max-width: 1024px) {
.cs-cart-button-wrapper {
    margin-top: 0px;
}   
}

@media (max-width: 768px) {
    .cs-single-product-container {
        flex-direction: column;
        gap: 20px;
    }
    .cs-single-product-image,
    .cs-single-product-details {
        min-width: unset;
        width: 100%;
    }
    .cs-single-product-details .cs-actions button {
        width: calc(50% - 5px); /* Half width on small screens */
        margin-right: 0;
        margin-bottom: 10px;
    }
    .cs-single-product-details .cs-actions button:first-child {
           margin-right: 10px;
    }

    /* Adjust product grid columns for smaller screens */
    .cs-products-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    }

    /* Checkout table responsiveness */
    .cs-checkout-cart-table, .cs-checkout-profile-table {
        display: block;
        width: 100%;
    }
    .cs-checkout-cart-table thead, .cs-checkout-cart-table tbody, .cs-checkout-cart-table tr, .cs-checkout-cart-table th, .cs-checkout-cart-table td,
    .cs-checkout-profile-table thead, .cs-checkout-profile-table tbody, .cs-checkout-profile-table tr, .cs-checkout-profile-table th, .cs-checkout-profile-table td {
        display: block;
    }
    .cs-checkout-cart-table thead tr, .cs-checkout-profile-table thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }
    .cs-checkout-cart-table tr, .cs-checkout-profile-table tr {
        border: 1px solid #ddd;
        margin-bottom: 10px;
    }
    .cs-checkout-cart-table td, .cs-checkout-profile-table td {
        border: none;
        border-bottom: 1px solid #eee;
        position: relative;
        padding-left: 50%;
        text-align: right;
    }
    .cs-checkout-cart-table td:before, .cs-checkout-profile-table td:before {
        position: absolute;
        top: 6px;
        left: 6px;
        width: 45%;
        padding-right: 10px;
        white-space: nowrap;
        text-align: left;
        font-weight: bold;
    }
    .cs-checkout-cart-table td:nth-of-type(1):before { content: "Product"; }
    .cs-checkout-cart-table td:nth-of-type(2):before { content: "Quantity"; }
    .cs-checkout-cart-table td:nth-of-type(3):before { content: "Price"; }
    .cs-checkout-cart-table td:nth-of-type(4):before { content: "Subtotal"; }
    .cs-checkout-profile-table td:nth-of-type(1):before { content: "Kanji Name:"; }
    .cs-checkout-profile-table td:nth-of-type(2):before { content: "Furigana Name:"; }
    .cs-checkout-profile-table td:nth-of-type(3):before { content: "Romaji Name:"; }
    .cs-checkout-profile-table td:nth-of-type(4):before { content: "Email:"; }
    .cs-checkout-profile-table td:nth-of-type(5):before { content: "Phone:"; }
    .cs-checkout-profile-table td:nth-of-type(6):before { content: "Gender:"; }
    .cs-checkout-profile-table td:nth-of-type(7):before { content: "Date of Birth:"; }
    .cs-checkout-profile-table td:nth-of-type(8):before { content: "Postcode:"; }
    .cs-checkout-profile-table td:nth-of-type(9):before { content: "Address:"; }

    .cs-checkout-cart-table tfoot td:before { /* Hide before for footer totals */
        content: none;
    }
    .cs-checkout-cart-table tfoot td {
        text-align: right !important;
        padding-left: 12px;
    }
}

