discord-widget {
  --color: #5865f2;
  --bgColor: #0c0c0d;
  --textColor: #ffffff;
  --buttonColor: #5865f2;
  --statusColor: #858585;

  display: flex;
  flex-direction: column;
  border-radius: 6px;
  overflow: hidden;
  font-family: Whitney, "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 14px;
  color: #fff;
  margin: 0 auto;
  width: 100%;
  max-width: 400px;
  height: 500px;
}

/* --- Box sizing consistency --- */
discord-widget,
discord-widget * {
  box-sizing: border-box;
}

/* --- Widget scrollbar --- */
discord-widget::-webkit-scrollbar {
  width: 16px;
}

discord-widget::-webkit-scrollbar-track {
  background: var(--bgColor);
}

discord-widget::-webkit-scrollbar-thumb {
  background: #222;
  border: 6px solid var(--bgColor);
  border-radius: 10px;
  transition: background 0.5s ease-in-out;
}

discord-widget::-webkit-scrollbar-thumb:hover {
  background: var(--color);
}

/* --- Header --- */
discord-widget widget-header {
  background-color: var(--color);
  font-weight: bold;
  padding: 16px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}

discord-widget widget-header widget-logo {
  background: url(discord_logo.svg) center / contain no-repeat;
  width: 124px;
  height: 34px;
  display: inline-block;
  transition: opacity 0.25s ease-out;
}

discord-widget widget-header widget-header-count {
  margin-left: auto;
}

/* --- Body --- */
discord-widget widget-body {
  background-color: var(--bgColor);
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-left: 16px;
  padding-right: 16px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.3);
  position: relative;
  scroll-padding-top: 12px;
  scroll-padding-bottom: 12px;
}

/* Pseudo-elements for scroll spacing (fixes header/footer clipping) */
discord-widget widget-body::before,
discord-widget widget-body::after {
  content: "";
  display: block;
  height: 10px; /* space between header/footer and first/last member */
  flex: 0 0 auto;
  pointer-events: none;
}

/* --- Members --- */
discord-widget widget-body widget-member {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0;
  padding: 0 8px;
  border-radius: 4px;
  transition: background-color 0.2s ease;
  animation: fadeIn 0.3s ease-in;
  min-height: 36px;
}

discord-widget widget-body widget-member:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

discord-widget widget-body widget-member .member-left {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 1;
  min-width: 0;
}

discord-widget widget-body widget-member widget-member-avatar {
  position: relative;
  contain: content;
  margin-right: 4px;
}

discord-widget widget-body widget-member widget-member-avatar img {
  border-radius: 50%;
  width: 36px;
  height: 36px;
  border: 2px solid var(--color);
  background-color: var(--color);
  display: block;
}

/* Status indicators */
.widget-member-status {
  position: absolute;
  bottom: 2px;
  right: 0px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--color);
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
}

.widget-member-status-online { background-color: #57f287; }
.widget-member-status-idle { background-color: #fee75c; }
.widget-member-status-dnd { background-color: #ed4245; }
.widget-member-status-offline { background-color: #80848e; }

/* Member names */
discord-widget widget-body widget-member widget-member-name {
  font-weight: bold;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 1;
  min-width: 0;
}

/* Status text */
discord-widget widget-body widget-member widget-member-status-text {
  color: var(--statusColor);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
  margin-left: auto;
  max-width: 40%;
  text-align: right;
  opacity: 1;
  transform: translateX(0);
  transition: all 0.3s ease-in-out;
}

/* --- Footer --- */
discord-widget widget-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-shrink: 0;
  min-height: 30px;
  padding: 6px 12px;
  background-color: var(--bgColor);
  box-shadow: 0 -1px 18px rgba(0,0,0,0.3), 0 -1px 0 rgba(0,0,0,0.2);
  color: #fff;
  position: relative;
  z-index: 2;
}

discord-widget widget-footer widget-button-join {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 30px;
  border-radius: 6px;
  background-color: var(--color);
  color: var(--textColor) !important;
  font-weight: 700;
  text-decoration: none;
  transition: background-color 0.25s ease-out;
  cursor: pointer;
}

discord-widget widget-footer widget-button-join:hover {
  background-color: var(--buttonColor);
}

discord-widget widget-footer widget-button-join:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

discord-widget widget-footer widget-button-join:not([href]) {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* --- Animations --- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: translateX(0); }
}

/* --- Responsive --- */
@media screen and (max-width: 540px) {
  discord-widget { font-size: 12px; }
  discord-widget widget-header, discord-widget widget-body { padding: 12px; }
  discord-widget widget-footer { padding: 4px 8px; flex-direction: column; gap: 8px; }
  discord-widget widget-footer widget-button-join { width: 100%; }
  discord-widget widget-body widget-member widget-member-status-text {
    transform: translateX(-30px);
    max-width: 80px;
    text-align: left;
  }
  discord-widget widget-body::before,
  discord-widget widget-body::after {
    height: 8px;
  }
  discord-widget widget-body widget-member widget-member-name { max-width: 120px; }
}

@media screen and (max-width: 400px) {
  discord-widget widget-body widget-member widget-member-status-text {
    opacity: 0;
    max-width: 0;
    transform: translateX(-30px);
    pointer-events: none;
  }
  discord-widget widget-body::before,
  discord-widget widget-body::after {
    height: 6px;
  }
  discord-widget widget-body widget-member widget-member-name { max-width: 100%; }
}
