/* ============================================================
   EGR Admin Panel — Enterprise Design System
   ============================================================ */

/* --- 1. CSS Custom Properties ----------------------------- */
:root {
  --egr-primary:        #1e3a5f;
  --egr-primary-hover:  #162d4a;
  --egr-accent:         #2563eb;
  --egr-accent-hover:   #1d4ed8;
  --egr-surface:        #f8fafc;
  --egr-surface-card:   #ffffff;
  --egr-border:         #e2e8f0;
  --egr-text:           #1e293b;
  --egr-text-muted:     #64748b;
  --egr-success:        #16a34a;
  --egr-warning:        #d97706;
  --egr-danger:         #dc2626;

  /* Bootstrap Override */
  --bs-primary:         #2563eb;
  --bs-primary-rgb:     37, 99, 235;
  --bs-body-font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --bs-body-color:      #1e293b;
  --bs-body-bg:         #f8fafc;
  --bs-border-color:    #e2e8f0;
  --bs-border-radius:   0.5rem;
}

/* --- 2. Base ---------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

body {
  background-color: var(--egr-surface);
  color: var(--egr-text);
  font-family: var(--bs-body-font-family);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  margin: 0;
  padding: 0;
}

/* --- 3. Top Navbar ---------------------------------------- */
.egr-navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--egr-primary);
  box-shadow: 0 1px 4px rgba(0,0,0,.18);
}
/* Prevent Bootstrap body-bg override from bleeding into navbar */
.egr-navbar,
.egr-navbar * {
  --bs-body-bg: transparent;
}
.egr-navbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.25rem;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

/* Brand */
.egr-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.01em;
  flex-shrink: 0;
}
.egr-brand-icon {
  width: 30px;
  height: 30px;
  background: rgba(255,255,255,.15);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.egr-brand-icon .lucide { width: 16px; height: 16px; stroke: #fff; }
.egr-brand:hover { color: rgba(255,255,255,.85); }

/* Nav links */
.egr-nav-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex: 1;
}
.egr-nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: rgba(255,255,255,.75);
  text-decoration: none;
  transition: background .12s, color .12s;
}
.egr-nav-link .lucide { width: 15px; height: 15px; }
.egr-nav-link:hover {
  background: rgba(255,255,255,.12);
  color: #fff;
}
.egr-nav-link.active {
  background: rgba(255,255,255,.18);
  color: #fff;
  font-weight: 600;
}

/* Right side */
.egr-nav-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: auto;
  flex-shrink: 0;
}
.egr-nav-user {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.8125rem;
  color: rgba(255,255,255,.75);
}
.egr-nav-user .lucide { width: 15px; height: 15px; }
.egr-nav-logout {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: rgba(255,255,255,.75);
  text-decoration: none;
  padding: 0.3rem 0.625rem;
  border-radius: 0.375rem;
  border: 1px solid rgba(255,255,255,.25);
  transition: background .12s, color .12s;
}
.egr-nav-logout .lucide { width: 15px; height: 15px; }
.egr-nav-logout:hover {
  background: rgba(255,255,255,.12);
  color: #fff;
  border-color: rgba(255,255,255,.4);
}

/* --- 4. Main Content -------------------------------------- */
.egr-main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.75rem 1.25rem 3rem;
}

.egr-main--wide {
  max-width: none;
}

/* --- 5. Page Header --------------------------------------- */
.egr-page-header {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--egr-border);
}
.egr-page-title {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--egr-primary);
  letter-spacing: -0.02em;
  margin: 0 0 0.125rem;
  line-height: 1.3;
}
.egr-page-subtitle {
  font-size: 0.875rem;
  color: var(--egr-text-muted);
  margin: 0;
}

/* --- 6. Back Button --------------------------------------- */
.egr-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--egr-text-muted);
  background: none;
  border: 1px solid var(--egr-border);
  border-radius: 0.375rem;
  padding: 0.3rem 0.625rem;
  text-decoration: none;
  transition: color .15s, border-color .15s, background .15s;
  margin-bottom: 1rem;
  cursor: pointer;
}
.egr-back-btn:hover {
  color: var(--egr-primary);
  border-color: var(--egr-primary);
  background: rgba(30,58,95,.05);
}
.egr-back-btn .lucide { width: 14px; height: 14px; }

/* --- 7. Cards --------------------------------------------- */
.card {
  border: 1px solid var(--egr-border) !important;
  border-radius: 0.625rem !important;
  box-shadow: 0 1px 3px rgba(0,0,0,.06) !important;
}
.card-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--egr-primary);
}

/* --- 8. Admin Panel Cards --------------------------------- */
.egr-admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: 1.25rem;
}
.egr-admin-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 1.25rem;
  background: var(--egr-surface-card);
  border: 1px solid var(--egr-border);
  border-radius: 0.75rem;
  text-decoration: none;
  color: var(--egr-text);
  font-weight: 500;
  font-size: 0.9375rem;
  transition: border-color .15s, box-shadow .15s;
  cursor: pointer;
}
.egr-admin-card:hover {
  border-color: var(--egr-accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
  color: var(--egr-text);
}
.egr-admin-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.25rem;
}
.egr-admin-card-icon .lucide { width: 20px; height: 20px; }
.egr-admin-card-icon.blue   { background: rgba(37,99,235,.1);  color: var(--egr-accent); }
.egr-admin-card-icon.green  { background: rgba(22,163,74,.1);  color: var(--egr-success); }
.egr-admin-card-icon.slate  { background: rgba(100,116,139,.1); color: var(--egr-text-muted); }
.egr-admin-card-icon.teal   { background: rgba(20,184,166,.1); color: #0d9488; }
.egr-admin-card-icon.orange { background: rgba(234,88,12,.1);  color: #ea580c; }
.egr-admin-card-icon.purple { background: rgba(124,58,237,.1); color: #7c3aed; }
.egr-admin-card-sub {
  font-size: 0.8rem;
  color: var(--egr-text-muted);
  font-weight: 400;
}

/* --- 9. Buttons ------------------------------------------- */
.btn {
  font-weight: 500;
  letter-spacing: 0.01em;
}
.btn-primary {
  background-color: var(--egr-accent) !important;
  border-color: var(--egr-accent) !important;
}
.btn-primary:hover {
  background-color: var(--egr-accent-hover) !important;
  border-color: var(--egr-accent-hover) !important;
}
.btn .lucide, .btn i[data-lucide] {
  width: 14px; height: 14px;
  vertical-align: middle;
  margin-right: 2px;
}

/* --- 10. Tables ------------------------------------------- */
.table {
  font-size: 0.875rem;
  --bs-table-bg: transparent;
  --bs-table-border-color: var(--egr-border);
}
.table > :not(caption) > * > * {
  padding: 0.625rem 0.75rem;
  border-color: var(--egr-border);
}
/* Light header (default) */
.table thead:not(.table-dark) th {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--egr-text-muted);
  background-color: var(--egr-surface) !important;
  border-bottom: 2px solid var(--egr-border) !important;
}
/* Dark header override — Bootstrap 5 uses CSS vars on the element */
thead.table-dark,
thead.table-dark th {
  --bs-table-bg:           var(--egr-primary) !important;
  --bs-table-border-color: rgba(255,255,255,.12) !important;
  --bs-table-color:        #fff !important;
  background-color: var(--egr-primary) !important;
  color: #fff !important;
  border-color: rgba(255,255,255,.12) !important;
}
thead.table-dark th a {
  color: #fff !important;
  text-decoration: none;
}
thead.table-dark th a:hover {
  color: rgba(255,255,255,.8) !important;
  text-decoration: underline;
}
/* Ensure tbody cells use consistent border color */
.table-bordered > :not(caption) > * > * {
  border-width: 1px;
  border-color: var(--egr-border);
}
.table-hover > tbody > tr:hover > * {
  --bs-table-accent-bg: rgba(30,58,95,.04);
  background-color: rgba(30,58,95,.04);
}

/* --- 11. Forms -------------------------------------------- */
.form-control, .form-select {
  border-color: var(--egr-border);
  font-size: 0.875rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--egr-accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.form-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--egr-text-muted);
  margin-bottom: 0.25rem;
}

/* --- 12. Login Page --------------------------------------- */
.egr-login-wrap {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: var(--egr-surface);
}
.egr-login-card {
  width: 100%;
  max-width: 400px;
  background: var(--egr-surface-card);
  border: 1px solid var(--egr-border);
  border-radius: 1rem;
  padding: 2.5rem 2rem;
  box-shadow: 0 4px 24px rgba(0,0,0,.08);
  text-align: center;
}
.egr-login-logo {
  width: 56px;
  height: 56px;
  background: var(--egr-primary);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.25rem;
}
.egr-login-logo .lucide { width: 28px; height: 28px; stroke: #fff; stroke-width: 2; }
.egr-login-title {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--egr-primary);
  margin-bottom: 0.25rem;
  letter-spacing: -0.02em;
}
.egr-login-subtitle {
  font-size: 0.875rem;
  color: var(--egr-text-muted);
  margin-bottom: 1.75rem;
}
.egr-login-btn {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.625rem;
  padding: 0.75rem 1.25rem;
  font-size: 0.9375rem;
  font-weight: 600;
  background: var(--egr-primary) !important;
  border-color: var(--egr-primary) !important;
  border-radius: 0.5rem;
  color: #fff !important;
  transition: background .15s, box-shadow .15s;
}
.egr-login-btn:hover {
  background: var(--egr-primary-hover) !important;
  border-color: var(--egr-primary-hover) !important;
  box-shadow: 0 4px 12px rgba(30,58,95,.25);
}
.egr-login-btn .lucide { width: 18px; height: 18px; flex-shrink: 0; }

/* --- 13. Lucide defaults ---------------------------------- */
.lucide {
  display: inline-block;
  vertical-align: middle;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

/* --- 14. Filter Bar --------------------------------------- */
.egr-filter-bar {
  background: var(--egr-surface-card);
  border: 1px solid var(--egr-border);
  border-radius: 0.625rem;
  padding: 1rem;
  margin-bottom: 1.25rem;
}

/* --- 15. Pagination --------------------------------------- */
.pagination .page-link {
  color: var(--egr-accent);
  border-color: var(--egr-border);
  font-size: 0.875rem;
}
.pagination .page-item.active .page-link {
  background-color: var(--egr-accent);
  border-color: var(--egr-accent);
}

/* --- 16. Badges ------------------------------------------- */
.badge.bg-primary { background-color: var(--egr-accent) !important; }

/* --- 17. User mgmt form spacing --------------------------- */
.egr-add-form .form-control,
.egr-add-form .form-select {
  margin-bottom: 0.5rem;
}

/* --- 18. Spin-Animation für laufende Jobs (HFC-Import etc.) --- */
@keyframes egr-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
.egr-spin {
  display: inline-block;
  animation: egr-spin 1s linear infinite;
}
