/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary-color: #000000;
  --primary-hover: #333333;
  --secondary-color: #666666;
  --accent-color: #E5E5E5;
  --text-color: #000000;
  --text-light: #666666;
  --bg-color: #FFFFFF;
  --card-bg: #FFFFFF;
  --border-radius: 4px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.12);
  --transition: all 0.3s ease;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', 'Roboto', 'Helvetica Neue', 'Arial', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  letter-spacing: -0.01em;
  direction: rtl;
}

/* App Container */
.app {
  width: 100vw;
  height: 100vh;
  height: 100dvh; /* Dynamic viewport height for mobile browsers */
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  background-color: var(--bg-color);
  border-bottom: 1px solid var(--accent-color);
  padding: 16px 20px;
  flex-shrink: 0;
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: row-reverse;
  justify-content: space-between;
  align-items: center;
}

.header-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-color);
  letter-spacing: -0.02em;
  margin: 0;
}

.btn-reset {
  padding: 8px 12px;
  font-size: 0.9rem;
  font-weight: 600;
  background-color: var(--primary-color);
  color: var(--bg-color);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.btn-reset:hover {
  background-color: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

/* Screen Base Styles */
.screen {
  width: 100%;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow: hidden;
}

.content {
  width: 100%;
  max-width: 500px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Welcome Screen */
.welcome-screen {
  text-align: center;
}

.welcome-text {
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--text-color);
  margin-bottom: 32px;
  letter-spacing: -0.02em;
  line-height: 1.4;
}

/* Buttons */
.btn {
  padding: 16px 32px;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: var(--transition);
  /* width: 100%; */
  text-align: center;
  font-family: inherit;
}

.btn-primary {
  background-color: var(--primary-color);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.btn-primary:disabled {
  background-color: var(--secondary-color);
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  background-color: transparent;
  color: var(--primary-color);
  border: 1px solid var(--primary-color);
}

.btn-secondary:hover {
  background-color: var(--primary-color);
  color: white;
}

.btn-option {
  padding: 16px 20px;
  background-color: var(--card-bg);
  color: var(--text-color);
  border: 1px solid var(--accent-color);
  font-size: 0.95rem;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.btn-option:hover:not(:disabled) {
  border-color: var(--primary-color);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.btn-option.active {
  background-color: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.btn-option:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Taste Button Colors - Only show colors when active */
.btn-option[data-taste="chocolate"].active {
  background-color: rgb(162, 137, 114);
  color: white;
  border-color: rgb(162, 137, 114);
}

.btn-option[data-taste="sweet-chocolate"].active {
  background-color: #c1a089;
  color: white;
  border-color: #c1a089;
}

.btn-option[data-taste="sweet"].active {
  background-color: #dec2b5;
  color: #333;
  border-color: #dec2b5;
}

.btn-option[data-taste="sweet-fruity"].active {
  background-color: #f3d5b8;
  color: #333;
  border-color: #f3d5b8;
}

.btn-option[data-taste="fruity"].active {
  background-color: #ebe4cc;
  color: #333;
  border-color: #ebe4cc;
}

/* Selection Screen */
.selection-screen .content {
  max-height: 100vh;
  overflow-y: auto;
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 20px));
}

.section-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary-color);
  text-align: right;
  letter-spacing: -0.02em;
}

.section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.section-subtitle {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-color);
  text-align: center;
}

.button-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  grid-auto-rows: 1fr;
}

.divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: var(--text-light);
  font-weight: 600;
  margin: 8px 0;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--accent-color);
}

.divider span {
  padding: 0 16px;
}

.text-input {
  width: 100%;
  padding: 16px;
  font-size: 1rem;
  font-family: inherit;
  border: 1px solid var(--accent-color);
  border-radius: var(--border-radius);
  background-color: var(--card-bg);
  color: var(--text-color);
  resize: vertical;
  min-height: 100px;
  transition: var(--transition);
}

.text-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
}

.text-input:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.text-input::placeholder {
  color: var(--text-light);
}

.button-container {
  display: flex;
  flex-direction: row-reverse;
  gap: 12px;
  margin-top: 8px;
  padding-bottom: env(safe-area-inset-bottom, 16px);
}

.button-container .btn {
  flex: 1;
}

/* Loading Screen */
.loading-screen {
  text-align: center;
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 3px solid var(--accent-color);
  border-top: 3px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 24px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading-text {
  font-size: 1.1rem;
  color: var(--text-color);
  font-weight: 500;
}

/* Results Screen */
.results-screen {
  padding: 0;
}

.results-screen .content {
  max-width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.results-screen .section-title {
  padding: 8px;
  flex-shrink: 0;
}

/* Bundle Selector */
.bundle-selector {
  padding: 20px;
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  border-top: 1px solid var(--accent-color);
  background-color: var(--card-bg);
}

/* Custom Dropdown */
.custom-dropdown {
  position: relative;
  flex: 2;
  max-width: 300px;
}

.dropdown-button {
  width: 100%;
  padding: 12px 16px;
  background: #FFFFFF;
  border: 1px solid #E0E0E0;
  border-radius: 8px;
  color: var(--text-color);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.dropdown-button:hover {
  border-color: #BDBDBD;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.dropdown-button:active {
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Next Bundle Button */
.btn-next-bundle {
  flex: 1;
  max-width: 200px;
  padding: 10px 16px;
  background: #FFFFFF;
  border: 1px solid #E0E0E0;
  border-radius: 8px;
  color: var(--text-color);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  white-space: nowrap;
}

.btn-next-bundle:hover:not(:disabled) {
  border-color: #BDBDBD;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.btn-next-bundle:active:not(:disabled) {
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.btn-next-bundle:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.dropdown-text {
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 4px;
}

.discount-badge {
  font-size: 0.85rem;
  color: #28A745;
  font-weight: 600;
}

.dropdown-arrow {
  font-size: 0.75rem;
  transition: transform 0.3s ease;
  display: inline-block;
}

.dropdown-arrow.open {
  transform: rotate(180deg);
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: #FFFFFF;
  border: 1px solid #E0E0E0;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  overflow: hidden;
  z-index: 1000;
  animation: dropdownSlide 0.2s ease;
}

@keyframes dropdownSlide {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.dropdown-item {
  width: 100%;
  padding: 12px 16px;
  background: transparent;
  border: none;
  border-bottom: 1px solid #F5F5F5;
  color: var(--text-color);
  font-size: 1rem;
  font-weight: 500;
  text-align: right;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.dropdown-item:last-child {
  border-bottom: none;
}

.dropdown-item:hover {
  background: #F5F5F5;
  color: var(--text-color);
}

.dropdown-item.active {
  background: #F0F0F0;
  color: var(--text-color);
  font-weight: 600;
}

.dropdown-discount {
  font-size: 0.85rem;
  color: #28A745;
  font-weight: 600;
  white-space: nowrap;
}

.coffee-scroll-container {
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 0 20px;
  margin: 0 -20px;
  direction: rtl;
  min-height: 0; /* Important: allows flex child to shrink below content size */
  display: flex;
  align-items: center; /* Vertically center the cards */
}

.coffee-grid {
  display: flex;
  gap: 16px;
  padding: 0 20px 20px 20px;
  min-width: min-content;
  height: fit-content;
  max-height: 100%;
}

.coffee-card {
  flex: 0 0 280px;
  background-color: var(--card-bg);
  border-radius: var(--border-radius);
  padding: 16px;
  border: 1px solid var(--accent-color);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  /* gap: 12px; */
  gap: 8px;
  /*height: 420px; /* Fixed height for consistent card sizes */
}

.coffee-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--text-color);
}

.coffee-image-container {
  width: 100%;
  height: 200px;
  border-radius: var(--border-radius);
  overflow: hidden;
  background-color: #F5F5F5;
  flex-shrink: 0; /* Prevent image from shrinking */
}

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

.coffee-name {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-color);
  letter-spacing: -0.01em;
  line-height: 1.4;
  /*min-height: 2.8em; /* Reserve space for 2 lines of text */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.coffee-weight {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-light);
  flex-shrink: 0;
}

.coffee-price {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary-color);
  flex-shrink: 0;
  margin-top: auto; /* Push to bottom of card */
}

/* Taste Badges */
.taste-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  min-height: 60px; /* Reserve space for taste badges to maintain consistent card height */
  align-content: flex-start;
}

.taste-badge {
  font-size: 12px;
  padding: 4px 8px;
  border: 1px solid #999;
  border-radius: 4px;
  background: transparent;
  color: var(--text-color);
  font-weight: 500;
  white-space: nowrap;
}

.summary {
  background-color: var(--card-bg);
  padding: 10px 20px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--accent-color);
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex-shrink: 0;
}

.total {
  display: flex;
  flex-direction: row-reverse;
  justify-content: space-between;
  align-items: flex-start;
  /* padding: 12px 0; */
}

.total-price-container {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.original-price {
  font-size: 1rem;
  color: #999;
  text-decoration: line-through;
  margin-bottom: 4px;
  margin-right: 4px;
  font-weight: 500;
}

.total-label {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-color);
}

.total-price {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--primary-color);
}

.shipping-note {
  font-size: 16px;
  color: var(--text-light);
  text-align: right;
  margin: 0;
}

.btn-purchase {
  font-size: 1.1rem;
  padding: 18px;
}

/* Scrollbar Styling for Webkit Browsers */
.coffee-scroll-container::-webkit-scrollbar {
  height: 8px;
}

.coffee-scroll-container::-webkit-scrollbar-track {
  background: var(--bg-color);
  border-radius: 4px;
}

.coffee-scroll-container::-webkit-scrollbar-thumb {
  background: var(--accent-color);
  border-radius: 4px;
}

.coffee-scroll-container::-webkit-scrollbar-thumb:hover {
  background: var(--secondary-color);
}

/* Tablet and Desktop Styles */
@media (min-width: 768px) {
  .header-title {
    font-size: 1.75rem;
  }

  .welcome-text {
    font-size: 2.25rem;
  }

  .button-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .coffee-grid {
    justify-content: center;
    flex-wrap: wrap;
  }

  .coffee-card {
    flex: 0 0 220px;
  }

  .results-screen .content {
    max-width: 1200px;
    margin: 0 auto;
  }
}

@media (min-width: 1024px) {
  .coffee-scroll-container {
    overflow-x: auto;
    padding: 0 40px; /* More padding on desktop */
    margin: 0;
  }

  .coffee-grid {
    justify-content: center;
    flex-wrap: nowrap; /* Keep all cards in one line on desktop */
    gap: 20px; /* Even spacing between cards */
    width: 100%;
    padding: 0 0 20px 0;
  }
  
  /* Cards take equal width and fill the screen */
  .coffee-card {
    flex: 1 1 0; /* Equal width for all cards */
    min-width: 180px;
    max-width: 280px;
    height: auto;
  }
  
  /* Ensure all cards have the same height */
  .coffee-card {
    display: flex;
    flex-direction: column;
  }
  
  .coffee-image-container {
    flex-shrink: 0;
  }
  
  .coffee-name {
    flex-shrink: 0;
  }
  
  .coffee-weight {
    flex-shrink: 0;
  }
}

/* Large desktop - more space for cards */
@media (min-width: 1280px) {
  .coffee-scroll-container {
    padding: 0 60px;
  }
  
  .coffee-grid {
    gap: 24px;
  }
  
  .coffee-card {
    min-width: 200px;
    max-width: 320px;
  }
  
  .results-screen .content {
    max-width: 1400px;
  }
}

/* Extra large desktop - larger cards */
@media (min-width: 1536px) {
  .coffee-scroll-container {
    padding: 0 80px;
  }
  
  .coffee-grid {
    gap: 28px;
  }
  
  .coffee-card {
    min-width: 220px;
    max-width: 360px;
  }
  
  .results-screen .content {
    max-width: 1600px;
  }
}

/* Mobile adjustments for header */
@media (max-width: 480px) {
  .header-title {
    font-size: 1.25rem;
  }

  .btn-reset {
    padding: 6px 10px;
    font-size: 0.85rem;
  }
  
  /* Bundle selector responsive */
  .bundle-selector {
    padding: 8px;
    gap: 8px;
  }
  
  .custom-dropdown {
    max-width: none;
  }
  
  .btn-next-bundle {
    max-width: none;
  }
  
  .dropdown-button {
    padding: 10px 12px;
    font-size: 0.9rem;
  }
  
  .dropdown-item {
    padding: 10px 12px;
    font-size: 0.9rem;
  }
  
  /* Smaller product cards on mobile */
  .coffee-card {
    flex: 0 0 240px;
  }
  
  .coffee-image-container {
    height: 160px;
  }
  
  .coffee-name {
    font-size: 1rem;
    /*min-height: 2.8em; /* Keep consistent height on mobile too */
  }
  
  .coffee-weight {
    font-size: 0.875rem;
  }
  
  .coffee-price {
    font-size: 1.1rem;
  }
}

/* Extra small height devices - make cards even more compact */
@media (max-height: 700px) {
  .coffee-image-container {
    height: 140px;
  }
  
  .coffee-card {
    gap: 8px;
    padding: 12px;
    height: 360px; /* Adjusted height for smaller screens */
  }
  
  .results-screen .section-title {
    padding: 16px 20px;
    font-size: 1.5rem;
  }
  
  .coffee-scroll-container {
    padding: 0 16px;
    margin: 0 -16px;
  }
  
  .coffee-grid {
    padding: 0 16px 16px 16px;
  }
}

/* Very small height devices - ultra compact */
@media (max-height: 600px) {
  .coffee-image-container {
    height: 120px;
  }
  
  .coffee-card {
    height: 320px; /* Adjusted height for very small screens */
  }
  
  .coffee-name {
    font-size: 0.95rem;
  }
  
  .results-screen .section-title {
    padding: 12px 20px;
    font-size: 1.35rem;
  }
}

/* Modal Styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal-content {
  background-color: var(--card-bg);
  border-radius: var(--border-radius);
  max-width: 500px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-close {
  position: absolute;
  top: 16px;
  left: 16px;
  background: transparent;
  border: none;
  font-size: 32px;
  color: var(--text-color);
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  transition: color 0.2s;
}

.modal-close:hover {
  color: var(--primary-color);
}

.modal-header {
  padding: 24px;
  border-bottom: 1px solid var(--accent-color);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.modal-coffee-image {
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: var(--border-radius);
  background-color: #F5F5F5;
}

.modal-coffee-name {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-color);
  text-align: center;
  margin: 0;
}

.modal-body {
  padding: 24px;
}

.modal-description {
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-color);
  margin: 0 0 20px 0;
  text-align: right;
}

.modal-taste-notes {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--accent-color);
}

.modal-section-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-color);
  margin: 0 0 12px 0;
  text-align: right;
}

.modal-taste-notes .taste-badges {
  justify-content: flex-start;
}

/* Mobile adjustments for modal */
@media (max-width: 768px) {
  .modal-overlay {
    padding: 16px;
  }
  
  .modal-content {
    max-height: 85vh;
  }
  
  .modal-coffee-image {
    width: 100px;
    height: 100px;
  }
  
  .modal-coffee-name {
    font-size: 1.25rem;
  }
  
  .modal-body {
    padding: 20px;
  }
  
  .modal-description {
    font-size: 0.95rem;
  }
}

