/* Catppuccin Mocha palette (same as portfolio, for visual consistency) */
:root {
  --base: #1e1e2e;
  --mantle: #181825;
  --crust: #11111b;
  --text: #cdd6f4;
  --subtext1: #bac2de;
  --subtext0: #a6adc8;
  --surface1: #45475a;
  --surface0: #313244;
  --mauve: #cba6f7;
  --pink: #f5c2e7;
  --blue: #89b4fa;
  --red: #f38ba8;
  --teal: #94e2d5;
  --green: #a6e3a1;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", system-ui, sans-serif;
  background: var(--base);
  color: var(--text);
  display: flex;
  justify-content: center;
}

/* Verhindert, dass geschuetzte Seiteninhalte kurz aufblitzen, bevor auth-guard.js
   die Login-Pruefung abgeschlossen hat. Wird per JS entfernt, sobald Auth bestaetigt ist. */
body.auth-pending {
  visibility: hidden;
}

main {
  width: 100%;
  max-width: 640px;
  padding: 3rem 1.5rem;
}

main.db-main {
  max-width: 800px;
}

.page-nav {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.page-nav a {
  color: var(--subtext0);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  padding-bottom: 0.3rem;
  border-bottom: 2px solid transparent;
}

.page-nav a:hover {
  color: var(--text);
}

.page-nav a.active {
  color: var(--mauve);
  border-bottom-color: var(--mauve);
}

.page-nav a.home-link {
  color: var(--teal);
  padding-right: 1rem;
  border-right: 1px solid var(--surface1);
}

.nav-logout {
  margin-left: auto;
}

/* Login */
main.login-main {
  max-width: 360px;
  margin-top: 4rem;
}

#login-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

#login-form input {
  padding: 0.75rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--surface1);
  background: var(--mantle);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
}

#login-form input:focus {
  outline: none;
  border-color: var(--mauve);
}

#login-form button {
  padding: 0.75rem 1.25rem;
  border: none;
  border-radius: 10px;
  background: linear-gradient(90deg, var(--mauve), var(--blue));
  color: var(--crust);
  font-family: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
}

.login-error {
  margin-top: 1rem;
  color: var(--red);
  font-size: 0.9rem;
}

.login-error.hidden {
  display: none;
}

.hidden {
  display: none;
}

/* Admin */
#add-user-form {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 1rem;
}

#add-user-form input[type="text"],
#add-user-form input[type="password"] {
  padding: 0.65rem 0.9rem;
  border-radius: 10px;
  border: 1px solid var(--surface1);
  background: var(--mantle);
  color: var(--text);
  font-family: inherit;
}

#add-user-form button {
  padding: 0.65rem 1.1rem;
  border: none;
  border-radius: 10px;
  background: linear-gradient(90deg, var(--mauve), var(--blue));
  color: var(--crust);
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--subtext1);
  font-size: 0.9rem;
}

h1 {
  margin: 0 0 1.5rem;
  font-size: 2rem;
  font-weight: 700;
  background: linear-gradient(90deg, var(--mauve), var(--blue));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

#todo-form {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 1.5rem;
}

#todo-input {
  flex: 1;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--surface1);
  background: var(--mantle);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
}

#todo-input:focus {
  outline: none;
  border-color: var(--mauve);
}

#todo-form button {
  padding: 0.75rem 1.25rem;
  border: none;
  border-radius: 10px;
  background: linear-gradient(90deg, var(--mauve), var(--blue));
  color: var(--crust);
  font-family: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform 0.15s ease;
}

#todo-form button:hover {
  transform: translateY(-2px);
}

#todo-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.todo-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: var(--mantle);
  border: 1px solid var(--surface0);
  border-radius: 12px;
}

.todo-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--mauve);
  cursor: pointer;
}

.todo-item span {
  flex: 1;
  word-break: break-word;
}

.todo-item.done span {
  color: var(--subtext0);
  text-decoration: line-through;
}

.todo-item button {
  border: none;
  background: transparent;
  color: var(--red);
  font-size: 1.1rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.25rem;
}

.empty-state {
  text-align: center;
  color: var(--subtext0);
  margin-top: 2rem;
}

.empty-state.hidden {
  display: none;
}

/* File upload / gallery */
#upload-form {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

#file-input {
  flex: 1;
  min-width: 180px;
  padding: 0.6rem;
  border-radius: 10px;
  border: 1px solid var(--surface1);
  background: var(--mantle);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
}

#upload-form button {
  padding: 0.75rem 1.25rem;
  border: none;
  border-radius: 10px;
  background: linear-gradient(90deg, var(--mauve), var(--blue));
  color: var(--crust);
  font-family: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform 0.15s ease;
}

#upload-form button:hover {
  transform: translateY(-2px);
}

.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
}

.file-card {
  position: relative;
  background: var(--mantle);
  border: 1px solid var(--surface0);
  border-radius: 12px;
  overflow: hidden;
}

.file-card img {
  display: block;
  width: 100%;
  height: 120px;
  object-fit: cover;
  background: var(--surface0);
}

.file-meta {
  display: flex;
  flex-direction: column;
  padding: 0.6rem 0.75rem;
  gap: 0.1rem;
}

.file-name {
  font-size: 0.82rem;
  word-break: break-word;
}

.file-size {
  font-size: 0.75rem;
  color: var(--subtext0);
}

.icon-btn-delete {
  border: none;
  background: transparent;
  color: var(--red);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0.25rem;
}

.file-card .icon-btn-delete {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(17, 17, 27, 0.75);
  font-size: 0.9rem;
}

/* Database view */
.db-hint {
  color: var(--subtext0);
  font-size: 0.9rem;
  margin-top: -1rem;
  margin-bottom: 2rem;
}

h2 {
  font-size: 1.1rem;
  margin: 2rem 0 0.75rem;
  color: var(--mauve);
}

h2 code {
  font-size: 0.95rem;
  color: var(--teal);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--surface0);
  border-radius: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th, td {
  padding: 0.65rem 0.9rem;
  text-align: left;
  white-space: nowrap;
}

thead {
  background: var(--surface0);
}

th {
  color: var(--subtext0);
  font-weight: 600;
}

tbody tr {
  background: var(--mantle);
  border-top: 1px solid var(--surface0);
}

tbody td {
  color: var(--subtext1);
}

/* LoL / Riot linking */
#link-form {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin: 1.25rem 0;
}

#link-form input,
#link-form select {
  padding: 0.65rem 0.9rem;
  border-radius: 10px;
  border: 1px solid var(--surface1);
  background: var(--mantle);
  color: var(--text);
  font-family: inherit;
}

#link-form button {
  padding: 0.65rem 1.1rem;
  border: none;
  border-radius: 10px;
  background: linear-gradient(90deg, var(--mauve), var(--blue));
  color: var(--crust);
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
}

.grafana-embed {
  margin: 1.25rem 0;
  border: 1px solid var(--surface0);
  border-radius: 12px;
  overflow: hidden;
  background: var(--mantle);
}

.grafana-embed iframe {
  width: 100%;
  height: 560px;
  border: none;
  display: block;
}

.icon-btn-delete-text {
  padding: 0.6rem 1.1rem;
  border: 1px solid var(--surface1);
  border-radius: 10px;
  background: transparent;
  color: var(--subtext1);
  font-family: inherit;
  cursor: pointer;
}

.icon-btn-delete-text:hover {
  border-color: var(--red);
  color: var(--red);
}

/* Profil */
.profile-card {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.profile-avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--surface1);
}

.profile-username {
  margin: 0 0 0.75rem;
  font-size: 1.2rem;
  font-weight: 600;
}

/* LoL Stats Seite: breiter als der Standard-Content, damit die Profilkarte
   und das Grafana-Panel nebeneinander/gross genug Platz haben. */
main.lol-main {
  max-width: 1100px;
}

.lol-profile-card {
  display: flex;
  align-items: center;
  gap: 2.5rem;
  flex-wrap: wrap;
  background: var(--mantle);
  border: 1px solid var(--surface0);
  border-radius: 16px;
  padding: 1.75rem 2.25rem;
  margin: 1.5rem 0;
}

.lol-identity {
  min-width: 150px;
}

.lol-riot-id {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 700;
}

.lol-riot-id .lol-tag {
  color: var(--subtext0);
  font-weight: 400;
  margin-left: 0.15rem;
}

.lol-region {
  margin: 0.25rem 0 0;
  color: var(--subtext0);
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.rank-badge {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.5rem;
  border-left: 1px solid var(--surface0);
  border-right: 1px solid var(--surface0);
}

.rank-emblem {
  width: 60px;
  height: 60px;
  flex-shrink: 0;
}

.rank-emblem-svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.4));
}

.rank-tier {
  margin: 0;
  font-weight: 700;
  font-size: 1.05rem;
}

.rank-lp {
  margin: 0.2rem 0 0;
  color: var(--subtext0);
  font-size: 0.9rem;
}

.winrate-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  margin-left: auto;
}

.winrate-donut-svg {
  width: 88px;
  height: 88px;
}

.winrate-record {
  margin: 0;
  font-size: 0.85rem;
  color: var(--subtext1);
  font-weight: 600;
}

.winrate-record .wl-sep {
  color: var(--subtext0);
  font-weight: 400;
  margin: 0 0.15rem;
}

.lol-relink-row {
  display: flex;
  justify-content: flex-end;
  margin-top: -0.5rem;
}

@media (max-width: 720px) {
  .lol-profile-card {
    justify-content: center;
    text-align: center;
  }
  .rank-badge {
    border-left: none;
    border-right: none;
    padding: 1rem 0;
    border-top: 1px solid var(--surface0);
    border-bottom: 1px solid var(--surface0);
    width: 100%;
    justify-content: center;
  }
  .winrate-block {
    margin-left: 0;
  }
}
