/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Light Mode Variables */
  --bg-primary: #f5f5f5;
  --bg-secondary: #ffffff;
  --text-primary: #333;
  --text-secondary: #666;
  --sidebar-bg: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --border-color: #e0e0e0;
  --shadow-light: rgba(0, 0, 0, 0.1);
  --shadow-medium: rgba(0, 0, 0, 0.15);
  --overlay-bg: rgba(0, 0, 0, 0.7);
  --accent-color: #667eea;
  --success-color: #16a34a;
  --error-color: #dc2626;
  --text-color: var(--text-primary);
  --card-background: var(--bg-secondary);
  --shadow-color: var(--shadow-light);
}

[data-theme="dark"] {
  /* Dark Mode Variables */
  --bg-primary: #1a1a1a;
  --bg-secondary: #2d2d2d;
  --text-primary: #ffffff;
  --text-secondary: #b0b0b0;
  --sidebar-bg: linear-gradient(135deg, #2d3748 0%, #4a5568 100%);
  --border-color: #404040;
  --shadow-light: rgba(0, 0, 0, 0.3);
  --shadow-medium: rgba(0, 0, 0, 0.5);
  --overlay-bg: rgba(0, 0, 0, 0.8);
  --accent-color: #8b5cf6;
  --success-color: #22c55e;
  --error-color: #ef4444;
  --text-color: var(--text-primary);
  --card-background: var(--bg-secondary);
  --shadow-color: var(--shadow-light);
}

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Dashboard Container */
.dashboard-container {
  min-height: 100vh;
  display: flex;
  flex-direction: row;
}

/* Left Sidebar Navigation */
.sidebar-navigation {
  width: 250px;
  background: var(--sidebar-bg);
  color: white;
  display: flex;
  flex-direction: column;
  box-shadow: 2px 0 4px var(--shadow-light);
  position: fixed;
  height: 100vh;
  left: 0;
  top: 0;
  z-index: 100;
  transition: width 0.3s ease, transform 0.3s ease;
}

.sidebar-navigation.collapsed {
  width: 60px;
}

.sidebar-header {
  padding: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 70px;
}

.app-logo {
  display: inline-block;
  border-radius: 6px;
  box-shadow: 0 1px 2px var(--shadow-light);
}

.sidebar-toggle {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 8px;
  border-radius: 4px;
  transition: background-color 0.2s ease;
  font-size: 16px;
  flex-shrink: 0;
}

.sidebar-toggle:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.sidebar-title {
  font-size: 1.2rem;
  font-weight: 600;
  margin: 0;
  flex: 1;
  transition: opacity 0.3s ease;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-navigation.collapsed .sidebar-title {
  opacity: 0;
  pointer-events: none;
}

.nav-buttons {
  padding: 1rem 0;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  margin-top: auto;
}

.theme-toggle {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 12px 8px;
  border-radius: 6px;
  transition: background-color 0.2s ease;
  font-size: 14px;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none; /* verhindert Unterstreichung bei <a> */
}

.theme-toggle:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.theme-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.theme-text {
  transition: opacity 0.3s ease;
}

.sidebar-navigation.collapsed .theme-text {
  opacity: 0;
  pointer-events: none;
}

.nav-buttons {
  padding: 1rem 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* Header - Entfernt da jetzt in Sidebar */

/* Tab Navigation - Jetzt als Sidebar Buttons */
.tab-btn {
  background: none;
  border: none;
  padding: 12px 1rem;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.8);
  transition: all 0.3s ease;
  margin: 2px 8px;
  border-radius: 6px;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  position: relative;
}

.tab-btn:hover {
  color: white;
  background-color: rgba(255, 255, 255, 0.1);
}

.tab-btn.active {
  color: white;
  background-color: rgba(255, 255, 255, 0.2);
}

.tab-icon {
  font-size: 16px;
  flex-shrink: 0;
  transition: transform 0.3s ease;
}

.tab-text {
  transition: opacity 0.3s ease;
}

.sidebar-navigation.collapsed .tab-text {
  opacity: 0;
  pointer-events: none;
}

.sidebar-navigation.collapsed .tab-btn {
  justify-content: unset;
  padding: 12px;
  margin: 2px 4px;
}

.sidebar-navigation.collapsed .tab-icon {
  transform: translateX(0);
}

/* Content Area */
.dashboard-content {
  flex: 1;
  margin-left: 250px;
  background-color: var(--bg-primary);
  min-height: 100vh;
  overflow: hidden;
  transition: margin-left 0.3s ease, background-color 0.3s ease;
}

.dashboard-content.sidebar-collapsed {
  margin-left: 60px;
}

.tab-content {
  display: none;
  height: 100vh;
  overflow: hidden;
}

.tab-content.active {
  display: block;
}

/* Iframe Grid for Dashboard Overview - Dynamisches Layout */
.iframe-grid {
  display: grid;
  height: 100vh;
  gap: 1px;
}

.iframe-container {
  background: var(--bg-secondary);
  overflow: hidden;
  border: 1px solid var(--border-color);
  position: relative;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

/* Ladebalken Styles */
.iframe-loading {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--card-background);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 10;
  border-radius: 8px;
  transition: opacity 0.3s ease;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-color);
  border-top: 3px solid var(--accent-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 15px;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.loading-text {
  color: var(--text-color);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 20px;
  text-align: center;
}

.loading-progress {
  width: 80%;
  height: 4px;
  background: var(--border-color);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}

.loading-progress-bar {
  height: 100%;
  background: var(--accent-color);
  width: 0%;
  transition: width 0.3s ease, background-color 0.3s ease;
  border-radius: 2px;
}

.iframe-container iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* Fullscreen Button */
.fullscreen-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  opacity: 0.8;
  transition: opacity 0.3s ease, transform 0.2s ease;
  backdrop-filter: blur(4px);
}

.fullscreen-btn:hover {
  opacity: 1;
  transform: scale(1.1);
  background: rgba(0, 0, 0, 0.9);
}

.fullscreen-btn:active {
  transform: scale(0.95);
}

/* Fullscreen Modal */
.fullscreen-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: var(--overlay-bg);
  display: flex;
  flex-direction: column;
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.fullscreen-modal.active {
  opacity: 1;
  visibility: visible;
}

.modal-header {
  background: var(--sidebar-bg);
  color: white;
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 8px var(--shadow-light);
}

.modal-header h3 {
  margin: 0;
  font-size: 1.2rem;
}

.close-modal {
  background: none;
  border: none;
  color: white;
  font-size: 20px;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 4px;
  transition: background-color 0.2s ease;
}

.close-modal:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.modal-content {
  flex: 1;
  background: var(--bg-secondary);
  display: flex;
}

.modal-content iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* Snackbar Notifications */
#snackbarContainer {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.snackbar {
  min-width: 220px;
  max-width: 480px;
  padding: 10px 14px;
  border-radius: 6px;
  color: #fff;
  background: #333;
  box-shadow: 0 4px 12px var(--shadow-light);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .2s ease, transform .2s ease;
  pointer-events: auto;
}
.snackbar.show { opacity: 1; transform: translateY(0); }
.snackbar-success { background: #16a34a; }
.snackbar-error { background: #dc2626; }
.snackbar-info { background: #4b5563; }

/* Import Diff Modal */
.import-diff-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: var(--overlay-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2500;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.import-diff-modal.active {
  opacity: 1;
  visibility: visible;
}

.import-diff-content {
  background: var(--bg-secondary);
  border-radius: 8px;
  box-shadow: 0 10px 25px var(--shadow-medium);
  max-width: 700px;
  max-height: 80vh;
  width: 90%;
  display: flex;
  flex-direction: column;
  color: var(--text-primary);
}

.import-diff-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.import-diff-header h3 {
  margin: 0;
  color: var(--text-primary);
}

.close-btn {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 0;
  width: 30px;
  height: 30px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.close-btn:hover {
  background: var(--border-color);
  color: var(--text-primary);
}

.import-diff-body {
  padding: 1rem 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.diff-legend {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.diff-legend span {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.diff-new { color: #16a34a; }
.diff-modified { color: #f59e0b; }
.diff-deleted { color: #dc2626; }
.diff-unchanged { color: var(--text-secondary); }

.diff-section {
  margin-bottom: 1.5rem;
}

.diff-section h4 {
  margin: 0 0 0.5rem 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1rem;
}

.diff-item {
  padding: 0.5rem;
  margin: 0.3rem 0;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.9rem;
}

.diff-item.diff-new {
  background: rgba(22, 163, 74, 0.1);
  border-left: 3px solid #16a34a;
}

.diff-item.diff-modified {
  background: rgba(245, 158, 11, 0.1);
  border-left: 3px solid #f59e0b;
}

.diff-item.diff-deleted {
  background: rgba(220, 38, 38, 0.1);
  border-left: 3px solid #dc2626;
}

.diff-item.diff-unchanged {
  background: var(--bg-primary);
  border-left: 3px solid var(--border-color);
  color: var(--text-secondary);
}

.diff-changes {
  margin-top: 0.3rem;
  margin-left: 1rem;
  font-size: 0.85rem;
}

.diff-change {
  margin: 0.2rem 0;
}

.diff-old {
  background: rgba(220, 38, 38, 0.2);
  padding: 1px 3px;
  border-radius: 2px;
  text-decoration: line-through;
}

.diff-new-value {
  background: rgba(22, 163, 74, 0.2);
  padding: 1px 3px;
  border-radius: 2px;
}

.diff-empty {
  text-align: center;
  color: var(--text-secondary);
  font-style: italic;
  padding: 2rem;
}

.import-diff-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.btn {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background-color 0.2s ease;
}

.btn-primary {
  background: var(--accent-color);
  color: #fff;
}

.btn-primary:hover {
  background: #5b6bcf;
}

.btn-secondary {
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--border-color);
}

/* Navigation Groups */
.nav-group-header {
  display: flex;
  align-items: center;
  padding: 8px 1rem;
  margin: 4px 8px 0 8px;
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.group-icon {
  font-size: 14px;
  margin-right: 6px;
  flex-shrink: 0;
}

.group-text {
  flex: 1;
  transition: opacity 0.3s ease;
}

.sidebar-navigation.collapsed .group-text {
  opacity: 0;
  pointer-events: none;
}

.group-toggle {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 6px;
  border-radius: 3px;
  transition: background-color 0.2s ease;
  flex-shrink: 0;
}

.group-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.sidebar-navigation.collapsed .group-toggle {
  display: none;
}

.nav-group-items {
  transition: max-height 0.3s ease, opacity 0.3s ease;
  overflow: hidden;
}

.nav-group-items.collapsed {
  max-height: 0 !important;
  opacity: 0.3;
}

.nav-group-items.grouped {
  max-height: 500px; /* Fallback für Transition */
}

.tab-btn.grouped-item {
  margin-left: 16px;
  margin-right: 16px;
  position: relative;
}

.tab-btn.grouped-item::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 50%;
  transform: translateY(-50%);
  width: 2px;
  height: 60%;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 1px;
}

.sidebar-navigation.collapsed .tab-btn.grouped-item {
  margin-left: 4px;
  margin-right: 4px;
}

.sidebar-navigation.collapsed .tab-btn.grouped-item::before {
  display: none;
}

/* Dashboard Group Filter */
.dashboard-group-filter {
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
}

.group-filter-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

.group-filter-container label {
  font-size: 0.9rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

#dashboardGroupFilter {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 4px 8px;
  color: var(--text-primary);
  font-size: 0.9rem;
  min-width: 150px;
}

#dashboardGroupFilter:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

/* Health Status Indicators */
.health-status {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  transition: all 0.3s ease;
  opacity: 0.9;
}

.health-indicator {
  display: inline-block;
  font-size: 12px;
  line-height: 1;
}

.health-online {
  color: #16a34a;
  background: #16a34a;
}

.health-offline {
  color: #dc2626;
  background: #dc2626;
}

.health-timeout {
  color: #f59e0b;
  background: #f59e0b;
}

.health-checking {
  color: #6b7280;
  background: #6b7280;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

.sidebar-navigation.collapsed .health-status {
  display: none;
}

/* Dashboard Controls */
.dashboard-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  gap: 16px;
}

.dashboard-group-filter {
  padding: 0;
  background: none;
  border: none;
}

.dashboard-health-summary {
  display: flex;
  align-items: center;
  gap: 8px;
}

.health-summary-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

.health-summary-label {
  font-size: 0.9rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.health-summary-stats {
  display: flex;
  align-items: center;
  gap: 6px;
}

.health-stat {
  display: flex;
  align-items: center;
  font-size: 0.85rem;
  font-weight: 500;
  gap: 2px;
}

.health-stat.health-online {
  color: #16a34a;
}

.health-stat.health-offline {
  color: #dc2626;
}

.health-stat.health-checking {
  color: #6b7280;
}

.health-stat.health-total {
  color: var(--text-secondary);
  margin-left: 4px;
}

.health-stat.health-total::before {
  content: '/';
  margin-right: 2px;
}

.health-refresh-btn {
  background: none;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 4px 6px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 12px;
  transition: all 0.2s ease;
}

.health-refresh-btn:hover {
  background: var(--border-color);
  color: var(--text-primary);
  transform: rotate(180deg);
}

/* Responsive Health Controls */
@media (max-width: 768px) {
  .dashboard-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  
  .health-summary-container {
    justify-content: center;
  }
  
  .health-summary-label {
    display: none;
  }
}

/* Single Iframe for Individual Server Views */
.single-iframe {
  height: 100vh;
  overflow: hidden;
  position: relative;
  background: var(--bg-secondary);
  transition: background-color 0.3s ease;
  cursor: default; /* Kein Pointer-Cursor für einzelne Server */
}

.single-iframe iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* Kein Hover-Effekt für einzelne Server-Tabs */

/* Responsive Design */
@media (max-width: 768px) {
  .sidebar-navigation {
    width: 200px;
  }

  .sidebar-navigation.collapsed {
    width: 50px;
  }

  .dashboard-content {
    margin-left: 200px;
  }

  .dashboard-content.sidebar-collapsed {
    margin-left: 50px;
  }

  .sidebar-header {
    padding: 0.8rem;
  }

  .sidebar-title {
    font-size: 1rem;
  }

  .tab-btn {
    font-size: 12px;
    padding: 10px 0.8rem;
  }

  .sidebar-navigation.collapsed .tab-btn {
    padding: 10px 6px;
  }

  .modal-header {
    padding: 0.8rem 1rem;
  }

  .modal-header h3 {
    font-size: 1rem;
  }
}

@media (max-width: 480px) {
  .sidebar-navigation {
    width: 60px;
  }

  .sidebar-navigation.collapsed {
    width: 45px;
  }

  .sidebar-title {
    display: none;
  }

  .tab-btn {
    justify-content: center;
    padding: 12px 8px;
  }

  .tab-icon {
    font-size: 18px;
  }

  .dashboard-content {
    margin-left: 60px;
  }

  .dashboard-content.sidebar-collapsed {
    margin-left: 45px;
  }

  .modal-header {
    padding: 0.5rem;
  }
}

/* Loading States - Angepasst */
iframe {
  background-color: var(--bg-secondary);
  background-image: linear-gradient(
    45deg,
    transparent 40%,
    rgba(255, 255, 255, 0.1) 50%,
    transparent 60%
  );
  background-size: 100px 100px;
  animation: loading 1.5s infinite;
}

[data-theme="dark"] iframe {
  background-image: linear-gradient(
    45deg,
    transparent 40%,
    rgba(255, 255, 255, 0.05) 50%,
    transparent 60%
  );
}

@keyframes loading {
  0% {
    background-position: -100px 0;
  }
  100% {
    background-position: 100px 0;
  }
}

/* Optimierte iframe Darstellung - Inhalt skalieren */
.iframe-container,
.single-iframe {
  overflow: hidden; /* Verhindert dass skalierte Inhalte überlaufen */
}

.iframe-container iframe,
.single-iframe iframe,
.modal-content iframe {
  border: none;
  display: block;
}

/* Skalierte iframes für Dashboard und einzelne Server */
.iframe-container iframe,
.single-iframe iframe {
  opacity: 1;
  transition: opacity 0.3s;
  transform: scale(0.5);
  transform-origin: 0px 0px;
  width: 200%;
  height: 200%;
  border: none;
  overflow: hidden;
  animation: auto ease 0s 1 normal none running none;
  /* Zusätzliche Browser-spezifische Eigenschaften */
  -webkit-transform: scale(0.5);
  -webkit-transform-origin: 0 0;
  -moz-transform: scale(0.5);
  -moz-transform-origin: 0 0;
  -ms-transform: scale(0.5);
  -ms-transform-origin: 0 0;
}

/* Modal iframe - volle Größe ohne Skalierung */
.modal-content iframe {
  width: 100%;
  height: 100%;
  transform: scale(1);
}

/* Scrollbar entfernt für body */
html,
body {
  overflow: hidden;
  height: 100%;
}

/* Scrollbar Styling für iframes */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--text-secondary);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-primary);
}

/* Close Button für Fullscreen */
.fullscreen-close {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1001;
  background: var(--overlay-bg);
  color: white;
  border: none;
  padding: 12px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transition: all 0.2s ease;
}

.fullscreen-close:hover {
  background: rgba(0, 0, 0, 0.9);
  transform: scale(1.05);
}

/* Smooth Transitions */
* {
  transition: color 0.3s ease, background-color 0.3s ease,
    border-color 0.3s ease;
}

/* --------------------------------------------- */
/* Verwaltung / Admin Panel Styles               */
/* --------------------------------------------- */

#admin {
  height: 100vh;
  overflow: auto;
  background: var(--bg-primary);
  padding: 16px;
}

.admin-panel { /* Wrapper falls benötigt */
  display: block;
  min-height: 100%;
}

#admin h2 {
  font-size: 1.35rem;
  margin: 0 0 12px;
  font-weight: 600;
  color: var(--text-primary);
}

#admin-header-actions { display:flex; gap:8px; }

.admin-toolbar {
  display:flex;
  gap:12px;
  flex-wrap:wrap;
  align-items:center;
  margin: 4px 0 14px;
}

.admin-toolbar input[type="text"] {
  flex:1 1 280px;
  max-width:420px;
  padding:6px 10px;
  border:1px solid var(--border-color);
  border-radius:6px;
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.admin-toolbar input[type="text"]:focus { border-color: var(--accent-color); outline:none; }

.admin-toolbar .toolbar-group { display:flex; gap:8px; align-items:center; }

#unsavedBadge { 
  display:inline-flex; align-items:center; gap:4px; 
  background: var(--accent-color); color:#fff; 
  padding:2px 8px; border-radius:12px; font-size:11px; font-weight:500; 
  letter-spacing:.3px; box-shadow:0 1px 2px var(--shadow-light);
}

body[data-unsaved="true"] #unsavedBadge { animation: pulseUnsaved 1.4s ease-in-out infinite; }
@keyframes pulseUnsaved { 0%,100% { filter:brightness(1); } 50% { filter:brightness(1.25); } }

#admin #adminInfoBar {
  background: var(--bg-secondary);
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 13px;
}

#admin table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 2px 6px var(--shadow-light);
  overflow: hidden;
  margin-top: 10px;
  font-size: 13px;
}

#admin table thead tr {
  background: var(--sidebar-bg);
  color: #fff;
}

#admin table th,
#admin table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

#admin table tbody tr:hover {
  background: rgba(0,0,0,0.03);
}
[data-theme="dark"] #admin table tbody tr:hover {
  background: rgba(255,255,255,0.05);
}

#admin table tbody tr.row-dirty { background: color-mix(in srgb, var(--accent-color) 12%, transparent); }
[data-theme="dark"] #admin table tbody tr.row-dirty { background: color-mix(in srgb, var(--accent-color) 22%, transparent); }

/* Drag & Drop States */
#admin table tbody tr[draggable="true"] { cursor: grab; }
#admin table tbody tr[draggable="true"]:active { cursor: grabbing; }
#admin table tbody tr.drag-origin { opacity: .45; }
#admin table tbody tr.drag-over { outline: 2px dashed var(--accent-color); outline-offset: -2px; }

#admin table tbody tr.row-duplicate { background: rgba(255,0,0,0.08); }
#admin table tbody tr.row-duplicate td:first-child { position: relative; }
#admin table tbody tr.row-duplicate td:first-child::after { content: 'Duplikat'; position: absolute; top:2px; left:2px; font-size:10px; background:#c53030; color:#fff; padding:1px 4px; border-radius:3px; }
#admin table tbody input.invalid { border-color:#dc2626 !important; background: rgba(220,38,38,0.15); }

/* Drag Handle */
#admin .drag-cell { width:26px; text-align:center; cursor:grab; }
#admin .drag-handle { cursor:grab; user-select:none; display:inline-block; padding:2px 4px; color:var(--text-secondary); }
#admin tr.drag-origin .drag-handle { opacity:0.4; }
#admin .drag-handle:active { cursor:grabbing; }
#admin tr:focus-within { outline: 2px solid var(--accent-color); outline-offset: 0; }

/* Auto-Save Toggle */
#admin .autosave-toggle { font-size:12px; display:inline-flex; align-items:center; gap:4px; background:var(--bg-secondary); padding:4px 8px; border-radius:6px; border:1px solid var(--border-color); cursor:pointer; }
#admin .autosave-toggle input { margin:0; }
#admin .autosave-toggle:hover { background:var(--bg-hover); }

.nav-buttons .tab-btn.drag-origin { opacity:.5; }
.nav-buttons .tab-btn.drag-over { box-shadow: 0 0 0 2px var(--accent-color) inset; }

#admin table input[type="text"],
#admin table input[type="number"],
#admin table input:not([type]),
#admin table input[type="url"],
#admin table input {
  width: 100%;
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 4px 6px;
  font: inherit;
  outline: none;
  transition: border-color .2s ease, background-color .2s ease, box-shadow .2s ease;
}

#admin table input:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent-color) 40%, transparent);
}

#admin table input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

#admin button {
  font: inherit;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-primary);
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  line-height: 1.2;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: background-color .2s ease, color .2s ease, border-color .2s ease;
}

#admin button:hover {
  background: var(--accent-color);
  color: #fff;
  border-color: var(--accent-color);
}

#admin #btnSaveConfig {
  background: var(--accent-color);
  color: #fff;
  border: 1px solid var(--accent-color);
  font-weight: 500;
}

#admin #btnSaveConfig:hover {
  filter: brightness(1.1);
}

#admin #btnAddServer {
  background: var(--bg-secondary);
}

#admin #btnAddServer:hover {
  background: var(--accent-color);
  color: #fff;
}

#admin table td:last-child button[data-action="delete"] {
  background: transparent;
  color: #e11d48;
  border: 1px solid #e11d48;
}

#admin table td:last-child button[data-action="delete"]:hover {
  background: #e11d48;
  color: #fff;
}

/* Icon Buttons in Aktion-Spalte */
#admin table td button[data-action] { min-width:32px; padding:4px 6px; }
#admin table td button[data-action="up"],
#admin table td button[data-action="down"] { font-size:14px; }

/* Key-Spalte monospace */
#admin table td:first-child input[data-field="key"] { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace; font-size:12px; }

/* Horizontal Scroll auf sehr kleinen Displays */
@media (max-width: 860px) {
  #admin table { display:block; overflow:auto; white-space:nowrap; }
  #admin table thead, #admin table tbody, #admin table tr { display:table; width:100%; table-layout:fixed; }
}

/* Sticky Kopfzeile beim Scrollen */
#admin table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
}

/* Sanfter Scroll für Admin */
#admin {
  scroll-behavior: smooth;
}

/* Kleinere Buttons im Tabellenkopf */
#admin table td button {
  min-width: 32px;
  justify-content: center;
}

/* Info-Bar bei ungespeicherten Änderungen hervorheben */
body[data-unsaved="true"] #admin #adminInfoBar {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent-color) 35%, transparent);
}

