/* Updated 3pm complete */

/* Revised: August 25, 2024, 13:35 MT */

/* CSS Reset */
html, body, div, span, h1, h2, h3, h4, h5, h6, p, a, img, ul, li, button, form, label, input {
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 100%;
  font: inherit;
  vertical-align: baseline;
}

/* Global Styles and Color Palette */
:root {
  /* Color Palette - Centralized color management */
  --primary-color: #4CAF50; /* Green - used for View Details buttons */
  --secondary-color: #f44336; /* Red - used for Add to Cart buttons */
  --background-color: #4CAF50; /* Green - used for header and footer backgrounds (nav is using this) */
  --text-color: #fff; /* White - used for text on dark backgrounds */
  --border-color: #ddd; /* Light gray - used for borders */
  --description-color: #444; /* Dark gray - used for product descriptions */
  --title-text-color: #2c3e50; /* Dark Blue for main site title */

  --font-family: 'Kanit', sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  font-family: var(--font-family);
  font-size: 16px;
  line-height: 1.5;
}

/* Header Styles */
.header {
  height: auto;
  min-height: 312px; /* Changed from 208px (208 * 1.5) for desktop */
  width: 100%;
  background-image: url('Images/header-image-desktop.jpg');
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  background-color: #ffffff; /* Changed from #f0f0f0 to white */
  color: var(--text-color);
  padding: 1em;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;

  position: fixed; /* Added for sticky effect */
  top: 0;          /* Added */
  left: 0;         /* Added */
  z-index: 1000;   /* Added */
}

/* Navigation Styles */
nav {
  background-color: var(--background-color);
  padding: 1em 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 322px; /* Changed from 218px (312px + 10px) for desktop */
}

nav h1 {
  /* Styles the H1 within the nav bar on index.html */
  color: var(--title-text-color); /* Changed from var(--text-color) */
  font-size: 1.8em; 
  margin: 0 0 0.5em 0; 
}

nav ul {
  list-style: none;
  display: flex;
  justify-content: center;
  margin: 0;
}

nav li {
  margin: 0 10px;
}

nav a {
  color: var(--text-color);
  text-decoration: none;
}

nav a:focus {
  outline: 2px solid var(--text-color);
}

/* Main Styles */
main {
  padding: 2em;
}

/* Product List Styles */
.product-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  justify-content: center;
}

/* Product Styles */
.product {
  border: 1px solid var(--border-color);
  border-radius: 10px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
}

/* Image Container Styles */
.image-container {
  width: 100%;
  padding: 20px;
  overflow: hidden;
  position: relative;
}

.product-link {
  display: block;
  overflow: hidden;
  cursor: pointer;
}

.product-link img {
  width: 100%;
  height: auto;
  transition: transform 0.3s ease-in-out;
  will-change: transform;
}

.product-link:hover img {
  transform: scale(1.1);
}

/* Optional: Add an overlay effect on hover */
.product-link::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.1);
  opacity: 0;
  transition: opacity 0.3s ease-in-out;
}

.product-link:hover::after {
  opacity: 1;
}

/* Product Description Styles */
.product-description {
  padding: 20px;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}

.product-description h3 {
  margin-top: 0;
}

.product-description p {
  font-size: 1rem;
  color: var(--description-color);
  flex-grow: 1;
}

/* Button Styles */
.button {
  display: inline-block;
  background-color: var(--primary-color);
  color: var(--text-color);
  text-decoration: none;
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
  margin-top: 15px;
  border: none;
  border-radius: 5px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.button:hover {
  /* background-color: color-mix(in srgb, var(--primary-color) 80%, black); */
  background-color: #388E3C; /* Darker green for hover */
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.button:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.button:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.5);
}

/* View Details Button Styles */
.button.view-details-button,
.product-list .product .button.view-details-button,
.related-product-list .product .button.view-details-button {
  background-color: var(--primary-color);
  color: var(--text-color);
}

.button.view-details-button:hover,
.product-list .product .button.view-details-button:hover,
.related-product-list .product .button.view-details-button:hover {
  /* background-color: color-mix(in srgb, var(--primary-color) 80%, black); */
  background-color: #388E3C; /* Darker green for hover */
}

/* Add to Cart Button Styles */
.product-info .button.add-to-cart-button {
  background-color: var(--secondary-color);
  color: var(--text-color);
}

.product-info .button.add-to-cart-button:hover {
  /* background-color: color-mix(in srgb, var(--secondary-color) 80%, black); */
  background-color: #D32F2F; /* Darker red for hover */
}

/* Product Detail Styles (for product.html) */
.product-detail {
  display: flex;
  flex-wrap: wrap;
  gap: 2em;
  margin-bottom: 2em;
}

.product-image {
  flex: 1 1 300px;
}

.product-image img {
  max-width: 100%;
  height: auto;
}

.product-info {
  flex: 1 1 300px;
}

.product-price {
  font-size: 1.2em;
  font-weight: bold;
  margin: 1em 0;
}

form {
  margin-top: 1em;
}

input[type="number"] {
  width: 50px;
  margin-right: 1em;
  padding: 5px;
  border: 1px solid var(--border-color);
}

/* Related Products Styles (for product.html) */
.related-product-list {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  justify-content: center;
  margin-top: 2em;
}

.related-product-list .product {
  flex: 0 1 calc(25% - 20px);
  min-width: 200px;
  max-width: 300px;
  display: flex;
  flex-direction: column;
}

.related-product-list .product img {
  max-width: 100%;
  height: auto;
}

.related-product-list .product h3 {
  margin-top: 0.5em;
}

.related-product-list .product p {
  flex-grow: 1;
}

.related-product-list .product .button {
  align-self: center;
  width: 100%;
}

/* Footer Styles */
footer {
  background-color: var(--background-color);
  color: var(--text-color);
  padding: 1em;
  text-align: center;
  clear: both;
}

footer p {
  margin-bottom: 10px;
}

/* Footer Image Styles */
.footer-image {
  max-width: 100%;
  height: auto;
}

/* Heading Styles */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-family);
}

/* Responsive Styles */
@media (max-width: 1200px) {
  .related-product-list .product {
    flex: 0 1 calc(33.333% - 20px);
  }
}

@media (max-width: 1024px) {
  .header {
    background-image: url('Images/header-image-tablet.jpg');
    min-height: 107px;
    /* Existing styles for .header within this media query, if any, will be preserved */
  }
  nav {
    margin-top: 117px;
  }
  
  .product {
    flex-basis: calc(50% - 20px);
  }
}

@media (max-width: 900px) {
  .related-product-list .product {
    flex: 0 1 calc(50% - 20px);
  }
}

@media (max-width: 768px) {
  .product-detail {
    flex-direction: column;
    align-items: center;
  }

  .header {
    /* position: fixed; is inherited from base */
    background-image: url('Images/header-image-mobile.jpg');
    background-size: 100% auto; 
    background-repeat: no-repeat; 
    min-height: 50vw; 
  }

  nav { 
    margin-top: calc(50vw + 10px); /* Correct for fixed header of 50vw height in this range */
  }

  .product {
    flex-basis: 100%;
  }
  
  nav ul {
    flex-direction: column;
    align-items: center;
  }
  
  nav li {
    margin: 5px 0;
  }
}

@media (max-width: 600px) {
  .related-product-list .product {
    flex: 0 1 100%;
  }
}

@media (max-width: 480px) {
  .header {
    min-height: 50vw; 
    position: static !important; /* Ensure header is in normal flow */
    /* Inherits background-image, background-size, background-repeat from 768px rule */
    /* background-color: #ffffff; is already set */
  }
  nav {
    margin-top: 10px !important; /* Ensure correct margin for static header */
    /* Other nav styles like flex-direction: column will apply here */
  }
  
  .product {
    flex-basis: 100%;
  }
  
  nav ul {
    flex-direction: column;
    align-items: center;
  }
  
  nav li {
    margin: 5px 0;
  }
}

/* Cart Styles */
.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1em;
    margin-bottom: 1em;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: #fff;
}

.cart-item-content {
    display: flex;
    align-items: center;
    gap: 1em;
    flex-grow: 1;
}

.cart-item-image {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: 4px;
}

.cart-item-details {
    flex-grow: 1;
}

.cart-item-details h4 {
    margin: 0 0 0.5em 0;
    font-size: 1.2em;
    color: var(--text-color);
}

.cart-item-price {
    color: #666;
    margin: 0.5em 0;
}

.cart-item-total {
    font-weight: bold;
    color: var(--primary-color);
    margin: 0.5em 0;
}

.quantity-controls {
    display: flex;
    align-items: center;
    gap: 0.5em;
    margin: 0.5em 0;
}

.quantity-btn {
    padding: 0.25em 0.5em;
    border: 1px solid var(--border-color);
    background: var(--background-color);
    color: var(--text-color);
    cursor: pointer;
    border-radius: 4px;
}

.quantity-display {
    min-width: 2em;
    text-align: center;
}

.remove-item {
    padding: 0.5em 1em;
    background: var(--secondary-color);
    color: var(--text-color);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    margin-left: 1em;
}

#cart-summary {
    margin: 2em 0;
    padding: 1em;
    background: #f9f9f9;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

#cart-summary h3 {
    margin: 0 0 1em 0;
    color: var(--text-color);
}

#cart-summary div {
    margin: 0.5em 0;
    display: flex;
    justify-content: space-between;
}

#total {
    font-weight: bold;
    font-size: 1.2em;
    border-top: 1px solid var(--border-color);
    padding-top: 0.5em;
    margin-top: 0.5em;
}

/* Styles moved from inline */
.contact-intro {
    margin-bottom: 2em;
    text-align: center;
}

.address-block {
    margin-bottom: 1.5em; /* Added from inline style */
}

.footer-admin-link {
    font-size: 0.8em;
    color: #777;
}

/* Styles for Checkout Page Enhancements */

/* Add this new style for .form-group */
#shipping-form .form-group {
    margin-bottom: 15px; /* Adds space below each form group */
}

/* Style for the labels within the form groups */
#shipping-form .form-group label {
    display: block; /* Ensures the label takes its own line */
    font-weight: bold;
    color: var(--title-text-color); /* Dark blueish-grey, can be changed to a more direct blue if needed */
    margin-bottom: 5px; /* Adds a small space between the label and the input field below it */
}

/* Overall Checkout Section */
#checkout {
    max-width: 800px; /* Constrain width for better readability on wider screens */
    margin: 0 auto; /* Center the checkout section */
    padding: 20px;
    background-color: #f9f9f9; /* Light background for the checkout area */
    border-radius: 8px;
    box-shadow: 0 0 15px rgba(0,0,0,0.1);
}

#checkout h2, 
#checkout h3 {
    color: var(--title-text-color); /* Use consistent title color */
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

/* Cart Items Section */
#cart-items {
    margin-bottom: 30px;
}
/* cart-item styles already exist and should be fine */

/* Order Summary */
#cart-summary {
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    margin-bottom: 30px;
}

#cart-summary h3 {
    margin-top: 0; /* Remove default top margin if any */
}

#cart-summary div {
    margin-bottom: 10px; /* Space out summary lines */
    font-size: 1.1em;
}

#cart-summary #total {
    font-weight: bold;
    font-size: 1.3em;
    color: var(--primary-color); /* Highlight total */
    margin-top: 15px;
}

/* Shipping Information Form Styling */
#shipping-info {
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    margin-bottom: 30px;
    border: 1px solid #e0e0e0; /* Slightly lighter border */
}

#shipping-info h3 {
    margin-top: 0;
}

#shipping-form .form-row {
    display: flex;
    align-items: center; /* Vertically align label and fields */
    margin-bottom: 15px; /* Space between rows */
    padding: 10px 0;
    border-bottom: 1px solid #f5f5f5; /* Light separator line */
}

#shipping-form .form-row:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

#shipping-form .form-label {
    flex-basis: 25%; /* Adjust as needed for label width */
    padding-right: 15px;
    text-align: left; /* Labels aligned to the left */
    font-size: 0.9em; /* Smaller font for labels as in image */
    color: #555;
}

#shipping-form .form-label label {
    font-weight: normal; /* Labels in image are not bold */
    margin-bottom: 0; /* Remove bottom margin as it's part of form-row alignment */
}

#shipping-form .form-label label::before {
    content: "*";
    color: red;
    margin-right: 3px;
}

#shipping-form .form-fields {
    flex-basis: 75%; /* Adjust as needed for field width */
    display: flex;
    gap: 10px; /* For fields like First Name / Last Name */
}

#shipping-form .form-fields input[type="text"],
#shipping-form .form-fields input[type="email"],
#shipping-form .form-fields input[type="tel"],
#shipping-form .form-fields select {
    width: 100%; /* Inputs take full width of their container within form-fields */
    padding: 10px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.95em;
    color: #333;
    background-color: #f0f8ff; /* Pale AliceBlue background for empty fields with placeholder */
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
    line-height: 1.5; /* Ensure sufficient line height */
    min-height: 40px; /* Ensure a minimum height for better text visibility */
}

#shipping-form .form-fields input[type="text"]:not(:placeholder-shown),
#shipping-form .form-fields input[type="email"]:not(:placeholder-shown),
#shipping-form .form-fields input[type="tel"]:not(:placeholder-shown),
#shipping-form .form-fields select:valid { /* :valid can work for select if a default "disabled" option is present */
    background-color: #fff; /* White background when filled or selected */
}

/* Specific for First Name / Last Name to be half width */
#shipping-form .form-fields input#firstName,
#shipping-form .form-fields input#lastName {
    flex: 1; /* Each takes half of the .form-fields container */
}

#shipping-form .form-fields select {
    appearance: none; /* Basic reset for custom select arrow if desired later */
    background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20width%3D%2220%22%20height%3D%2220%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M5%208l5%205%205-5z%22%20fill%3D%22%23555%22%2F%3E%3C%2Fsvg%3E'); /* Simple SVG arrow */
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 12px;
    padding-right: 30px; /* Make space for the arrow */
}

#shipping-form .form-fields input[type="text"]:focus,
#shipping-form .form-fields input[type="email"]:focus,
#shipping-form .form-fields input[type="tel"]:focus,
#shipping-form .form-fields select:focus {
    outline: none;
    border-color: var(--primary-color); /* Use your primary color for focus */
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.15);
    background-color: #fff; /* Ensure focus overrides the pale blue */
}

/* Payment Section */
#payment-section {
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    text-align: center; /* Center PayPal button container */
}

#payment-section h3 {
    margin-top: 0;
    text-align: left; /* Align heading to the left */
}

#paypal-button-container {
    margin-top: 20px;
    display: inline-block; /* Allows centering if parent is text-align: center */
    min-width: 250px; /* Ensure it has some minimum width */
}

/* Responsive adjustments for checkout */
@media (max-width: 768px) {
    #checkout {
        padding: 15px;
    }

    #shipping-form .form-row {
        flex-direction: column; /* Stack label and fields */
        align-items: stretch; /* Make children take full width */
        padding: 5px 0;
    }

    #shipping-form .form-label {
        flex-basis: auto; /* Reset flex-basis */
        padding-right: 0;
        margin-bottom: 8px; /* Space between label and fields when stacked */
        text-align: left;
    }

    #shipping-form .form-fields {
        flex-basis: auto; /* Reset flex-basis */
        flex-direction: column; /* Stack first/last name if they were side-by-side */
    }
    
    #shipping-form .form-fields input#firstName,
    #shipping-form .form-fields input#lastName {
        flex: none; /* Reset flex for stacked layout */
        width: 100%;
    }

    #shipping-form input[type="text"],
    #shipping-form input[type="email"],
    #cart-summary div,
    #cart-summary #total {
        font-size: 1em; /* Adjust font sizes for smaller screens */
    }
}

@media (max-width: 480px) {
    #checkout {
        padding: 10px;
    }
    #cart-summary, #shipping-info, #payment-section {
        padding: 15px;
    }
}