/* ============================================================
   MWD SiteRadar — CI angelehnt an thorsten.cloud
   Dark-Mode, Violett-Akzent, Quicksand + Space Grotesk
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Quicksand:wght@400;500;600;700&family=Space+Grotesk:wght@500;600;700&display=swap');

:root {
  --bg:           #040a29;
  --bg-2:         #02051a;
  --surface:      rgba(190, 193, 210, .06);
  --surface-hover:rgba(190, 193, 210, .10);
  --surface-solid:rgba(190, 193, 210, .085);
  --border:       rgba(190, 193, 210, .14);
  --border-hover: rgba(190, 193, 210, .22);
  --text:         #c5c8d8;
  --text-strong:  #dcdfec;
  --text-muted:   #a8abb8;
  --heading:      #ffffff;
  --primary:      #7500ec;
  --primary-2:    #a46bff;
  --cyan:         #34d6ff;
  --lime:         #b8ff5a;
  --success:      #b8ff5a;
  --warning:      #fbbf24;
  --danger:       #ff3d81;
  --radius:       18px;
  --radius-sm:    12px;
  --radius-pill:  999px;
  --gap:          16px;
  --container:    1120px;
  --header-h:     68px;
  --shadow:       0 28px 60px rgba(0, 0, 0, .55);
  --glow:         0 0 0 1px rgba(117, 0, 236, .25), 0 0 60px rgba(117, 0, 236, .25);
  --font-body:    "Quicksand", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Space Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.6;
  min-height: 100vh;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(1200px 800px at 8% 12%, rgba(117, 0, 236, .35), transparent 55%),
    radial-gradient(900px 700px at 72% 18%, rgba(47, 183, 200, .08), transparent 55%),
    radial-gradient(680px 560px at 18% 92%, rgba(246, 238, 218, .04), transparent 60%);
  pointer-events: none;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--heading);
  font-weight: 700;
  letter-spacing: -.01em;
  line-height: 1.25;
}

a {
  color: var(--cyan);
  text-decoration: none;
  transition: color .16s ease;
}

a:hover { color: var(--primary-2); }

/* ---- Header ---- */
header#app-header {
  display: flex;
  align-items: center;
  gap: var(--gap);
  padding: 0 24px;
  height: var(--header-h);
  background: rgba(4, 10, 41, .85);
  backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  transition: box-shadow .2s ease;
}

header .brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--heading);
  letter-spacing: .02em;
  background: linear-gradient(135deg, var(--primary-2), var(--cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

header .spacer { flex: 1; }

#app-nav {
  display: flex;
  gap: 4px;
}

#app-nav a {
  color: var(--text-muted);
  padding: 7px 14px;
  border-radius: 10px;
  font-size: .88rem;
  font-weight: 600;
  transition: all .16s ease;
}

#app-nav a:hover {
  color: var(--heading);
  background: var(--surface);
}

#app-nav a.active {
  color: var(--heading);
  background: rgba(117, 0, 236, .12);
}

#app-user {
  color: var(--text-muted);
  font-size: .82rem;
}

/* ---- Buttons ---- */
button, .btn {
  font-family: var(--font-display);
  font-size: .88rem;
  font-weight: 600;
  padding: 9px 20px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--heading);
  cursor: pointer;
  letter-spacing: .2px;
  transition: transform .16s ease, background .16s ease, border-color .16s ease, box-shadow .16s ease;
}

button:hover, .btn:hover {
  transform: translateY(-1px);
  background: var(--surface-hover);
  border-color: var(--border-hover);
}

button:active { transform: translateY(0); }

button.primary, .btn-primary {
  border-color: rgba(117, 0, 236, .55);
  background: linear-gradient(135deg, #7500ece6, #a46bffb3);
  color: #fff;
  box-shadow: 0 18px 45px rgba(117, 0, 236, .22);
}

button.primary:hover, .btn-primary:hover {
  border-color: rgba(52, 214, 255, .35);
  box-shadow: 0 18px 45px rgba(117, 0, 236, .35);
}

button.ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

button.ghost:hover {
  color: var(--heading);
  border-color: var(--border-hover);
}

button.danger {
  background: rgba(255, 61, 129, .15);
  color: var(--danger);
  border-color: rgba(255, 61, 129, .3);
}

button.danger:hover {
  background: rgba(255, 61, 129, .25);
  border-color: rgba(255, 61, 129, .5);
}

button.success {
  background: rgba(184, 255, 90, .1);
  color: var(--lime);
  border-color: rgba(184, 255, 90, .25);
}

#app-logout {
  font-size: .82rem;
  padding: 6px 14px;
}

/* ---- Inputs ---- */
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="datetime-local"],
textarea, select {
  font-family: var(--font-body);
  font-size: .92rem;
  font-weight: 500;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-strong);
  outline: none;
  transition: border-color .16s ease, box-shadow .16s ease;
}

input:focus, textarea:focus, select:focus {
  border-color: rgba(117, 0, 236, .5);
  box-shadow: 0 0 0 3px rgba(117, 0, 236, .12);
}

select {
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none' stroke='%23a8abb8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 10px 6px;
  padding-right: 36px;
  cursor: pointer;
}

select:hover { border-color: var(--border-hover); }

/* ---- Custom Select (JS-gesteuert) ---- */
.cs {
  position: relative;
  display: inline-block;
  width: 100%;
  min-width: 170px;
}

.cs-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-strong);
  font-family: var(--font-body);
  font-size: .92rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color .16s ease, box-shadow .16s ease;
  user-select: none;
}

.cs-trigger:hover { border-color: var(--border-hover); }
.cs.open .cs-trigger {
  border-color: rgba(117, 0, 236, .5);
  box-shadow: 0 0 0 3px rgba(117, 0, 236, .12);
}

.cs-trigger svg {
  flex-shrink: 0;
  transition: transform .16s ease;
}

.cs.open .cs-trigger svg {
  transform: rotate(180deg);
}

.cs-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  z-index: 60;
  max-height: 240px;
  overflow-y: auto;
  display: none;
}

.cs.open .cs-dropdown { display: block; }

.cs-option {
  padding: 9px 14px;
  cursor: pointer;
  font-size: .88rem;
  color: var(--text);
  transition: background .1s ease, color .1s ease;
}

.cs-option:hover {
  background: rgba(117, 0, 236, .12);
  color: var(--heading);
}

.cs-option.selected {
  color: var(--primary-2);
  font-weight: 600;
}

.cs-option.selected::before {
  content: '✓ ';
  color: var(--primary-2);
}

/* ---- Tooltip Trigger (das ?-Icon) ---- */
.tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-left: 5px;
  border-radius: 50%;
  background: rgba(117, 0, 236, .15);
  color: var(--primary-2);
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 700;
  cursor: help;
  vertical-align: middle;
  flex-shrink: 0;
}

/* ---- Tooltip Popup (gerendert via JS an body) ---- */
.tip-popup {
  position: fixed;
  z-index: 9999;
  background: var(--bg-2);
  border: 1px solid var(--border);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: .8rem;
  font-weight: 500;
  line-height: 1.55;
  color: var(--text);
  white-space: pre-line;
  max-width: 340px;
  box-shadow: 0 20px 50px rgba(0,0,0,.5), 0 0 0 1px rgba(117,0,236,.15);
  pointer-events: none;
  opacity: 0;
  transition: opacity .12s ease;
}

.tip-popup.visible {
  opacity: 1;
}

/* ---- Layout ---- */
main#app-main {
  max-width: var(--container);
  margin: 0 auto;
  padding: 28px 24px;
}

main#app-main:has(.leads-fullwidth) {
  max-width: none;
  padding: 0;
}

body:has(.leads-fullwidth) {
  overflow: hidden;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: var(--gap);
  transition: border-color .16s ease, box-shadow .2s ease;
}

.card:hover {
  border-color: var(--border-hover);
}

/* ---- Full-Width Leads-Übersicht ---- */
.leads-fullwidth {
  max-width: none;
  border-radius: 0;
  border-left: none;
  border-right: none;
  margin: 0;
  padding: 0 40px 0;
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--header-h));
  overflow: hidden;
}

.leads-fullwidth .filters {
  flex-shrink: 0;
  padding: 16px 0;
}

.leads-meta {
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: .78rem;
  padding: 0 0 8px;
}

.leads-table-wrap {
  flex: 1;
  overflow-y: auto;
  overflow-x: auto;
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.leads-table-wrap table.data {
  width: 100%;
}

.leads-table-wrap thead {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg);
}

.leads-table-wrap thead th {
  background: var(--bg);
  border-bottom: 2px solid var(--border);
}

.ext-link {
  opacity: .4;
  font-size: .8em;
  margin-left: 6px;
  transition: opacity .16s ease;
}

.ext-link:hover { opacity: 1; }
.ext-link svg { vertical-align: -1px; }

/* ---- Leads Table Cell Styles ---- */
.td-domain { white-space: nowrap; }
.td-domain .lead-link { font-weight: 600; }
.td-date { font-size: .78rem; opacity: .5; white-space: nowrap; }
.ver { opacity: .45; margin-left: 4px; font-size: .85em; }
.perf-icons { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; }
.perf-icons svg { opacity: .5; vertical-align: -1px; margin-right: 1px; }

/* ---- Lead-Modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 5, 26, .75);
  backdrop-filter: blur(6px);
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 24px;
  overflow-y: auto;
}

.modal-content {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 960px;
  box-shadow: 0 40px 100px rgba(0,0,0,.6), var(--glow);
  position: relative;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  transition: all .16s ease;
  padding: 0;
  min-width: 0;
}

.modal-close:hover {
  background: var(--surface-hover);
  color: var(--heading);
  transform: none;
}

.modal-body {
  padding: 28px 32px;
}

.modal-body h2 { margin-top: 0; }

@media (max-width: 860px) {
  .leads-fullwidth { padding: 0 14px; }
  .modal-overlay { padding: 20px 8px; }
  .modal-body { padding: 20px 16px; }
}

.card h2 {
  margin-top: 0;
  font-size: 1.3rem;
}

.card h3 {
  margin-top: 0;
  font-size: 1.05rem;
}

/* ---- KPI Dashboard ---- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--gap);
  margin-bottom: var(--gap);
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: border-color .16s ease, box-shadow .2s ease;
}

.kpi:hover {
  border-color: rgba(117, 0, 236, .35);
  box-shadow: 0 14px 40px rgba(117, 0, 236, .10);
}

.kpi .label {
  color: var(--text-muted);
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.kpi .value {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--heading);
  margin-top: 8px;
  line-height: 1;
}

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

table.data th, table.data td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

table.data th {
  color: var(--text-muted);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .06em;
}

table.data tbody tr {
  transition: background .12s ease;
}

table.data tbody tr:hover td {
  background: var(--surface-hover);
}

table.data td a {
  font-weight: 600;
}

/* ---- Badges ---- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-family: var(--font-display);
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .02em;
  border: 1px solid transparent;
}

.badge.new           { background: rgba(164, 107, 255, .12); color: var(--primary-2); border-color: rgba(164, 107, 255, .25); }
.badge.in_progress   { background: rgba(52, 214, 255, .12); color: var(--cyan); border-color: rgba(52, 214, 255, .25); }
.badge.contacted     { background: rgba(117, 0, 236, .15); color: var(--primary-2); border-color: rgba(117, 0, 236, .3); }
.badge.interested    { background: rgba(184, 255, 90, .12); color: var(--lime); border-color: rgba(184, 255, 90, .25); }
.badge.not_interested{ background: rgba(168, 171, 184, .1); color: var(--text-muted); border-color: rgba(168, 171, 184, .15); }
.badge.customer      { background: rgba(184, 255, 90, .18); color: var(--lime); border-color: rgba(184, 255, 90, .35); }
.badge.blacklisted   { background: rgba(255, 61, 129, .12); color: var(--danger); border-color: rgba(255, 61, 129, .25); }

/* ---- Login / Setup ---- */
.login-wrap {
  max-width: 440px;
  margin: 80px auto;
}

.login-wrap .card {
  box-shadow: var(--shadow);
  border-color: rgba(117, 0, 236, .15);
}

.login-wrap h2 {
  text-align: center;
  font-size: 1.5rem;
  margin-bottom: 24px;
}

.login-wrap button[type="submit"],
.login-wrap .btn-primary {
  width: 100%;
  padding: 12px;
  font-size: .95rem;
  border-color: rgba(117, 0, 236, .55);
  background: linear-gradient(135deg, #7500ece6, #a46bffb3);
  color: #fff;
  box-shadow: 0 18px 45px rgba(117, 0, 236, .22);
}

/* ---- Forms ---- */
.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.form-row label {
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.form-row input, .form-row textarea, .form-row select {
  width: 100%;
}

/* ---- Alerts ---- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-weight: 500;
  border: 1px solid transparent;
}

.alert.error   { background: rgba(255, 61, 129, .1); color: var(--danger); border-color: rgba(255, 61, 129, .2); }
.alert.success { background: rgba(184, 255, 90, .1); color: var(--lime); border-color: rgba(184, 255, 90, .2); }
.alert.info    { background: rgba(52, 214, 255, .1); color: var(--cyan); border-color: rgba(52, 214, 255, .2); }

/* ---- Toast ---- */
#app-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 14px 22px;
  background: rgba(4, 10, 41, .92);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-weight: 600;
  font-size: .88rem;
  display: none;
  z-index: 200;
}

#app-toast.show { display: block; }
#app-toast.success { border-color: rgba(184, 255, 90, .3); color: var(--lime); }
#app-toast.error { border-color: rgba(255, 61, 129, .3); color: var(--danger); }

/* ---- Filters ---- */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 20px;
}

.filters .form-row {
  margin-bottom: 0;
}

.filters button {
  margin-top: auto;
}

/* ---- Actions Bar ---- */
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 20px;
}

/* ---- Pagination ---- */
.pagination {
  display: flex;
  gap: 4px;
  justify-content: center;
  margin-top: 20px;
  flex-wrap: wrap;
}

.pagination button {
  min-width: 38px;
  padding: 6px 10px;
  font-size: .82rem;
}

/* ---- Scan-History-Sparkline ---- */
.history-chart {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 60px;
  padding: 8px 0;
}

.history-chart .bar {
  flex: 1;
  min-width: 6px;
  max-width: 20px;
  border-radius: 3px 3px 0 0;
  transition: height .2s ease;
  position: relative;
}

.history-chart .bar:hover::after {
  content: attr(data-tip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 4px 8px;
  border-radius: 6px;
  font-size: .7rem;
  white-space: nowrap;
  color: var(--text);
  z-index: 10;
}

/* ---- Two-Column Layout ---- */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap);
}

@media (max-width: 860px) {
  .two-col { grid-template-columns: 1fr; }
  main#app-main { padding: 14px; }
  #app-nav { gap: 2px; }
  #app-nav a { padding: 6px 8px; font-size: .82rem; }
  header#app-header { padding: 0 14px; gap: 8px; }
}

/* ---- Pre / Code ---- */
pre {
  white-space: pre-wrap;
  background: var(--bg-2);
  padding: 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: .85rem;
  line-height: 1.65;
}

code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: .85em;
  background: var(--surface);
  padding: 2px 6px;
  border-radius: 4px;
}

/* ---- QR / 2FA ---- */
.qr-wrap {
  background: #fff;
  padding: 16px;
  border-radius: var(--radius-sm);
  display: inline-block;
  box-shadow: var(--shadow);
}

.qr-wrap svg {
  display: block;
  width: 220px;
  height: 220px;
}

.mono {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: .82rem;
  word-break: break-all;
  color: var(--primary-2);
}

/* ---- Details / Accordion ---- */
details {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
}

details summary {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--heading);
  cursor: pointer;
  list-style: none;
}

details summary::before {
  content: '+';
  display: inline-block;
  width: 20px;
  color: var(--primary-2);
  font-weight: 700;
}

details[open] summary::before {
  content: '−';
}

/* ---- Scrollbar (Webkit) ---- */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(190, 193, 210, .15);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(190, 193, 210, .25);
}

/* ---- Loading Pulse ---- */
#app-loading {
  text-align: center;
  padding: 80px 0;
  color: var(--text-muted);
  font-size: 1.1rem;
  animation: pulse 1.5s ease-in-out infinite;
}

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