* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f5f5f5;
  min-height: 100vh;
}

.container {
  max-width: 500px;
  margin: 0 auto;
  padding: 20px;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

h1 {
  font-size: 1.5rem;
  color: #333;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 1rem;
  cursor: pointer;
  transition: background-color 0.2s;
}

.btn-primary {
  background: #4a90d9;
  color: white;
}

.btn-primary:hover {
  background: #357abd;
}

.btn-danger {
  background: #e74c3c;
  color: white;
}

.btn-danger:hover {
  background: #c0392b;
}

.btn-add {
  background: #27ae60;
  color: white;
  width: 44px;
  height: 44px;
  font-size: 1.5rem;
  padding: 0;
  flex-shrink: 0;
}

.btn-add:hover {
  background: #219a52;
}

.add-section {
  margin-bottom: 20px;
  display: flex;
  gap: 8px;
}

.input-wrapper {
  position: relative;
  flex: 1;
}

#item-input {
  flex: 1;
  padding: 12px 16px;
  font-size: 1rem;
  border: 2px solid #ddd;
  border-radius: 8px;
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
}

#item-input:focus {
  border-color: #4a90d9;
}

.suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 52px;
  background: white;
  border: 1px solid #ddd;
  border-radius: 8px;
  margin-top: 4px;
  list-style: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  z-index: 100;
  display: none;
}

.suggestions.active {
  display: block;
}

.suggestions li {
  padding: 12px 16px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.suggestions li:hover,
.suggestions li.selected {
  background: #f0f7ff;
}

.suggestions li:first-child {
  border-radius: 8px 8px 0 0;
}

.suggestions li:last-child {
  border-radius: 0 0 8px 8px;
}

.shopping-actions {
  margin-bottom: 20px;
}

.item-list {
  list-style: none;
}

.item {
  display: flex;
  align-items: center;
  padding: 16px;
  background: white;
  border-radius: 8px;
  margin-bottom: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  transition: opacity 0.2s, transform 0.2s;
}

.item.checked {
  opacity: 0.6;
}

.item.checked .item-name {
  text-decoration: line-through;
  color: #888;
}

.item-checkbox {
  display: none;
}

.item-check {
  width: 24px;
  height: 24px;
  border: 2px solid #ddd;
  border-radius: 50%;
  margin-right: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
}

.item.checked .item-check {
  background: #27ae60;
  border-color: #27ae60;
}

.item.checked .item-check::after {
  content: '✓';
  color: white;
  font-size: 14px;
}

.item-name {
  flex: 1;
  font-size: 1rem;
  color: #333;
}

.item-delete {
  background: none;
  border: none;
  color: #ccc;
  font-size: 1.25rem;
  cursor: pointer;
  padding: 4px 8px;
  transition: color 0.2s;
}

.item-delete:hover {
  color: #e74c3c;
}

/* Item Quantity Controls */
.item-quantity {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-right: 8px;
}

.qty-btn {
  width: 28px;
  height: 28px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #f5f5f5;
  color: #333;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.qty-btn:hover:not(:disabled) {
  background: #e0e0e0;
  border-color: #ccc;
}

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

.qty-value {
  min-width: 24px;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 500;
  color: #333;
}

/* Quantity badge in shopping view */
.item-qty-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  background: #4a90d9;
  color: white;
  border-radius: 11px;
  font-size: 0.8rem;
  font-weight: 600;
  margin-left: auto;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: #888;
}

.hidden {
  display: none !important;
}

/* Shopping mode styles */
body.shopping-mode .item {
  cursor: pointer;
}

body.shopping-mode .item:active {
  transform: scale(0.98);
}

body.shopping-mode .item-delete {
  display: none;
}

body.shopping-mode .item-check {
  pointer-events: none;
}

/* Tab Navigation */
.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.tab {
  flex: 1;
  padding: 12px 16px;
  border: none;
  background: #e0e0e0;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  text-align: center;
  color: #333;
}

.tab:hover {
  background: #d0d0d0;
}

.tab.active {
  background: #4a90d9;
  color: white;
}

/* Add Meal Button */
.btn-meal {
  background: #9b59b6;
  color: white;
  white-space: nowrap;
}

.btn-meal:hover {
  background: #8e44ad;
}

/* Meals Section */
.meals-add {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

#meal-name-input {
  flex: 1;
  padding: 12px 16px;
  font-size: 1rem;
  border: 2px solid #ddd;
  border-radius: 8px;
  outline: none;
  transition: border-color 0.2s;
}

#meal-name-input:focus {
  border-color: #4a90d9;
}

.meal-list {
  list-style: none;
}

.meal-card {
  background: white;
  border-radius: 8px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.meal-header {
  display: flex;
  align-items: center;
  padding: 16px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.meal-header:hover {
  background: #f9f9f9;
}

.meal-name {
  flex: 1;
  font-size: 1rem;
  font-weight: 500;
  color: #333;
}

.meal-count {
  font-size: 0.875rem;
  color: #888;
  margin-right: 12px;
}

.meal-actions {
  display: flex;
  gap: 8px;
}

.meal-actions button {
  background: none;
  border: none;
  color: #888;
  cursor: pointer;
  padding: 4px 8px;
  font-size: 1rem;
  transition: color 0.2s;
}

.meal-actions button:hover {
  color: #333;
}

.meal-actions .expand-meal {
  transition: transform 0.2s;
}

.meal-card.expanded .expand-meal {
  transform: rotate(90deg);
}

.meal-actions .delete-meal:hover {
  color: #e74c3c;
}

.meal-items {
  border-top: 1px solid #eee;
  padding: 12px 16px;
  display: none;
}

.meal-card.expanded .meal-items {
  display: block;
}

.meal-item {
  display: flex;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #f0f0f0;
}

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

.meal-item-name {
  flex: 1;
  color: #555;
}

.meal-item-delete {
  background: none;
  border: none;
  color: #ccc;
  cursor: pointer;
  font-size: 1rem;
  padding: 4px 8px;
  transition: color 0.2s;
}

.meal-item-delete:hover {
  color: #e74c3c;
}

.meal-item-add {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  position: relative;
}

.meal-item-input {
  flex: 1;
  padding: 8px 12px;
  font-size: 0.875rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  outline: none;
}

.meal-item-input:focus {
  border-color: #4a90d9;
}

.btn-add-item {
  background: #27ae60;
  color: white;
  border: none;
  border-radius: 6px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.875rem;
}

.btn-add-item:hover {
  background: #219a52;
}

/* Modal Styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: white;
  border-radius: 12px;
  width: 100%;
  max-width: 400px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #eee;
}

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

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #888;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}

.modal-close:hover {
  color: #333;
}

#modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}

.modal-meals-list,
.modal-items-list {
  list-style: none;
}

.modal-meal-item {
  padding: 12px 16px;
  border: 1px solid #eee;
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.modal-meal-item:hover {
  background: #f0f7ff;
  border-color: #4a90d9;
}

.modal-meal-name {
  font-weight: 500;
  color: #333;
}

.modal-meal-count {
  font-size: 0.875rem;
  color: #888;
  margin-top: 4px;
}

.modal-item {
  display: flex;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid #f0f0f0;
}

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

.modal-item input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin-right: 12px;
  cursor: pointer;
}

.modal-item label {
  flex: 1;
  cursor: pointer;
  color: #333;
}

.modal-select-all {
  display: flex;
  align-items: center;
  padding: 8px 0 16px;
  border-bottom: 1px solid #eee;
  margin-bottom: 8px;
}

.modal-select-all input {
  width: 20px;
  height: 20px;
  margin-right: 12px;
  cursor: pointer;
}

.modal-select-all label {
  font-weight: 500;
  cursor: pointer;
  color: #333;
}

.modal-actions {
  display: flex;
  gap: 12px;
  padding: 16px 20px;
  border-top: 1px solid #eee;
}

.modal-actions .btn {
  flex: 1;
}

#modal-cancel {
  background: #e0e0e0;
  color: #333;
}

#modal-cancel:hover {
  background: #d0d0d0;
}

/* Store Select in Shopping Mode */
.store-select {
  flex: 1;
  padding: 10px 12px;
  font-size: 1rem;
  border: 2px solid #ddd;
  border-radius: 8px;
  background: white;
  cursor: pointer;
  outline: none;
}

.store-select:focus {
  border-color: #4a90d9;
}

.store-name-display {
  flex: 1;
  padding: 10px 12px;
  font-size: 1rem;
  font-weight: 500;
  color: #333;
}

.shopping-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

/* Stores Section */
.stores-add {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

#store-name-input {
  flex: 1;
  padding: 12px 16px;
  font-size: 1rem;
  border: 2px solid #ddd;
  border-radius: 8px;
  outline: none;
  transition: border-color 0.2s;
}

#store-name-input:focus {
  border-color: #4a90d9;
}

.store-list {
  list-style: none;
}

.store-card {
  background: white;
  border-radius: 8px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.store-header {
  display: flex;
  align-items: center;
  padding: 16px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.store-header:hover {
  background: #f9f9f9;
}

.store-name {
  flex: 1;
  font-size: 1rem;
  font-weight: 500;
  color: #333;
}

.store-count {
  font-size: 0.875rem;
  color: #888;
  margin-right: 12px;
}

.store-actions {
  display: flex;
  gap: 8px;
}

.store-actions button {
  background: none;
  border: none;
  color: #888;
  cursor: pointer;
  padding: 4px 8px;
  font-size: 1rem;
  transition: color 0.2s;
}

.store-actions button:hover {
  color: #333;
}

.store-actions .delete-store:hover {
  color: #e74c3c;
}

.store-actions .expand-store {
  transition: transform 0.2s;
}

.store-card.expanded .expand-store {
  transform: rotate(90deg);
}

.store-items {
  border-top: 1px solid #eee;
  padding: 12px 16px;
  display: none;
  max-height: 400px;
  overflow-y: auto;
}

.store-card.expanded .store-items {
  display: block;
}

.store-item {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  background: #f9f9f9;
  border-radius: 6px;
  margin-bottom: 6px;
  cursor: grab;
  transition: all 0.2s;
}

.store-item:hover {
  background: #f0f0f0;
}

.store-item.dragging {
  opacity: 0.5;
  background: #e0e0e0;
}

.store-item.drag-over {
  border-top: 2px solid #4a90d9;
}

.store-item-handle {
  color: #bbb;
  margin-right: 12px;
  cursor: grab;
}

.store-item-name {
  flex: 1;
  color: #555;
}

.store-item-remove {
  background: none;
  border: none;
  color: #ccc;
  cursor: pointer;
  font-size: 1rem;
  padding: 4px 8px;
  transition: color 0.2s;
}

.store-item-remove:hover {
  color: #e74c3c;
}

.store-unordered {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px dashed #ddd;
}

.store-unordered-title {
  font-size: 0.875rem;
  color: #888;
  margin-bottom: 8px;
}

.store-unordered-item {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  background: #fff;
  border: 1px dashed #ddd;
  border-radius: 6px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.store-unordered-item:hover {
  background: #f0f7ff;
  border-color: #4a90d9;
}

/* Shopping View */
.shopping-view .item {
  cursor: pointer;
}

.shopping-view .item:active {
  transform: scale(0.98);
}

.shopping-view .item-delete {
  display: none;
}

.shopping-view .item-check {
  pointer-events: none;
}

/* Store Order View (Full-screen) */
.store-order-view {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 120px);
}

.store-order-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-shrink: 0;
}

.btn-back {
  background: #e0e0e0;
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background-color 0.2s;
  color: #333;
}

.btn-back:hover {
  background: #d0d0d0;
}

.store-order-title {
  flex: 1;
  font-size: 1.25rem;
  font-weight: 500;
  color: #333;
}

.store-order-count {
  font-size: 0.875rem;
  color: #888;
}

.store-order-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: white;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.store-order-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.store-order-item {
  display: flex;
  align-items: center;
  padding: 4px 8px;
  background: #f9f9f9;
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: grab;
  transition: all 0.2s;
}

.store-order-item:hover {
  background: #f0f0f0;
}

.store-order-item.drag-over {
  border-top: 3px solid #4a90d9;
  margin-top: -3px;
}

.store-order-item-handle {
  color: #bbb;
  margin-right: 8px;
  font-size: 1.1rem;
  cursor: grab;
}

.store-order-item-name {
  flex: 1;
  color: #333;
  font-size: 1rem;
}

.store-order-item-remove {
  background: none;
  border: none;
  color: #ccc;
  cursor: pointer;
  font-size: 1.25rem;
  padding: 4px 8px;
  transition: color 0.2s;
}

.store-order-item-remove:hover {
  color: #e74c3c;
}

.store-order-unordered {
  border-top: 1px solid #eee;
  padding: 16px;
  flex-shrink: 0;
  max-height: 200px;
  overflow-y: auto;
}

.store-order-unordered-title {
  font-size: 0.875rem;
  color: #888;
  margin-bottom: 12px;
}

.store-order-unordered-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.store-order-unordered-item {
  display: inline-block;
  padding: 8px 14px;
  background: #fff;
  border: 1px dashed #ddd;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.9rem;
  color: #555;
}

.store-order-unordered-item:hover {
  background: #f0f7ff;
  border-color: #4a90d9;
  color: #4a90d9;
}

/* Login Styles */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-box {
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  padding: 40px;
  width: 100%;
  max-width: 360px;
}

.login-box h1 {
  text-align: center;
  margin-bottom: 32px;
  color: #333;
}

.login-field {
  margin-bottom: 16px;
}

.login-field input {
  width: 100%;
  padding: 14px 16px;
  font-size: 1rem;
  border: 2px solid #ddd;
  border-radius: 8px;
  outline: none;
  transition: border-color 0.2s;
}

.login-field input:focus {
  border-color: #4a90d9;
}

.login-error {
  background: #fee;
  color: #c00;
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 0.9rem;
}

.login-btn {
  width: 100%;
  padding: 14px;
  font-size: 1.1rem;
  margin-top: 8px;
}

.login-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

/* Loading State */
.loading-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

/* Header Actions */
.header-actions {
  display: flex;
  gap: 8px;
}

.btn-logout {
  background: #e0e0e0;
  color: #333;
}

.btn-logout:hover {
  background: #d0d0d0;
}
