/* ---------------- Tokens / Theme variables ---------------- */
:root {
  --bg-dark: #0e0e0e;
  --menu-bg-dark: #1c1c1c;
  --card-bg-dark: #121212;
  --text-dark: #f5f5f5;
  --muted-dark: #888888;

  --bg-light: #ffffff;
  --menu-bg-light: #eaeaea;
  --card-bg-light: #ffffff;
  --text-light: #111111;
  --muted-light: #7b848c;

  --gray-100: #f0f0f0;
  --gray-300: #d1d1d1;
  --gray-500: #888888;
  --gray-700: #444444;
  --gray-900: #1a1a1a;

  /* layout */
  --avatar-size: 80px;
  --card-size: 300px;
  --card-padding: 10px;
  --card-radius: 10px;
  --card-aspect: 1 / 1;
  --card-bottom-max: 120px;
  --header-height: 56px;
  --footer-height: 56px;
  --gap: 10px;
  --transition: 220ms ease;
  --font-sans: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;

  --footer-icon: var(--gray-500);
  --footer-icon-hover: var(--text-dark);
}

/* Theme mapping */
:root {
  --page-bg: var(--bg-dark);
  --menu-bg: var(--menu-bg-dark);
  --card-bg: var(--card-bg-dark);
  --text: var(--text-dark);
  --muted: var(--muted-dark);
}
html.light {
  --page-bg: var(--bg-light);
  --menu-bg: var(--menu-bg-light);
  --card-bg: var(--card-bg-light);
  --text: var(--text-light);
  --muted: var(--muted-light);
  --footer-icon-hover: var(--text-light);
}

/* ---------------- Base ---------------- */
* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
}
body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--page-bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background var(--transition), color var(--transition);
  line-height: 1.45;
  font-size: 15px;
  padding-bottom: calc(var(--footer-height) + 12px);
}

/* ---------------- Header / Brand / Controls ---------------- */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  background: var(--menu-bg);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  z-index: 1001;
}

/* Sort select styling (applies to main and admin selects) */
.sort-select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  display: inline-block;
  min-width: 140px;
  max-width: 220px;
  padding: 8px 36px 8px 12px;
  border-radius: 8px;
  border: 1px solid rgba(0,0,0,0.08);
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(0,0,0,0.02));
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  background-color: var(--card-bg);
  background-image: linear-gradient(45deg, transparent 50%, rgba(0,0,0,0.25) 50%),
                    linear-gradient(135deg, rgba(0,0,0,0.25) 50%, transparent 50%),
                    linear-gradient(to right, transparent, transparent);
  background-position: calc(100% - 18px) calc(1em + 2px), calc(100% - 13px) calc(1em + 2px), 100% 0;
  background-size: 6px 6px, 6px 6px, 2.5em 2.5em;
  background-repeat: no-repeat;
  transition: box-shadow .12s ease, border-color .12s ease, transform .12s ease;
}

/* Hover / focus */
.sort-select:hover { box-shadow: 0 6px 18px rgba(0,0,0,0.06); }
.sort-select:focus {
  outline: none;
  border-color: rgba(43,144,255,0.9);
  box-shadow: 0 6px 18px rgba(43,144,255,0.08);
}

/* Brand */
.site-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.site-logo {
  width: 40px;
  height: 40px;
  display: flex;
  align-content: center;
}
.site-logo img{
  width: 100%;
  height: 100%
}
.site-title {
  font-weight: 700;
  font-size: 1.02rem;
}
.site-sub {
  font-size: 0.88rem;
  color: var(--muted);
}

/* Controls container */
.site-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Admin/theme controls */
.about-btn,
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  margin: 0;
  background: transparent;
  border: none;
  color: var(--text);
  cursor: pointer;
  line-height: 1;
  font-size: 1.5rem;
  text-decoration: none;
}
.about-btn i,
.theme-toggle i {
  color: inherit;
  font-size: 1.5rem;
  pointer-events: none;
}

/* ---------------- Layout / Container / Grid ---------------- */
.container {
  width: 100%;
  padding: calc(var(--header-height) + 14px) 18px
    calc(var(--header-height) + 14px);
  margin: 0 auto;
  box-sizing: border-box;
}

/* Grid used on main page: center when few items */
.grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap);
  justify-content: center; /* center cards when few */
  align-items: flex-start;
}

/* ---------------- Card (generic) ---------------- */
.card {
  background: var(--card-bg);
  color: var(--text);
  border-radius: var(--card-radius);
  padding: var(--card-padding);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
  aspect-ratio: var(--card-aspect);
  overflow: hidden;
  transition: background var(--transition), box-shadow var(--transition);
  display: flex;
  align-items: stretch;
}
html.light .card {
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.06);
}

/* Card inner spacing */
.card-inner {
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  padding: 6px;
  box-sizing: border-box;
}

/* Top */
.card-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding-top: 6px;
}
.avatar {
  width: var(--avatar-size);
  height: var(--avatar-size);
  border-radius: 10px;
  object-fit: cover;
  background: var(--gray-700);
}
.title {
  font-weight: 700;
  font-size: 1rem;
  text-align: center;
  margin: 0;
}
.members {
  color: var(--muted);
  font-size: 0.9rem;
}

/* Middle */
.card-middle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* Buttons (primary) */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  background: var(--gray-100);
  color: var(--gray-900);
  border: none;
}
html.light .btn {
  background: var(--gray-900);
  color: var(--gray-100);
}
.btn:hover {
  opacity: 0.95;
}

/* Bottom */
.card-bottom {
  width: 100%;
  text-align: left;
  padding: 0 6px 6px;
  box-sizing: border-box;
}
.card-meta {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 6px;
}
.card-notes {
  color: inherit;
  font-size: 0.9rem;
  white-space: pre-wrap;
  max-height: var(--card-bottom-max);
  overflow: auto;
  padding-right: 6px;
}

/* Invalid */
.invalid-warning {
  margin-top: 4px;
  padding: 8px 14px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 700;
  display: inline-block;
}

/* ---------------- Footer ---------------- */
.site-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--footer-height);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--menu-bg-dark);
  border-top: 1px solid var(--gray-700);
  z-index: 1000;
}
html.light .site-footer {
  background: var(--menu-bg-light);
  border-top: 1px solid var(--gray-300);
}
.footer-links {
  display: flex;
  gap: 16px;
  align-items: center;
}
.footer-links a {
  color: var(--footer-icon);
  text-decoration: none;
  font-size: 1.1rem;
}
.footer-links a:hover {
  color: var(--footer-icon-hover);
}

/* ---------------- Admin panel specific styles ---------------- */
.admin-container {
  max-width: 980px;
  margin: 0 auto;
  padding: 8px;
  box-sizing: border-box;
  margin-top: calc(var(--header-height) + 8px);
  padding-bottom: calc(var(--footer-height) + 8px);
}

/* Compact form rows */
.form-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}
.form-row input[type="text"],
.form-row input[type="password"],
.form-row input[type="url"],
.form-row select {
  width: 100%;
  padding: 7px 9px;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  background: var(--card-bg);
  color: var(--text);
  font-size: 13px;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
  box-shadow: none;
}

/* server-form: compact, NOT a square card */
.server-form {
  width: 100%;
  max-width: 100%;
  background: var(--card-bg);
  border-radius: 10px;
  padding: 10px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  box-sizing: border-box;
}
html.light .server-form {
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.06);
}

/* Small buttons used in admin panel */
.btn.small {
  padding: 6px 10px;
  font-size: 13px;
  border-radius: 8px;
}

/* Admin list (table-like) */
.admin-list {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Each server row in admin list */
.server-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: 10px;
  background: var(--card-bg);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}
html.light .server-row {
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.06);
}

/* server-row avatar */
.server-row .avatar {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
}

/* server-row content */
.server-row .meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.server-row .meta .name {
  font-weight: 700;
}
.server-row .meta .info {
  color: var(--muted);
  font-size: 0.9rem;
}
.server-row .meta .notes {
  color: var(--muted);
  font-size: 0.9rem;
  white-space: pre-wrap;
  max-height: 4.8em;
  overflow: hidden;
}
.server-row .actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Inline status badges */
.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: var(--gray-900);
  background: var(--gray-100);
}
html.light .badge {
  color: var(--gray-100);
  background: var(--gray-900);
}

/* Empty state */
.admin-empty {
  color: var(--muted);
  padding: 12px;
  text-align: center;
}

/* Accessibility helpers */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* ---------------- Main page fixed-card styles ---------------- */
/* Ensure cards are fixed squares (300x300) and centered when few items */
.fixed-card {
  width: var(--card-size);
  height: var(--card-size);
  padding: var(--card-padding);
  display: flex;
  align-items: stretch;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.06);
  transition: transform 160ms ease, box-shadow 160ms ease;
}
.fixed-card .card-inner {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
}
.fixed-card .card-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding-top: 4px;
}
.fixed-card .avatar {
  border-radius: 12px;
  object-fit: cover;
  background: var(--bg);
}
.fixed-card .title {
  font-weight: 700;
  font-size: 1.05rem;
  margin: 0;
  text-align: center;
  word-break: break-word;
}
.fixed-card .card-middle {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
}
.fixed-card .members-line {
  font-weight: 600;
  color: var(--text);
  font-size: 0.95rem;
}
.fixed-card .invite-wrap {
  display: flex;
  justify-content: center;
  width: 100%;
}
.fixed-card .invite-btn {
  margin-top: 4px;
  padding: 8px 14px;
  border-radius: 8px;
  background: var(--gray-100);
  color: var(--gray-900);
  text-decoration: none;
  font-weight: 700;
  display: inline-block;
}
.fixed-card .invite-btn.disabled {
  opacity: 0.5;
  pointer-events: none;
}
.fixed-card .card-bottom {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px 4px 8px 4px;
}
.fixed-card .card-category {
  align-self: flex-start;
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 600;
}
.fixed-card .card-note {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: normal;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------------- About page specific styles ---------------- */

.about {
  font-size: 15px;
}
.about h1 {
  text-align: center;
}

/* ---------------- Responsive tweaks ---------------- */

@media (max-width:540px) {
  .site-sub {
    display: none;
  }
  .sort-select {
    min-width: 100px;
  }
}
@media (max-width: 400px) {
  .site-title {
    font-size: 14px;
  }
}

/* ---------------- End of file ---------------- */