:root {
  --primary-green: #2ecc71;
  --primary-green-hover: #27ae60;
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  font-family: var(--font-family);
}

body {
  background: #111;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding-bottom: 70px; /* Muudetud: jätab alumisse äärde ruumi Netlify märgise jaoks, et nupud ei jääks peitu */
  box-sizing: border-box;
}

#app-container {
  width: 100%;
  max-width: 420px;
  height: 100vh;
  position: relative;
  overflow: hidden;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
}

.view {
  display: none !important;
  flex-direction: column;
  height: 100%;
  width: 100%;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
}

.view.active {
  display: flex !important;
  z-index: 2;
}

/* ==========================================
   ESIMENE EKRAAN: SISSELOGIMINE
   ========================================== */
#view-login {
  justify-content: center;
  align-items: center;
  padding: 20px;
  text-align: center;
  position: relative;
  background: url('https://images.unsplash.com/photo-1767277672167-18105701959b?q=80&w=988&auto=format&fit=crop') center/cover no-repeat;
}

#view-login::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #969696;
  mix-blend-mode: multiply;
  z-index: 1;
}

#view-login > * {
  position: relative;
  z-index: 2;
}

.login-title {
  font-family: 'Caprasimo', serif !important;
  color: #ffffff;
  text-align: center;
  line-height: 1.05;
  margin-bottom: 174px;
  text-transform: uppercase;
}

.title-line-1 { font-family: 'Caprasimo', serif !important; font-size: 53.11px; display: block; }
.title-line-2 { font-family: 'Caprasimo', serif !important; font-size: 85.73px; display: block; }
.title-line-3 { font-family: 'Caprasimo', serif !important; font-size: 59.63px; display: block; }

.password-wrapper {
  position: relative;
  width: 292px;
  margin-bottom: 21px;
  margin-left: auto;
  margin-right: auto;
}

.login-input {
  width: 292px;
  height: 56px;
  background: #ffffff;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  color: #2c3e50;
  padding: 0 45px 0 20px;
  outline: none;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  text-align: left;
}

.login-input::placeholder {
  color: #a0aec0;
  font-weight: 300;
}

.toggle-password {
  position: absolute;
  right: 15px;
  top: 50%;
  transform: translateY(-50%);
  cursor: pointer;
  background: none;
  border: none;
  padding: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #a0aec0;
  transition: color 0.2s;
}

.toggle-password:hover {
  color: #2c3e50;
}

.toggle-password svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

.btn-login {
  width: 292px;
  height: 56px;
  background: #bdc3c7;
  color: #ffffff;
  border: none;
  border-radius: 12px;
  font-size: 18px;
  font-weight: 700;
  cursor: not-allowed;
  pointer-events: none;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  transition: background 0.2s ease, box-shadow 0.2s ease;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

.btn-login.active {
  background: var(--primary-green);
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 4px 15px rgba(46, 204, 113, 0.3);
}

.btn-login.active:active {
  background: var(--primary-green-hover);
}

/* ==========================================
   TEINE EKRAAN: NIMEKIRJAD
   ========================================== */
#view-lists {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 230px;
  padding-bottom: 115px;
  text-align: center;
  position: relative;
  background: url('https://images.unsplash.com/photo-1767277672167-18105701959b?q=80&w=988&auto=format&fit=crop') center/cover no-repeat;
  height: 100vh;
  box-sizing: border-box;
}

#view-lists::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #969696;
  mix-blend-mode: multiply;
  z-index: 1;
}

#view-lists > * {
  position: relative;
  z-index: 2;
}

.lists-container {
  width: 292px;
  flex-grow: 0;
  max-height: calc(5 * 45px + 5 * 19px + 22.5px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 19px;
  margin-left: auto;
  margin-right: auto;
  scrollbar-width: none;
}

.lists-container::-webkit-scrollbar {
  display: none;
}

.list-card-wrapper {
  position: relative;
  width: 292px;
  height: 45px;
  flex-shrink: 0;
  overflow: hidden;
}

.list-card {
  width: 292px;
  height: 45px;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 12px;
  font-family: 'Poppins', sans-serif;
  font-size: 20px;
  font-weight: 500;
  color: #2c3e50;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  transition: transform 0.25s ease-out;
}

.list-card-delete {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 65px;
  background: #e74c3c;
  color: white;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1;
  cursor: pointer;
  border-radius: 12px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  transform: translateX(100%);
  transition: transform 0.25s ease-out;
}

.list-card-wrapper.swiped .list-card {
  transform: translateX(-73px);
}

.list-card-wrapper.swiped .list-card-delete {
  transform: translateX(0);
}

.list-card-delete svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.btn-create-list {
  margin-top: auto;
  width: 292px;
  height: 56px;
  background: var(--primary-green);
  color: #ffffff;
  border: none;
  border-radius: 12px;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(46, 204, 113, 0.3);
  transition: background 0.2s ease;
  flex-shrink: 0;
}

.btn-create-list:active {
  background: var(--primary-green-hover);
}

.empty-lists-msg {
  font-family: 'Poppins', sans-serif;
  font-weight: 500;
  font-size: 18px;
  color: #ffffff;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
  line-height: 1.4;
  padding: 0 20px;
}

/* ==========================================
   KOLMAS EKRAAN: NIMEKIRJA SISU (#view-detail)
   ========================================== */
#view-detail {
  background-color: #FBFBFB;
  overflow-y: auto;
  text-align: left;
  position: relative;
  padding-bottom: 40px; /* Tagab, et sisu ei lõpeks vastu serva */
}

.detail-header {
  position: relative;
  width: 100%;
  height: 195px;
  background: url('https://images.unsplash.com/photo-1767277672167-18105701959b?q=80&w=988&auto=format&fit=crop') center/cover no-repeat;
  flex-shrink: 0;
}

.detail-header::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.8) 72%);
  z-index: 1;
}

.detail-header > * {
  position: relative;
  z-index: 2;
}

.detail-back-btn {
  position: absolute;
  bottom: 15px;
  left: 15px;
  width: 40px;
  height: 40px;
  background: #ffffff;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.detail-back-btn svg {
  width: 20px;
  height: 20px;
  stroke: #2c3e50;
  stroke-width: 2.5;
  fill: none;
}

.detail-title {
  position: absolute;
  bottom: 35px;
  left: 63px;
  transform: translateY(50%);
  font-family: 'Poppins', sans-serif;
  font-weight: 600;
  font-size: 25px;
  color: #ffffff;
  line-height: 1;
}

/* Plus nupp ja lahtiklapitavad nupud päises */
.detail-add-btn {
  position: absolute;
  bottom: 15px;
  right: 15px;
  width: 56px;
  height: 56px;
  background: var(--primary-green);
  border: none;
  border-radius: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(46, 204, 113, 0.4);
  transition: all 0.2s ease;
}

.detail-add-btn svg {
  width: 18px;
  height: 18px;
  stroke: #ffffff;
  stroke-width: 3;
  fill: none;
}

.header-action-buttons {
  position: absolute;
  bottom: 15px;
  right: 15px;
  display: none;
  gap: 7px;
  align-items: center;
}

.header-action-buttons.active {
  display: flex;
}

.btn-header-add,
.btn-header-delete-checked {
  width: 99px;
  height: 56px;
  border: none;
  border-radius: 28px;
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  font-size: 14px;
  color: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.btn-header-add {
  background: var(--primary-green);
}

.btn-header-delete-checked {
  background: #D7272A;
}

.detail-filters-section {
  padding: 17px 0 15px 0;
  background-color: #FBFBFB;
}

.filter-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 19px 0 15px;
  margin-bottom: 12px;
}

.sort-label {
  font-family: 'Poppins', sans-serif;
  font-weight: 600;
  font-size: 13.6px;
  color: #000000;
}

.all-stores-link {
  font-family: 'Poppins', sans-serif;
  font-weight: 400;
  font-size: 13.6px;
  color: #000000;
  cursor: pointer;
}

.categories-scroll-wrapper {
  width: 100%;
  overflow-x: auto;
  overflow-y: visible !important; /* Parandatud: hoiab ära kolmanda rea ära lõikamise */
  scrollbar-width: none;
  padding: 0 15px;
  padding-bottom: 15px !important; /* Parandatud: annab alumisele osale hingamisruumi */
}

.categories-scroll-wrapper::-webkit-scrollbar {
  display: none;
}

.categories-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: auto !important; /* Parandatud: ei piira kõrgust rangelt, et kõik read mahuksid ära */
  min-height: 115px;
  width: max-content;
  padding-bottom: 8px !important;
}

.category-row {
  display: flex;
  gap: 8px;
}

.cat-chip {
  padding: 8px 16px;
  border-radius: 20px;
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  font-size: 11.5px;
  color: #000000;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  transition: background-color 0.2s, color 0.2s;
}

.cat-green { background-color: #b1ffcc; }
.cat-cyan { background-color: #a7f3ff; }
.cat-pink { background-color: #ffd1ec; }
.cat-orange { background-color: #fce3b8; }
.cat-blue { background-color: #9cd4ff; }
.cat-purple { background-color: #e3c4ff; }
.cat-yellow { background-color: #fffeb8; }
.cat-rose { background-color: #ffb8c4; }
.cat-peach { background-color: #ffdec4; }
.cat-gray { background-color: #b8b8b8; color: #ffffff; }

.cat-chip.inactive {
  background-color: #E0E0E0 !important;
  color: #000000 !important;
  box-shadow: none;
}

/* ==========================================
   TOODETE LISTIDE KUVAMINE
   ========================================== */
.products-content {
  padding: 10px 0 60px 0;
}

.category-section {
  margin-bottom: 15px;
  display: none;
}

.category-header-title {
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  font-size: 20px;
  color: #000000;
  margin-bottom: 8px;
  padding-left: 15px;
}

.product-item {
  position: relative;
  display: flex;
  align-items: center;
  height: 45px;
  margin: 0 15px;
  padding: 0 9px;
  border-radius: 12px;
  background-color: transparent;
  transition: background-color 0.2s;
  cursor: pointer;
}

.product-item.checked {
  background-color: rgba(52, 199, 89, 0.25);
}

.product-checkbox {
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background-color: #D9D9D9;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-right: 15px;
  transition: background-color 0.2s;
}

.product-checkbox svg {
  display: none;
  width: 14px;
  height: 14px;
  stroke: #24803B;
  stroke-width: 3.5;
  fill: none;
}

.product-item.checked .product-checkbox {
  background-color: #34C759;
}

.product-item.checked .product-checkbox svg {
  display: block;
}

.product-info {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.product-row-1 {
  display: flex;
  align-items: baseline;
  gap: 18px;
}

.product-name {
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  font-size: 16.2px;
  color: #000000;
  line-height: 1.1;
}

.product-qty {
  font-family: 'Poppins', sans-serif;
  font-weight: 500;
  font-size: 12.6px;
  color: #000000;
}

.product-row-2 {
  display: flex;
  align-items: baseline;
  gap: 18px;
  margin-top: 1px;
}

.product-store, .product-comment {
  font-family: 'Poppins', sans-serif;
  font-weight: 400;
  font-size: 12px;
  color: #555555;
  line-height: 1;
}

.product-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-left: 10px;
}

.product-edit-btn,
.product-delete-btn {
  width: 34px;
  height: 34px;
  background-color: #D9D9D9;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.product-edit-btn svg,
.product-delete-btn svg {
  width: 16px;
  height: 16px;
  fill: #FFFFFF;
}

.product-divider {
  width: calc(100% - 30px);
  height: 1px;
  background-color: #E9E9E9;
  margin: 5px 15px;
}


/* ==========================================
   POP-UP MENÜÜD (Poed, Kustutamine, Lisa toode)
   ========================================== */
.store-modal-overlay,
.delete-modal-overlay,
.add-product-modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(0, 0, 0, 0.25);
  z-index: 100;
  display: none;
  align-items: flex-end;
}

.store-modal-overlay.active,
.delete-modal-overlay.active,
.add-product-modal-overlay.active {
  display: flex;
}

.store-modal-content,
.delete-modal-content,
.add-product-modal-content {
  width: 100%;
  background: #ffffff;
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  box-shadow: 0px 0px 10px 4px rgba(0, 0, 0, 0.25);
  padding: 24px 20px 40px 20px; /* Parandatud: lisatud alumisse äärde rohkem ruumi */
  display: flex;
  flex-direction: column;
  max-height: 85vh; /* Parandatud: ei lase akendel liiga pikaks venida */
  overflow-y: auto; /* Parandatud: teeb akna sisu vajadusel keritavaks */
}

.store-modal-header,
.delete-modal-header,
.add-product-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.store-modal-title,
.delete-modal-title,
.add-product-title {
  font-family: 'Poppins', sans-serif;
  font-weight: 900;
  font-size: 20px;
  color: #000000;
}

.store-modal-close,
.delete-modal-close,
.add-product-close {
  width: 32px;
  height: 32px;
  background: #000000;
  border: none;
  border-radius: 50%;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
}

.store-modal-list {
  overflow-y: auto;
  max-height: calc(4 * 45px);
  scrollbar-width: none;
}

.store-modal-list::-webkit-scrollbar {
  display: none;
}

.store-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 45px;
  padding: 0 5px;
  cursor: pointer;
  font-family: 'Poppins', sans-serif;
  font-weight: 500;
  font-size: 16.2px;
  color: #000000;
}

.store-item-divider {
  width: 100%;
  height: 1px;
  background-color: #E9E9E9;
}

.store-check-icon {
  width: 20px;
  height: 20px;
  stroke: #34C759;
  stroke-width: 3.5;
  fill: none;
  display: none;
}

.store-item.selected .store-check-icon {
  display: block;
}

/* Kustutamise kinnitusnupud */
.delete-modal-buttons {
  display: flex;
  gap: 15px;
  margin-top: 10px;
}

.btn-delete-yes {
  flex: 1;
  height: 48px;
  background: transparent;
  border: 2px solid var(--primary-green);
  border-radius: 12px;
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  font-size: 16px;
  color: #000000;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-delete-yes:active {
  background: rgba(46, 204, 113, 0.15);
}

.btn-delete-no {
  flex: 1;
  height: 48px;
  background: transparent;
  border: none;
  border-radius: 12px;
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  font-size: 16px;
  color: #000000;
  cursor: pointer;
}

.btn-delete-no:active {
  background: rgba(0, 0, 0, 0.05);
}

/* Toote lisamise vormi elemendid */
.add-form-group {
  margin-bottom: 15px;
  width: 100%;
}

.add-form-label {
  display: block;
  font-family: 'Poppins', sans-serif;
  font-weight: 500;
  font-size: 12.6px;
  color: #5D5D5D;
  margin-bottom: 5px;
}

.add-form-input {
  width: 100%;
  height: 35px;
  background: #EFEFEF;
  border: none;
  border-radius: 8px;
  padding: 0 12px;
  font-family: 'Poppins', sans-serif;
  font-weight: 500;
  font-size: 16.2px;
  color: #000000;
  outline: none;
}

.add-form-input::placeholder,
.add-row-input::placeholder,
.add-textarea::placeholder {
  font-weight: 300;
  color: #a0aec0;
}

.add-form-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 15px;
  width: 100%;
}

.add-row-label {
  font-family: 'Poppins', sans-serif;
  font-weight: 500;
  font-size: 12.6px;
  color: #5D5D5D;
  flex-shrink: 0;
}

.add-row-input {
  flex-grow: 1;
  height: 35px;
  background: #EFEFEF;
  border: none;
  border-radius: 8px;
  padding: 0 10px;
  font-family: 'Poppins', sans-serif;
  font-weight: 500;
  font-size: 16.2px;
  color: #000000;
  outline: none;
  min-width: 0;
}

.add-textarea {
  flex-grow: 1;
  height: 67px;
  background: #EFEFEF;
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  font-family: 'Poppins', sans-serif;
  font-weight: 500;
  font-size: 16.2px;
  color: #000000;
  outline: none;
  resize: none;
}

.add-comment-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  width: 100%;
  margin-bottom: 10px;
  gap: 20px;
}

.btn-submit-add {
  width: 55px;
  height: 55px;
  background: #34C759;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(52, 199, 89, 0.4);
  flex-shrink: 0;
}

.btn-submit-add svg {
  width: 24px;
  height: 24px;
  stroke: #ffffff;
  stroke-width: 3.5;
  fill: none;
}

/* Kategooria rippmenüü lisamisvormis */
.custom-select-wrapper {
  position: relative;
  width: 100%;
}

.custom-select-trigger {
  width: 100%;
  height: 35px;
  background: #EFEFEF;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  cursor: pointer;
  font-family: 'Poppins', sans-serif;
  font-weight: 500;
  font-size: 16.2px;
  color: #000000;
}

.custom-select-trigger.placeholder {
  color: #A0AEC0;
  font-weight: 300;
}

.custom-select-arrow {
  width: 16px;
  height: 16px;
  stroke: #000000;
  stroke-width: 2.5;
  fill: none;
  transition: transform 0.2s ease;
}

.custom-select-wrapper.open .custom-select-arrow {
  transform: rotate(180deg);
}

.custom-select-dropdown {
  position: absolute;
  top: 40px;
  left: 0;
  width: 100%;
  background: #FBFBFB;
  border-radius: 8px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.15);
  max-height: 160px;
  overflow-y: auto;
  display: none;
  z-index: 120;
  scrollbar-width: none;
}

.custom-select-dropdown::-webkit-scrollbar {
  display: none;
}

.custom-select-wrapper.open .custom-select-dropdown {
  display: block;
}

.custom-dropdown-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 40px;
  padding: 0 12px;
  cursor: pointer;
  font-family: 'Poppins', sans-serif;
  font-weight: 500;
  font-size: 14px;
  color: #000000;
  border-bottom: 1px solid #E9E9E9;
}

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

.custom-dropdown-item.selected .store-check-icon {
  display: block;
}