/* ============================================================
   CrustControl – Stylesheet  (mobile-first)
   ============================================================ */

/* --- CSS Variables ----------------------------------------- */
:root {
  --red:       #e63946;
  --red-dark:  #c1121f;
  --orange:    #f4a261;
  --orange-dk: #e07a3a;
  --green:     #2a9d8f;
  --green-dk:  #1f7a6e;
  --yellow:    #ffd166;
  --blue:      #264653;
  --light:     #fff8f0;
  --white:     #ffffff;
  --gray-100:  #f5f5f5;
  --gray-200:  #e9ecef;
  --gray-400:  #ced4da;
  --gray-600:  #6c757d;
  --gray-800:  #343a40;

  --shadow-sm: 0 2px 8px rgba(0,0,0,.08);
  --shadow:    0 4px 16px rgba(0,0,0,.12);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.16);

  --radius:    10px;
  --radius-lg: 16px;

  --font:      system-ui, -apple-system, 'Segoe UI', sans-serif;
  --touch-min: 48px;
}

/* --- Reset ------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--light);
  color: var(--gray-800);
  line-height: 1.5;
  min-height: 100vh;
}
img { max-width: 100%; }
a { color: var(--red); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }

/* --- Layout ------------------------------------------------ */
.page-wrap {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1rem 2rem;
}

/* --- Top-Navigation --------------------------------------- */
.topbar {
  background: var(--blue);
  color: #fff;
  padding: .75rem 1rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}
.topbar-brand {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--orange);
  flex: 1;
  text-decoration: none;
}
.topbar-brand:hover { text-decoration: none; }
.topbar-nav { display: flex; gap: .5rem; flex-wrap: wrap; }
.topbar-nav a {
  color: rgba(255,255,255,.85);
  padding: .35rem .7rem;
  border-radius: 6px;
  font-size: .875rem;
  font-weight: 500;
  transition: background .15s;
}
.topbar-nav a:hover, .topbar-nav a.active {
  background: rgba(255,255,255,.15);
  color: #fff;
  text-decoration: none;
}
.topbar-user {
  color: rgba(255,255,255,.65);
  font-size: .8rem;
  white-space: nowrap;
}

/* --- Page Header ------------------------------------------ */
.page-header {
  padding: 1.25rem 0 .75rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
}
.page-header h1 {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--blue);
  flex: 1;
}
.page-header h1 span { color: var(--red); }

/* --- Cards ------------------------------------------------ */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.card-header {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: 1rem;
  padding-bottom: .75rem;
  border-bottom: 1.5px solid var(--gray-200);
}
.card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--blue);
  flex: 1;
}

/* --- Buttons ---------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .6rem 1.2rem;
  border: none;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: .9rem;
  cursor: pointer;
  transition: background .15s, transform .1s, box-shadow .15s;
  min-height: var(--touch-min);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(.97); }

.btn-primary   { background: var(--red);    color: #fff; }
.btn-primary:hover   { background: var(--red-dark); }
.btn-secondary { background: var(--blue);   color: #fff; }
.btn-secondary:hover { background: #1a3341; }
.btn-success   { background: var(--green);  color: #fff; }
.btn-success:hover   { background: var(--green-dk); }
.btn-warning   { background: var(--yellow); color: var(--gray-800); }
.btn-warning:hover   { background: #f0c04a; }
.btn-orange    { background: var(--orange); color: #fff; }
.btn-orange:hover    { background: var(--orange-dk); }
.btn-outline   { background: transparent; color: var(--red); border: 2px solid var(--red); }
.btn-outline:hover   { background: var(--red); color: #fff; }
.btn-gray      { background: var(--gray-200); color: var(--gray-800); }
.btn-gray:hover      { background: var(--gray-400); }
.btn-danger    { background: #e63946; color: #fff; }
.btn-danger:hover    { background: #c1121f; }
.btn-sm  { padding: .35rem .75rem; font-size: .8rem; min-height: 36px; }
.btn-lg  { padding: .85rem 2rem; font-size: 1.1rem; min-height: 56px; }
.btn-full { width: 100%; }

/* --- Forms ------------------------------------------------ */
.form-group { margin-bottom: 1rem; }
.form-label {
  display: block;
  font-weight: 600;
  font-size: .875rem;
  color: var(--gray-800);
  margin-bottom: .35rem;
}
.form-control {
  display: block;
  width: 100%;
  padding: .65rem .85rem;
  border: 1.5px solid var(--gray-400);
  border-radius: var(--radius);
  font-size: 1rem;
  background: var(--white);
  color: var(--gray-800);
  transition: border-color .15s, box-shadow .15s;
  min-height: var(--touch-min);
}
.form-control:focus {
  border-color: var(--red);
  outline: none;
  box-shadow: 0 0 0 3px rgba(230,57,70,.15);
}
textarea.form-control { min-height: 100px; resize: vertical; }
select.form-control { cursor: pointer; }
.form-hint { font-size: .78rem; color: var(--gray-600); margin-top: .25rem; }
.form-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 140px; }

/* Checkboxen / Toggle-Chips */
.toggle-group {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-top: .35rem;
}
.toggle-chip input[type="checkbox"] { display: none; }
.toggle-chip label {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .5rem 1rem;
  border: 2px solid var(--gray-400);
  border-radius: 50px;
  cursor: pointer;
  font-size: .9rem;
  font-weight: 500;
  color: var(--gray-600);
  background: var(--white);
  transition: all .15s;
  min-height: var(--touch-min);
  user-select: none;
}
.toggle-chip input:checked + label {
  border-color: var(--red);
  background: var(--red);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.toggle-chip label:hover {
  border-color: var(--red);
  color: var(--red);
}

/* Checkbox-Liste (Admin) */
.check-list { display: flex; flex-direction: column; gap: .5rem; }
.check-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .6rem .85rem;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .12s;
}
.check-item:hover { background: var(--gray-100); }
.check-item input[type="checkbox"] { width: 20px; height: 20px; cursor: pointer; accent-color: var(--red); }

/* --- Alerts ----------------------------------------------- */
.alert {
  padding: .85rem 1rem;
  border-radius: var(--radius);
  font-size: .9rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: flex-start;
  gap: .5rem;
}
.alert-success { background: #d1fae5; color: #065f46; }
.alert-error   { background: #fee2e2; color: #991b1b; }
.alert-info    { background: #dbeafe; color: #1e40af; }
.alert-warning { background: #fef9c3; color: #713f12; }

/* --- Tables ----------------------------------------------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
  background: var(--white);
}
th, td {
  padding: .7rem .85rem;
  text-align: left;
  border-bottom: 1px solid var(--gray-200);
}
th {
  background: var(--gray-100);
  font-weight: 700;
  color: var(--blue);
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--gray-100); }

/* --- Badges ----------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: .2rem .55rem;
  border-radius: 50px;
  font-size: .75rem;
  font-weight: 700;
  white-space: nowrap;
}
.badge-red     { background: #fee2e2; color: #991b1b; }
.badge-green   { background: #d1fae5; color: #065f46; }
.badge-orange  { background: #ffedd5; color: #9a3412; }
.badge-yellow  { background: #fef9c3; color: #713f12; }
.badge-blue    { background: #dbeafe; color: #1e40af; }
.badge-gray    { background: var(--gray-200); color: var(--gray-600); }

/* Status-Badge */
.status-neu       { background: var(--gray-200); color: var(--gray-800); }
.status-in-arbeit { background: #fef9c3; color: #713f12; }
.status-im-ofen   { background: #ffedd5; color: #9a3412; }
.status-fertig    { background: #d1fae5; color: #065f46; }
.status-abgeholt  { background: var(--gray-200); color: var(--gray-600); }

/* ============================================================
   BESTELLSEITE (bestellen.php)
   ============================================================ */
.order-hero {
  text-align: center;
  padding: 1.5rem 0 1rem;
}
.order-hero .pizza-icon { font-size: 3rem; }
.order-hero h1 { font-size: 1.6rem; font-weight: 800; color: var(--blue); margin-top: .5rem; }
.order-hero .event-name { color: var(--red); font-size: 1.1rem; font-weight: 700; margin-top: .25rem; }
.order-hero .event-detail { color: var(--gray-600); font-size: .9rem; margin-top: .25rem; }

.zutaten-titel {
  font-weight: 700;
  color: var(--blue);
  font-size: 1rem;
  margin-bottom: .5rem;
  margin-top: .25rem;
}
.zutaten-info {
  font-size: .8rem;
  color: var(--gray-600);
  margin-bottom: .75rem;
}

/* ============================================================
   DANKE-SEITE (danke.php)
   ============================================================ */
.danke-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  text-align: center;
  padding: 2rem 1rem;
}
.danke-wrap .big-number {
  font-size: clamp(5rem, 20vw, 10rem);
  font-weight: 900;
  color: var(--red);
  line-height: 1;
  margin: 1rem 0;
}
.danke-wrap h2 { font-size: 1.4rem; color: var(--blue); }
.danke-wrap p  { color: var(--gray-600); margin-top: .5rem; max-width: 360px; }
.danke-icon    { font-size: 3rem; margin-bottom: .5rem; }

/* ============================================================
   KÜCHEN-ANSICHT (kueche.php)
   ============================================================ */
.kueche-stats {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.stat-box {
  flex: 1;
  min-width: 100px;
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: .85rem 1rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.stat-box .stat-val {
  font-size: 2rem;
  font-weight: 900;
  color: var(--blue);
  line-height: 1;
}
.stat-box .stat-label {
  font-size: .75rem;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-top: .25rem;
}
.stat-box.stat-red   .stat-val { color: var(--red); }
.stat-box.stat-green .stat-val { color: var(--green); }
.stat-box.stat-org   .stat-val { color: var(--orange-dk); }

/* Bestellkarte */
.order-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1rem 1.1rem;
  margin-bottom: .75rem;
  border-left: 4px solid var(--gray-400);
  transition: border-color .2s, box-shadow .2s;
  animation: slideIn .3s ease;
}
@keyframes slideIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.order-card.status-in-arbeit { border-left-color: var(--yellow); }
.order-card.status-im-ofen   { border-left-color: var(--orange); }

.order-card.status-fertig {
  border-left-color: var(--green);
  border-left-width: 6px;
  background: #edfcf5;
  box-shadow: 0 3px 18px rgba(42,157,143,.22);
  animation: fertigGlow 2.5s ease-in-out infinite;
  position: relative;
  overflow: hidden;
}
/* Großer Haken im Hintergrund */
.order-card.status-fertig::after {
  content: '✓';
  position: absolute;
  right: .6rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 5.5rem;
  font-weight: 900;
  color: rgba(42,157,143,.13);
  line-height: 1;
  pointer-events: none;
  user-select: none;
}
@keyframes fertigGlow {
  0%,100% { box-shadow: 0 3px 18px rgba(42,157,143,.22); }
  50%      { box-shadow: 0 4px 28px rgba(42,157,143,.42); }
}

.order-card-header {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  margin-bottom: .6rem;
}
.order-num {
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--red);
  min-width: 54px;
  line-height: 1;
}
.order-info { flex: 1; }
.order-name { font-size: 1.1rem; font-weight: 700; color: var(--blue); }
.order-time { font-size: .78rem; color: var(--gray-600); margin-top: .1rem; }
.order-status-badge { align-self: flex-start; }

.order-zutaten {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin-bottom: .85rem;
}
.order-zutat-tag {
  background: var(--gray-100);
  color: var(--gray-800);
  border-radius: 20px;
  padding: .22rem .65rem;
  font-size: .82rem;
  font-weight: 500;
}

.order-actions {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
}

/* ============================================================
   ABHOLUNG-DISPLAY (abholung.php)
   ============================================================ */
.abholung-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}
.abholung-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1.25rem 1rem;
  text-align: center;
  animation: popIn .4s cubic-bezier(.34,1.56,.64,1);
}
@keyframes popIn {
  from { opacity: 0; transform: scale(.8); }
  to   { opacity: 1; transform: scale(1); }
}
.abholung-nr {
  font-size: clamp(3rem, 10vw, 5rem);
  font-weight: 900;
  color: var(--red);
  line-height: 1;
}
.abholung-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--blue);
  margin: .35rem 0 .85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.abholung-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--gray-600);
  font-size: 1.1rem;
}
.abholung-empty .icon { font-size: 3rem; }

/* ============================================================
   ADMIN / DASHBOARD
   ============================================================ */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.dash-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem 1rem;
  text-align: center;
  text-decoration: none;
  color: inherit;
  transition: box-shadow .15s, transform .12s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .35rem;
}
.dash-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
  text-decoration: none;
}
.dash-card .icon { font-size: 2.5rem; }
.dash-card .label { font-weight: 700; color: var(--blue); font-size: .95rem; }
.dash-card .count {
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--red);
  line-height: 1;
}

/* QR-Code Box */
.qr-box {
  text-align: center;
  padding: 1.5rem;
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.qr-box img, #qr-canvas { border: 8px solid var(--white); box-shadow: var(--shadow); }
.qr-url { font-size: .85rem; color: var(--gray-600); word-break: break-all; margin-top: .75rem; }

/* Allergen-Icons */
.allergen-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: .65rem;
  font-weight: 800;
  text-transform: uppercase;
}
.icon-vegan  { background: #d1fae5; color: #065f46; }
.icon-veg    { background: #dbeafe; color: #1e40af; }
.icon-rind   { background: #ffedd5; color: #9a3412; }
.icon-schwein { background: #fce7f3; color: #9d174d; }
.icon-haehn  { background: #fef9c3; color: #713f12; }
.icon-fisch  { background: #e0f2fe; color: #0c4a6e; }

/* ============================================================
   LOGIN
   ============================================================ */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--blue) 0%, #1a3340 100%);
  padding: 1rem;
}
.login-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 2rem 1.75rem;
  width: 100%;
  max-width: 400px;
}
.login-logo { text-align: center; font-size: 3rem; margin-bottom: .5rem; }
.login-card h1 {
  text-align: center;
  color: var(--blue);
  font-size: 1.8rem;
  margin-bottom: 1.5rem;
}
.login-card h1 span { color: var(--red); }

/* ============================================================
   EVENT-SELEKTOR
   ============================================================ */
.event-selector {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: .85rem 1rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
}
.event-selector label { font-weight: 600; font-size: .875rem; color: var(--blue); white-space: nowrap; }
.event-selector select { flex: 1; min-width: 180px; }

/* ============================================================
   REFRESH-INDICATOR
   ============================================================ */
.refresh-bar {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .8rem;
  color: var(--gray-600);
  margin-bottom: .75rem;
}
.refresh-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--green);
  animation: blink 2s infinite;
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: .2; }
}

/* ============================================================
   PRINT
   ============================================================ */
@media print {
  .topbar, .btn, .order-actions, .event-selector, .no-print { display: none !important; }
  body { background: #fff; }
  .card, .order-card { box-shadow: none; border: 1px solid #ddd; }
}

/* ============================================================
   MEDIA QUERIES
   ============================================================ */
@media (min-width: 640px) {
  .order-actions { flex-wrap: nowrap; }
  .kueche-stats  { gap: 1rem; }
}

@media (min-width: 768px) {
  .topbar { padding: .85rem 1.5rem; }
  .page-wrap { padding: 0 1.5rem 2rem; }
  .order-card { padding: 1.1rem 1.25rem; }
  .dashboard-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}

@media (min-width: 1024px) {
  .page-wrap { padding: 0 2rem 2rem; }
}

/* Accessibility */
:focus-visible { outline: 3px solid var(--red); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
