/* ==============================
 * Eventrechner — Styles
 * ============================== */

:root {
  --bg: #0b0b0b;
  --card: #121212;
  --muted: #9aa0a6;
  --text: #f2f2f2;
  --accent: #1db954;
  --accent-2: #2d8cff;
  --danger: #e53935;
  --radius: 16px;
  --gap: 10px;
  --header-h: 44px;
  --footer-h: 146px;
}

* { box-sizing: border-box; }

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif;
  overflow-y: auto;
}

/* ==============================
 * Header
 * ============================== */
header#fixedHeader {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-h);
  background: var(--card);
  border-bottom: 1px solid #232323;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px 0 20px;
  z-index: 5;
}

.title {
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: .2px;
}

.settings-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  transition: transform 0.15s ease, background 0.15s ease;
}

.settings-btn::before {
  content: "⚙";
  font-size: 26px;
  line-height: 1;
}

.settings-btn:hover,
.settings-btn.settings-pressing {
  background: rgba(255, 255, 255, 0.08);
}

.settings-btn.settings-pressing {
  transform: scale(0.92);
}

.settings-btn:active {
  transform: scale(0.92);
  background: rgba(255, 255, 255, 0.12);
}

/* ==============================
 * Content area
 * ============================== */
.content {
  padding-top: var(--header-h);
  padding-bottom: calc(var(--footer-h) + 20px);
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap);
  padding: 12px;
  max-width: 1200px;
  margin: 0 auto;
}

.item-btn {
  width: 100%;
  min-height: 64px;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid #1e1e1e;
  background: #141414;
  color: var(--text);
  font-size: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  user-select: none;
  cursor: pointer;
  transition: transform 0.2s ease, filter 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  will-change: transform, filter, box-shadow;
}

.item-btn:active {
  background: #101010;
}

/* Leer-Zustand deutlicher hervorheben */
#itemsList .item-btn:only-child {
  opacity: 1;
  background: transparent;
  border: 2px dashed #333;
  color: var(--muted);
  font-size: 16px;
  min-height: 120px;
  cursor: pointer;
}

#itemsList .item-btn:only-child::before {
  content: "+";
  display: block;
  font-size: 32px;
  font-weight: 300;
  margin-bottom: 8px;
  color: var(--accent);
}

#itemsList .item-btn:only-child:active {
  background: rgba(255, 255, 255, 0.03);
  border-color: var(--accent);
}

.item-name {
  font-weight: 700;
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-price {
  opacity: .9;
  font-variant-numeric: tabular-nums;
  margin-top: 4px;
}

@media (hover: hover) and (pointer: fine) {
  .item-btn:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
  }

  .item-btn:active {
    transform: translateY(0) scale(0.98);
  }
}

/* ==============================
 * History
 * ============================== */
.history-bar {
  position: relative;
  margin: 0 12px;
  border: 1px solid #232323;
  background: #151515;
  border-radius: 14px;
  overflow: hidden;
}

.history-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
}

.hist-count {
  color: var(--muted);
  margin-left: 6px;
  font-weight: 700;
}

.toggle-icon {
  font-size: 18px;
  width: 24px;
  text-align: center;
  user-select: none;
}

.history-panel {
  display: none;
  border-top: 1px solid #232323;
  padding: 10px 12px 12px;
}

.history-panel.open {
  display: block;
}

.history-list {
  display: grid;
  grid-auto-rows: minmax(36px, auto);
  gap: 6px;
}

.history-item {
  background: #141414;
  border: 1px solid #1e1e1e;
  border-radius: 12px;
  padding: 8px 10px;
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  font-size: 14px;
  user-select: none;
}

.h-name { font-weight: 700; }

.h-count {
  color: var(--muted);
  font-weight: 700;
}

.h-amt {
  font-variant-numeric: tabular-nums;
  opacity: .9;
}

/* ==============================
 * Footer
 * ============================== */
footer#fixedFooter {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: #151515;
  border-top: 1px solid #222;
  padding: 0.875em 0.875em 2em;
  z-index: 5;
}

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

.label {
  font-size: 18px;
  font-weight: 800;
}

.total {
  font-size: 1.5em;
  font-weight: 700;
  margin: 0 0 0.3125em;
}

.actions {
  margin-top: 0.625em;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.625em;
}

.btn {
  height: 44px;
  border: none;
  border-radius: var(--radius);
  font-weight: 800;
  font-size: 16px;
  cursor: pointer;
  color: white;
  transition: filter 0.15s ease, transform 0.1s ease, background 0.15s ease;
}

.btn:hover { filter: brightness(1.1); }
.btn:active { transform: scale(0.97); }

.btn.green { background: var(--accent); }
.btn.blue { background: var(--accent-2); }
.btn.red { background: var(--danger); }

/* Pfand-Buttons visuell trennen */
#pfandPlus { background: #169c44; }
#pfandPlus:active { background: #128238; filter: none; }
#pfandMinus { background: #757575; }
#pfandMinus:active { background: #616161; filter: none; }

/* ==============================
 * Bottom sheet
 * ============================== */
.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .55);
  display: none;
  z-index: 6;
}

.backdrop.open { display: block; }

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: #151515;
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  border-top: 1px solid #222;
  transform: translateY(100%);
  transition: transform .25s ease-out;
  padding: 14px;
  z-index: 7;
}

.sheet.open { transform: translateY(0%); }

.sheet h3 {
  margin: 0 0 10px;
  font-size: 18px;
}

.field {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: var(--gap);
  margin-top: 8px;
  align-items: center;
}

.field label {
  grid-column: 1 / -1;
  font-size: 13px;
  color: var(--muted);
}

.input {
  height: 46px;
  background: #0f0f0f;
  color: var(--text);
  border: 1px solid #282828;
  border-radius: 12px;
  padding: 0 12px;
  font-size: 16px;
}

.sheet .row-gap { height: 10px; }
.sheet .btn { width: 100%; }

.hint {
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.4;
}

.divider {
  margin: 10px 0;
  height: 1px;
  background: #232323;
  border: 0;
}

.color-picker-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
}

.color-label {
  font-size: 13px;
  color: var(--muted);
  display: none;
}

#itemColor {
  width: 50px;
  height: 46px;
  padding: 0;
  border: 1px solid #282828;
  border-radius: 12px;
  cursor: pointer;
}

/* ==============================
 * Share & load config
 * ============================== */
.share-container,
.load-config-container {
  width: 100%;
  max-width: 100%;
  margin-top: 16px;
}

.load-config-container { margin-top: 24px; }

.share-input-group,
.load-input-group {
  display: flex;
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.share-input,
.load-input {
  flex: 1;
  padding: 14px 16px;
  background: #1e1e1e;
  color: #ffffff;
  border: 1px solid #444;
  border-right: none;
  border-radius: 12px 0 0 12px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
}

.share-input:focus,
.load-input:focus { border-color: #1a73e8; }

.share-button,
.load-button {
  white-space: nowrap;
  border-radius: 0 12px 12px 0;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

#shareLinkContainer { display: none; }

/* ==============================
 * Responsive
 * ============================== */
@media (min-width: 768px) {
  :root { --footer-h: 110px; }

  .grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }

  footer#fixedFooter {
    padding: 0.625em 0.875em 1em;
  }

  .total {
    font-size: 1.3em;
    margin: 0;
  }

  .actions {
    margin-top: 0.5em;
  }

  .actions .btn {
    height: 38px;
    font-size: 15px;
  }

  .item-btn {
    height: 100%;
    min-height: 80px;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 10px;
    font-size: 16px;
  }

  .item-name,
  .item-price {
    width: 100%;
    text-align: center;
  }

  .item-price {
    margin-top: 4px;
    font-size: 1em;
  }

  .history-panel.open { display: block; }
}

@media (max-width: 767px) {
  .field {
    grid-template-columns: 1fr;
  }

  .field > * {
    width: 100%;
    margin-bottom: 8px;
  }

  #itemColor {
    width: 100% !important;
    height: 50px !important;
  }

  .color-label { display: block; }
}

@media (max-width: 480px) {
  .share-input,
  .load-input {
    padding: 12px 14px;
    font-size: 14px;
  }

  .share-button,
  .load-button {
    padding: 0 12px;
    font-size: 14px;
  }
}

/* ==============================
 * Accessibility
 * ============================== */
@media (prefers-reduced-motion: reduce) {
  .sheet { transition: none; }
}
