/* CSS Variables - Reused from index.html for consistency */
:root {
    --primary-bg-dark: #1A3A5A; /* Deep Blue */
    --secondary-bg-light: #F0F4F8; /* Off-White/Light Grey */
    --accent-green: #28B463; /* Vibrant Green for emphasis */
    --accent-orange: #EB984E; /* Warm Orange for CTAs */
    --text-dark: #333333; /* Dark Grey for body text */
    --text-light: #FFFFFF; /* White for text on dark backgrounds */
    --border-light: #D5DBDB; /* Light border color */
    --card-bg: #FFFFFF; /* White for product cards */
    --shadow-color: rgba(0, 0, 0, 0.1);
    --error-red: #E74C3C;
}

/* Base Styles */
body {
    font-family: 'Inter', sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--secondary-bg-light);
    color: var(--text-dark);
    line-height: 1.5; /* Increased line-height for better readability */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--accent-green);
    text-decoration: none;
    transition: color 0.3s ease;
}

a:hover {
    color: var(--primary-bg-dark);
}

/* Header Styles - Reused */
.header {
    background-color: var(--primary-bg-dark);
    color: var(--text-light);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    box-shadow: 0 4px 8px var(--shadow-color);
}

.logo {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-light);
    margin-right: 1rem;
}

.logo span {
    color: var(--accent-green);
}

/* Navigation Styles - Reused */
.nav-menu {
    display: flex;
    align-items: center;
}

.nav-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
}

.nav-list li {
    margin-left: 2rem;
}

.nav-list a {
    color: var(--text-light);
    font-weight: 600;
    font-size: small;
    padding: 0.5rem 0;
    position: relative;
    transition: color 0.3s ease;
}

.nav-list a::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: 0;
    left: 0;
    background-color: var(--accent-green);
    transition: width 0.3s ease;
}

.nav-list a:hover::after,
.nav-list a.active::after {
    width: 100%;
}

/* Hamburger Menu Icon - Reused */
.hamburger {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 35px;
    height: 25px;
    cursor: pointer;
    z-index: 1001;
}

.hamburger span {
    display: block;
    width: 100%;
    height: 3px;
    background-color: #1A3A5A; /* Changed to light for visibility on dark background */
    border-radius: 2px;
    transition: all 0.3s ease-in-out;
}

/* Hamburger Animation - Reused */
.hamburger.active span:nth-child(1) {
    transform: translateY(11px) rotate(45deg);
}

.hamburger.active span:nth-child(2) {
    opacity: 0;
}

.hamburger.active span:nth-child(3) {
    transform: translateY(-11px) rotate(-45deg);
}

/* Main Content Styling - Adapted from products.html */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem; /* Added default padding to prevent content from touching edges */
}

/* Hero Section */
.hero {
    background-size: cover;
    background-position: center;
    color: var(--text-light);
    text-align: center;
    padding: 6rem 2rem;
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
}

.hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5); /* Dark overlay */
    z-index: -1;
}

.hero-content {
    max-width: 800px;
}

.hero h1 {
    /* Using clamp for fluid typography */
    font-size: clamp(2rem, 5vw, 3.8rem);
    margin-bottom: 1rem;
    line-height: 1.2;
    font-weight: 700;
}

.hero p {
    font-size: clamp(1rem, 2.5vw, 1.3rem);
    margin-bottom: 2.5rem;
    opacity: 0.9;
}

.hero .btn {
    background-color: var(--accent-green);
    color: var(--text-light);
    padding: 1rem 2.5rem;
    border-radius: 8px;
    font-size: 1.2rem;
    font-weight: 600;
    transition: background-color 0.3s ease, transform 0.2s ease;
    display: inline-block;
}

.hero .btn:hover {
    background-color: #23A059;
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

h2 {
    font-size: large;
    font-weight: bold;
    color: #1A3A5A;
}
.category-grid {
    display: grid;
    /* This is already good, it handles responsiveness for you */
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;/* Increased gap for better spacing */
    padding-left: 0;
    padding-right: 0;
}

.category-card {
    background-color: var(--card-bg);
    border-radius: 10px;
    box-shadow: 0 4px 10px var(--shadow-color);
    overflow: hidden;
    text-align: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    width: 0 auto;
    margin: 0 auto;
}

.category-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.category img {
    max-width: 100%; /* Ensures image doesn't overflow container */
    height: auto;
    animation: bounceIn 0.8s ease-out; /* Simple entry animation */
}

.category-card h3 {
    font-size: 1.5rem;
    color: var(--primary-bg-dark);
    margin-bottom: 0.3rem;
    font-weight: 400;
}

.category-card p {
    font-size: 1rem;
    color: var(--text-dark);
    margin-bottom: 0.4rem;
    flex-grow: 1; /* Allows paragraph to take available space */
}

.category-card .btns {
    display: inline-block;
    background-color: var(--accent-green);
    color: var(--text-light);
    padding: 0.8rem;
    border: solid 2px var(--accent-white);
    border-radius: 6px;
    font-weight: 600;
    font-size: small;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

.category-card .btn:hover {
    background-color: #77db2b; /* Slightly darker green */
    transform: translateY(-2px);
}

.page-title {
    text-align: center;
    font-size: clamp(2rem, 5vw, 3rem); /* Added clamp for fluid typography */
    margin: 3rem 0;
    color: var(--primary-bg-dark);
    position: relative;
    padding-bottom: 10px;
}

.page-title::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: 0;
    transform: translateX(-50%);
    width: 100px;
    height: 4px;
    background-color: var(--accent-green);
    border-radius: 2px;
}

.product-grid {
  display: grid;
  /* This creates a responsive grid that wraps items */
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px; /* Space between the grid items */
  padding: 20px;
  max-width: 1200px; /* Optional: Sets a max width for the grid on very large screens */
  margin: 0 auto; /* This centers the entire grid container */
}

.product-card {
  display: flex;
  flex-direction: column;
  align-items: center; /* This centers all child elements horizontally */
  text-align: center; /* This centers text within the card */
  padding: 20px;
  border: 1px solid #ddd;
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  background-color: #fff;
}

/* Specific centering for the images inside the cards */
.product-card img {
  margin: 0 auto; /* Centers the image */
  display: block; /* Important for margin: auto to work */
  max-width: 100%;
  height: auto;
}

.product-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.product-image-container {
    width: 100%;
    height: 200px;
    overflow: hidden;
    background-color: var(--secondary-bg-light);
    display: flex;
    justify-content: center;
    align-items: center;
    border-bottom: 1px solid var(--border-light);
}

.product-image-container img {
    max-width: 80%;
    max-height: 80%;
    object-fit: contain;
    border-radius: 5px;
}

.product-info {
    padding: 1.5rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.product-info h3 {
    font-size: 1.6rem;
    color: var(--primary-bg-dark);
    margin-top: 0;
    margin-bottom: 5px;
    font-weight: 600;
}
    
.product-info .cas-number {
    font-size: 0.9rem;
    color: #777;
    margin-bottom: 5px;
}

.product-info p.description {
    font-size: 0.95rem;
    color: var(--text-dark);
    margin-bottom: 5px;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

.product-price {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--accent-orange);
    margin-bottom: 5px;
}

.product-card .btn, .variant-toggle {
    display: block;
    width: calc(90% - 3rem);
    margin: 0 1.5rem 1.5rem;
    background-color: var(--accent-green);
    color: var(--text-light);
    padding: 5px;
    border-radius: 6px;
    font-weight: 600;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

.product-card .btn:hover {
    background-color: #23A059;
    transform: translateY(-2px);
}

/* Disclaimer Modal - Reused */
.disclaimer-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.disclaimer-modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.disclaimer-modal {
    background-color: var(--card-bg);
    padding: 2.5rem;
    border-radius: 12px;
    max-width: 600px;
    width: 90%;
    box-shadow: 0 10px 30px var(--shadow-color);
    text-align: center;
    transform: translateY(-20px);
    transition: transform 0.3s ease;
}

.disclaimer-modal-overlay.show .disclaimer-modal {
    transform: translateY(0);
}

.disclaimer-modal h2 {
    color: var(--primary-bg-dark);
    font-size: 2.2rem;
    margin-bottom: 1.5rem;
    font-weight: 700;
}

.disclaimer-modal p {
    font-size: 1rem;
    color: var(--text-dark);
    margin-bottom: 2rem;
    text-align: left;
}

.disclaimer-modal button {
    background-color: var(--accent-orange);
    color: var(--text-light);
    padding: 1rem 2.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

.disclaimer-modal button:hover {
    background-color: #D37230;
    transform: translateY(-2px);
}

.error-message {
    color: var(--error-red);
    margin-top: 1rem;
    font-weight: 600;
    display: none;
}

/* Variation Styles - Reused */
.variant-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.variant-table th, .variant-table td {
    border: 1px solid #ddd;
    padding: 0.5rem;
    text-align: center;
}

.variant-table th {
    background-color: #f5f5f5;
    font-weight: bold;
}

/* Style for the collapsible section */
.variants-container {
  display: none; /* Hides the variants table by default */
  max-height: 0;
  overflow: hidden;
  transition: all 0.3s ease-in-out;
}

/* Class to show the container when the toggle is clicked */
.variants-container.open {
  display: block;
  max-height: 500px; /* A value larger than the max height of the table */
}

/* Style for the clickable toggle button */
.variant-toggle {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 10px 0;
  border-bottom: 1px solid #ccc;
  margin-top: 15px;
}

.variant-toggle span {
  font-weight: bold;
}

.variant-toggle i {
  transition: transform 0.3s ease-in-out;
}

/* Rotate the arrow when the container is open */
.variant-toggle.active i {
  transform: rotate(180deg);
}

.product-detail img {
    border: 1px solid #ccc;
    margin-bottom: 1rem;
}

.checkout-form input,
.checkout-form textarea {
    width: 100%;
    padding: 10px;
    margin: 0.5rem 0 1rem;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.alert.success {
    background-color: #d4edda;
    color: #155724;
    padding: 1rem;
    border-left: 5px solid #28a745;
}

.alert.error {
    background-color: #f8d7da;
    color: #721c24;
    padding: 1rem;
    border-left: 5px solid #dc3545;
}

.contact-form input, .contact-form textarea, 
.checkout-form input, .checkout-form textarea {
    width: 80%;
}


/* Footer Styles - Reused */
.footer {
    background-color: var(--primary-bg-dark);
    color: var(--text-light);
    text-align: center;
    padding: 2.5rem 2rem;
    border-top-left-radius: 15px;
    border-top-right-radius: 15px;
    margin-top: 2rem;
    box-shadow: 0 -4px 8px rgba(0, 0, 0, 0.1);
}

.footer p {
    margin: 0;
    font-size: 0.9rem;
    opacity: 0.8;
}

.footer .footer-links {
    list-style: none;
    padding: 0;
    margin-top: 1rem;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
}

.footer .footer-links li {
    margin: 0.5rem 1rem;
}

.footer .footer-links a {
    color: var(--text-light);
    opacity: 0.8;
    transition: opacity 0.3s ease;
    font-size: small;
}

.footer .footer-links a:hover {
    opacity: 1;
    color: var(--accent-green);
}

/* Updated Responsive Adjustments
    - Refined breakpoints for cleaner transitions.
    - Added fluid typography with clamp() for better scaling.
    - Ensured padding and layout are optimized for all screen sizes.
*/

/* Media query for tablets and smaller desktops */
@media (max-width: 992px) {
    * {
        font-size: small;
        font-weight: 100;
    }
    tr, th, td {
        font-size: smaller;
    }
    .container {
        padding: 0;
    }
    .variant-table th:nth-child(5),
    .variant-table td:nth-child(5) {
        display: none; /* Hide Subtotal and Action on smaller screens */
    }
    .hero {
        padding: 1rem 0.5rem;
        min-height: 250px;
    }
    .hero h1 {
        font-size: clamp(2rem, 5vw, 3rem);
    }
    .hero p {
        font-size: clamp(1rem, 2.5vw, 1.2rem);
    }
    
    .page-title {
        font-size: clamp(2rem, 5vw, 2.5rem);
    }
}

/* Media query for mobile devices */
@media (max-width: 768px) {
    .header {
        padding: 1rem;
        flex-wrap: nowrap; /* Prevents wrapping on small screens */
    }
    .head p, .head a {
        font-size: small;
    }

    .logo {
        font-size: 1.5rem;
    }

    .hamburger {
        display: flex;
    }

    .nav-menu {
        flex-basis: 100%;
        justify-content: flex-end;
    }

    .nav-list {
        flex-direction: column;
        position: fixed;
        top: 0;
        right: -100%;
        width: 70%;
        max-width: 300px;
        height: 100%;
        background-color: var(--primary-bg-dark);
        padding: 1rem 0.5rem;
        box-shadow: -4px 0 10px var(--shadow-color);
        transition: right 0.3s ease-in-out;
        z-index: 1000;
        align-items: center;
    }
    
    .nav-list.active {
        right: 0;
    }

    .nav-list li {
        margin: 0.7rem 0;
    }

    .page-title {
        margin: 1rem 0;
        font-size: clamp(1.8rem, 5vw, 2.2rem);
    }

    .hero {
  /* ... existing styles ... */
  height: 60vh; /* Use viewport height for a more flexible height */
  /* This ensures the hero section takes up 60% of the screen's height, regardless of device */
}

/* Adjust font sizes for smaller screens using a media query */
  .hero h1 {
    font-size: 2rem;
  }
  .hero p {
    font-size: 1rem;
  }
  .btn {
    font-size: x-small;
    font-weight: 200;
    padding: 0;
  }
}
    
    .category-card {
        max-width: 75%; /* Allows cards to fill the container width */
        margin: 0 auto;
    }

    .product-card p {
        font-size: 0.7rem;
    }
    
    .product-info h3 {
        font-size: 0.8rem;
    }
    
    .product-detail h1 {
        font-size: 1.5rem;
    }
    .product-detail p {
        font-size: 0.8rem;
    }
    .product-price {
        font-size: 0.8rem;
    }

    .disclaimer-modal {
        padding: 0.8rem;
        width: 95%; /* Adjust for smaller screens */
    }
    
    .disclaimer-modal h2 {
        font-size: 0.8rem;
    }
    
    .disclaimer-modal p {
        font-size: 0.5rem;
    }

  /* This is the most common fix. */
  .container,
  .category-grid, .product-card {
    padding-left: 0;
    padding-right: 0;
  }
  /* This ensures the cards are centered and have no external margins. */
  .category-card, .product-card {
    margin-left: 0;
    margin-right: 0;
    /* Optional, but often helpful for mobile */
    width: 100%;
  }

/* Minor adjustments for extra small screens */
@media (max-width: 480px) {
    .header {
        padding: 0.3rem;
    }
    
    .logo {
        font-size: 0.7rem;
    }

    .product-info h3 {
        font-size: 0.7rem;
    }
    .product-price {
        font-size: 0.6rem;
    }
}