@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
  --bg-app: #f8fafc;
  --surface: #ffffff;
  --primary: #059669;
  --primary-gradient: linear-gradient(135deg, #10b981 0%, #047857 100%);
  --accent: #f59e0b;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --danger: #ef4444;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
  --shadow-card: 0 10px 25px -5px rgba(0,0,0,0.04), 0 8px 10px -6px rgba(0,0,0,0.02);
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-pill: 9999px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  padding: 24px 16px 90px;
}

.container {
  max-width: 860px;
  margin: 0 auto;
}

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.logo {
  font-size: 1.6rem;
  font-weight: 800;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.user-badge {
  font-size: 0.85rem;
  color: var(--text-muted);
  background: #fff;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

/* Navigation Tabs */
nav {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 6px;
  background: #fff;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
nav::-webkit-scrollbar { display: none; }

nav button, nav a {
  background: transparent;
  color: var(--text-muted);
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

nav button.active, nav button:hover {
  background: var(--primary-gradient);
  color: #fff;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
}

/* Tab-Sichtbarkeit */
.view-section {
  display: none !important;
}
.view-section.active {
  display: block !important;
  animation: fadeIn 0.2s ease-in-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Karten */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-card);
}

h2 {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text-main);
}

/* Inputs & Formulare */
label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

input[type="text"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.95rem;
  background: #fff;
  color: var(--text-main);
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.12);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 11px 20px;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
  background: var(--primary-gradient);
  color: #fff;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
}

.btn:active { transform: scale(0.98); }

.btn-secondary {
  background: #f1f5f9;
  color: var(--text-main);
  box-shadow: none;
}
.btn-secondary:hover { background: #e2e8f0; }

.btn-danger {
  background: var(--danger);
  color: #fff;
  box-shadow: none;
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 700;
  background: #ecfdf5;
  color: var(--primary);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

/* Tabellen-Struktur & Responsiveness */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 320px;
}

th, td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

th {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
}

.msg {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  font-size: 0.9rem;
}
.msg-error { background: #fef2f2; color: #dc2626; border: 1px solid #fee2e2; }
.msg-success { background: #ecfdf5; color: #059669; border: 1px solid #d1fae5; }

/* Klickbare Rezeptkarten */
.clickable-recipe {
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.clickable-recipe:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card);
  border-color: var(--primary);
}

/* Filterleiste */
.filter-bar {
  background: #fff;
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.filter-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.filter-pills a, .sub-tab-btn {
  text-decoration: none;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  border: 1px solid var(--border);
  background: var(--bg-app);
  cursor: pointer;
  transition: all 0.2s;
}
.filter-pills a.active, .sub-tab-btn.active {
  background: var(--primary-gradient);
  color: #fff;
  border-color: transparent;
}
.search-form {
  display: flex;
  gap: 8px;
  width: 100%;
}
.search-form input {
  margin: 0;
  flex-grow: 1;
}
.search-form button {
  padding: 10px 16px;
  white-space: nowrap;
}
.author-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 700;
}
.author-link:hover { text-decoration: underline; }

/* Aktions-Buttons (Bearbeiten / Löschen) */
.btn-action-icon {
  padding: 6px 10px;
  font-size: 0.8rem;
  border-radius: 8px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: none;
  cursor: pointer;
}
.btn-edit { background: #e0f2fe; color: #0284c7; }
.btn-edit:hover { background: #bae6fd; }
.btn-del { background: #fee2e2; color: #dc2626; }
.btn-del:hover { background: #fecaca; }

/* Zutaten Suche & Tag-Builder */
.ing-search-container {
  position: relative;
  margin-bottom: 12px;
}
.ing-dropdown {
  position: absolute;
  top: 100%; left: 0; right: 0;
  max-height: 180px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  z-index: 50;
  display: none;
}
.ing-dropdown-item {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
}
.ing-dropdown-item:hover {
  background: var(--bg-app);
  color: var(--primary);
}
.selected-ing-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 18px;
}
.selected-ing-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-app);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}
.selected-ing-row .name {
  flex-grow: 1;
  font-weight: 600;
  font-size: 0.9rem;
}
.selected-ing-row input[type="number"] {
  width: 85px;
  margin: 0;
  padding: 6px 8px;
  font-size: 0.88rem;
}
.selected-ing-row select {
  width: 95px;
  margin: 0;
  padding: 6px 8px;
  font-size: 0.88rem;
}
.selected-ing-row .btn-remove {
  background: #fee2e2;
  color: #dc2626;
  border: none;
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  font-weight: bold;
}

/* Portions-Skalierer im Modal */
.portion-scaler {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-app);
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  margin-bottom: 14px;
}
.portion-btn {
  background: #fff;
  border: 1px solid var(--border);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: bold;
  color: var(--primary);
}
.portion-btn:hover {
  background: var(--primary);
  color: #fff;
}

/* Kühlschrank-Suche Checkboxen */
.ingredient-chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 240px;
  overflow-y: auto;
  padding: 10px;
  background: var(--bg-app);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}
.ingredient-chip {
  display: inline-flex;
  align-items: center;
  user-select: none;
  cursor: pointer;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 6px 12px;
  font-size: 0.85rem;
  transition: all 0.15s;
}
.ingredient-chip input { margin: 0 6px 0 0; cursor: pointer; }
.ingredient-chip:hover { border-color: var(--primary); }

/* Modals */
.modal-backdrop {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 10000;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-backdrop.active { display: flex; }
.modal-content {
  background: #fff;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 650px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.2);
  position: relative;
}
.modal-close {
  position: absolute;
  top: 18px;
  right: 18px;
  background: #f1f5f9;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

/* Smartphone Optimierung */
@media (max-width: 680px) {
  body {
    padding: 12px 10px 90px;
    overflow-x: hidden;
  }

  nav {
    position: fixed;
    bottom: 8px;
    left: 8px;
    right: 8px;
    margin: 0;
    justify-content: flex-start;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(12px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18);
    z-index: 9999;
    padding: 6px 8px;
    gap: 6px;
    border-radius: 20px;
  }

  nav button, nav a {
    padding: 8px 12px;
    font-size: 0.78rem;
    flex-shrink: 0;
  }

  th, td {
    padding: 8px 6px;
    font-size: 0.8rem;
  }
}
