/* Admin CSS - Phase 5.3.1 */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f0f2f5;
  color: #333;
  min-height: 100vh;
}

/* ============================================================
   LAYOUT: Sidebar + Content
   ============================================================ */

.admin-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.admin-sidebar {
  width: 260px;
  background: #1a237e;
  color: white;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform 0.3s;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h1 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 4px;
}

.sidebar-header .subtitle {
  font-size: 12px;
  opacity: 0.6;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.nav-section {
  padding: 8px 20px 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  opacity: 0.4;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  border-left: 3px solid transparent;
}

.nav-item:hover {
  background: rgba(255,255,255,0.08);
  color: white;
}

.nav-item.active {
  background: rgba(255,255,255,0.12);
  color: white;
  border-left-color: #64b5f6;
}

.nav-item .nav-icon {
  width: 20px;
  text-align: center;
  font-size: 16px;
}

.nav-item .nav-badge {
  margin-left: auto;
  background: #f44336;
  color: white;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 600;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 12px;
}

.sidebar-footer .user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.sidebar-footer .user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #3949ab;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
}

.sidebar-footer .user-name {
  font-weight: 500;
}

.sidebar-footer .user-role {
  font-size: 11px;
  opacity: 0.6;
}

.sidebar-footer .sidebar-links {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

.sidebar-footer .sidebar-links a {
  color: rgba(255,255,255,0.5);
  text-decoration: none;
  font-size: 12px;
}

.sidebar-footer .sidebar-links a:hover {
  color: white;
}

/* Content Area */
.admin-content {
  flex: 1;
  margin-left: 260px;
  padding: 24px 32px;
  min-height: 100vh;
}

/* ============================================================
   HEADER
   ============================================================ */

.content-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 2px solid #e0e0e0;
}

.content-header h2 {
  font-size: 22px;
  color: #1a237e;
  display: flex;
  align-items: center;
  gap: 10px;
}

.content-header .header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  font-family: inherit;
}

.btn-primary { background: #1976d2; color: white; }
.btn-primary:hover { background: #1565c0; }
.btn-success { background: #2e7d32; color: white; }
.btn-success:hover { background: #1b5e20; }
.btn-danger { background: #c62828; color: white; }
.btn-danger:hover { background: #b71c1c; }
.btn-secondary { background: #f5f5f5; color: #333; }
.btn-secondary:hover { background: #e0e0e0; }
.btn-small { padding: 4px 10px; font-size: 12px; }
.btn-icon { padding: 6px 8px; min-width: 32px; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ============================================================
   CARDS & PANELS
   ============================================================ */

.card {
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  overflow: hidden;
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #f0f0f0;
  background: #fafbfc;
}

.card-header h3 {
  font-size: 15px;
  font-weight: 600;
  color: #333;
}

.card-body {
  padding: 20px;
}

/* Module panels */
.module-panel {
  display: none;
}

.module-panel.active {
  display: block;
}

/* ============================================================
   TABLES
   ============================================================ */

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid #f0f0f0;
  font-size: 13px;
}

.data-table th {
  background: #fafbfc;
  font-weight: 600;
  color: #555;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.data-table tr:hover {
  background: #f9f9f9;
}

.data-table .actions {
  white-space: nowrap;
}

.data-table .actions .btn {
  margin-right: 4px;
}

/* ============================================================
   BADGES
   ============================================================ */

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-success { background: #e8f5e9; color: #2e7d32; }
.badge-warning { background: #fff3e0; color: #e65100; }
.badge-danger { background: #ffebee; color: #c62828; }
.badge-info { background: #e3f2fd; color: #1565c0; }
.badge-neutral { background: #f5f5f5; color: #666; }

/* ============================================================
   FORMS
   ============================================================ */

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  font-size: 13px;
  color: #555;
}

.form-group label .required {
  color: #c62828;
}

.form-control {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s;
}

.form-control:focus {
  outline: none;
  border-color: #1976d2;
}

select.form-control {
  appearance: auto;
}

textarea.form-control {
  min-height: 100px;
  resize: vertical;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-inline {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.form-inline .form-group {
  flex: 1;
  margin-bottom: 0;
}

/* ============================================================
   KPI GRID (fuer System-Status)
   ============================================================ */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform 0.2s;
}

.kpi-card:hover {
  transform: translateY(-2px);
}

.kpi-icon {
  font-size: 28px;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  flex-shrink: 0;
}

.kpi-icon.blue { background: #e3f2fd; }
.kpi-icon.green { background: #e8f5e9; }
.kpi-icon.orange { background: #fff3e0; }
.kpi-icon.red { background: #ffebee; }
.kpi-icon.purple { background: #f3e5f5; }

.kpi-value {
  font-size: 24px;
  font-weight: 700;
  color: #333;
  line-height: 1;
}

.kpi-label {
  font-size: 12px;
  color: #999;
  margin-top: 4px;
}

/* ============================================================
   SERVICE STATUS GRID
   ============================================================ */

.service-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.service-card {
  background: white;
  border-radius: 12px;
  padding: 16px 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  display: flex;
  align-items: center;
  gap: 14px;
}

.service-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.service-dot.ok { background: #4caf50; }
.service-dot.error { background: #f44336; }
.service-dot.unavailable { background: #9e9e9e; }
.service-dot.degraded { background: #ff9800; }

.service-info {
  flex: 1;
}

.service-name {
  font-size: 14px;
  font-weight: 600;
  color: #333;
}

.service-detail {
  font-size: 12px;
  color: #999;
  margin-top: 2px;
}

/* ============================================================
   FILTER BAR
   ============================================================ */

.filter-bar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.filter-bar .form-control {
  width: auto;
  min-width: 150px;
}

.filter-bar .search-input {
  flex: 1;
  min-width: 200px;
}

/* ============================================================
   EMPTY STATE
   ============================================================ */

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #999;
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.empty-state-text {
  font-size: 14px;
}

/* ============================================================
   LOADING
   ============================================================ */

.loading {
  text-align: center;
  padding: 40px;
  color: #999;
  font-size: 14px;
}

.spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid #e0e0e0;
  border-top-color: #1976d2;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 8px;
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================================
   MESSAGES / TOAST
   ============================================================ */

.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 14px 20px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 1000;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  transition: all 0.3s;
  max-width: 400px;
  display: none;
}

.toast.show { display: block; }
.toast.success { background: #2e7d32; color: white; }
.toast.error { background: #c62828; color: white; }
.toast.info { background: #1976d2; color: white; }

/* ============================================================
   MODAL
   ============================================================ */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
}

.modal-overlay.show {
  display: flex;
}

.modal {
  background: white;
  border-radius: 12px;
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid #f0f0f0;
}

.modal-header h3 {
  font-size: 18px;
  color: #333;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #999;
  padding: 0;
  line-height: 1;
}

.modal-close:hover { color: #333; }

.modal-body {
  padding: 24px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid #f0f0f0;
}

/* ============================================================
   TAGS (fuer Synonyme)
   ============================================================ */

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  background: #e3f2fd;
  color: #1565c0;
  border-radius: 12px;
  font-size: 12px;
}

.tag .tag-remove {
  cursor: pointer;
  font-size: 14px;
  opacity: 0.6;
  background: none;
  border: none;
  color: inherit;
  padding: 0;
  line-height: 1;
}

.tag .tag-remove:hover { opacity: 1; }

/* ============================================================
   CONDITION BUILDER (Rule-Editor)
   ============================================================ */

.condition-builder {
  background: #f7f8fa;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}

.condition-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.condition-row .form-control {
  flex: 1;
}

.condition-row .operator-select {
  width: 120px;
  flex: none;
}

.condition-row .value-input {
  width: 150px;
  flex: none;
}

/* ============================================================
   PAGINATION
   ============================================================ */

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 20px;
  font-size: 13px;
}

.pagination .page-info {
  color: #999;
}

/* ============================================================
   AUDIT LOG SPECIFIC
   ============================================================ */

.audit-detail {
  font-family: 'Courier New', monospace;
  font-size: 12px;
  background: #f7f8fa;
  padding: 8px 12px;
  border-radius: 6px;
  max-height: 200px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

.mobile-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 101;
  background: #1a237e;
  color: white;
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 18px;
  cursor: pointer;
}

@media (max-width: 1024px) {
  .admin-sidebar {
    transform: translateX(-100%);
  }

  .admin-sidebar.open {
    transform: translateX(0);
  }

  .admin-content {
    margin-left: 0;
    padding: 16px;
    padding-top: 56px;
  }

  .mobile-toggle {
    display: block;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .service-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-bar .form-control {
    width: 100%;
  }

  .content-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .data-table {
    font-size: 12px;
  }

  .data-table th,
  .data-table td {
    padding: 8px;
  }
}

/* ============================================================
   ONBOARDING WIZARD - Phase 5.3.2
   ============================================================ */

.wizard-progress {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 24px;
  padding: 20px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.wizard-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  position: relative;
}

.wizard-step .step-num {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  background: #e0e0e0;
  color: #999;
  transition: all 0.3s;
}

.wizard-step.active .step-num {
  background: #1976d2;
  color: white;
  box-shadow: 0 2px 8px rgba(25, 118, 210, 0.4);
}

.wizard-step.completed .step-num {
  background: #4caf50;
  color: white;
}

.wizard-step .step-label {
  font-size: 11px;
  color: #999;
  white-space: nowrap;
}

.wizard-step.active .step-label {
  color: #1976d2;
  font-weight: 600;
}

.wizard-step.completed .step-label {
  color: #4caf50;
}

.wizard-connector {
  width: 40px;
  height: 2px;
  background: #e0e0e0;
  margin: 0 4px;
  margin-bottom: 20px;
}

.wizard-panel {
  display: none;
}

.wizard-panel.active {
  display: block;
  animation: wizardFadeIn 0.3s ease;
}

@keyframes wizardFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.wizard-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid #f0f0f0;
}

.wizard-actions > div {
  display: flex;
  gap: 8px;
}

/* Setup Status Items */
.setup-status {
  margin: 16px 0;
}

.setup-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  font-size: 14px;
  border-bottom: 1px solid #f5f5f5;
}

.setup-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}

.setup-dot.pending { background: #e0e0e0; }
.setup-dot.ok { background: #4caf50; }
.setup-dot.error { background: #f44336; }
.setup-dot.in-progress {
  background: #1976d2;
  animation: pulse 1s ease infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Doc/User Item List */
.doc-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: #f7f8fa;
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 13px;
}

/* Info Box */
.info-box {
  background: #e3f2fd;
  border-radius: 8px;
  padding: 16px;
  margin: 16px 0;
  font-size: 14px;
}

/* Progress Bar */
.progress-bar-container {
  background: #e0e0e0;
  border-radius: 4px;
  height: 6px;
  width: 100px;
  display: inline-block;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: #4caf50;
  border-radius: 4px;
  transition: width 0.3s;
}

@media (max-width: 768px) {
  .wizard-progress {
    flex-wrap: wrap;
    gap: 8px;
  }

  .wizard-connector {
    width: 20px;
  }

  .wizard-step .step-label {
    font-size: 10px;
  }
}
