/* crm/app/static/css/style.css
   handwerk.ki CRM — Corporate Design
   Basiert auf website/src/styles/global.css */

@font-face {
  font-family: 'Inter';
  src: url('/static/fonts/InterVariable.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: 'Lexend';
  src: url('/static/fonts/Lexend.woff2') format('woff2');
  font-weight: 700 900;
  font-display: swap;
}

:root {
  --off-white:      #fafaf9;
  --light-grey:     #f0efec;
  --mid-grey:       #ebe9e6;
  --text:           #1c1917;
  --text-secondary: #57534e;
  --text-muted:     #5c5754;
  --orange:         #d97706;
  --orange-dark:    #b45309;
  --orange-light:   rgba(217,119,6,0.08);
  --gradient-brand: linear-gradient(135deg, #d97706 0%, #b45309 100%);
  --radius-card:    14px;
  --radius-sm:      8px;
  --ease:           cubic-bezier(0.4, 0, 0.2, 1);
  --font-body:      'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-heading:   'Lexend', 'Inter', system-ui, sans-serif;
  --header-h:       56px;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { height: 100%; }
body {
  font-family: var(--font-body);
  background: var(--off-white);
  color: var(--text);
  min-height: 100%;
  font-size: 0.88rem;
  line-height: 1.5;
}

/* --- Header --- */
.header {
  height: var(--header-h);
  background: #fff;
  border-bottom: 1px solid var(--mid-grey);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-logo { height: 24px; }
.header-nav { display: flex; gap: 0.25rem; align-items: center; }
.header-nav a {
  text-decoration: none;
  color: var(--text-secondary);
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 500;
  transition: all 0.15s var(--ease);
}
.header-nav a:hover { background: var(--light-grey); color: var(--text); }
.header-nav a.active { background: var(--orange-light); color: var(--orange); font-weight: 600; }
.header-nav .logout {
  color: var(--text-muted);
  font-size: 0.78rem;
  margin-left: 0.5rem;
}

/* --- Login --- */
.login-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
}
.login-box {
  background: #fff;
  border-radius: var(--radius-card);
  padding: 2.5rem;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 8px 24px rgba(0,0,0,0.04);
}
.login-logo { height: 32px; margin-bottom: 2rem; display: block; }
.login-label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
  display: block;
}
.login-input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--mid-grey);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.15s var(--ease);
}
.login-input:focus { border-color: var(--orange); }
.login-btn {
  width: 100%;
  margin-top: 1.25rem;
  padding: 0.7rem;
  background: var(--gradient-brand);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s var(--ease);
}
.login-btn:hover { opacity: 0.9; }
.login-error {
  color: #dc2626;
  font-size: 0.78rem;
  margin-top: 0.75rem;
  text-align: center;
}

/* --- Filter Bar --- */
.filter-bar {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  background: #fff;
  border-bottom: 1px solid var(--mid-grey);
  flex-wrap: wrap;
  align-items: center;
}
.filter-bar select,
.filter-bar input {
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--mid-grey);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.82rem;
  outline: none;
  background: #fff;
}
.filter-bar select:focus,
.filter-bar input:focus { border-color: var(--orange); }
.filter-bar input { flex: 1; min-width: 180px; }

/* --- Stats Bar --- */
.stats-bar {
  display: flex;
  gap: 0.4rem;
  padding: 0.5rem 1.5rem;
  flex-wrap: wrap;
  background: var(--light-grey);
}
.stat-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 99px;
  color: #fff;
  white-space: nowrap;
}

/* --- Map --- */
.map-container {
  flex: 1;
  min-height: calc(100vh - var(--header-h) - 100px);
}
#map { width: 100%; height: calc(100vh - var(--header-h) - 105px); }
.leaflet-popup-content { font-family: var(--font-body); font-size: 0.82rem; line-height: 1.5; }
.leaflet-popup-content .popup-name {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.88rem;
  margin-bottom: 0.25rem;
}
.leaflet-popup-content .popup-branche {
  font-size: 0.72rem;
  color: var(--text-secondary);
}
.leaflet-popup-content .popup-link {
  display: inline-block;
  margin-top: 0.4rem;
  color: var(--orange);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.78rem;
}
.leaflet-popup-content .popup-link:hover { text-decoration: underline; }

/* --- List --- */
.list-container { padding: 0 1.5rem 2rem; }
.leads-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.75rem;
}
.leads-table th {
  text-align: left;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.6rem 0.75rem;
  border-bottom: 2px solid var(--mid-grey);
  cursor: pointer;
  user-select: none;
}
.leads-table th:hover { color: var(--text); }
.leads-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--light-grey);
  font-size: 0.82rem;
  vertical-align: middle;
}
.leads-table tr { cursor: pointer; transition: background 0.1s var(--ease); }
.leads-table tr:hover { background: var(--orange-light); }

/* --- Status Badge --- */
.status-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 99px;
  color: #fff;
  white-space: nowrap;
}

/* --- Detail --- */
.detail-container { max-width: 800px; margin: 0 auto; padding: 1.5rem; }
.detail-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.detail-header h1 {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 800;
}
.detail-back {
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.82rem;
  margin-bottom: 0.5rem;
  display: inline-block;
}
.detail-back:hover { color: var(--orange); }
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  background: #fff;
  border-radius: var(--radius-card);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.detail-field label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: block;
  margin-bottom: 0.15rem;
}
.detail-field span, .detail-field a {
  font-size: 0.88rem;
  color: var(--text);
  word-break: break-word;
}
.detail-field a { color: var(--orange); text-decoration: none; }
.detail-field a:hover { text-decoration: underline; }
.detail-field.full { grid-column: 1 / -1; }

/* Status Select */
.status-select {
  padding: 0.35rem 0.5rem;
  border: 2px solid var(--mid-grey);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
}
.status-select:focus { border-color: var(--orange); }

/* Notizen */
.notizen-box {
  background: #fff;
  border-radius: var(--radius-card);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.notizen-box h3 {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
}
.notizen-textarea {
  width: 100%;
  min-height: 80px;
  padding: 0.65rem;
  border: 1px solid var(--mid-grey);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.82rem;
  resize: vertical;
  outline: none;
}
.notizen-textarea:focus { border-color: var(--orange); }
.notizen-save {
  margin-top: 0.5rem;
  padding: 0.4rem 1rem;
  background: var(--gradient-brand);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

/* --- Activity Timeline --- */
.timeline {
  background: #fff;
  border-radius: var(--radius-card);
  padding: 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.timeline h3 {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
}
.timeline-item {
  display: flex;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--light-grey);
}
.timeline-item:last-child { border-bottom: none; }
.timeline-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--light-grey);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  flex-shrink: 0;
}
.timeline-content { flex: 1; }
.timeline-content p { font-size: 0.82rem; }
.timeline-content time {
  font-size: 0.68rem;
  color: var(--text-muted);
}
.timeline-form {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.timeline-form select,
.timeline-form input {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--mid-grey);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.82rem;
  outline: none;
}
.timeline-form input { flex: 1; min-width: 200px; }
.timeline-form button {
  padding: 0.4rem 0.85rem;
  background: var(--text);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

/* Mini Map */
.mini-map {
  height: 200px;
  border-radius: var(--radius-card);
  margin-bottom: 1.25rem;
  overflow: hidden;
}

/* --- Responsive --- */
@media (max-width: 600px) {
  .filter-bar { padding: 0.5rem 1rem; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-container { padding: 1rem; }
  .list-container { padding: 0 1rem 2rem; }
  .header { padding: 0 1rem; }
}

/* --- Layout Wrapper --- */
.page-content {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - var(--header-h));
}

/* --- Filter Reset Button --- */
.filter-reset {
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--mid-grey);
  border-radius: var(--radius-sm);
  background: #fff;
  font-size: 0.82rem;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s var(--ease);
}
.filter-reset:hover { border-color: var(--orange); color: var(--orange); }

/* --- Map Empty State --- */
.map-empty {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #fff;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-sm);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  font-size: 0.88rem;
  color: var(--text-secondary);
  z-index: 500;
  pointer-events: none;
}
.map-container { position: relative; }

/* --- Custom Drop Pins --- */
.pin-icon {
  position: relative;
  width: 30px;
  height: 38px;
}
.pin-icon svg { filter: drop-shadow(0 2px 3px rgba(0,0,0,0.25)); }
.pin-icon .pin-emoji {
  position: absolute;
  top: 5px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 13px;
  line-height: 1;
}

/* --- Cluster Override --- */
.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
  background: rgba(217,119,6,0.2) !important;
}
.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
  background: var(--orange) !important;
  color: #fff !important;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.78rem;
}

/* --- Ansprechpartner --- */
.contacts-box {
  background: #fff;
  border-radius: var(--radius-card);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.contacts-box h3 {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
}
.contact-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--light-grey);
}
.contact-item:last-of-type { border-bottom: none; }
.contact-info { flex: 1; }
.contact-info .contact-name {
  font-weight: 600;
  font-size: 0.88rem;
}
.contact-info .contact-rolle {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.contact-info .contact-details {
  font-size: 0.82rem;
  margin-top: 0.15rem;
}
.contact-info .contact-details a {
  color: var(--orange);
  text-decoration: none;
}
.contact-info .contact-details a:hover { text-decoration: underline; }
.contact-actions {
  display: flex;
  gap: 0.25rem;
  flex-shrink: 0;
}
.contact-actions button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.78rem;
  color: var(--text-muted);
  padding: 0.2rem 0.35rem;
  border-radius: 4px;
}
.contact-actions button:hover { background: var(--light-grey); color: var(--text); }
.contact-form {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.contact-form input {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--mid-grey);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.82rem;
  outline: none;
  flex: 1;
  min-width: 120px;
}
.contact-form input:focus { border-color: var(--orange); }
.contact-form button {
  padding: 0.4rem 0.85rem;
  background: var(--text);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}
