/* ============================================================
   Variablen & Reset
   ============================================================ */
:root {
  --bg:          #0e0d14;
  --surface:     #1a1825;
  --surface2:    #231f32;
  --border:      rgba(255,255,255,.08);
  --wine:        #9b2335;
  --wine-light:  #c03040;
  --whisky:      #c4873a;
  --whisky-light:#e0a050;
  --text:        #f0eefd;
  --text-muted:  #8a88a0;
  --star-on:     #f5c542;
  --star-off:    #3a3850;
  --radius:      14px;
  --shadow:      0 4px 24px rgba(0,0,0,.45);
  --transition:  .2s ease;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
}

/* ============================================================
   Header
   ============================================================ */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(14,13,20,.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 1rem;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: .75rem;
  height: 60px;
}

.logo {
  font-size: 1.25rem;
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: -.3px;
}
.logo span { color: var(--wine); }

.search-wrap {
  flex: 1;
  position: relative;
}
.search-wrap svg {
  position: absolute;
  left: .75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}
#searchInput {
  width: 100%;
  padding: .5rem .75rem .5rem 2.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: .9rem;
  outline: none;
  transition: border-color var(--transition);
}
#searchInput:focus { border-color: var(--wine); }
#searchInput::placeholder { color: var(--text-muted); }

/* ============================================================
   User Menu
   ============================================================ */
.user-menu {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-shrink: 0;
}
.user-name {
  font-size: .8rem;
  color: var(--text-muted);
  display: none;
}
@media (min-width: 480px) {
  .user-name { display: block; }
}
.btn-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  color: var(--text-muted);
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
}
.btn-logout:hover {
  background: var(--surface2);
  color: var(--text);
}

/* ============================================================
   Toolbar (Filter + Sort)
   ============================================================ */
.toolbar {
  max-width: 1200px;
  margin: 1rem auto;
  padding: 0 1rem;
  display: flex;
  gap: .75rem;
  align-items: center;
  flex-wrap: wrap;
}

.filter-tabs {
  display: flex;
  background: var(--surface);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}
.filter-tab {
  padding: .35rem .9rem;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.filter-tab.active       { background: var(--wine);   color: #fff; }
.filter-tab.active.wine  { background: var(--wine); }
.filter-tab.active.whisky{ background: var(--whisky); color: #fff; }

.sort-select {
  margin-left: auto;
  padding: .35rem .75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: .85rem;
  outline: none;
  cursor: pointer;
}

.count-label {
  color: var(--text-muted);
  font-size: .85rem;
}

.view-toggle {
  display: flex;
  background: var(--surface);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}
.view-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}
.view-btn.active { background: var(--surface2); color: var(--text); }

/* ============================================================
   Grid
   ============================================================ */
.grid {
  max-width: 1200px;
  margin: 0 auto 5rem;
  padding: 0 1rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

/* Empty state */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 4rem 1rem;
  color: var(--text-muted);
}
.empty-state svg { opacity: .3; margin-bottom: 1rem; }
.empty-state h3  { font-size: 1.1rem; margin-bottom: .5rem; color: var(--text); }

/* ============================================================
   Card
   ============================================================ */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  display: flex;
  flex-direction: column;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: rgba(255,255,255,.15);
}

.card-img {
  aspect-ratio: 3/4;
  width: 100%;
  object-fit: cover;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
}
.card-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-img-placeholder { color: var(--text-muted); opacity: .4; }

.card-body {
  padding: .75rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: .3rem;
}

.card-type {
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  border-radius: 4px;
  padding: 2px 6px;
  align-self: flex-start;
}
.card-type.wine   { background: rgba(155,35,53,.25);  color: var(--wine-light); }
.card-type.rot    { background: rgba(155,35,53,.25);  color: #d04060; }
.card-type.rose   { background: rgba(210,100,130,.25);color: #e0789a; }
.card-type.weiss  { background: rgba(196,175,58,.25); color: #c8b440; }
.card-type.whisky { background: rgba(196,135,58,.25); color: var(--whisky-light); }

.card-name {
  font-size: .9rem;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-stars { display: flex; gap: 2px; }
.star       { font-size: .9rem; line-height: 1; }
.star.on    { color: var(--star-on); }
.star.off   { color: var(--star-off); }
.star.half  { position: relative; color: var(--star-off); }
.star.half::after {
  content: '★';
  position: absolute;
  left: 0;
  width: 50%;
  overflow: hidden;
  color: var(--star-on);
}

.card-shop {
  font-size: .75rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================================
   FAB
   ============================================================ */
.fab {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--wine);
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(155,35,53,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), transform var(--transition);
  z-index: 50;
}
.fab:hover { background: var(--wine-light); transform: scale(1.05); }

/* ============================================================
   Modal
   ============================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}
.modal-backdrop.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-width: 540px;
  max-height: 92dvh;
  overflow-y: auto;
  padding: 1.5rem 1.25rem 2rem;
  transform: translateY(100%);
  transition: transform .3s cubic-bezier(.4,0,.2,1);
}
.modal-backdrop.open .modal { transform: translateY(0); }

/* Desktop: centered */
@media (min-width: 600px) {
  .modal-backdrop {
    align-items: center;
    padding: 1rem;
  }
  .modal {
    border-radius: var(--radius);
    max-height: 90dvh;
    transform: scale(.95);
  }
  .modal-backdrop.open .modal { transform: scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}
.modal-title { font-size: 1.1rem; font-weight: 700; }
.modal-close {
  background: var(--surface2);
  border: none;
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition);
}
.modal-close:hover { color: var(--text); }

/* Detail modal layout */
.detail-img {
  width: 100%;
  max-height: 300px;
  object-fit: cover;
  border-radius: 10px;
  margin-bottom: 1rem;
  background: var(--surface2);
}
.detail-img-placeholder {
  width: 100%;
  height: 180px;
  background: var(--surface2);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  margin-bottom: 1rem;
  opacity: .5;
}
.detail-meta { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: .75rem; }
.detail-name { font-size: 1.4rem; font-weight: 700; margin-bottom: .5rem; }
.detail-stars { display: flex; gap: 3px; font-size: 1.2rem; }
.detail-rating-text { color: var(--text-muted); font-size: .85rem; }
.detail-desc  { color: var(--text-muted); font-size: .9rem; line-height: 1.6; margin-bottom: .75rem; white-space: pre-wrap; }
.detail-shop  { font-size: .85rem; color: var(--text-muted); }
.detail-shop span { color: var(--text); }
.detail-date  { font-size: .75rem; color: var(--text-muted); margin-top: .5rem; }

.modal-actions {
  display: flex;
  gap: .75rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

/* ============================================================
   Form
   ============================================================ */
.form-group { margin-bottom: 1rem; }
label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: .35rem;
  text-transform: uppercase;
  letter-spacing: .4px;
}

.type-toggle {
  display: flex;
  background: var(--surface2);
  border-radius: 8px;
  padding: 3px;
  gap: 3px;
}
.type-btn {
  flex: 1;
  padding: .5rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}
.type-btn.active.wine   { background: var(--wine);   color: #fff; }
.type-btn.active.whisky { background: var(--whisky); color: #fff; }

input[type=text],
input[type=url],
textarea,
select {
  width: 100%;
  padding: .65rem .75rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: .9rem;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition);
  -webkit-appearance: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--wine); }
textarea { resize: vertical; min-height: 80px; }

/* Subtype toggle */
.subtype-toggle {
  display: flex;
  background: var(--surface2);
  border-radius: 8px;
  padding: 3px;
  gap: 3px;
}
.subtype-btn {
  flex: 1;
  padding: .4rem .5rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}
.subtype-btn.active          { background: var(--surface); color: var(--text); }
.subtype-btn.active.rot      { background: rgba(155,35,53,.35);  color: #d04060; }
.subtype-btn.active.rose     { background: rgba(210,100,130,.35);color: #e0789a; }
.subtype-btn.active.weiss    { background: rgba(196,175,58,.35); color: #c8b440; }

/* Star rating input */
.star-input { display: flex; gap: 6px; }
.star-input .si {
  font-size: 1.8rem;
  cursor: pointer;
  color: var(--star-off);
  transition: color .1s, transform .1s;
  line-height: 1;
  user-select: none;
}
.star-input .si:hover,
.star-input .si.on { color: var(--star-on); }
.star-input .si:hover { transform: scale(1.2); }

/* Image upload */
.img-upload-area {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 1.5rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  position: relative;
}
.img-upload-area:hover { border-color: var(--wine); background: rgba(155,35,53,.05); }
.img-upload-area.has-image { padding: 0; border-style: solid; overflow: hidden; }
.img-upload-area.has-image img { width: 100%; max-height: 220px; object-fit: cover; display: block; }
.img-upload-area input[type=file] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}
.upload-hint { color: var(--text-muted); font-size: .85rem; margin-top: .4rem; }
.upload-icon { font-size: 2rem; margin-bottom: .5rem; opacity: .5; }

.img-actions {
  display: flex;
  gap: .5rem;
  margin-top: .5rem;
}

/* Buttons */
.btn {
  padding: .65rem 1.25rem;
  border-radius: 8px;
  border: none;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  justify-content: center;
}
.btn-primary { background: var(--wine);   color: #fff; flex: 1; }
.btn-primary:hover { background: var(--wine-light); }
.btn-secondary { background: var(--surface2); color: var(--text); }
.btn-secondary:hover { background: #2d2a40; }
.btn-danger { background: rgba(220,50,50,.15); color: #e05555; }
.btn-danger:hover { background: rgba(220,50,50,.3); }
.btn-icon { padding: .5rem; width: 36px; height: 36px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.form-actions { display: flex; gap: .75rem; margin-top: 1.25rem; }

/* ============================================================
   Loading / Spinner
   ============================================================ */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   Toast
   ============================================================ */
#toast {
  position: fixed;
  bottom: 5rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface2);
  color: var(--text);
  padding: .6rem 1.25rem;
  border-radius: 20px;
  font-size: .85rem;
  box-shadow: var(--shadow);
  pointer-events: none;
  opacity: 0;
  transition: opacity .3s, transform .3s;
  white-space: nowrap;
  z-index: 999;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============================================================
   Listenansicht
   ============================================================ */
.grid.list-view {
  grid-template-columns: 1fr;
  gap: .5rem;
}

.list-item {
  display: flex;
  align-items: center;
  gap: .9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .65rem .75rem;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}
.list-item:hover {
  border-color: rgba(255,255,255,.15);
  background: var(--surface2);
}

.list-thumb {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--surface2);
}
.list-thumb-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  opacity: .4;
}
.list-thumb-placeholder svg { width: 28px; height: 28px; }

.list-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: .2rem;
}
.list-top {
  display: flex;
  align-items: center;
  gap: .5rem;
}
.list-name {
  font-size: .95rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-desc {
  font-size: .78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-arrow {
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 480px) {
  .grid { grid-template-columns: repeat(2, 1fr); gap: .75rem; }
  .logo  { font-size: 1rem; }
}
@media (min-width: 768px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}
@media (min-width: 1024px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
}
