*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
    background: var(--app-bg);
}

body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    background: var(--app-bg);
    color: var(--app-text);
}

.sidebar-toggle {
    position: fixed;
    top: var(--sidebar-toggle-top);
    left: var(--sidebar-width);
    transform: translateX(-50%);
    width: var(--sidebar-toggle-width);
    height: var(--sidebar-toggle-height);
    border: none;
    border-radius: 0 var(--sidebar-toggle-radius) var(--sidebar-toggle-radius) 0;
    background: rgba(35, 39, 42, 0.85);
    color: var(--text-white);
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1200;
    box-shadow: 0 10px 16px rgba(0, 0, 0, 0.35);
    transition: background 0.2s ease, left 0.3s ease, transform 0.2s ease;
    padding: 0;
}

.sidebar-toggle:focus-visible {
    outline: 2px solid rgba(88, 101, 242, 0.8);
    outline-offset: 2px;
}

.sidebar-toggle:hover {
    background: rgba(88, 101, 242, 0.95);
}

.sidebar-toggle__icon {
    width: 0;
    height: 0;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-right: 12px solid var(--text-white);
    transition: transform 0.2s ease;
}

body.has-sidebar .sidebar-toggle {
    display: inline-flex;
}

body.sidebar-collapsed .sidebar-toggle {
    left: 0;
    border-radius: 0 var(--sidebar-toggle-radius) var(--sidebar-toggle-radius) 0;
    transform: none;
}

body.sidebar-collapsed .sidebar-toggle__icon {
    transform: rotate(180deg);
}

@media (max-width: 1024px) {
    body.has-sidebar .sidebar-toggle {
        left: var(--sidebar-width);
        border-radius: 0 var(--sidebar-toggle-radius-wide) var(--sidebar-toggle-radius-wide) 0;
        transform: translateX(-50%);
    }
}

/* Flash-Meldungen */
.flash-message {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: var(--layout-gap);
    font-size: 1.05rem;
    line-height: 1.4;
    background: var(--km-surface-750);
    color: var(--app-text-secondary);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.flash-message.success {
    background: var(--flash-success-bg);
    color: var(--text-white);
}

.flash-message.error {
    background: var(--flash-error-bg);
    color: var(--text-white);
}

.flash-message.warning {
    background: var(--flash-warning-bg);
    color: var(--text-dark);
}

.flash-message.info {
    background: var(--flash-info-bg);
    color: var(--text-white);
}

.flash-message .alert-close {
    margin-left: auto;
    background: transparent;
    border: none;
    color: var(--app-text-secondary);
    cursor: pointer;
    font-size: 1.5rem;
    line-height: 1;
    opacity: 0.75;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease, opacity 0.2s ease, transform 0.2s ease;
}

.flash-message .alert-close:hover,
.flash-message .alert-close:focus {
    color: var(--text-bright);
    opacity: 1;
    transform: scale(1.05);
}

.flash-message .alert-close:focus {
    outline: 2px solid rgba(88, 101, 242, 0.35);
    outline-offset: 2px;
}

/* Modern Sidebar Styling */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--km-surface-750) 0%, var(--km-surface-760) 100%);
    color: var(--text-white);
    padding: 0;
    position: fixed;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
    border-right: 1px solid var(--border-strong);
    z-index: 1100;
    transform: translateX(0);
    transition: transform 0.3s ease;
    --text-white: #fff;
    --text-soft: #e3e3e3;
    --text-muted: #b9bbbe;
    --text-muted-strong: #8e9297;
    --text-muted-soft: #aaa;
}

/* Sidebar Header */
.sidebar-header {
    padding: 2.25rem 1.5rem 1.25rem 1.5rem;
    padding-right: 2.75rem;
    border-bottom: 1px solid var(--border-strong);
    background: rgba(54, 57, 63, 0.5);
    position: relative;
}

.server-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.server-avatar-small {
    flex-shrink: 0;
}

.server-icon-sidebar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid var(--accent-discord);
    object-fit: cover;
}

.server-icon-fallback {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-discord), var(--accent-discord-strong));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-white);
    border: 2px solid var(--accent-discord);
}

.server-details {
    flex: 1;
    min-width: 0;
    margin-top: 0.25rem;
}

.server-name-sidebar {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 0.25rem 0;
    color: var(--text-white);
    line-height: 1.2;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.server-status {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Navigation */
.sidebar-nav {
    padding: 0.5rem 0;
    flex: 1 1 auto;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.nav-section {
    margin-bottom: 0.5rem;
}

.nav-section-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted-strong);
    margin: 0 0 0.5rem 0;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-section-title i {
    font-size: 0.875rem;
}

.nav-items {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-item {
    margin: 0;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1.5rem;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    position: relative;
    min-height: 36px;
}

.nav-link:has(.multiline-text) {
    padding: 0.4rem 1.5rem;
    min-height: 42px;
    align-items: center;
}

.nav-link:hover {
    background: rgba(79, 84, 92, 0.32);
    color: var(--text-white);
    border-left-color: var(--accent-nav);
}

.nav-link.active {
    background: rgba(160, 82, 45, 0.15);
    color: var(--text-white);
    border-left-color: var(--accent-nav);
}

.nav-link.active::before {
    content: '';
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    background: var(--accent-nav);
    border-radius: 50%;
}

.nav-link i {
    font-size: 1rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.nav-link:has(.multiline-text) i {
    align-self: center;
}

.nav-link span {
    flex: 1;
    line-height: 1.3;
}

.nav-link .multiline-text {
    line-height: 1.2;
    font-size: 1rem;
}

/* Sidebar Footer */
.sidebar-actions {
    padding: 1rem;
    margin-top: 0.5rem;
    border-top: 1px solid var(--border-strong);
    background: rgba(35, 39, 42, 0.5);
}

.sidebar-footer {
    margin-top: auto;
    padding: 0.75rem 1rem;
    background: rgba(35, 39, 42, 0.5);
}

.quick-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.quick-action-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.overview-btn {
    background: rgba(114, 137, 218, 0.1);
    color: var(--accent-discord);
    border-color: rgba(114, 137, 218, 0.2);
}

.overview-btn:hover {
    background: rgba(114, 137, 218, 0.2);
    color: var(--text-white);
    text-decoration: none;
}

.overview-btn.active {
    background: rgba(114, 137, 218, 0.25);
    color: var(--text-white);
    border-color: var(--accent-discord);
}

.back-btn {
    background: rgba(67, 181, 129, 0.1);
    color: var(--accent-back);
    border-color: rgba(67, 181, 129, 0.2);
}

.back-btn:hover {
    background: rgba(67, 181, 129, 0.2);
    color: var(--text-white);
    text-decoration: none;
}

.quick-action-btn i {
    font-size: 0.875rem;
    width: 16px;
    text-align: center;
}

/* Datenschutz Link in Sidebar */
.sidebar-privacy {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-strong);
}

.sidebar-privacy .privacy-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.25rem 0;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.75rem;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-muted-strong);
}

.sidebar-privacy .privacy-link:hover {
    background: transparent;
    color: var(--text-white);
    text-decoration: underline;
}

.sidebar-privacy .privacy-link i {
    font-size: 0.75rem;
    width: 14px;
    text-align: center;
}

/* Scrollbar Styling */
.sidebar-nav::-webkit-scrollbar {
    width: 6px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(79, 84, 92, 0.6);
    border-radius: 3px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: rgba(79, 84, 92, 0.8);
}

.main-content {
    margin-left: var(--sidebar-width);
    padding: var(--content-padding);
    background: var(--km-surface-760);
    color: var(--app-text);
    min-height: 100vh;
}

body.sidebar-collapsed .sidebar {
    transform: translateX(-100%);
    box-shadow: none;
}

body.sidebar-collapsed .main-content {
    margin-left: 0;
}

body.sidebar-no-transition .sidebar,
body.sidebar-no-transition .main-content {
    transition: none !important;
}

html.prefers-sidebar-collapsed body.has-sidebar .sidebar {
    transform: translateX(-100%);
    box-shadow: none;
}

html.prefers-sidebar-collapsed body.has-sidebar .main-content {
    margin-left: 0;
}

/* Für die Dashboard-Hauptseite ohne Sidebar */
.main-content--full {
    margin-left: 0 !important;
    width: 100% !important;
}

.server-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: var(--layout-gap);
}

.server-list .server-card {
    background: var(--surface-card);
    border-radius: 16px;
    box-shadow: 0 2px 16px rgba(0,0,0,0.18);
    padding: 0;
    margin: 0;
    font-size: 1.22em;
    font-weight: 500;
    color: var(--text-soft);
    width: 100%;
    max-width: 100%;
    min-height: 130px;
    text-align: center;
    transition: transform 0.12s, box-shadow 0.12s;
    overflow: hidden;
}

@media (min-width: 768px) {
  .server-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--layout-gap);
  }

  .server-list .server-card {
    flex: 0 0 350px;  /* ab hier darf er „breit“ werden */
  }
}

.server-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 22px;
    padding: 0;
    color: inherit;
    text-decoration: none;
    width: 100%;
    min-height: 90px;
    height: 100%;
    transition: background 0.12s, color 0.12s;
}

.server-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--surface-deep);
    margin-right: 0;
    display: block;
}

.server-icon.placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4em;
    font-weight: bold;
    color: var(--text-muted-soft);
    background: var(--surface-deep);
    width: 56px;
    height: 56px;
    border-radius: 50%;
    margin-right: 0;
}

.server-name {
    font-size: 1em;
    font-weight: 500;
    color: var(--app-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
}

.server-card:hover, .server-link:hover {
    transform: translateY(-4px) scale(1.03);
    box-shadow: 0 6px 24px rgba(0,0,0,0.22);
    background: var(--surface-strong);
    color: var(--text-white);
}

h1 {
    font-size: 2em;
}


.card:hover {
    border: 2px solid var(--hover-border-color);
}

.server-link:hover {
    border: 2px solid var(--hover-border-color) !important;
}


/* Performance: Reduziere Repaints */
.server-card, .info-box, .panel-container {
    will-change: transform;
    transform: translateZ(0);
}

/* Optimiere Animationen */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

@media (max-width: 1024px) {
    body.has-sidebar .main-content {
        margin-left: 0;
    }

    body.has-sidebar:not(.sidebar-collapsed) .sidebar {
        transform: translateX(0);
    }

    body.has-sidebar .sidebar-toggle {
        left: 20px;
    }
}

@media (max-width: 768px) {
  /* Body-Scroll bei geöffneter Sidebar sperren */
  body.sidebar-scroll-lock {
    overflow: hidden;
    overscroll-behavior: contain;
  }

  .main-content {
    margin-left: 0;
    padding: var(--content-padding-mobile);
  }

  .sidebar-toggle {
    top: var(--sidebar-toggle-top-mobile);
    left: var(--sidebar-toggle-left-mobile);
  }
}
