:root {
  /* Erlaubt dem Browser, zwischen Light und Dark zu wählen */
  color-scheme: light dark;

  --primary-color: light-dark(#007bff, #375a7f);
  --danger-color: #ff4444;
  --bg-color: light-dark(#f9f9f9, #121212);
  --card-bg: light-dark(#ffffff, #1e1e1e);
  --text-color: light-dark(#333, #e0e0e0);
  --text-muted: light-dark(gray, #aaa);
  --border-color: light-dark(#ccc, #444);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 4px 6px rgba(0, 0, 0, 0.3);
  --radius: 6px;
  --radius-lg: 8px;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  max-width: 500px;
  margin: 2rem auto;
  padding: 0 1rem;
  background-color: var(--bg-color);
  color: var(--text-color);
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

h1 {
  color: var(--text-color);
}

@scope (.app-header) {
  :scope {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    font-size: 0.9rem;
  }

  .welcome-text {
    color: var(--text-muted);
  }

  .logout-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;

    &:hover {
      text-decoration: underline;
    }
  }
}

input,
button {
  padding: 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background: var(--card-bg);
  color: var(--text-color);
  font-size: 14px;
  transition: all 0.2s;
  &:focus {
    outline: none;
    border-color: var(--primary-color);
  }
}

button {
  cursor: pointer;
  font-weight: 600;
}
button:hover {
  background-color: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

/* Kapselung der Todo-Eingabe */
@scope (.todo-create-form) {
  :scope {
    display: flex;
    gap: 10px;
    margin-bottom: 2rem;
    background: var(--card-bg);
    padding: 20px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
  }

  input {
    flex: 1;
  }
}

/* Kapselung der Todo-Elemente */
@scope (.todo-item) {
  :scope {
    display: flex;
    align-items: center;
    background: var(--card-bg);
    padding: 10px;
    margin-bottom: 10px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    list-style: none;
  }

  .todo-checkbox {
    margin-right: 10px;
    width: 18px;
    height: 18px;
    cursor: pointer;
  }

  .todo-content {
    flex: 1;
    font-size: 16px;

    &.completed {
      text-decoration: line-through;
      color: var(--text-muted);
    }
  }

  .todo-delete {
    margin-left: 10px;
    color: var(--danger-color);
    background: none;
    border: none;
    font-weight: bold;
    cursor: pointer;
    padding: 5px;

    &:hover {
      opacity: 0.8;
    }
  }
}

@scope (.todo-list) {
  :scope {
    padding: 0;
    margin: 0;
  }
}

/* Kapselung des Auth-Formulars */
@scope (.auth-form) {
  :scope {
    margin-bottom: 2rem;
    background: var(--card-bg);
    padding: 20px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
  }

  h2 {
    color: var(--text-color);
    margin-top: 0;
  }

  input {
    display: block;
    margin-bottom: 15px;
    width: 100%;
    padding: 12px;
    box-sizing: border-box;
  }

  button {
    width: 100%;
    padding: 12px;

    &.btn-primary {
      background-color: var(--primary-color);
      color: white;
      border: none;
    }

    &.btn-secondary {
      background-color: light-dark(#eee, #333);
      border: 1px solid var(--border-color);
      color: var(--text-color);
    }
  }

  p {
    text-align: center;
    margin-top: 15px;
    font-size: 0.9rem;

    a {
      color: var(--primary-color);
      text-decoration: none;
      &:hover {
        text-decoration: underline;
      }
    }
  }
}

/* Modern 2026 feature: Container Queries for responsive forms if needed */
@container (min-width: 400px) {
  .auth-form {
    padding: 30px;
  }
}

.htmx-indicator {
  display: none;
}
.htmx-request .htmx-indicator {
  display: inline-block;
}
.htmx-request.htmx-indicator {
  display: inline-block;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #ccc;
  border-top: 2px solid #333;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  display: inline-block;
  vertical-align: middle;
  margin-left: 8px;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}
