/* =========================
   Base
========================= */
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Arial, sans-serif;
}

:root {
  --blue: #2d6cdf;        /* Hauptfarbe (Header/Buttons) */
  --blue-dark: #0056b3;   /* Hover/Active */
  --text-on-blue: #fff;
}

/* =========================
   Header & Dropdown
========================= */
.header {
  background-color: var(--blue);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dropdown { position: relative; display: inline-block; }
.dropdown-button {
  background-color: var(--blue-dark);
  color: #fff;
  padding: 10px 20px;
  border: 0;
  cursor: pointer;
  border-radius: 4px;
}
.dropdown-button:hover { background-color: #004085; }

.dropdown-content {
  display: none;
  position: absolute;
  left: 0;
  width: 300px;
  background-color: #f9f9f9;
  border-radius: 4px;
  box-shadow: 0 8px 16px rgba(0,0,0,0.2);
  z-index: 10;
}

.new-category a {
  display: block;
  color: #007bff;
  font-weight: bold;
  padding: 12px 16px;
  text-decoration: none;
}
.new-category a:hover {
  text-decoration: underline;
  background-color: #f1f1f1;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  color: #fff;
  font-weight: bold;
}
.username { font-size: 0.95rem; }

.logout-link {
  color: #fff;
  text-decoration: none;
  font-weight: bold;
  padding: 0.4rem 0.8rem;
  border-radius: 4px;
  transition: background-color 0.2s ease;
}
.logout-link:hover { background-color: rgba(255, 255, 255, 0.2); }

/* =========================
   Kategorie-Liste
========================= */
.category-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}
.category-entry:hover { filter: brightness(90%); }
.category-entry .label {
  flex: 1;
  padding: 8px 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* =========================
   Overlays
========================= */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background-color: rgba(0,0,0,0.5);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}
.overlay-content {
  background-color: #fff;
  padding: 12px;
  border-radius: 8px;
  width: 400px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.overlay-content label {
  display: block;
  margin-bottom: 2px;
  font-weight: bold;
}
.overlay-content input[type="text"],
.overlay-content select {
  width: 100%;
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
}
.overlay-content input[type="color"] {
  width: 50px;
  height: 30px;
  border: none;
  cursor: pointer;
}
.color-picker {
  display: flex;
  align-items: center;
  gap: 10px;
}

.overlay-content button {
  display: block;
  width: 100%;
  padding: 10px;
  margin: 8px 0;
  font-size: 1em;
  background-color: var(--blue);
  color: #fff;
  border: 0;
  border-radius: 4px;
  cursor: pointer;
}
.overlay-content button:hover { background-color: #1f56bf; }
#deleteCategoryButton { background-color: #dc3545; }
#deleteCategoryButton:hover { background-color: #b02a37; }



/* =========================
   Artikel-Overlay
========================= */
#articleOverlay .input-row {
  display: flex;
  gap: 9px;
  margin-bottom: 2px;
}

.field-amount input[type="text"],
.field-unit input[type="text"] {
  width: 12ch;
  height: 32px;
  padding: 4px 6px;
  font-size: 0.9rem;
}

/* Einheit + Mikro nebeneinander */
.unit-with-mic {
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

#articleOverlay .mic-btn {
  height: 32px;
  width: 34px;
  border: none;
  border-radius: 6px;
  background: var(--blue);
  color: #fff;
  cursor: pointer;
  margin-top: -2px;
}
#articleOverlay .mic-btn:hover {
  filter: brightness(1.05);
}

/* Abstände zwischen Feldern */
#articleOverlay #articleName {
  margin-bottom: 10px; /* Abstand zu Kategorie */
}

/* =========================
   Artikelliste
========================= */
#articleList {
  max-width: 500px;
  margin-left: 10px;
}
.article-entry {
  display: flex;
  justify-content: space-between;
  padding: 8px;
  margin-bottom: 4px;
  border-radius: 4px;
}
.article-entry.done .text {
  text-decoration: line-through;
  opacity: 0.6;
}
.article-actions {
  display: flex;
  gap: 8px;
}

/* =========================
   Hinweise
========================= */
.toast {
  position: fixed;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  background: rgba(0,0,0,.8);
  color: #fff;
  padding: .6rem .9rem;
  border-radius: .6rem;
}
.speech-notice {
  background: #ffec99;
  border: 1px solid #ffe066;
  padding: .6rem .8rem;
  border-radius: .6rem;
  margin-bottom: .8rem;
}
/* Overlay: sanftes Fade + kleiner Slide der Box */
.overlay{
  display: flex;                 /* bleibt Flex für zentrieren */
  justify-content: center;
  align-items: center;

  /* Startzustand (versteckt) */
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .18s ease, visibility .18s ease;
}

.overlay.open{
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Inhalt leicht „hochkommen“ lassen */
.overlay .overlay-content{
  transform: translateY(-6px);
  transition: transform .22s ease;
}
.overlay.open .overlay-content{
  transform: translateY(0);
}
.mic-btn {
  background: #2d6cdf;       /* Blau */
  width: 40px;               /* Buttonbreite */
  height: 40px;              /* Buttonhöhe */
  border-radius: 8px;        /* abgerundet */
  display: flex;
  align-items: center;       /* vertikal zentrieren */
  justify-content: center;   /* horizontal zentrieren */
  font-size: 20px;           /* Emoji-Größe */
  line-height: 1;            /* Basislinie neutralisieren */
  cursor: pointer;
  border: none;
  padding: 0;
}
.header {
    display: flex;
    align-items: center;
    justify-content: space-between; /* User-Info rechts halten */
}

.left-buttons {
    display: flex;
    align-items: center;
    gap: 10px; /* kleiner Abstand zwischen den Buttons */
}

.btn-danger {
    background: #dc3545;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 8px 12px;
    height: 36px;
    line-height: 1;
    cursor: pointer;
}

.btn-danger:hover {
    background: #c82333;
}
/* Roter Button (Erledigte löschen) */
.btn-danger {
  background: #dc3545; color: #fff; border: none; border-radius: 4px;
  padding: 8px 12px; height: 36px; line-height: 1; cursor: pointer;
}
.btn-danger:hover { background: #c82333; }

/* Optionen-Dropdown rechts */
.options { position: relative; }
.options-btn{
  height: 36px;
  min-width: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: 10px;
  background: rgba(255,255,255,.2);
  color: #fff;
  font: 700 18px/1 system-ui,-apple-system,Segoe UI,Roboto,sans-serif;
  cursor: pointer;
}
.options-btn:hover{ background: rgba(255,255,255,.3); }
/* Menü-Popup */
.options-menu{
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 200px;
  background: #fff;
  color: #111;
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0,0,0,.2);
  padding: 6px;
  display: none;
  z-index: 1200; /* über Header, unter Overlays */
}
.options-menu.open{ display: block; }

.options-menu .menu-item{
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: 0;
  background: transparent;
  color: inherit;
  text-decoration: none;
  border-radius: 8px;
  cursor: pointer;
  font: 600 14px/1.2 system-ui,-apple-system,Segoe UI,Roboto,sans-serif;
}
/* ==== Add-Button: harte Overrides + hübsch ==== */
#addArticleButton.btn-add{
  -webkit-appearance: none;
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  height: 36px;
  padding: 0 14px;
  border: 0 !important;
  border-radius: 4px !important;
  font: 600 14px/1 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  cursor: pointer;
  color: #0a7fc2;
  background: linear-gradient(180deg, #fff 0%, #f7fbff 100%);
  box-shadow: 0 6px 18px rgba(0,0,0,.12);
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease, background .2s ease;
}
#addArticleButton.btn-add:hover{
  filter: brightness(0.98);
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(0,0,0,.16);
}
@media (max-width: 600px) and (orientation: portrait){
  :root{ --overlay-top-gap: 20px; }

  .overlay.open{
    align-items: start;
    justify-items: center;
    padding-top: max(var(--overlay-top-gap), env(safe-area-inset-top));
    /* falls woanders place-items gesetzt ist */
    place-items: start center;
  }

  .overlay .overlay-content{
    max-height: calc(100dvh - var(--overlay-top-gap) - 24px);
  }
}
/* Danger-Styling für den ersten Menüpunkt */
.options-menu .menu-item.danger,
.options-menu #miClearDone {
  background: #dc3545;   /* rot hinterlegt */
  color: #fff;
}

.options-menu .menu-item.danger:hover,
.options-menu #miClearDone:hover {
  background: #c82333;   /* dunkler bei Hover */
}