@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700&display=swap');

:root {
  --primary-color: #0a84ff;
  --primary-hover: #0071e3;
  --background-color: #f5f5f7;
  --card-background: #ffffff;
  --text-color: #1d1d1f;
  --subtle-text: #6e6e73;
  --border-color: #d2d2d7;
  --danger-color: #d93025;
  --danger-hover: #c5221f;
}

html {
  height: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  margin: 0;
  padding: 0;
  background-color: var(--background-color);
  color: var(--text-color);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  background: var(--card-background);
  border-bottom: 1px solid var(--border-color);
  padding: 0 2rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

nav a, nav form button {
  color: var(--text-color);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.2s ease;
}

nav a:hover {
  color: var(--primary-color);
}

nav form button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

main {
  padding: 2rem;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  flex: 1 0 auto;
}

h1, h2, h3 {
  font-weight: 700;
}

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

.card {
  background: var(--card-background);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  display: flex;
  flex-direction: column;
}

.card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 20px rgba(0,0,0,0.05);
}

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

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

.card-content h3 {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
}
.card-content h3 a {
  text-decoration: none;
  color: var(--text-color);
}

.card-content .price {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 1rem;
}

.card-content .actions {
  margin-top: auto;
}

.product-detail {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
  background: var(--card-background);
  padding: 2rem;
  border-radius: 12px;
  border: 1px solid var(--border-color);
}

.product-detail img {
  width: 100%;
  border-radius: 8px;
}

@media (max-width: 800px) {
  .product-detail {
    grid-template-columns: 1fr;
  }
}

/* ========================================
   MOBILE RESPONSIVE STYLES
   ======================================== */

/* Tablets and smaller (max-width: 768px) */
@media (max-width: 768px) {
  /* Header adjustments */
  header {
    padding: 0 1rem;
    height: auto;
    min-height: 56px;
    flex-wrap: wrap;
  }
  
  nav {
    gap: 1rem;
    flex-wrap: wrap;
  }
  
  nav a, nav form button {
    font-size: 0.85rem;
  }
  
  /* Main content padding */
  main {
    padding: 1rem;
  }
  
  /* Grid adjustments */
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
  }
  
  /* Card adjustments */
  .card img {
    height: 160px;
  }
  
  .card-content {
    padding: 0.75rem;
  }
  
  .card-content h3 {
    font-size: 1rem;
  }
  
  .card-content .price {
    font-size: 1.1rem;
  }
  
  /* Hero section */
  .hero {
    padding: 2rem 1rem;
    margin-bottom: 2rem;
  }
  
  .hero h1 {
    font-size: 2rem;
  }
  
  .hero p {
    font-size: 1rem;
  }
  
  /* Product detail */
  .product-detail {
    grid-template-columns: 1fr;
    padding: 1rem;
    gap: 1.5rem;
  }
  
  /* Forms */
  form {
    max-width: 100%;
  }
  
  /* Tables - make them scrollable */
  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  table {
    min-width: 600px;
  }
  
  th, td {
    padding: 0.75rem 0.5rem;
    font-size: 0.9rem;
  }
  
  /* Cart summary */
  .cart-summary {
    max-width: 100%;
    margin-left: 0;
  }
  
  /* Buttons */
  button, .button {
    padding: 0.65rem 1.25rem;
    font-size: 0.95rem;
  }
  
  /* Category filter */
  .category-filter {
    gap: 0.5rem;
  }
  
  .category-filter a {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
  }
  
  /* Footer */
  footer {
    padding: 1.5rem 1rem;
    font-size: 0.9rem;
  }
}

/* Mobile phones (max-width: 480px) */
@media (max-width: 480px) {
  /* Header - stack navigation on very small screens */
  header {
    flex-direction: column;
    align-items: flex-start;
    padding: 0.75rem 1rem;
    gap: 0.75rem;
  }
  
  nav {
    width: 100%;
    justify-content: space-between;
  }
  
  nav a, nav form button {
    font-size: 0.8rem;
  }
  
  /* Grid - single column on mobile */
  .grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  
  /* Card images */
  .card img {
    height: 200px;
  }
  
  /* Hero section - smaller text */
  .hero h1 {
    font-size: 1.75rem;
  }
  
  .hero p {
    font-size: 0.95rem;
  }
  
  /* Product detail */
  .product-detail {
    padding: 1rem;
    gap: 1rem;
  }
  
  /* Forms - full width inputs */
  form input, form textarea {
    padding: 0.65rem;
    font-size: 0.95rem;
  }
  
  /* Buttons - full width on mobile */
  button, .button {
    width: 100%;
    padding: 0.75rem;
  }
  
  /* Cart item adjustments */
  .cart-item-row img {
    width: 50px;
    height: 50px;
  }
  
  /* Cart summary */
  .cart-summary {
    padding: 1rem;
  }
  
  .cart-summary .total {
    font-size: 1.25rem;
  }
  
  /* Category filter - smaller on mobile */
  .category-filter {
    gap: 0.5rem;
  }
  
  .category-filter a {
    padding: 0.35rem 0.7rem;
    font-size: 0.8rem;
  }
  
  /* Quantity controls */
  .quantity-control button {
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }
  
  .quantity-control span {
    min-width: 50px;
    font-size: 1.1rem;
  }
  
  /* Product badges */
  .product-badge {
    font-size: 0.7rem;
    padding: 0.2rem 0.4rem;
  }
  
  /* Headings */
  h1 {
    font-size: 1.75rem;
  }
  
  h2 {
    font-size: 1.5rem;
  }
  
  h3 {
    font-size: 1.25rem;
  }
  
  /* Tables on mobile - stack or horizontal scroll */
  table {
    font-size: 0.85rem;
  }
  
  th, td {
    padding: 0.5rem 0.25rem;
  }
}

/* Very small screens (max-width: 360px) */
@media (max-width: 360px) {
  .hero h1 {
    font-size: 1.5rem;
  }
  
  .hero p {
    font-size: 0.9rem;
  }
  
  .card-content h3 {
    font-size: 0.95rem;
  }
  
  .card-content .price {
    font-size: 1rem;
  }
  
  nav a, nav form button {
    font-size: 0.75rem;
  }
}

/* Landscape orientation adjustments for mobile */
@media (max-height: 500px) and (orientation: landscape) {
  .hero {
    padding: 1.5rem 1rem;
  }
  
  .hero h1 {
    font-size: 1.5rem;
  }
  
  .hero p {
    font-size: 0.9rem;
  }
  
  main {
    padding: 1rem;
  }
}

/* Touch-friendly adjustments */
@media (hover: none) and (pointer: coarse) {
  /* Increase tap target sizes for touch devices */
  button, .button, nav a {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  
  .category-filter a {
    min-height: 40px;
  }
  
  /* Remove hover effects on touch devices */
  .card:hover {
    transform: none;
    box-shadow: none;
  }
  
  /* Add active state instead */
  .card:active {
    transform: scale(0.98);
  }
  
  button:active, .button:active {
    transform: scale(0.96);
  }
}

button, .button {
  display: inline-block;
  background: var(--primary-color);
  border: none;
  color: #fff;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  transition: background-color 0.2s ease;
}

button:hover, .button:hover {
  background: var(--primary-hover);
}

button.danger {
  background-color: var(--danger-color);
}
button.danger:hover {
  background-color: var(--danger-hover);
}

form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 500px;
}

form label {
  font-weight: 500;
}

form input, form textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card-background);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

th, td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

th {
  background-color: var(--card-background);
  font-weight: 600;
}

tr:last-child td {
  border-bottom: none;
}

.cart-item-row {
  vertical-align: middle;
}

.cart-item-row img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 8px;
  margin-right: 1rem;
}

.cart-summary {
  margin-top: 2rem;
  padding: 1.5rem;
  background: var(--card-background);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  max-width: 350px;
  margin-left: auto;
}

.cart-summary h2 {
  margin-top: 0;
}

.cart-summary .total {
  font-size: 1.5rem;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.cart-summary .button {
  width: 100%;
}

footer {
  text-align: center;
  padding: 2rem;
  background: var(--card-background);
  border-top: 1px solid var(--border-color);
  margin-top: auto;
  color: var(--subtle-text);
  flex-shrink: 0;
}

.hero {
  background: var(--primary-color);
  color: white;
  padding: 4rem 2rem;
  border-radius: 16px;
  text-align: center;
  margin-bottom: 3rem;
}

.hero h1 {
  font-size: 3rem;
  margin: 0 0 1rem;
}

.hero p {
  font-size: 1.25rem;
  margin: 0 0 2rem;
  opacity: 0.95;
}

.quantity-control {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.quantity-control button {
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 1.2rem;
  line-height: 1;
  border-radius: 4px;
}

.quantity-control span {
  min-width: 40px;
  text-align: center;
  font-weight: 500;
}

.category-filter {
  display: flex;
  gap: 1rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.category-filter a {
  padding: 0.5rem 1rem;
  background: var(--card-background);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  text-decoration: none;
  color: var(--text-color);
  transition: all 0.2s ease;
}

.category-filter a:hover, .category-filter a.active {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.product-badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  background: var(--primary-color);
  color: white;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

/* Rich Text Description Styles */
.product-description {
  line-height: 1.8;
}

.product-description p {
  margin: 1rem 0;
}

.product-description h1, .product-description h2, .product-description h3 {
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
}

.product-description ul, .product-description ol {
  margin: 1rem 0;
  padding-left: 2rem;
}

.product-description li {
  margin: 0.5rem 0;
}

.product-description a {
  color: var(--primary-color);
  text-decoration: underline;
}

.product-description img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 1rem 0;
}

.product-description strong {
  font-weight: 700;
}

.product-description em {
  font-style: italic;
}
