:root {
  --bg: #fff;
  --text: #000;
  --highlight: #e0f7ff;
  --checked-bg: #d1ffd1;
  --primary: #4a6fa5;
  --primary-light: #e0e8f5;
  --secondary: #6c757d;
  --accent: #28a745;
}

body.dark {
  --bg: #1e1e1e;
  --text: #eee;
  --highlight: #333;
  --checked-bg: #2e662e;
  --primary-light: #2c3e50;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: Arial, sans-serif;
  margin: 0;
  padding: 20px;
  transition: background 0.3s, color 0.3s;
  max-width: 1200px;
  margin: 0 auto;
}

.header {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-bottom: 20px;
  border-bottom: 1px solid #ddd;
  padding-bottom: 15px;
}

.header h1 {
  margin: 0;
  color: var(--primary);
}

.controls-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.search-container {
  flex-grow: 1;
  max-width: 400px;
  position: relative;
}

#search {
  padding: 10px 15px;
  font-size: 16px;
  width: 100%;
  border-radius: 20px;
  border: 1px solid #ccc;
  background: var(--bg);
  color: var(--text);
}

.action-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

/* Removed .language-selector select styles */

.print-container {
  display: flex;
  align-items: center;
  gap: 10px;
}

.print-option {
  font-size: 14px;
  white-space: nowrap;
}

button,
input[type="checkbox"] {
  cursor: pointer;
}

button {
  padding: 8px 15px;
  font-size: 14px;
  border: 1px solid #ccc;
  background: var(--bg);
  color: var(--text);
  border-radius: 20px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 5px;
}

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

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

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

.tag-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 15px 0;
}

.tag-btn {
  font-size: 13px;
  padding: 5px 12px;
  background: var(--bg);
  border: 1px solid #ddd;
}

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

.category {
  margin-top: 20px;
}

.category h2 {
  font-size: 18px;
  margin-bottom: 10px;
  cursor: pointer;
  background: var(--primary-light);
  padding: 10px 15px;
  border-radius: 5px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.checklist {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 10px;
  overflow: hidden;
  transition: max-height 0.3s ease-out;
}

.hidden {
  display: none !important;
}

.item {
  display: flex;
  align-items: center;
  border: 1px solid #ddd;
  padding: 8px 12px;
  border-radius: 5px;
  background: var(--bg);
  transition: background-color 0.3s;
}

.item.highlight {
  background-color: var(--checked-bg) !important;
}

.item:hover {
  background-color: var(--highlight);
}

.item label {
  flex-grow: 1;
  display: flex;
  align-items: center;
  gap: 8px;
}

.quantity-controls {
  display: flex;
  align-items: center;
  margin-left: 10px;
  gap: 5px;
}

.quantity-controls button {
  font-size: 16px;
  width: 28px;
  height: 28px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.quantity-controls input[type="number"] {
  width: 30px;
  text-align: center;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 4px;
  background: var(--bg);
  color: var(--text);
  -moz-appearance: textfield; /* Firefox */
}

/* Remove arrows for Chrome, Safari, Edge, Opera */
.quantity-controls input[type="number"]::-webkit-outer-spin-button,
.quantity-controls input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.item button.delete {
  background: none;
  border: none;
  color: #ff4d4d;
  font-size: 18px;
  margin-left: 5px;
  padding: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.item button.delete:hover {
  background: rgba(255, 77, 77, 0.1);
}

.add-custom-btn {
  background-color: var(--bg);
  color: var(--primary);
  border: 1px dashed var(--primary);
  padding: 8px 12px;
  margin-top: 10px;
  width: 100%;
  text-align: left;
  border-radius: 5px;
  cursor: pointer;
  font-weight: normal;
  display: flex;
  align-items: center;
  box-sizing: border-box;
}

.add-custom-btn:hover {
  background-color: var(--highlight);
}

.add-custom-btn:before {
  content: "+";
  margin-right: 8px;
  font-weight: bold;
}

#notes {
  width: 100%;
  height: 100px;
  margin-top: 30px;
  padding: 15px;
  font-size: 16px;
  border-radius: 5px;
  border: 1px solid #ddd;
  background: var(--bg);
  color: var(--text);
  resize: vertical;
}

.caret {
  transition: transform 0.3s ease;
}

.fade-out {
  opacity: 0;
  height: 0;
  padding: 0;
  margin: 0;
  overflow: hidden;
  transition: all 0.5s ease;
}

.print-options {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Share and Import Modal Styles */
.share-options,
.import-options {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.share-section,
.import-section {
  border: 1px solid #ddd;
  padding: 15px;
  border-radius: 8px;
  background: var(--highlight);
}

.share-section h4,
.import-section h4 {
  margin-top: 0;
  margin-bottom: 10px;
  color: var(--primary);
  font-size: 16px;
}

.url-container {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.url-container input {
  flex-grow: 1;
  padding: 8px 12px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.url-container button {
  padding: 8px 15px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  white-space: nowrap;
}

.url-container button:hover {
  background: var(--accent);
}

.export-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.export-buttons button {
  padding: 10px 15px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.export-buttons button:hover {
  background: var(--accent);
}

.file-container {
  display: flex;
  align-items: center;
  gap: 10px;
}

.file-container input[type="file"] {
  display: none;
}

.file-label {
  padding: 8px 15px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  display: inline-block;
}

.file-label:hover {
  background: var(--accent);
}

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background-color: var(--primary);
  color: white;
  padding: 10px 20px;
  border-radius: 5px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  z-index: 1001;
  transition: opacity 0.5s;
}

.toast.success {
  background-color: var(--accent);
}

.toast.error {
  background-color: #dc3545;
}

@media print {
  .header,
  .tag-filters,
  .delete,
  .add-custom-btn,
  .quantity-controls button {
    display: none !important;
  }
  body {
    padding: 0;
    margin: 0;
    width: 100%;
    font-size: 12px;
  }
  #categories {
    column-count: 3;
    column-gap: 20px;
    width: 100%;
  }
  .category {
    break-inside: avoid;
    page-break-inside: avoid;
    margin-bottom: 10px;
    display: block;
    border-bottom: 1px solid #ddd;
  }
  .category h2 {
    background: none;
    border-bottom: 1px solid #000;
    padding: 5px 0;
    font-size: 14px;
    margin-top: 5px;
    margin-bottom: 5px;
    display: block;
  }
  .checklist {
    display: block;
  }
  .item {
    display: none;
    page-break-inside: avoid;
    break-inside: avoid;
    border: none;
    border-bottom: 1px solid #eee;
    padding: 3px 0;
    margin-bottom: 3px;
    font-size: 12px;
    border-radius: 0;
  }
  body.print-all .item,
  body.print-selected .item.checked,
  body.print-selected .item.has-qty {
    display: flex;
    align-items: center;
  }
  .item label {
    display: flex;
    align-items: center;
    gap: 5px;
  }
  .quantity-controls {
    display: none;
  }
  .print-qty {
    order: 2;
    min-width: 15px;
    text-align: center;
    display: inline-block;
    margin: 0 3px;
  }
  .category.empty-for-print {
    display: none !important;
  }
  .qty-print {
    display: none;
  }
  #notes {
    display: none;
  }
  #notes:not(:placeholder-shown) {
    display: block;
    page-break-before: always;
  }
  .caret {
    display: none;
  }
}

@media print {
  .modal,
  .add-custom-btn,
  .buy-btn,
  .search-clear,
  .custom-item-input-container,
  .language-selector /* Removed this style as the element is gone */,
  .toast {
    display: none !important;
  }
}

@media (max-width: 768px) {
  .controls-row {
    flex-direction: column;
    align-items: stretch;
  }
  .search-container {
    max-width: 100%;
  }
  .action-buttons {
    justify-content: space-between;
  }
  .checklist {
    grid-template-columns: 1fr;
  }
  .print-options {
    flex-direction: column;
    align-items: flex-start;
  }
}

.undo-toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--primary);
  color: white;
  padding: 10px 20px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  gap: 15px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  z-index: 1000;
  transition: opacity 0.5s;
}

.undo-toast button {
  background: white;
  color: var(--primary);
  border: none;
  padding: 5px 10px;
  border-radius: 3px;
  cursor: pointer;
  font-weight: bold;
}

.undo-toast button:hover {
  background: #f0f0f0;
}

/* Modal styles */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

.modal-content {
  background-color: var(--bg);
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  width: 90%;
  max-width: 400px;
  position: relative;
}

.close-modal {
  position: absolute;
  top: 10px;
  right: 15px;
  font-size: 24px;
  cursor: pointer;
  color: var(--secondary);
}

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

.modal h3 {
  margin-top: 0;
  margin-bottom: 20px;
  color: var(--primary);
  font-size: 18px;
}

.form-group {
  margin-bottom: 15px;
}

.form-group label {
  display: block;
  margin-bottom: 5px;
  font-weight: bold;
}

.form-group input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
}

.save-custom-btn {
  background-color: var(--primary);
  color: white;
  border: none;
  padding: 10px 15px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
  margin-top: 10px;
  width: 100%;
}

.save-custom-btn:hover {
  background-color: var(--accent);
}

/* Add styles for the inline custom item input */
.custom-item-input-container {
  display: flex;
  align-items: center;
  background-color: var(--bg);
  border: 1px dashed var(--primary);
  border-radius: 5px;
  padding: 8px 12px;
  margin-top: 10px;
  width: 100%;
  box-sizing: border-box;
}

.custom-item-input {
  flex-grow: 1;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  padding: 0;
  outline: none;
}

.custom-item-save {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 18px;
  padding: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  cursor: pointer;
}

.custom-item-save:hover {
  background: rgba(74, 111, 165, 0.1);
}

/* Buy button styling */
.buy-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 18px;
  margin-left: 5px;
  padding: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  cursor: pointer;
}

.buy-btn:hover {
  background: rgba(40, 167, 69, 0.1);
}

/* Search clear button */
.search-container {
  position: relative;
}

.search-clear {
  position: absolute;
  right: 1px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--secondary);
  cursor: pointer;
  padding: 0;
  font-size: 16px;
  width: 12px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-clear:hover {
  color: var(--text);
}

/* Share and Import Modal Styles */
.share-options,
.import-options {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.share-section,
.import-section {
  border: 1px solid #ddd;
  padding: 15px;
  border-radius: 8px;
  background: var(--highlight);
}

.share-section h4,
.import-section h4 {
  margin-top: 0;
  margin-bottom: 10px;
  color: var(--primary);
  font-size: 16px;
}

.url-container {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.url-container input {
  flex-grow: 1;
  padding: 8px 12px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.url-container button {
  padding: 8px 15px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  white-space: nowrap;
}

.url-container button:hover {
  background: var(--accent);
}

.export-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.export-buttons button {
  padding: 10px 15px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.export-buttons button:hover {
  background: var(--accent);
}

.file-container {
  display: flex;
  align-items: center;
  gap: 10px;
}

.file-container input[type="file"] {
  display: none;
}

.file-label {
  padding: 8px 15px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  display: inline-block;
}

.file-label:hover {
  background: var(--accent);
}

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background-color: var(--primary);
  color: white;
  padding: 10px 20px;
  border-radius: 5px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  z-index: 1001;
  transition: opacity 0.5s;
}

.toast.success {
  background-color: var(--accent);
}

.toast.error {
  background-color: #dc3545;
}

@media (max-width: 768px) {
  .url-container {
    flex-direction: column;
  }

  .export-buttons {
    flex-direction: column;
  }

  .file-container {
    flex-direction: column;
    align-items: stretch;
  }
}
