/********************
 * 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 {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  touch-action: none;
}

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

.app {
  max-width: 500px;
  margin: auto;

  overflow-x: hidden;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/********************
 * HEADER & SEARCH
 ********************/
.header {
  position: fixed;
  top: 0;
  left: 50%;
  z-index: 2200;
  display: flex;
  transform: translateX(-50%);
  width: 100%;
  max-width: 500px;
  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);
}

#searchOverlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.25);
  z-index: 2000; 
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

#searchOverlay.active {
  opacity: 1;
  pointer-events: auto;
}

#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: 2100;
  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;
}

.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;
}

.menu-db-info {
  margin-top: 10px;
  padding-top: 8px;
  font-size: 12px;
  opacity: 0.6;
  border-top: 1px solid rgba(0,0,0,0.1);
}

/********************
 * LIST
 ********************/
.list-container {
  flex: 1;
  overflow-y: auto;

  padding: 10px;

  /* Platz für fixed header */
  padding-top: calc(60px + env(safe-area-inset-top));

  /* Platz für Statusbar */
  padding-bottom: calc(40px + env(safe-area-inset-bottom));

  -webkit-overflow-scrolling: touch;
}

.category {
  margin-top: 15px;
}

.category.removing {
  opacity: 0;
  transform: translateY(-4px);
  transition: all 0.2s ease;
}

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

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

  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}

.category-title::after {
  content: "";
  width: 6px;
  height: 6px;
  border-right: 2px solid var(--text-light);
  border-bottom: 2px solid var(--text-light);
  transform: rotate(45deg);
  transition: transform 0.2s ease;
  margin-left: 6px;
}

.category.collapsed .category-title::after {
  transform: rotate(-45deg);
}

.category .item {
  max-height: 60px; /* etwas größer als echte Höhe */
  overflow: hidden;

  transition:
    max-height 0.25s ease,
    opacity 0.2s ease,
    margin 0.2s ease,
    padding 0.2s ease;
}

.category.collapsed .item {
  max-height: 0;
  opacity: 0;

  margin-top: 0;
  margin-bottom: 0;

  padding-top: 0;
  padding-bottom: 0;
}

#recommendations {
  margin-top: 60px;
  padding-top: 10px;
  padding-bottom: 15px;
  border-top: 1px solid rgba(0,0,0,0.05);
  border-bottom: 1px solid rgba(0,0,0,0.05);
}

#recommendations .category-title {
  opacity: 0.9;
}

.item {
  position: relative;

  background: var(--card);
  height: 48px;
  padding: 0 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;

  overflow: hidden;
}

.item::after {
  content: "";
  position: absolute;

  top: 0;
  left: 0;
  right: 0;
  bottom: 0;

  border-top: 2px solid var(--primary);
  border-right: 2px solid var(--primary);
  border-bottom: 2px solid var(--primary);
  border-left: none;

  border-radius: 8px;

  opacity: 0;

  pointer-events: none;

  transition: opacity 0.5s ease;
}

.item,
.item * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: 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.just-added {
  animation: pulseHighlight 0.35s ease;
}

@keyframes pulseHighlight {
  0%   { transform: scale(0.98); }
  50%  { transform: scale(1.02); }
  100% { transform: scale(1); }
}

.item.just-added::after {
  opacity: 1;
}

.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;
  justify-content: center;
  flex: 1;
  overflow: hidden;
  height: 100%;
}

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

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

.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.dummy {
  visibility: hidden;
  pointer-events: none;
}

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

.item.removing {
  opacity: 0;
  transition: opacity 0.2s ease;
}

.item.collapsing {
  height: 0;
  padding-top: 0;
  padding-bottom: 0;
  margin-bottom: 0;

  transition:
    height 0.25s ease,
    padding 0.25s ease,
    margin 0.25s ease;
}

/* Startzustand */
.item.entering {
  opacity: 0;
  transform: translateY(-6px);
}

/* Endzustand */
.item.entering-active {
  opacity: 0.5;
  transform: translateY(0);

  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
}

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

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

  padding-top: calc(env(safe-area-inset-top) + 60px);
  padding-bottom: 20px;

  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;
}

#deleteContainer {
  margin-top: 10px;
}

/********************
 * SCROLL
 ********************/
.overlay-content {
  max-height: calc(100dvh - 140px);
  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-light); 
  opacity: 0.8;
}

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);
}

/********************
 * SYNONYMS
 ********************/
#synonyms {
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-light);   
  opacity: 0.8;               
  line-height: 1.4;
}

#synonyms strong {
  font-weight: 500;
  color: var(--text-light);
  opacity: 0.7;
}

/********************
 * 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 */
}

/********************
 * SECONDARY BUTTON
 ********************/
.btn-secondary {
  width: 100%;
  margin-top: 10px;
  padding: 12px;

  border-radius: 12px;
  border: 1px solid var(--border-strong);

  background: var(--bg);
  color: var(--text-main);

  font-size: 16px;
  font-weight: bold;

  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-secondary:hover {
  background: var(--hover-soft);
}

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

/********************
 * +-Button
 ********************/
.add-btn {
  display: block;
  margin: 10px auto;

  width: 48px;
  height: 48px;

  border-radius: 50%;
  border: none;

  background: var(--primary);
  color: var(--bg);

  font-size: 28px;
  line-height: 1;

  cursor: pointer;

  box-shadow: 0 4px 10px rgba(0,0,0,0.15);

  transition: transform 0.1s ease, box-shadow 0.1s ease;

  position: relative;
  z-index: 2;
}

.add-btn:hover {
  transform: scale(1.05);
}

.add-btn:active {
  transform: scale(0.95);
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/********************
 * SORT OVERLAY
 ********************/

.sort-categories-wrapper {
  margin-top: 10px;
  max-height: 40vh;
  overflow-y: auto;
  padding-right: 4px;
}

.sort-row {
  display: flex;
  align-items: center;
  justify-content: space-between;

  background: var(--input-bg);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 6px;

  font-size: 15px;

  transition: transform 0.25s ease, opacity 0.25s ease;
}

.sort-row.disabled {
  opacity: 1; /* wichtig: nicht runterziehen */
  background: #f3f3f3;
  color: var(--text-light);
}

.sort-row.disabled span {
  opacity: 0.6;
}

.sort-row.disabled .sort-buttons button {
  opacity: 0.3;
}

/* linker Teil (Icon + Name) */
.sort-row span {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Buttons rechts */
.sort-buttons {
  display: flex;
  gap: 6px;
}

.sort-buttons button {
  width: 32px;
  height: 32px;

  border-radius: 8px;
  border: 1px solid var(--border);

  background: var(--bg);
  cursor: pointer;

  font-size: 14px;
}

.sort-buttons button:active {
  transform: scale(0.95);
}

/********************
 * 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: 5000;
}

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

/********************
 * PWA-INSTALL-HINT
 ********************/
.install-hint {
  margin-top: 50px;
  display: flex;
  justify-content: center;
  align-items: center;

  text-align: left;
  padding: 20px;

  color: var(--text-secondary);
  font-size: 15px;

  min-height: auto;
}

.install-hint:empty {
  display: none;
}

.install-hint ul {
  padding-left: 18px;
}

.install-hint li {
  margin-bottom: 8px;
}

/********************
 * HIDDEN-HINT
 ********************/
.hidden-hint {
  margin: 16px 16px 8px;
  padding: 12px;

  border-radius: 12px;

  background: var(--primary);
  color: white;

  font-size: 14px;
  font-weight: 500;
  text-align: center;

  cursor: pointer;

  box-shadow: 0 4px 10px rgba(0,0,0,0.12);
  transition: all 0.15s ease;
}

/* Hover (Desktop) */
.hidden-hint:hover {
  background: var(--primary-dark);
}

/* Active (Mobile wichtig!) */
.hidden-hint:active {
  transform: scale(0.97);
}

/********************
 * STATUSBAR
 ********************/
.statusbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 500px;

  background: var(--bg);

  padding: 3px 10px;
  padding-bottom: calc(3px + env(safe-area-inset-bottom));

  font-size: 12px;
  line-height: 1;

  box-shadow: 0 -1px 0 rgba(0,0,0,0.05);
  text-align: center;

  z-index: 1500;
}

.progress {
  margin-top: 3px;
  height: 3px;
  background: var(--border-soft);
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--primary);
  transition: width 0.2s ease, background 0.2s ease;
}

/* wenn alles erledigt */
.progress-bar.complete {
  background: #4cd964;
}