/* Reset und Basis-Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
    'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
    sans-serif;
  line-height: 1.5;
  font-weight: 400;
  color: #213547;
  background-color: #ffffff;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  padding: 0;
  min-width: 320px;
  min-height: 100vh;
  overflow-x: hidden;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  outline: none;
}

button:focus-visible {
  outline: 2px solid #4CAF50;
  outline-offset: 2px;
}

/* App Container */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: #f5f5f5;
}

/* Header */
.app-header {
  background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
  color: white;
  padding: 1.25rem;
  text-align: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-header h1 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

/* Main Content */
.app-main {
  flex: 1;
  padding-bottom: 100px;
  overflow-y: auto;
}

/* Loading State */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 100px);
  gap: 1rem;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid #e0e0e0;
  border-top-color: #4CAF50;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.loading p {
  color: #666;
  font-size: 1.1rem;
}

/* Error State */
.error {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 100px);
  color: #f44336;
  font-size: 1.25rem;
  padding: 2rem;
  text-align: center;
}

/* Product Grid */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1rem;
  padding: 1rem;
  width: 100%;
}

.product-card {
  background: white;
  border: 2px solid #e0e0e0;
  border-radius: 12px;
  padding: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  min-height: 180px;
}

.product-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
  border-color: #4CAF50;
}

.product-card:active {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.product-image {
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 8px;
  background: #f5f5f5;
  position: relative;
}

.product-image img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.product-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: #f44336;
  color: white;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  z-index: 10;
}

.product-info {
  text-align: center;
  width: 100%;
}

.product-name {
  font-size: 1rem;
  font-weight: 600;
  color: #333;
  margin: 0 0 0.5rem 0;
  line-height: 1.3;
}

.product-price {
  font-size: 1.1rem;
  font-weight: 700;
  color: #4CAF50;
  margin: 0;
}

/* Cart Toggle Button */
.cart-toggle {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
  color: white;
  border: none;
  border-radius: 50px;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: 0 4px 20px rgba(76, 175, 80, 0.4);
  cursor: pointer;
  transition: all 0.3s ease;
  z-index: 999;
  font-size: 1rem;
  font-weight: 600;
}

.cart-toggle:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(76, 175, 80, 0.5);
}

.cart-toggle:active {
  transform: translateY(0);
}

.cart-toggle svg {
  flex-shrink: 0;
}

.cart-toggle-badge {
  background: #f44336;
  color: white;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 700;
}

.cart-toggle-price {
  font-size: 1.1rem;
  font-weight: 700;
}

/* Cart */
.cart {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-top: 3px solid #4CAF50;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.2);
  z-index: 1000;
  transition: all 0.3s ease;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.cart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border-bottom: 1px solid #e0e0e0;
  background: #f9f9f9;
  flex-shrink: 0;
}

.cart-header h2 {
  margin: 0;
  font-size: 1.25rem;
  color: #333;
}

.cart-close {
  background: transparent;
  border: none;
  color: #666;
  padding: 0.5rem;
  cursor: pointer;
  border-radius: 50%;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cart-close:hover {
  background: #f0f0f0;
  color: #333;
}

.cart-close:active {
  transform: scale(0.95);
}

.cart-items {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
  max-height: 50vh;
}

.cart-footer {
  flex-shrink: 0;
  border-top: 1px solid #e0e0e0;
  background: #f9f9f9;
  padding: 1rem;
}

.cart-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.cart-total-label {
  font-size: 1rem;
  color: #666;
  font-weight: 600;
}

.cart-total-amount {
  font-size: 1.75rem;
  font-weight: 700;
  color: #4CAF50;
}

.cart-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  background: #f9f9f9;
  border-radius: 8px;
  margin-bottom: 0.5rem;
  gap: 1rem;
}

.cart-item-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.cart-item-name {
  font-weight: 600;
  color: #333;
  font-size: 0.95rem;
}

.cart-item-price {
  color: #4CAF50;
  font-weight: 600;
  font-size: 0.9rem;
}

.cart-item-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.quantity-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: white;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  padding: 0.25rem;
}

.quantity-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: #4CAF50;
  color: white;
  border-radius: 6px;
  font-size: 1.25rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.quantity-btn:hover {
  background: #45a049;
  transform: scale(1.05);
}

.quantity-btn:active {
  transform: scale(0.95);
}

.quantity-display {
  min-width: 30px;
  text-align: center;
  font-weight: 600;
  color: #333;
  font-size: 1rem;
}

.remove-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: #f44336;
  color: white;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.remove-btn:hover {
  background: #da190b;
  transform: scale(1.05);
}

.remove-btn:active {
  transform: scale(0.95);
}

.checkout-btn {
  width: 100%;
  padding: 1.25rem;
  background: #4CAF50;
  color: white;
  border: none;
  font-size: 1.25rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-radius: 8px;
}

.checkout-btn:hover {
  background: #45a049;
}

.checkout-btn:active {
  transform: scale(0.98);
}

/* Tablet */
@media (min-width: 768px) {
  .app-header h1 {
    font-size: 2rem;
  }

  .product-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1.25rem;
  }

  .product-card {
    min-height: 200px;
  }

  .product-image {
    width: 100px;
    height: 100px;
  }

  .cart-item {
    padding: 1rem;
  }

  .checkout-btn {
    padding: 1.5rem;
    font-size: 1.5rem;
  }
}

/* Desktop */
@media (min-width: 1024px) {
  .product-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
  }

  .cart {
    max-width: 500px;
    right: 1rem;
    left: auto;
    bottom: 1rem;
    border-radius: 12px;
    border: 3px solid #4CAF50;
    max-height: 70vh;
  }

  .cart-header {
    border-radius: 12px 12px 0 0;
  }

  .cart-toggle {
    bottom: 2rem;
    right: 2rem;
  }
}
