/* === CI Color Variables === */
:root {
  --ci-orange: #FF6B35;
  --ci-orange-hover: #e55a2b;
  --ci-orange-light: rgba(255, 107, 53, 0.1);
  --ci-blue: #3498DB;
  --ci-blue-hover: #2980B9;
  --ci-blue-light: rgba(52, 152, 219, 0.1);
  --ci-gray: #34495E;
  --ci-gray-light: #3d566e;
  --ci-gray-lighter: #4a6274;
  --ci-bg: #F8F9FA;

  /* Bootstrap Primary Override */
  --bs-primary: #3498DB;
  --bs-primary-rgb: 52, 152, 219;
  --bs-link-color: #3498DB;
  --bs-link-color-rgb: 52, 152, 219;
  --bs-link-hover-color: #2980B9;
  --bs-link-hover-color-rgb: 41, 128, 185;
}

/* Bootstrap Component Overrides */
.btn-primary {
  --bs-btn-bg: #3498DB;
  --bs-btn-border-color: #3498DB;
  --bs-btn-hover-bg: #2980B9;
  --bs-btn-hover-border-color: #2980B9;
  --bs-btn-active-bg: #2471a3;
  --bs-btn-active-border-color: #2471a3;
  --bs-btn-disabled-bg: #3498DB;
  --bs-btn-disabled-border-color: #3498DB;
}

.btn-outline-primary {
  --bs-btn-color: #3498DB;
  --bs-btn-border-color: #3498DB;
  --bs-btn-hover-bg: #3498DB;
  --bs-btn-hover-border-color: #3498DB;
  --bs-btn-active-bg: #3498DB;
  --bs-btn-active-border-color: #3498DB;
}

/* CTA / Accent Buttons (Warning-Klasse als Orange-Akzent) */
.btn-warning {
  --bs-btn-bg: #FF6B35;
  --bs-btn-border-color: #FF6B35;
  --bs-btn-color: #fff;
  --bs-btn-hover-bg: #e55a2b;
  --bs-btn-hover-border-color: #e55a2b;
  --bs-btn-hover-color: #fff;
  --bs-btn-active-bg: #cc4f25;
  --bs-btn-active-border-color: #cc4f25;
  --bs-btn-active-color: #fff;
}

.btn-outline-warning {
  --bs-btn-color: #FF6B35;
  --bs-btn-border-color: #FF6B35;
  --bs-btn-hover-bg: #FF6B35;
  --bs-btn-hover-border-color: #FF6B35;
  --bs-btn-hover-color: #fff;
  --bs-btn-active-bg: #FF6B35;
  --bs-btn-active-border-color: #FF6B35;
  --bs-btn-active-color: #fff;
}

.bg-primary {
  background-color: #3498DB !important;
}

.bg-warning {
  background-color: #FF6B35 !important;
  color: #fff !important;
}

.text-primary {
  color: #3498DB !important;
}

.text-warning {
  color: #FF6B35 !important;
}

.border-primary {
  border-color: #3498DB !important;
}

a {
  color: var(--ci-blue);
}

a:hover {
  color: var(--ci-blue-hover);
}

.page-item.active .page-link {
  background-color: #3498DB;
  border-color: #3498DB;
}

.page-link {
  color: #3498DB;
}

.page-link:hover {
  color: #2980B9;
}

.form-control:focus, .form-select:focus {
  border-color: #3498DB;
  box-shadow: 0 0 0 0.25rem rgba(52, 152, 219, 0.25);
}

.form-check-input:checked {
  background-color: #3498DB;
  border-color: #3498DB;
}

/* Auto-Highlighting Styles */
.search-highlight {
  background: linear-gradient(120deg, #fff3cd 0%, #ffeaa7 100%);
  color: #856404;
  padding: 1px 3px;
  border-radius: 3px;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(255, 193, 7, 0.3);
  transition: all 0.2s ease;
  border: 1px solid rgba(255, 193, 7, 0.4);
}

.search-highlight:hover {
  background: #ffd32a;
  transform: scale(1.02);
}

/* Animierte Einblendung */
@keyframes highlight-in {
  from {
    background-color: #ff6b6b;
    transform: scale(1.1);
  }
  to {
    background-color: #fff3cd;
    transform: scale(1);
  }
}

.search-highlight {
  animation: highlight-in 0.6s ease-out;
}

/* Wareneingang Tabellen-Optimierung */
#positionsTable {
  font-size: 0.875rem;
}

#positionsTable th {
  padding: 0.5rem 0.25rem;
  vertical-align: middle;
  font-size: 0.8rem;
  font-weight: 600;
}

#positionsTable td {
  padding: 0.5rem 0.25rem;
  vertical-align: middle;
}

#positionsTable .form-control-sm {
  font-size: 0.8rem;
  padding: 0.25rem 0.5rem;
}

#positionsTable code {
  font-size: 0.75rem;
  padding: 0.125rem 0.25rem;
}

#positionsTable .badge {
  font-size: 0.75rem;
}

/* Container-Box Styling */
.main-container {
  max-width: 1400px;
  margin: 0 auto;
  background: #ffffff;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
  border-radius: 12px;
  min-height: calc(100vh - 40px);
  margin-top: 20px;
  margin-bottom: 20px;
  overflow: visible; /* Wichtig fuer Dropdown */
  position: relative;
}

.main-content {
  padding: 2rem;
  position: relative;
}

/* Header mit niedrigerem z-index */
.app-header {
  background: linear-gradient(135deg, var(--ci-gray) 0%, var(--ci-gray-light) 100%);
  color: white;
  padding: 1.5rem 2rem;
  border-radius: 12px 12px 0 0;
  position: relative;
  overflow: visible; /* Wichtig fuer Dropdown */
  z-index: 10; /* Niedriger als Dropdown */
}

.app-header::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 200px;
  height: 100%;
  background: linear-gradient(45deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0.05) 100%);
  transform: skewX(-15deg);
  transform-origin: top;
  z-index: 1;
}

.app-header .header-content {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.app-header .logo-section {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.app-header .logo-icon {
  background: none;
  border-radius: 0;
  padding: 0;
  width: 100px;
  height: 100px;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
  box-shadow: none;
  transition: transform 0.3s ease;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.3));
}

.app-header .logo-icon:hover {
  transform: scale(1.08) rotate(-3deg);
  box-shadow: none;
}

.app-header .logo-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Footer Logo */
.footer-logo {
  height: 20px;
  width: auto;
  opacity: 0.6;
  transition: opacity 0.2s ease;
}

.footer-logo:hover {
  opacity: 1;
}

/* Login Page Logo */
.login-logo {
  width: 260px;
  height: auto;
  filter: drop-shadow(0 6px 20px rgba(0,0,0,0.18));
}

.app-header .app-title {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  text-shadow: 0 2px 4px rgba(0,0,0,0.3);
  line-height: 1.2;
}

.app-header .app-subtitle {
  margin: 0;
  font-size: 1rem;
  opacity: 0.9;
  font-weight: 400;
  margin-top: 0.25rem;
}

.app-header .user-section {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: rgba(255,255,255,0.15);
  padding: 0.75rem 1.25rem;
  border-radius: 30px;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.2);
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  user-select: none;
  z-index: 11; /* Hoeher als Header */
}

.app-header .user-section:hover {
  background: rgba(255,255,255,0.25);
  transform: translateY(-1px);
}

/* User Dropdown Menu */
.user-dropdown-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  background: white;
  border-radius: 12px;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(0, 0, 0, 0.08);
  min-width: 200px;
  z-index: 1040 !important; /* Ueber Content, unter Bootstrap-Modals (1050+) */
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px) scale(0.95);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.user-dropdown-menu.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.user-dropdown-menu::before {
  content: '';
  position: absolute;
  top: -8px;
  right: 20px;
  width: 16px;
  height: 16px;
  background: white;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-bottom: none;
  border-right: none;
  transform: rotate(45deg);
}

.user-dropdown-header {
  padding: 1rem;
  border-bottom: 1px solid #f0f0f0;
  background: #f8f9fa;
}

.user-dropdown-header .user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-dropdown-header .user-avatar-large {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--ci-blue) 0%, var(--ci-blue-hover) 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  color: white;
  font-size: 1rem;
}

.user-dropdown-header .user-details h6 {
  margin: 0;
  font-weight: 600;
  color: #333;
  font-size: 0.95rem;
}

.user-dropdown-header .user-details p {
  margin: 0;
  font-size: 0.8rem;
  color: #666;
}

.user-dropdown-menu a {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  color: var(--ci-gray);
  text-decoration: none;
  transition: all 0.2s ease;
  font-size: 0.9rem;
}

.user-dropdown-menu a:hover {
  background: #f8f9fa;
  color: #dc3545;
}

.user-dropdown-menu a i {
  margin-right: 0.75rem;
  width: 18px;
  font-size: 1rem;
}

.user-dropdown-menu a.dropdown-item-link:hover {
  background: #f0f4ff;
  color: var(--ci-blue);
}

.user-dropdown-menu a.logout-link {
  color: #dc3545;
  border-top: 1px solid #f0f0f0;
}

.user-dropdown-menu a.logout-link:hover {
  background: #fff5f5;
  color: #c82333;
}

.app-header .user-avatar {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--ci-blue) 0%, var(--ci-blue-hover) 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 0.95rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.app-header .user-name {
  font-weight: 600;
  font-size: 1rem;
}

.nav-tabs {
  margin: 0;
  padding: 1.5rem 2rem 0 2rem;
  background: #f8f9fa;
  border-bottom: 2px solid #dee2e6;
  border-radius: 12px 12px 0 0;
}

body {
  background: #f8f9fa;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.nav-tabs .nav-link.active {
  background: #fff;
  border-color: #dee2e6 #dee2e6 #fff;
}

.tab-content {
  background: #fff;
  border-radius: 0 0 12px 12px;
  padding: 1.5em;
}

.form-control, .btn {
  border-radius: 8px !important;
}

/* Verbesserte Tabellen-Styles */
.table thead th {
  background: #f4f6fa;
  font-weight: 600;
  border-bottom: 2px solid #dee2e6;
}

/* FIX: Sortier-Links in dunklen Table-Headers optimal lesbar machen */
.table-dark {
  --bs-table-bg: #212529;
}

.table-dark th {
  background-color: var(--ci-gray) !important;
  border-color: var(--ci-gray-lighter) !important;
  color: #fff !important;
  font-weight: 600;
  padding: 12px 8px;
}

.table-dark th a {
  color: #ffffff !important;
  text-decoration: none !important;
  display: inline-flex;
  align-items: center;
  font-weight: 600;
  transition: all 0.2s ease;
}

.table-dark th a:hover {
  color: #e3f2fd !important;
  text-decoration: none !important;
  text-shadow: 0 0 3px rgba(255,255,255,0.3);
}

.table-dark th a:focus {
  color: #ffffff !important;
  outline: 2px solid var(--ci-blue);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Sortier-Icons hervorheben */
.table-dark th a i.bi-chevron-up,
.table-dark th a i.bi-chevron-down {
  color: var(--ci-blue) !important;
  font-size: 0.875rem;
  margin-left: 4px;
  font-weight: bold;
}

/* Icons in Tabellen-Headern */
.table-dark th i.bi {
  color: #adb5bd !important;
  margin-right: 4px;
}

/* Hover-Effekte fuer ganze Tabellenzeilen */
.table-hover tbody tr:hover {
  background-color: var(--ci-blue-light) !important;
}

/* Code-Bloecke in Tabellen verbessern */
code {
  background-color: #f8f9fa !important;
  color: var(--ci-blue) !important;
  border: 1px solid #e9ecef;
  border-radius: 4px;
  font-size: 0.875em;
  font-weight: 500;
}

/* Badges verbessern */
.badge {
  font-weight: 500;
  letter-spacing: 0.025em;
}

/* === Sortable/Filterable Table Styles === */
.th-sortable {
  cursor: pointer !important;
  user-select: none;
}

.th-sortable:hover {
  background-color: rgba(0, 0, 0, 0.15) !important;
}

.sort-indicator {
  display: inline-block;
  margin-left: 4px;
  opacity: 0.4;
  font-size: 0.75rem;
}

.sort-indicator.active {
  opacity: 1;
  color: var(--ci-blue) !important;
}

.table-no-results-row td {
  background: #fff3cd !important;
}

/* Filter-Buttons im Header einzeilig halten */
[data-table-filterable] thead th {
  white-space: nowrap;
}
[data-table-filterable] thead th > a.d-flex {
  display: inline-flex !important;
}

/* Excel-style Filter Button */
.col-filter-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  padding: 0 4px;
  font-size: 0.8rem;
  margin-left: 4px;
  vertical-align: middle;
  transition: color 0.2s;
}

.col-filter-btn:hover {
  color: #fff;
}

.col-filter-btn.active {
  color: #ffc107 !important;
}

/* Table-Responsive: overflow sichtbar wenn Filter offen */
.table-responsive.filter-open {
  overflow: visible !important;
}

.card:has(.table-responsive.filter-open) {
  overflow: visible !important;
}

.card-body:has(.table-responsive.filter-open) {
  overflow: visible !important;
}

/* Excel-style Filter Dropdown */
.col-filter-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 220px;
  max-width: 320px;
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  z-index: 1030;
  display: none;
  font-weight: 400;
  color: #212529;
}

.col-filter-dropdown.show {
  display: block;
}

.col-filter-dropdown .filter-search {
  width: 100%;
  border: none;
  border-bottom: 1px solid #dee2e6;
  padding: 8px 12px;
  font-size: 0.8rem;
  outline: none;
  border-radius: 8px 8px 0 0;
}

.col-filter-dropdown .filter-search:focus {
  box-shadow: inset 0 -2px 0 var(--ci-blue);
}

.col-filter-dropdown .filter-actions {
  display: flex;
  gap: 8px;
  padding: 6px 12px;
  border-bottom: 1px solid #f0f0f0;
  background: #f8f9fa;
}

.col-filter-dropdown .filter-actions a {
  font-size: 0.8rem;
  font-weight: 600;
  color: #fff;
  text-decoration: none;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 4px;
  background: var(--ci-blue);
}

.col-filter-dropdown .filter-actions a:hover {
  background: var(--ci-blue-hover);
  color: #fff;
  text-decoration: none;
}

.col-filter-dropdown .filter-list {
  max-height: 220px;
  overflow-y: auto;
  padding: 4px 0;
}

.col-filter-dropdown .filter-list label {
  display: flex;
  align-items: center;
  padding: 4px 12px;
  margin: 0;
  font-size: 0.8rem;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.1s;
}

.col-filter-dropdown .filter-list label:hover {
  background: #e9ecef;
}

.col-filter-dropdown .filter-list label input {
  margin-right: 8px;
  flex-shrink: 0;
}

.col-filter-dropdown .filter-list .filter-item-hidden {
  display: none;
}

.col-filter-dropdown .filter-apply {
  display: block;
  width: calc(100% - 16px);
  margin: 8px;
  padding: 6px;
  font-size: 0.8rem;
  border-radius: 6px;
}

/* Breadcrumbs Styling */
.breadcrumb-container {
  background: #f8f9fa;
  padding: 0.75rem 2rem;
  border-bottom: 1px solid #dee2e6;
}

.breadcrumb {
  margin: 0;
  padding: 0;
  background: transparent;
}

.breadcrumb-item + .breadcrumb-item::before {
  content: "\203A";
  color: #6c757d;
  font-size: 1.2rem;
}

.breadcrumb-item a {
  color: var(--ci-blue);
  text-decoration: none;
  transition: color 0.2s;
}

.breadcrumb-item a:hover {
  color: var(--ci-blue-hover);
  text-decoration: underline;
}

.breadcrumb-item.active {
  color: #6c757d;
  font-weight: 500;
}

/* Loading Spinner Overlay */
#globalLoadingSpinner {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1045; /* Ueber Content, unter Bootstrap-Modals (1050+) */
  backdrop-filter: blur(3px);
}

#globalLoadingSpinner.show {
  display: flex;
}

.spinner-content {
  background: white;
  padding: 2rem;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  text-align: center;
}

.spinner-border-custom {
  width: 3rem;
  height: 3rem;
  border: 0.3rem solid #e9ecef;
  border-top-color: var(--ci-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Status Timeline */
.status-timeline {
  display: flex;
  justify-content: space-between;
  position: relative;
  padding: 2rem 0;
}

.status-timeline::before {
  content: '';
  position: absolute;
  top: 45px;
  left: 10%;
  right: 10%;
  height: 3px;
  background: #e9ecef;
  z-index: 0;
}

.timeline-item {
  flex: 1;
  text-align: center;
  position: relative;
  z-index: 1;
}

.timeline-marker {
  width: 50px;
  height: 50px;
  background: #e9ecef;
  border: 3px solid #e9ecef;
  border-radius: 50%;
  margin: 0 auto 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  color: #6c757d;
  transition: all 0.3s ease;
  position: relative;
  z-index: 2;
}

.timeline-item.completed .timeline-marker {
  background: var(--ci-blue);
  border-color: var(--ci-blue);
  color: white;
  box-shadow: 0 4px 8px rgba(52, 152, 219, 0.3);
}

.timeline-item.completed .timeline-marker i {
  animation: checkmark 0.5s ease;
}

@keyframes checkmark {
  0% { transform: scale(0); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

.timeline-content h6 {
  font-weight: 600;
  color: #6c757d;
}

.timeline-item.completed .timeline-content h6 {
  color: var(--ci-blue);
}

/* Buttons in Tabellen */
.btn-sm {
  font-size: 0.8125rem;
  padding: 0.375rem 0.75rem;
}

/* Karten-Styles */
.card {
  border: none;
  box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
  border-radius: 12px;
}

.card-header {
  background-color: #f8f9fa;
  border-bottom: 1px solid #dee2e6;
  font-weight: 600;
  border-radius: 12px 12px 0 0 !important;
}

/* Alert-Verbesserungen */
.alert {
  border: none;
  border-radius: 8px;
  border-left: 4px solid;
}

.alert-success { border-left-color: #198754; }
.alert-danger { border-left-color: #dc3545; }
.alert-warning { border-left-color: #FF6B35; }
.alert-info { border-left-color: #0dcaf0; }

/* Navigation verbesserungen */
.nav-tabs {
  border-bottom: 2px solid #dee2e6;
}

.nav-tabs .nav-link {
  border-radius: 8px 8px 0 0;
  font-weight: 500;
  transition: all 0.2s ease;
}

.nav-tabs .nav-link:hover {
  border-color: #e9ecef #e9ecef #dee2e6;
  background-color: #f8f9fa;
}

/* Empty State Verbesserungen */
.display-4 {
  opacity: 0.5;
}

/* Input Groups */
.input-group-text {
  background-color: #f8f9fa;
  border-color: #dee2e6;
  color: #6c757d;
}

/* Responsive Anpassungen */
@media (max-width: 1450px) {
  .main-container {
    margin: 10px;
    max-width: calc(100vw - 20px);
  }
}
