@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --bg-base: #09090b;
  --surface: rgba(24, 24, 27, 0.6);
  --surface-hover: rgba(39, 39, 42, 0.8);
  --border: rgba(255, 255, 255, 0.08);
  --border-highlight: rgba(255, 255, 255, 0.15);
  
  --text-main: #f4f4f5;
  --text-muted: #a1a1aa;
  
  --primary: #8b5cf6;
  --danger: #ef4444;
  --success: #10b981;
  
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-full: 9999px;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 12px -2px rgba(0, 0, 0, 0.6), 0 2px 4px -2px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 12px 30px -4px rgba(0, 0, 0, 0.7);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background-color: var(--bg-base);
  background-image: 
    radial-gradient(ellipse at top left, rgba(139, 92, 246, 0.15), transparent 40%),
    radial-gradient(ellipse at bottom right, rgba(59, 130, 246, 0.1), transparent 40%);
  background-attachment: fixed;
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
  padding-bottom: 2rem;
}

body.is-admin { padding-bottom: 100px; }

.hidden { display: none !important; }

/* --- App Header --- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(9, 9, 11, 0.7);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 800px;
  margin: 0 auto;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  font-size: 1.3rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #e879f9, #8b5cf6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header-actions { display: flex; gap: 0.5rem; }

.icon-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 0.6rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover { background: var(--surface-hover); border-color: var(--border-highlight); transform: translateY(-1px); }

/* --- Main Layout --- */
.main-content {
  max-width: 800px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem;
}

/* --- Filter & Sortierleiste (Custom Dropdowns) --- */
.filter-bar {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  align-items: flex-start;
}

.custom-dropdown {
  position: relative;
}

/* Kategorie nimmt restlichen Platz ein */
#category-dropdown {
  flex: 1;
}

/* Sortieren ist etwas schmaler und fest */
#sort-dropdown {
  flex: 0 0 auto;
  width: 140px; 
}

/* Menü soll nach rechts aufklappen, um nicht aus dem Bild zu ragen */
#sort-dropdown .dropdown-menu {
  left: auto;
  right: 0;
  min-width: 160px;
}

.dropdown-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(10px);
}
.dropdown-trigger:hover { background: var(--surface-hover); border-color: var(--border-highlight); }
.dropdown-trigger .chevron { transition: transform 0.3s ease; color: var(--text-muted); flex-shrink: 0; }

.custom-dropdown.open .dropdown-trigger .chevron { transform: rotate(180deg); }

.dropdown-menu {
  position: absolute;
  top: calc(100% + 0.5rem);
  left: 0;
  width: 100%;
  min-width: 200px;
  background: #18181b;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 0.5rem;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  max-height: 300px;
  overflow-y: auto;
}

.custom-dropdown.open .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
}
.dropdown-item:hover { background: var(--surface-hover); color: var(--text-main); }
.dropdown-item.active { background: rgba(255,255,255,0.05); color: var(--text-main); }

.color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 8px currentColor;
}

/* --- Link Grid --- */
.link-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
}
@media (min-width: 640px) {
  .link-grid { grid-template-columns: repeat(2, 1fr); }
}

/* --- Link Cards --- */
.link-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  backdrop-filter: blur(12px);
  overflow: hidden;
  animation: cardFadeIn 0.4s ease-out backwards;
}

@keyframes cardFadeIn {
  from { opacity: 0; transform: translateY(15px); }
  to { opacity: 1; transform: translateY(0); }
}

.link-card:hover {
  box-shadow: var(--shadow-lg);
  border-color: var(--border-highlight);
  transform: translateY(-3px);
}

.link-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 1.5rem;
  bottom: 1.5rem;
  width: 3px;
  border-radius: 0 4px 4px 0;
  background: var(--cat-color, var(--primary));
  box-shadow: 0 0 12px var(--cat-color, var(--primary));
  opacity: 0.8;
}

.link-card-header { display: flex; flex-direction: column; gap: 0.3rem; }

.link-card-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0;
  color: var(--text-main);
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.link-card-category {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--cat-color, var(--primary));
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.link-card-url {
  font-size: 0.85rem;
  color: var(--text-muted);
  word-break: break-all;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  opacity: 0.8;
}

.link-card-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.5;
}

.link-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
  padding-top: 0.75rem;
}

/* --- Buttons --- */
.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.65rem 1.2rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: #7c3aed; }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text-main); background: var(--surface); }

.copy-btn {
  background: rgba(255,255,255,0.04);
  color: var(--text-main);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.8rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.copy-btn:hover { background: var(--surface-hover); border-color: var(--border-highlight); }
.copy-btn.copied { background: var(--success); color: white; border-color: var(--success); }

.edit-btns { display: flex; gap: 0.4rem; }
.edit-btns button {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.edit-btns button:hover { background: var(--surface-hover); color: var(--text-main); }
.edit-btns button.danger:hover { background: rgba(239, 68, 68, 0.15); color: var(--danger); border-color: rgba(239, 68, 68, 0.3); }

/* --- Scroll to Top Button --- */
.scroll-top-btn {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(10px);
  z-index: 40;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  animation: fadeIn 0.3s ease-out;
}
.scroll-top-btn:hover { background: var(--surface-hover); transform: translateY(-3px); border-color: var(--border-highlight); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* --- App Bottom Navigation (Admin only) --- */
.bottom-nav {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 3rem);
  max-width: 400px;
  height: 68px;
  background: rgba(24, 24, 27, 0.85);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 40px -10px rgba(0,0,0,0.8);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 50;
}

.nav-item {
  background: transparent;
  border: none;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  font-size: 0.7rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 0.5rem 1.2rem;
  border-radius: var(--radius-md);
}
.nav-item:hover { color: var(--text-main); background: rgba(255,255,255,0.05); }

/* --- Dialoge --- */
.modal {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0;
  max-width: 440px;
  width: calc(100% - 2rem);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8);
  background: #18181b;
  color: var(--text-main);
}
.modal::backdrop { background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(8px); }

.modal-form { padding: 1.75rem; display: flex; flex-direction: column; gap: 0.75rem; }
.modal-form h2 { margin: 0 0 0.25rem; font-size: 1.3rem; font-weight: 700; letter-spacing: -0.02em; }
.modal-hint { color: var(--text-muted); font-size: 0.9rem; margin: 0 0 0.5rem; }

.modal-form label { font-size: 0.8rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-top: 0.4rem; }
.modal-form input,
.modal-form select,
.modal-form textarea {
  width: 100%;
  padding: 0.8rem 1rem;
  font-size: 1rem;
  font-family: inherit;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  background: rgba(0,0,0,0.3);
  color: white;
  transition: all 0.2s ease;
}
.modal-form input:focus,
.modal-form select:focus,
.modal-form textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: rgba(0,0,0,0.5);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}
.modal-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1rem; }
.error-text { color: var(--danger); font-size: 0.85rem; margin: 0; min-height: 1.2em; font-weight: 500;}

/* --- Toast --- */
.toast {
  position: fixed;
  bottom: 110px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #27272a;
  color: white;
  border: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-full);
  font-size: 0.9rem;
  font-weight: 500;
  z-index: 999;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  animation: toastIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}
.toast.error { background: var(--danger); border-color: var(--danger); }
@keyframes toastIn { to { opacity: 1; transform: translateX(-50%) translateY(0); } }

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 4rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px dashed var(--border-highlight);
}