/* MD3 Variables */
:root {
  --md-sys-color-primary: #2E7D32;
  --md-sys-color-primary-container: #bdfcc2;
  /* Lighter shade of primary */
  --md-sys-color-on-primary: #ffffff;
  --md-sys-color-surface: #f8fbf1;
  --md-sys-color-surface-variant: #e0e5d9;
  --md-sys-color-on-surface: #191c19;
  --md-sys-color-on-surface-variant: #434840;
  --md-sys-color-outline: #73796f;

  --md-sys-typescale-body-large-font: 'Roboto', sans-serif;
  --md-sys-typescale-body-large-size: 16px;
  --md-sys-typescale-headline-large-size: 32px;

  --md-sys-elevation-level1: 0px 1px 3px 1px rgba(0, 0, 0, 0.15), 0px 1px 2px 0px rgba(0, 0, 0, 0.3);
  --md-sys-elevation-level2: 0px 2px 6px 2px rgba(0, 0, 0, 0.15), 0px 1px 2px 0px rgba(0, 0, 0, 0.3);
}

body {
  margin: 0;
  background-color: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  font-family: var(--md-sys-typescale-body-large-font);
  font-size: var(--md-sys-typescale-body-large-size);
  line-height: 1.5;
}

/* Typography */
h1,
h2,
h3 {
  margin: 0;
  font-weight: 400;
}

h1 {
  font-size: 36px;
  line-height: 44px;
}

h2 {
  font-size: 28px;
  line-height: 36px;
}

h3 {
  font-size: 20px;
  line-height: 28px;
  font-weight: 500;
}

a {
  text-decoration: none;
  color: inherit;
}

/* Layout Utilities */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
  padding: 24px 0;
}

/* Components */

/* App Bar */
header {
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  padding: 16px 0;
  box-shadow: var(--md-sys-elevation-level2);
  position: sticky;
  top: 0;
  z-index: 100;
}

header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: nowrap;
  /* Prevent wrapping on desktop */
}

/* ... */

nav {
  display: flex;
  align-items: center;
  flex-direction: row;
  /* Explicitly row */
}

nav a {
  margin-left: 24px;
  color: var(--md-sys-color-on-primary);
  font-weight: 500;
  opacity: 0.9;
  white-space: nowrap;
  /* Prevent text wrap */
}

/* ... */
.lang-switcher {
  display: flex;
  align-items: center;
  margin-left: 24px;
}

.lang-switcher a {
  margin-left: 8px;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 14px;
  text-transform: uppercase;
  color: var(--md-sys-color-on-primary);
  /* Ensure contrast */
}

.lang-switcher a.active {
  background-color: rgba(255, 255, 255, 0.2);
  font-weight: 700;
}

/* Cards */
.card {
  background-color: #fff;
  border-radius: 16px;
  box-shadow: var(--md-sys-elevation-level1);
  overflow: hidden;
  transition: box-shadow 0.2s ease;
  display: flex;
  flex-direction: column;
}

.card:hover {
  box-shadow: var(--md-sys-elevation-level2);
}

.card-image {
  height: 200px;
  background-color: var(--md-sys-color-surface-variant);
  overflow: hidden;
}

.card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-content {
  padding: 16px;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.card-title {
  font-size: 18px;
  margin-bottom: 8px;
  font-weight: 500;
}

.card-price {
  font-size: 20px;
  font-weight: 700;
  color: var(--md-sys-color-primary);
  margin-top: auto;
  padding-top: 12px;
}

.card-actions {
  padding: 16px;
  padding-top: 0;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 24px;
  border-radius: 20px;
  /* Pill shape */
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  border: none;
  transition: opacity 0.2s, box-shadow 0.2s;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn-primary {
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}

.btn-primary:active {
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.2);
}

.btn-text {
  background: transparent;
  color: var(--md-sys-color-primary);
}

.btn:hover {
  opacity: 0.9;
  box-shadow: var(--md-sys-elevation-level1);
}

/* Product Detail */
.product-detail {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
  padding: 48px 0;
}

.product-image-large img,
.main-image img {
  width: 100%;
  border-radius: 24px;
  box-shadow: var(--md-sys-elevation-level1);
  display: block;
}

.product-gallery {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-top: 16px;
}

.product-gallery img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 12px;
  cursor: pointer;
  transition: opacity 0.2s;
  border: 2px solid transparent;
}

.product-gallery img:hover {
  opacity: 0.8;
}

.product-gallery img.active {
  border-color: var(--md-sys-color-primary);
}

.product-info h1 {
  margin-bottom: 16px;
  color: var(--md-sys-color-on-surface);
}

.product-info .price {
  font-size: 32px;
  color: var(--md-sys-color-primary);
  font-weight: 700;
  margin-bottom: 24px;
}

.product-info .desc {
  font-size: 18px;
  line-height: 1.6;
  color: var(--md-sys-color-on-surface-variant);
  margin-bottom: 32px;
}

/* Rich Text Styles */
.rich-text h3 {
  margin-top: 24px;
  margin-bottom: 12px;
}

.rich-text ul,
.rich-text ol {
  margin-bottom: 16px;
  padding-left: 24px;
}

.rich-text p {
  margin-bottom: 16px;
}

/* Contact Form & Admin Forms */
form {
  max-width: 600px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
}

label {
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--md-sys-color-on-surface-variant);
}

input,
textarea,
select {
  padding: 12px 16px;
  border: 1px solid var(--md-sys-color-outline);
  border-radius: 4px;
  background-color: var(--md-sys-color-surface);
  font-family: inherit;
  font-size: 16px;
}

input:focus,
textarea:focus {
  border-color: var(--md-sys-color-primary);
  outline: 2px solid var(--md-sys-color-primary-container);
}

/* Admin Table */
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 24px;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--md-sys-elevation-level1);
}

th,
td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--md-sys-color-surface-variant);
}

th {
  background-color: var(--md-sys-color-surface-variant);
  font-weight: 500;
}

tr:hover {
  background-color: var(--md-sys-color-surface);
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 24px;
}

/* Hero Section */
.hero {
  background: var(--md-sys-color-primary-container);
  padding: 0;
  margin-bottom: 32px;
  border-radius: 0 0 32px 32px;
  background-size: cover;
  background-position: center;
  position: relative;
  /* Fix: Use Viewport Height for better scale */
  min-height: 75vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hero::before {
  /* Overlay for text readability if image used */
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  /* Stronger overlay */
  border-radius: 0 0 32px 32px;
  display: none;
}

.hero.has-bg::before {
  display: block;
}

.hero .container {
  position: relative;
  z-index: 2;
  text-align: center;
  max-width: 800px;
  padding: 24px;
}

.hero.has-bg h1,
.hero.has-bg p {
  color: #fff !important;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.8);
}

/* Menu Toggle */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--md-sys-color-on-primary);
  cursor: pointer;
  padding: 8px;
}

/* Utilities */
.table-responsive {
  overflow-x: auto;
  width: 100%;
  -webkit-overflow-scrolling: touch;
}

/* Responsive & Mobile */
@media (max-width: 768px) {

  /* Layout */
  .grid,
  .product-detail,
  form .grid-3-col,
  .contact-grid {
    grid-template-columns: 1fr !important;
    gap: 24px;
  }

  /* Generic grid collapse */
  div[style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  div[style*="grid-template-columns: 1fr 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  .product-detail {
    padding: 24px 0;
  }

  h1 {
    font-size: 28px;
    line-height: 1.2;
  }

  h2 {
    font-size: 24px;
  }

  .hero {
    min-height: 60vh;
  }

  /* Navigation & Header */
  header .container {
    flex-direction: row;
    /* Keep logo and toggle in row */
    justify-content: space-between;
    flex-wrap: wrap;
    /* allow nav to break line if needed, or use absolute */
    position: relative;
  }

  .menu-toggle {
    display: block;
  }

  nav {
    display: none;
    /* hidden by default */
    width: 100%;
    flex-direction: column;
    padding-bottom: 16px;
    align-items: center;
    background-color: var(--md-sys-color-primary);
    /* Dropdown effect */
    position: absolute;
    top: 100%;
    left: 0;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  }

  nav.open {
    display: flex;
  }

  nav a {
    margin: 8px 0;
    margin-left: 0;
    /* Override desktop */
    width: 100%;
    text-align: center;
    padding: 8px 0;
  }

  .lang-switcher {
    margin-top: 8px;
    margin-bottom: 16px;
    margin-left: 0;
    /* Override desktop */
    justify-content: center;
    display: flex;
  }
}