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

:root {
  --primary: #e67e22;
  --primary-dark: #d35400;
  --bg: #f5f6fa;
  --card: #ffffff;
  --border: #e0e4eb;
  --text: #2c3e50;
  --text-light: #7f8c8d;
  --danger: #e74c3c;
  --success: #27ae60;
  --radius: 10px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

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

.hidden { display: none !important; }

/* Login */
.login-box {
  max-width: 380px; margin: 80px auto; padding: 40px;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  text-align: center;
}
.login-logo { font-size: 48px; margin-bottom: 12px; }
.login-box h1 { font-size: 26px; color: var(--primary); margin-bottom: 4px; }
.login-sub { color: var(--text-light); font-size: 14px; margin-bottom: 28px; }
.form-group { text-align: left; margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text-light); }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--border);
  border-radius: 7px; font-size: 15px; transition: border 0.2s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none; border-color: var(--primary);
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border: none; border-radius: 7px;
  font-size: 14px; font-weight: 600; cursor: pointer; transition: all 0.15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c0392b; }
.btn-success { background: var(--success); color: #fff; }
.btn-full { width: 100%; justify-content: center; padding: 12px; font-size: 16px; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-xs { padding: 4px 8px; font-size: 12px; }

/* Header */
.app-header {
  position: sticky; top: 0; z-index: 100;
  background: var(--card); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; height: 56px; box-shadow: var(--shadow);
}
.header-left, .header-right { display: flex; align-items: center; gap: 12px; }
.header-logo { font-size: 22px; }
.header-title { font-size: 18px; font-weight: 700; color: var(--primary); }
.header-user { font-size: 14px; color: var(--text-light); }

/* Main – Desktop: volle Breite für horizontalen Scroll */
.main-content { padding: 20px 16px; overflow: hidden; }

/* ===================== DESKTOP: Tage nebeneinander ===================== */
#days-container {
  display: flex;
  flex-direction: row;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 16px;
  align-items: flex-start;
  /* Sanftes Scrolling */
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}

/* Scrollbar dezent stylen */
#days-container::-webkit-scrollbar { height: 6px; }
#days-container::-webkit-scrollbar-track { background: transparent; }
#days-container::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.day-card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
  /* Feste Breite pro Tag-Karte */
  min-width: 340px;
  max-width: 340px;
  flex-shrink: 0;
  scroll-snap-align: start;
}

.day-header {
  display: flex; flex-direction: column; gap: 10px;
  padding: 14px 18px; background: var(--primary); color: #fff;
  cursor: default;
}
.day-header-top { display: flex; align-items: center; justify-content: space-between; }
.day-header-left { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.day-weekday { font-size: 18px; font-weight: 700; }
.day-date { font-size: 14px; opacity: 0.85; }
.day-today-badge {
  background: rgba(255,255,255,0.25); padding: 2px 8px;
  border-radius: 20px; font-size: 12px; font-weight: 600;
}

/* Desktop: Inhalt immer sichtbar, Aktionen immer sichtbar */
.day-collapsible { display: block; }
.day-actions-btns { display: flex; gap: 8px; }
.day-toggle-arrow { display: none; }

/* Notes */
.day-notes { padding: 10px 18px; background: #fef9f0; border-bottom: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.note-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: #fde8c4; color: #e67e22; padding: 4px 10px;
  border-radius: 20px; font-size: 13px; font-weight: 500;
}
.note-chip .del-btn { cursor: pointer; font-size: 12px; opacity: 0.6; }
.note-chip .del-btn:hover { opacity: 1; }

/* Dishes */
.day-body { padding: 14px 18px; }
.dishes-empty { color: var(--text-light); font-size: 14px; padding: 8px 0; }
.day-section-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.6px; color: var(--text-light);
  border-bottom: 1px solid var(--border); padding-bottom: 5px; margin-bottom: 10px;
}

.dish-block {
  border: 1.5px solid var(--border); border-radius: 8px;
  margin-bottom: 14px; overflow: hidden;
}
.dish-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; background: #f8f9fc;
  border-bottom: 1px solid var(--border);
}
.dish-name { font-size: 16px; font-weight: 700; }
.dish-meta { font-size: 13px; color: var(--text-light); display: flex; gap: 10px; margin-top: 2px; flex-wrap: wrap; }
.dish-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* Participants */
.dish-section { padding: 10px 14px; }
.dish-section-title {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--text-light); margin-bottom: 8px;
}
.participants-table, .results-table {
  width: 100%; border-collapse: collapse; font-size: 14px;
}
.participants-table th, .results-table th {
  text-align: left; padding: 6px 8px; font-size: 12px;
  color: var(--text-light); border-bottom: 1px solid var(--border); font-weight: 600;
}
.participants-table td, .results-table td {
  padding: 7px 8px; border-bottom: 1px solid var(--border);
}
.participants-table tr:last-child td, .results-table tr:last-child td { border-bottom: none; }
.own-row { background: #fffbf5; }

/* Error */
.error { background: #fdecea; color: var(--danger); padding: 10px 12px; border-radius: 7px; font-size: 14px; margin-top: 8px; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 16px;
}
.modal {
  background: var(--card); border-radius: var(--radius);
  width: 100%; max-width: 480px; max-height: 90vh;
  overflow-y: auto; box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 18px; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-light); }
.modal-body { padding: 20px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* Users Admin */
.user-card {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; background: var(--card);
  border: 1.5px solid var(--border); border-radius: 8px; margin-bottom: 10px;
}
.user-info .user-name { font-weight: 600; font-size: 16px; }
.user-info .user-meta { font-size: 13px; color: var(--text-light); margin-top: 2px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.badge-admin { background: #fde8c4; color: var(--primary); }
.badge-inactive { background: #fdecea; color: var(--danger); }

/* ===================== MOBILE: Akkordeon ===================== */
@media (max-width: 700px) {
  .main-content { padding: 0; }

  #days-container {
    flex-direction: column;
    overflow-x: visible;
    gap: 0;
    padding-bottom: 0;
    scroll-snap-type: none;
  }

  .day-card {
    min-width: unset;
    max-width: unset;
    width: 100%;
    border-radius: 0;
    box-shadow: none;
    border-bottom: 1px solid var(--border);
    flex-shrink: unset;
    scroll-snap-align: unset;
  }
  .day-card:first-child { border-top: 1px solid var(--border); }

  /* Header wird zum Akkordeon-Toggle */
  .day-header {
    cursor: pointer;
    user-select: none;
    padding: 13px 16px;
  }
  .day-header:active { opacity: 0.85; }

  /* Pfeil-Indikator einblenden */
  .day-toggle-arrow { display: inline-block; }
  .day-toggle-arrow {
    font-size: 13px;
    opacity: 0.8;
    transition: transform 0.2s;
    margin-left: 6px;
    flex-shrink: 0;
  }
  .day-card.open .day-toggle-arrow { transform: rotate(180deg); }

  /* Aktionen nur bei offenem Akkordeon */
  .day-actions-btns { display: none; }
  .day-card.open .day-actions-btns { display: flex; gap: 6px; flex-wrap: wrap; }

  /* Toggle-Pfeil auf Mobile sichtbar */

  /* Kollabierter Inhalt */
  .day-collapsible {
    display: none;
    animation: slideDown 0.18s ease;
  }
  .day-card.open .day-collapsible { display: block; }

  /* Kompakte Gericht-Vorschau im geschlossenen Zustand */
  .day-summary {
    display: flex; flex-wrap: wrap; gap: 6px;
    padding: 8px 16px; background: #fafbfc;
    border-bottom: 1px solid var(--border);
  }
  .day-card.open .day-summary { display: none; }
  .summary-chip {
    font-size: 12px; color: var(--text-light);
    background: var(--bg); border: 1px solid var(--border);
    padding: 2px 8px; border-radius: 20px;
  }
  .summary-empty { font-size: 12px; color: #bbb; }

  .day-weekday { font-size: 16px; }
  .day-date { font-size: 13px; }
  .dish-header { flex-wrap: wrap; gap: 8px; }
  .participants-table, .results-table { font-size: 13px; }
  .btn-sm { padding: 5px 10px; font-size: 12px; }
  .btn-xs { padding: 3px 7px; font-size: 11px; }
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
