/* ============================================================
   EGR Vertriebs-App — Enterprise Design System
   ============================================================ */

/* --- 1. CSS Custom Properties (Design Tokens) -------------- */
:root {
  --egr-primary:        #1e3a5f;   /* Dunkelblau — Branding */
  --egr-primary-hover:  #162d4a;
  --egr-accent:         #2563eb;   /* Akzentblau — aktive Elemente */
  --egr-accent-hover:   #1d4ed8;
  --egr-surface:        #f8fafc;   /* Seitenhintergrund */
  --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;
  --bs-box-shadow-sm:   0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.05);
}

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

body {
  background-color: var(--egr-surface) !important;
  color: var(--egr-text);
  font-family: var(--bs-body-font-family);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Damit die Bottom-Nav keinen Content verdeckt */
body.has-bottom-nav {
  padding-bottom: 68px;
}

/* --- 3. Screen Container ------------------------------------ */
.egr-screen {
  max-width: 540px;
  margin: 0 auto;
  padding: 1.25rem 1rem 1rem;
  text-align: left;
}

/* --- 4. App Header ----------------------------------------- */
.egr-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0 1.25rem;
  border-bottom: 1px solid var(--egr-border);
  margin-bottom: 1.25rem;
}

.egr-header-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--egr-primary);
  margin: 0;
  letter-spacing: -0.01em;
}

.egr-header-subtitle {
  font-size: 0.75rem;
  color: var(--egr-text-muted);
  margin-top: 0.1rem;
}

.egr-header-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

/* --- 5. 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;
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
  text-decoration: none;
  margin-bottom: 0.875rem;
}
.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;
}

/* --- 6. Bottom Navigation Bar ------------------------------ */
.egr-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: var(--egr-surface-card);
  border-top: 1px solid var(--egr-border);
  display: flex;
  height: 60px;
  box-shadow: 0 -2px 10px rgba(0,0,0,.06);
}

.egr-bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 0.625rem;
  font-weight: 500;
  color: var(--egr-text-muted);
  cursor: pointer;
  border: none;
  background: transparent;
  padding: 6px 4px;
  transition: color .15s;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  -webkit-tap-highlight-color: transparent;
}
.egr-bottom-nav-item .lucide {
  width: 22px; height: 22px;
  min-width: 22px; min-height: 22px;
  stroke-width: 1.75;
  transition: stroke .15s;
}
.egr-bottom-nav-item.active {
  color: var(--egr-accent);
}
.egr-bottom-nav-item.active .lucide {
  stroke: var(--egr-accent);
}
.egr-bottom-nav-item:hover:not(.active) {
  color: var(--egr-primary);
}

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

/* --- 8. Address List --------------------------------------- */
.egr-address-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1rem;
  background: var(--egr-surface-card);
  border: 1px solid var(--egr-border);
  border-radius: 0.625rem;
  margin-bottom: 0.5rem;
  text-decoration: none;
  color: var(--egr-text);
  transition: border-color .15s, box-shadow .15s;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.egr-address-item:hover, .egr-address-item:focus {
  border-color: var(--egr-accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
  color: var(--egr-text);
  text-decoration: none;
}
.egr-address-item-main {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--egr-text);
  margin-bottom: 0.125rem;
}
.egr-address-item-sub {
  font-size: 0.8125rem;
  color: var(--egr-text-muted);
}
.egr-unit-badge {
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--egr-primary);
  background: rgba(30,58,95,.08);
  border-radius: 100px;
  padding: 0.2em 0.65em;
  margin-left: 0.75rem;
  white-space: nowrap;
}

/* --- 9. Unit Cards (Details Screen) ----------------------- */
.egr-unit-card {
  background: var(--egr-surface-card);
  border: 1px solid var(--egr-border);
  border-radius: 0.625rem;
  padding: 1rem;
  margin-bottom: 0.625rem;
  box-shadow: var(--bs-box-shadow-sm);
}
.egr-unit-card.is-offline-pending {
  border-color: #f59e0b;
  background: #fffbeb;
}
.egr-unit-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--egr-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.5rem;
}

/* --- 10. Status Select (mit Farb-Indicator) --------------- */
.egr-status-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.egr-status-dot {
  flex-shrink: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--egr-border);
  transition: background .2s;
}

/* Fallback-Farben für nicht-hex data-status-color Werte (legacy) */
.egr-status-dot[data-status-color="green"]  { background: var(--egr-success); }
.egr-status-dot[data-status-color="yellow"] { background: var(--egr-warning); }
.egr-status-dot[data-status-color="red"]    { background: var(--egr-danger); }
.egr-status-dot[data-status-color="blue"]   { background: var(--egr-accent); }
.egr-status-dot[data-status-color="grey"]   { background: #9ca3af; }

.egr-status-select {
  flex: 1;
}

/* --- 11. 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-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 0.375rem;
}
.btn-icon .lucide {
  width: 16px;
  height: 16px;
}

/* --- 12. Search / Filter Bar ------------------------------ */
.egr-filter-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  align-items: center;
}
.egr-filter-bar .form-control,
.egr-filter-bar .form-select {
  font-size: 0.875rem;
}
.egr-filter-bar .form-control {
  flex: 1;
  min-width: 0;
}

/* --- 13. Login Screen ------------------------------------- */
#login-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.egr-login-card {
  width: 100%;
  max-width: 380px;
  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: #ffffff;
  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: 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;
  text-decoration: none;
  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;
}

/* --- 14. Form Elements ------------------------------------ */
.form-control, .form-select {
  border-color: var(--egr-border);
  font-size: 0.9rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--egr-accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

/* --- 15. Badges ------------------------------------------- */
.badge.bg-primary {
  background-color: var(--egr-accent) !important;
}
.egr-note-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.7rem;
  font-weight: 500;
  padding: 0.15em 0.5em;
  border-radius: 100px;
  vertical-align: middle;
}
.egr-note-badge .lucide {
  width: 10px;
  height: 10px;
}

/* --- 16. Map Screen --------------------------------------- */
#map-screen .egr-screen {
  max-width: 100%;
  padding: 0;
}

/* --- 17. Spinner ------------------------------------------ */
.spinner-border.text-primary {
  color: var(--egr-accent) !important;
}

/* --- 18. Update-Banner (SW) ------------------------------- */
#sw-update-banner {
  font-family: var(--bs-body-font-family) !important;
  font-size: 0.875rem !important;
  border-radius: 0.625rem !important;
}

/* --- 19. Lucide Icon Defaults ----------------------------- */
.lucide {
  display: inline-block;
  vertical-align: middle;
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

/* --- 20. Offline-Pending Badge ---------------------------- */
.egr-pending-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.7rem;
  font-weight: 600;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
  border-radius: 100px;
  padding: 0.15em 0.5em;
}
.egr-pending-badge .lucide {
  width: 10px;
  height: 10px;
}

/* --- 21. Section Divider ---------------------------------- */
.egr-section-label {
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--egr-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin: 1.25rem 0 0.5rem;
}

/* --- 22. Config / Menu List ------------------------------- */
.egr-menu-list {
  border: 1px solid var(--egr-border);
  border-radius: 0.625rem;
  overflow: hidden;
  background: var(--egr-surface-card);
  margin-bottom: 1rem;
}
.egr-menu-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--egr-border);
  cursor: pointer;
  background: none;
  border-left: none;
  border-right: none;
  border-top: none;
  width: 100%;
  text-align: left;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--egr-text);
  transition: background .12s;
  -webkit-tap-highlight-color: transparent;
}
.egr-menu-item:last-child { border-bottom: none; }
.egr-menu-item:hover { background: var(--egr-surface); }
.egr-menu-item .lucide {
  width: 18px;
  height: 18px;
  color: var(--egr-text-muted);
  flex-shrink: 0;
}

/* --- 23. Responsive: max-width container for screens ------ */
@media (min-width: 768px) {
  .egr-screen {
    padding: 1.75rem 1.25rem;
  }
}
