/* Dashboard-specific styles - Optimized for LCP */

/* Critical above-the-fold styles for immediate rendering */
html,
body {
  background-color: #18191c;
  background-image: linear-gradient(135deg, var(--km-surface-750) 0%, #1e2124 100%) !important;
  background-repeat: no-repeat;
  background-attachment: fixed;
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  /* Optimize font rendering */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeSpeed;
}

@supports (min-height: 100dvh) {
  html,
  body {
    min-height: 100dvh;
  }
}

.main-content {
  min-height: 100vh;
  padding: 0;
  margin: 0;
  width: 100%;
}

.container-fluid {
  padding: 0 !important;
  margin: 0 !important;
  max-width: 100% !important;
  width: 100% !important;
  /* Prevent horizontal scrollbar */
  overflow-x: hidden;
}

/* Page header - critical for LCP */
.page-header {
  background: var(--km-surface-750) !important;
  border: none !important;
  border-radius: 0 !important;
  padding: 2rem 1rem !important;
  margin: 0 0 2rem 0 !important;
  width: 100%;
  text-align: center;
}

.page-header h1 {
  color: #fff;
  font-size: var(--page-header-title-size);
  font-weight: 700;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, #7289da, #5865f2);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-with-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

.page-header p {
  color: #b9bbbe;
  font-size: 1.125rem;
}

.welcome-section p {
  color: #b9bbbe;
  font-size: 1.125rem;
  margin-bottom: 1rem;
}

/* Welcome section - critical for first paint */
.welcome-section {
  text-align: center;
  margin-bottom: 3rem;
  padding: 2rem;
  background: rgba(54, 57, 63, 0.5);
  border-radius: 16px;
  backdrop-filter: blur(10px);
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}

.welcome-section h1 {
  color: #fff;
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, #7289da, #5865f2);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

.welcome-section .login-button-container {
  margin-top: 2.5rem;
}

.bot-avatar-header {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 3px solid #7289da;
  object-fit: cover;
  flex-shrink: 0;
  /* Use CSS to reduce visual size while keeping file size manageable */
  object-position: center;
}

.rickroll-avatar:hover {
  transform: scale(1.02);
  border-color: #6b7bd6;
  box-shadow: 0 0 8px rgba(88, 101, 242, 0.2);
}

.rickroll-link {
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}

.btn-login {
  background: linear-gradient(135deg, #7289da, #5865f2);
  border: none;
  color: #fff;
  padding: 1rem 2rem;
  border-radius: 12px;
  font-size: 1.125rem;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(114, 137, 218, 0.4);
}

/* Basic responsive */
@media (max-width: 768px) {
  .welcome-section h1 {
    font-size: 2rem;
  }
}

/* Override any sidebar styles that might leak through */
.sidebar {
  display: none !important;
}

.main-content {
  margin-left: 0 !important;
  width: 100% !important;
}

/* Flash Messages - sofortige Positionierung ohne JavaScript-Sprung */
.alert {
  position: fixed !important;
  top: 1rem !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  z-index: 9999 !important;
  min-width: 300px !important;
  max-width: 90vw !important;
  margin-bottom: 0 !important;
  padding: 12px 40px 12px 16px !important;
  border-radius: 8px !important;
  font-size: 1rem !important;
  font-weight: 500 !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
  opacity: 1 !important;
  transition: opacity 0.3s ease !important;
}

.alert-success {
  color: #fff !important;
  background: #4caf50 !important;
  border: 1px solid #43a047 !important;
}

.alert-danger {
  color: #fff !important;
  background: #f44336 !important;
  border: 1px solid #e53935 !important;
}

.alert-warning {
  color: #fff !important;
  background: #ff9800 !important;
  border: 1px solid #f57c00 !important;
}

.alert-info {
  color: #fff !important;
  background: #2196f3 !important;
  border: 1px solid #1976d2 !important;
}

/* Close Button für Flash Messages */
.alert .alert-close {
  position: absolute !important;
  top: 8px !important;
  right: 12px !important;
  background: none !important;
  border: none !important;
  font-size: 1.5rem !important;
  line-height: 1 !important;
  color: inherit !important;
  opacity: 0.6 !important;
  cursor: pointer !important;
  padding: 0 !important;
  width: 20px !important;
  height: 20px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: opacity 0.2s ease !important;
}

.alert .alert-close:hover {
  opacity: 1 !important;
}

/* Schutz gegen CSS-Overrides */
[data-flash-stabilized="true"] {
  position: fixed !important;
  top: 1rem !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  z-index: 9999 !important;
}

/* Image optimization for LCP */
.optimized-image {
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  /* Force browser to use hardware acceleration */
  transform: translateZ(0);
  will-change: transform;
  /* Prevent layout shift during load */
  aspect-ratio: 1 / 1;
  object-fit: cover;
}

/* Preload critical images to improve LCP */
.bot-avatar-header {
  /* Ensure consistent sizing to prevent CLS */
  min-width: 60px;
  min-height: 60px;
  max-width: 60px;
  max-height: 60px;
}

/* Subtile Layout Shift Prevention - behält das Design bei */
.server-avatar {
  background-color: var(--km-surface-525);
  opacity: 1;
}

.server-avatar[loading="lazy"] {
  min-height: 60px;
}

/* Loading state management */
.server-grid {
  opacity: 1;
}

/* Bot fallback icon - hidden by default */
.bot-fallback-icon {
  display: none;
}

/* Search results message - hidden by default */
.search-results-message {
  display: none;
}

/* Server avatar container */
.server-avatar-container {
  position: relative;
  width: 60px;
  height: 60px;
  flex-shrink: 0;
  /* Verhindert, dass Avatar schrumpft */
  align-self: flex-start;
  /* Avatar bleibt oben ausgerichtet */
}

/* Server avatar - positioniert über dem Fallback */
.server-avatar {
  display: block;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  object-fit: cover;
  position: relative;
  z-index: 2;
}

/* Server avatar fallback - Styling für Fallback-Avatare */
.server-avatar-fallback {
  display: flex;
  /* Immer da, aber hinter dem Bild */
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #7289da;
  color: #fff;
  font-weight: 700;
  font-size: 1.2rem;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  /* Hinter dem Bild */
}

/* Zeige Fallback nur wenn explizit aktiviert */
.server-avatar-fallback.show {
  display: flex;
}

/* Search functionality styles */
.search-container {
  max-width: 500px;
  margin: 0 auto 2rem auto;
  position: relative;
  padding: 0 1rem;
  box-sizing: border-box;
}

.search-input {
  background: var(--km-surface-525) !important;
  border: 2px solid var(--km-surface-525) !important;
  border-radius: 25px !important;
  color: #fff !important;
  padding: 12px 20px !important;
  font-size: 1rem !important;
  width: 100% !important;

  box-sizing: border-box; /* <--- das ist der wichtige Teil */
}

.search-input::placeholder {
  color: #b9bbbe !important;
}

.search-input:focus {
  background: var(--km-surface-650) !important;
  border-color: #7289da !important;
  box-shadow: 0 0 0 3px rgba(114, 137, 218, 0.2) !important;
  color: #fff !important;
  outline: none !important;
}

.search-icon {
  position: absolute;
  left: 24px;
  top: 50%;
  transform: translateY(-50%);
  color: #b9bbbe;
  font-size: 1.1rem;
}

/* Server grid styles */
.server-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 360px));
  justify-content: center;
  gap: 1.5rem;
  max-width: 1400px;
  margin: 0 auto 2rem auto;
  padding: 1rem 2rem 2rem 2rem;
  box-sizing: border-box;
}

.server-card {
  background: var(--km-surface-650);
  border-radius: 16px;
  border: 2px solid transparent;
  padding: 1.25rem;
  position: relative;
  cursor: pointer;
  width: 100%;
  min-height: 200px;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  overflow: hidden;
}

.server-card::before {
  content: '';
  position: absolute;
  top: -3px;
  left: -3px;
  right: -3px;
  bottom: -3px;
  background: linear-gradient(90deg, #a0522d, #8b4513);
  border-radius: 19px;
  opacity: 0;
  z-index: -1;
  pointer-events: none;
}

.server-card:hover:not(.disabled) {
  box-shadow: 0 8px 25px rgba(160, 82, 45, 0.25);
  z-index: 10;
}

.server-card:hover:not(.disabled)::before {
  opacity: 1;
}

.server-header {
  display: flex;
  align-items: flex-start;
  margin-bottom: 1rem;
  gap: 1rem;
  min-height: 60px;
  /* Mindesthöhe für Avatar */
}

.server-info {
  flex: 1;
  min-width: 0;
  /* Wichtig für text-overflow */
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.server-card .server-info h3 {
  color: #fff;
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0 0 0.5rem 0;
  line-height: 1.3;
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
  /* Verhindert, dass Text unter das Avatar rutscht */
  max-width: 100%;
}

.server-card .server-owner {
  color: #b9bbbe;
  font-size: 0.875rem;
  margin: 0.25rem 0 0 0;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.server-card .server-owner i {
  color: #faa61a;
  font-size: 0.75rem;
}

/* Emoji alignment optimized - using direct Unicode characters */
.server-card .server-owner {
  display: flex;
  align-items: baseline;
  gap: 0.25rem;
  line-height: 1.2;
}

/* Simple and effective emoji alignment */
.server-card .server-owner {
  display: flex;
  align-items: center;
  gap: 0.1rem;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.1rem;
}

.text-adjust {
  transform: translateY(2px);
  margin-left: 0.1rem;
}

/* Status badges */
.status-badges {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.status-badge {
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.status-badge.active {
  background: rgba(67, 181, 129, 0.2);
  color: #43b581;
  border: 1px solid #43b581;
}

.status-badge.warning {
  background: rgba(250, 166, 26, 0.2);
  color: #faa61a;
  border: 1px solid #faa61a;
}

.status-badge.error {
  background: rgba(240, 71, 71, 0.2);
  color: #f04747;
  border: 1px solid #f04747;
}

.status-badge.owner {
  background: rgba(114, 137, 218, 0.2);
  color: #7289da;
  border: 1px solid #7289da;
}



.btn-login:hover {
  background: linear-gradient(135deg, #5865f2, #4752c4);
  color: #fff;
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(114, 137, 218, 0.5);
}

/* Disabled state */
.server-card.disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.server-card.disabled:hover {
  transform: none;
  border-color: transparent;
  box-shadow: none;
}

.server-card.disabled::before {
  display: none;
}

.server-card.disabled .server-avatar,
.server-card.disabled .server-avatar-fallback {
  filter: grayscale(100%);
}

/* No servers message */
.no-servers {
  text-align: center;
  padding: 3rem 2rem;
  color: #b9bbbe;
}

.no-servers i {
  font-size: 4rem;
  color: var(--km-surface-525);
  margin-bottom: 1rem;
}

.no-servers h3 {
  color: #fff;
  margin-bottom: 0.5rem;
}

/* Search results message */
.search-results-message {
  text-align: center;
  padding: 2rem;
  margin: 0 auto 2rem auto;
  max-width: 600px;
  color: #b9bbbe;
  display: none;
}

.search-results-message i {
  font-size: 3rem;
  color: var(--km-surface-525);
  margin-bottom: 1rem;
  display: block;
}

.search-results-message h3 {
  color: #fff;
  margin-bottom: 0.5rem;
  font-size: 1.5rem;
}

.search-results-message p {
  color: #b9bbbe;
  font-size: 1rem;
  margin: 0;
}

/* Enhanced responsive design */
@media (max-width: 768px) {
  .search-container {
    margin: 0 1rem 2rem 1rem;
  }

  .server-grid {
    grid-template-columns: 1fr;
    padding: 0 1rem;
    gap: 1rem;
  }

  /* Bessere Textumbrüche auf mobilen Geräten */
  .server-card .server-info h3 {
    font-size: 1.1rem;
    line-height: 1.4;
  }
}

/* Spezielle Regeln für sehr lange Servernamen */
@media (max-width: 320px) {
  .server-header {
    gap: 0.75rem;
  }

  .server-card .server-info h3 {
    font-size: 1rem;
    line-height: 1.4;
  }
}

/* Verbesserte Textumbrüche für alle Bildschirmgrößen */
.server-card .server-info h3 {
  /* Bessere Wortumbrüche für deutsche Texte */
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* Dashboard-specific styles complete *//* Login Bu
tton Styling */
.login-btn {
    display: inline-block;
    margin: 32px auto 24px auto;
    padding: 12px 32px;
    font-size: 1.1em;
    background: #5865f2;
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.18);
    transition: background 0.2s;
}

.login-btn:hover {
    background: #4752c4;
}

@media (max-width: 768px) {
  .welcome-section {
    padding: 1.25rem;
    margin: 1.5rem 1rem 2rem 1rem;
    max-width: 100%;
  }

  .welcome-section h1 {
    font-size: 1.8rem;
    gap: 0.5rem;
    flex-wrap: wrap;
    text-align: center;
  }

  .welcome-section p {
    font-size: 0.95rem;
  }

  .btn-login {
    width: 100%;
    justify-content: center;
    padding: 0.8rem 1.25rem;
    font-size: 1rem;
  }
}

@media (max-width: 480px) {
  .server-card {
    padding: 0.9rem;
    border-radius: 12px;
    min-height: 0;
  }

  .server-header {
    gap: 0.75rem;
  }

  .status-badges {
    margin-top: 0.75rem;
  }

  .status-badge {
    font-size: 0.7rem;
    padding: 0.2rem 0.6rem;
  }
}

@media (max-width: 768px) {
  .page-header {
    padding: 1.5rem 1rem !important;
    margin-bottom: 1.5rem !important;
  }

  .page-header h1 {
    font-size: var(--page-header-title-size);
  }

  .page-header p {
    font-size: 1rem;
  }

  html, body {
    font-size: 15px;
  }
}

@media (max-width: 480px) {
  html, body {
    font-size: 14px;
  }
}

@media (max-width: 480px) {
  .alert {
    top: 0.5rem !important;
    min-width: 0 !important;
    max-width: 95vw !important;
    font-size: 0.9rem !important;
    padding: 10px 32px 10px 10px !important;
  }
}

@media (max-width: 480px) {
  .search-container {
    padding: 0;          /* gar kein Padding mehr vom Container */
    margin: 0 0 1.5rem 0;
  }
}
