/********************
 * ROOT (DESIGN SYSTEM)
 ********************/
:root {
  --primary: #F37E15;
  --primary-dark: #d96f12;

  --bg: #f5f5f5;
  --card: #ffffff;
  --input-bg: #f9f9f9;

  --text-main: #333;
  --text-secondary: #8e8e93;
  --text-light: #999;

  --border: #ddd;
  --border-strong: #ccc;
  --border-soft: #eee;

  --hover: #f0f0f0;
  --hover-soft: #e9e9e9;

  --danger: #ff3b30;
  --danger-bg: rgba(255, 59, 48, 0.08);
  --danger-bg-hover: rgba(255, 59, 48, 0.12);

  --low: #d1d1d6;

  --overlay: rgba(0,0,0,0.4);
  --toast: rgba(0,0,0,0.85);
}

/********************
 * GLOBAL
 ********************/
* {
  box-sizing: border-box;
}

html, body {
  overflow-x: hidden;
  background: var(--bg);
}

body {
  font-family: system-ui, sans-serif;
  margin: 0;
  overscroll-behavior: none;
}

.app {
  position: relative;
  max-width: 500px;
  margin: auto;
  padding: 10px;
  overflow-x: hidden;

  height: 100vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/********************
 * HEADER & SEARCH
 ********************/
.header {
  position: sticky;
  top: 0;
  z-index: 1500;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg);
  padding: 10px;
  padding-top: calc(10px + env(safe-area-inset-top));
  box-sizing: border-box;
  box-shadow: 0 1px 0 rgba(0,0,0,0.05);
}

.logo {
  width: 36px;
  height: 36px;
  border-radius: 8px;
}

#search {
  flex: 1;
  width: 100%;
  padding: 10px;
  font-size: 16px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
}

#suggestions {
  list-style: none;  
  margin: 0;
  padding: 0;
  position: fixed;  
  top: 70px;
  width: calc(100% - 20px);
  max-width: 500px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1500;
  background: var(--card);
  border-radius: 10px;
  box-shadow: 0 5px 15px rgba(0,0,0,0.1);
  max-height: min(40vh, 300px);
  overflow-y: auto;
}

#suggestions li {
  padding: 10px;
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer;
}

#suggestions li.active {
  background: var(--primary);
  color: var(--card);
}

#suggestions li:hover {
  background: var(--bg);
}

/********************
 * MENU
 ********************/
.menu-btn {
  background: none;
  border: none;
  padding: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* verstecken */
.hidden {
  display: none;
}

.menu-icon {
  width: 22px;
  height: 22px;
  color: var(--primary);
}

/* Touch-Feedback */
.menu-btn:active {
  transform: scale(0.95);
}

.btn-danger {
  background: var(--danger) !important;
  color: white;
}

@keyframes shake {
  0% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  50% { transform: translateX(4px); }
  75% { transform: translateX(-3px); }
  100% { transform: translateX(0); }
}

.shake {
  animation: shake 0.3s ease;
}

/********************
 * LIST
 ********************/
.category {
  margin-top: 15px;
}

.category-done.with-gap {
  margin-top: 30px;
}

.category-title {
  font-weight: bold;
  margin-bottom: 5px;
  padding-left: 2px;
}

.item {
  background: var(--card);
  padding: 10px;
  margin-bottom: 5px;
  margin-left: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  border-left: 4px solid transparent;
}

.item.importance-important {
  border-left-color: var(--danger);
  background: var(--danger-bg);
}

.item.importance-important:hover {
  background: var(--danger-bg-hover);
}

.item.done.importance-important {
  background: var(--card);
  border-left-color: var(--low);
}

.item.importance-normal {
  border-left-color: var(--primary);
}

.item.importance-low {
  border-left-color: var(--low);
}

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

.item.done {
  opacity: 0.5;
  filter: grayscale(0.3);
}

.item.done .item-name,
.item.done .item-details {
  text-decoration: line-through;
}

.item-left {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.item-name {
  font-size: 16px;
}

.item-details {
  font-size: 14px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-menu {
  background: none;
  border: none;
  font-size: 18px;
  padding: 6px 8px;
  margin-left: 8px;
  cursor: pointer;
  color: var(--text-secondary);
  border-radius: 6px;
  flex-shrink: 0;
  text-decoration: none;
  display: inline-block;
}

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

/********************
 * OVERLAY
 ********************/
.overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);

  display: flex;
  flex-direction: column;
  align-items: center; 
  justify-content: flex-start;

  padding-top: 90px;

  z-index: 4000;

  opacity: 0;
  transition: opacity 0.2s ease;
}

.overlay.show {
  opacity: 1;
}

.overlay.hidden {
  display: none;
}

/********************
 * OVERLAY CONTENT
 ********************/
.overlay-content {
  background: var(--card);
  padding: 18px;

  width: 92%;
  max-width: 420px;

  border-radius: 20px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);

  transform: translateY(-40px);
  opacity: 0;
  transition: all 0.25s ease;
}

.overlay.show .overlay-content {
  transform: translateY(0);
  opacity: 1;
}

/********************
 * SCROLL
 ********************/
.overlay-content {
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}

/********************
 * HEADER
 ********************/
.overlay-content h3 {
  margin-top: 0;
  margin-bottom: 12px;
}

/********************
 * OVERLAY CLOSE BUTTON
 ********************/
.overlay-content {
  position: relative;
}

.overlay-close {
  position: absolute;
  top: 10px;
  right: 12px;
  border: none;
  background: transparent;
  font-size: 22px;
  cursor: pointer;
  color: var(--text-light);
  transition: all 0.15s ease;
}

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

.overlay-close:active {
  transform: scale(0.9);
}

/********************
 * FORM ELEMENTS
 ********************/
.overlay-content label {
  display: block;
  font-size: 13px;
  margin: 10px 0 4px;
  color: var(--text-secondary);
}

input,
select {
  font-size: 16px;
  border-radius: 10px;
  box-sizing: border-box;
}

.overlay-content input,
.overlay-content select {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--border);
}

/********************
 * INPUT CLEAR BUTTON
 ********************/
.input-wrapper {
  position: relative;
  flex: 1;
}

.input-wrapper input {
  padding-right: 30px; /* Platz für X */
}

.input-wrapper span {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  color: var(--text-light);
  cursor: pointer;
  display: none;
  padding: 4px;
}

.input-wrapper span:hover {
  color: var(--text-main);
}

/********************
 * BUTTONS
 ********************/
#variants button,
#importance button {
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--bg);
  cursor: pointer;
  transition: all 0.15s ease;
}

#variants button:hover,
#importance button:hover {
  background: var(--hover-soft);
}

#variants button {
  padding: 6px 10px;
  font-size: 14px;
}

#importance button {
  flex: 1;
  padding: 8px;
}

/********************
 * VARIANTS
 ********************/
#variants {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

#variants button:active {
  transform: scale(0.95);
}

/********************
 * CATEGORY
 ********************/
#categorySelect {
  width: 100%;
  padding: 10px 35px 10px 12px;
  font-size: 16px;

  background-color: var(--input-bg); 
  border: none;               
  border-radius: 10px;     

  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;

  outline: none;

  background-image: url("data:image/svg+xml;utf8,<svg fill='%23999' height='20' viewBox='0 0 20 20' width='20' xmlns='http://www.w3.org/2000/svg'><path d='M5 7l5 5 5-5z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
}

#categorySelect:focus {
  border-color: var(--primary);  
}

/********************
 * IMPORTANCE BUTTONS
 ********************/
#importance {
  display: flex;
  gap: 6px;
  margin-top: 5px;
}

/* wichtig */
#importance button[data-value="important"].active {
  background: var(--danger);
  color: var(--card);
  border-color: var(--danger);
}

/* normal */
#importance button[data-value="normal"].active {
  background: var(--primary);
  color: var(--card);
  border-color: var(--primary);
}

/* unwichtig */
#importance button[data-value="low"].active {
  background: var(--low);
  color: var(--text-main);
  border-color: var(--low);
}

/********************
 * PRIMARY BUTTON
 ********************/
.btn-primary {
  width: 100%;
  margin-top: 15px;
  padding: 12px;
  border-radius: 12px;
  border: none;
  background: var(--primary);
  color: var(--card);
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

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

/* bestehender Button nutzt die Klasse */
#saveBtn {
  /* optional leer lassen oder drin lassen */
}

/********************
 * TOAST
 ********************/
#toast {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%) translateY(-10px);

  background: var(--toast);
  color: var(--card);
  padding: 10px 16px;
  border-radius: 20px;
  font-size: 14px;

  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  z-index: 3000;
}

#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}