@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;700&display=swap");

/* ======================================================================
   Design System
   ====================================================================== */
:root {
  --brand: #0e558c;
  --brand-dark: #14283c;
  --brand-light: #e6f0ff;
  --danger: #cc0000;

  --bg: #f4f7fb;
  --text: #1f2937;
  --text-soft: #64748b;
  --border: #dbe3ef;
  --card-bg: #ffffff;

  --background-light: #ffffff;
  --border-color: var(--border);
  --text-color-primary: var(--text);
  --text-color-secondary: #475569;
  --brand-color: var(--brand);

  --page-pad-x: 20px;

  --shadow-sm: 0 10px 24px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 18px 40px rgba(15, 23, 42, 0.10);

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-xl: 28px;
}

/* ======================================================================
   Base / Reset
   ====================================================================== */
*,
*:before,
*:after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  font-family: "DM Sans", "Segoe UI", Roboto, Arial, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(14, 85, 140, 0.06), transparent 320px),
    var(--bg);
  color: var(--text);
  line-height: 1.55;
  padding-left: var(--page-pad-x);
  padding-right: var(--page-pad-x);
  padding-top: 10px;
  transition: background 0.3s ease, color 0.3s ease;
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  width: 100%;
}

h1,
h2 {
  color: var(--brand-dark);
  margin-top: 0;
}

a {
  color: var(--brand);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.responsive-wrapper {
  width: min(1980px, calc(100% - 24px));
  margin-left: auto;
  margin-right: auto;
}

/* ======================================================================
   Buttons
   ====================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(135deg, var(--brand), #0b6db7);
  color: #fff;
  padding: 10px 16px;
  border: none;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: transform .12s ease, box-shadow .2s ease, opacity .2s ease;
  box-shadow: 0 10px 20px rgba(14, 85, 140, 0.18);
}

.btn:hover {
  text-decoration: none;
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn:focus-visible {
  outline: 2px solid var(--brand-dark);
  outline-offset: 2px;
}

.btn.small {
  padding: 8px 12px;
  font-size: 13px;
}

.btn-danger {
  background: linear-gradient(135deg, var(--danger), #ef4444);
  box-shadow: 0 10px 20px rgba(204, 0, 0, 0.14);
}

.btn-danger:hover {
  opacity: 0.95;
}

/* ======================================================================
   Header unter der Navbar (für Seiteninhalte)
   ====================================================================== */
header:not(.site-header) {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 40px;
  text-align: center;
}

header:not(.site-header) h1 {
  font-size: 1.8rem;
}

header:not(.site-header) nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* ======================================================================
   Flash / Hinweise
   ====================================================================== */
.flash {
  background: #e8fff0;
  border: 1px solid #b7efc5;
  color: #166534;
  padding: 12px 14px;
  border-radius: 12px;
  margin-bottom: 16px;
}

.flash.error {
  background: #fff1f2;
  border: 1px solid #fecdd3;
  color: #b91c1c;
}

/* ======================================================================
   Forms
   ====================================================================== */
form {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px;
  max-width: 500px;
  box-shadow: var(--shadow-sm);
}

label {
  font-weight: 700;
  margin-top: 10px;
  display: block;
}

input,
textarea,
select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-top: 4px;
  font-size: 14px;
  background: #fff;
  color: var(--text);
}

/* ======================================================================
   Tables
   ====================================================================== */
.table-wrapper {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  margin-top: 20px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead {
  background: linear-gradient(135deg, var(--brand), #0b6db7);
  color: #ffffff;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

tbody tr:hover {
  background: var(--brand-light);
}

table thead th:first-child,
table tbody td:first-child {
  width: 36px;
  text-align: center;
}

.row-check {
  transform: scale(1.1);
}

/* ======================================================================
   Login Page
   ====================================================================== */
.centered-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}

.login-container {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 40px 50px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-md);
  text-align: center;
}

.login-container h1 {
  margin-bottom: 20px;
  color: var(--brand-dark);
}

.login-container form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
}

/* ======================================================================
   Admin
   ====================================================================== */
.admin-grid {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 24px;
  align-items: start;
  margin-top: 30px;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.card h2 {
  margin: 0 0 12px;
  color: var(--brand-dark);
}

.user-list .table-wrapper {
  max-height: 600px;
  overflow-y: auto;
}

/* ======================================================================
   Suchleiste
   ====================================================================== */
#myInput {
  background-image: url('/css/searchicon.png');
  background-position: 10px 12px;
  background-repeat: no-repeat;
  width: 100%;
  font-size: 16px;
  padding: 12px 20px 12px 40px;
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 12px;
  background-color: var(--card-bg);
}

#myTable {
  border-collapse: collapse;
  width: 100%;
  border: 1px solid var(--border);
  font-size: 18px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--card-bg);
}

#myTable th,
#myTable td {
  text-align: left;
  padding: 12px;
}

#myTable tr {
  border-bottom: 1px solid var(--border);
}

#myTable tr.header,
#myTable tr:hover {
  background-color: #f1f5f9;
}

/* ======================================================================
   Kartenlayout – 2 Kacheln nebeneinander
   ====================================================================== */
.cards-stack {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-top: 20px;
  max-width: 1100px;
  margin-left: auto;
  margin-right: auto;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
  max-width: 1100px;
  margin: 24px auto 60px;
  padding: 0 16px;
}

.cards-grid:has(> :only-child) {
  justify-content: center;
  grid-template-columns: 1fr;
  max-width: 600px;
}

.cards-grid .card {
  position: relative !important;
  background: var(--card-bg) !important;
  border: 1px solid var(--border) !important;
  border-radius: 18px !important;
  overflow: hidden !important;
  box-shadow: 0 10px 24px rgba(0, 0, 0, .06) !important;
  transition: transform .18s ease, box-shadow .18s ease !important;
  display: flex !important;
  flex-direction: column !important;
  padding: 0 !important;
}

.cards-grid .card:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 28px rgba(0, 0, 0, .10);
}

.cards-grid .card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 6px;
  background: var(--fsr-color, var(--brand));
  z-index: 1;
}

.cards-grid .card img {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  background: #f2f2f2;
}

.cards-grid .card-body {
  padding: 16px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.cards-grid .card-title {
  font-weight: 800;
  font-size: 1.15rem;
  margin: 2px 0 6px;
  color: #111;
}

.cards-grid .card-title::after {
  content: "";
  display: block;
  width: 100%;
  height: 3px;
  margin-top: 6px;
  border-radius: 2px;
  background: var(--fsr-color, var(--brand));
  transform: scaleX(0.9);
  transform-origin: left;
  transition: transform .3s ease;
}

.cards-grid .card:hover .card-title::after {
  transform: scaleX(1);
}

.cards-grid .card-text {
  color: var(--text);
  font-size: .96rem;
  line-height: 1.45;
  flex: 1;
}

.cards-grid .card-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.cards-grid .card-link,
.cards-grid .card-actions .card-link,
.cards-grid .card-actions button.card-link {
  display: inline-block;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid #e0e0e0;
  background: #fafafa;
  text-decoration: none;
  color: #222;
  font-size: .92rem;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}

.cards-grid .card-link:hover {
  background: #f0f0f0;
  border-color: #d6d6d6;
}

.cards-grid .edit-btn {
  background: #e8f2ff;
  border-color: #9dc4ff;
}

.cards-grid .edit-btn:hover {
  background: #d4e7ff;
  border-color: #8bb5ff;
}

.cards-grid .danger-btn {
  background: #ffecec;
  border-color: #ffb3b3;
}

.cards-grid .danger-btn:hover {
  background: #ffd9d9;
  border-color: #ff9999;
}

.fsr-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 30px auto 0;
  max-width: 1100px;
  padding: 0 16px;
}

.alert {
  background: #fff8db;
  border: 1px solid #facc15;
  color: #854d0e;
  padding: 12px 16px;
  border-radius: 12px;
  margin: 20px 0;
  text-align: center;
}

.legend-box {
  margin-top: 40px;
  background: var(--background-light);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 30px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
}

.legend-title {
  margin-top: 0;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-color-primary);
  margin-bottom: 20px;
  border-bottom: 3px solid var(--brand-color);
  padding-bottom: 10px;
  display: inline-block;
}

.legend-list {
  margin: 0;
  padding: 0;
  list-style-type: none;
}

.legend-item {
  padding: 12px 0;
  font-size: 1.05rem;
  color: var(--text-color-secondary);
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid #f0f4f8;
  transition: background-color 0.2s;
}

.legend-item:last-child {
  border-bottom: none;
}

.legend-item:hover {
  background-color: rgba(0, 123, 255, 0.05);
  padding-left: 10px;
}

.legend-item strong {
  color: var(--brand-color);
  font-weight: 600;
  min-width: 90px;
  display: inline-block;
  text-align: left;
}

/* ======================================================================
   Dark Mode
   ====================================================================== */
  html.darkmode,
  html.darkmode {
    --bg: #0f172a;
    --text: #e5e7eb;
    --text-soft: #94a3b8;
    --border: #334155;
    --card-bg: #111827;

    --brand: #3b82f6;
    --brand-dark: #dbeafe;
    --brand-light: #1e293b;

    --background-light: #111827;
    --border-color: #334155;
    --text-color-primary: #e5e7eb;
    --text-color-secondary: #cbd5e1;
    --brand-color: #60a5fa;
  }

html.darkmode form,
html.darkmode .card,
html.darkmode .table-wrapper,
html.darkmode .login-container {
  background: #1e293b;
  border-color: #334155;
}

html.darkmode thead {
  background: linear-gradient(135deg, #1e3a8a, #2563eb);
}

html.darkmode tbody tr:hover {
  background: #1e293b;
}

html.darkmode input,
html.darkmode textarea,
html.darkmode select,
html.darkmode #myInput,
html.darkmode #myTable {
  background: #0f172a;
  color: #e5e7eb;
  border-color: #334155;
}

html.darkmode #myTable tr.header,
html.darkmode #myTable tr:hover {
  background-color: #1e293b;
}

/* ======================================================================
   Responsive
   ====================================================================== */
@media (max-width: 900px) {
  :root {
    --page-pad-x: 12px;
  }

  .responsive-wrapper {
    width: min(1980px, calc(100% - 24px));
  }

  .admin-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 850px) {
  .cards-stack,
  .cards-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .fsr-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
}