/* ═══════════════════════════════════════════════════════════
   FERTILIO DASHBOARD — Design System
   Matches main site: Warm Editorial Authority
   ═══════════════════════════════════════════════════════════ */

/* ─── Reset ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
input, button, textarea, select { font: inherit; }
a { color: inherit; text-decoration: none; }

/* ─── Variables (synced with fertilio.de) ────────────── */
:root {
  --color-bg: #FAF8F5;
  --color-bg-alt: #F0ECE6;
  --color-bg-card: #FFFFFF;
  --color-text: #1C1917;
  --color-text-muted: #78716C;
  --color-text-light: #A8A29E;
  --color-primary: #925038;
  --color-primary-light: #AD6C52;
  --color-primary-dark: #4A2A1B;
  --color-accent: #6B8A5E;
  --color-accent-light: #8DAE7F;
  --color-border: #E7E5E4;
  --color-border-light: #F0EEEC;
  --color-success: #6B8A5E;
  --color-warning: #D97706;
  --color-danger: #DC2626;

  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", monospace;

  --sidebar-width: 240px;
  --topbar-height: 64px;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(28, 25, 23, 0.04);
  --shadow-md: 0 4px 12px rgba(28, 25, 23, 0.06);
  --shadow-lg: 0 8px 24px rgba(28, 25, 23, 0.08);
  --transition: 180ms ease;
}

/* ─── Typography ─────────────────────────────────────── */
body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
}

/* ─── Layout ─────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--color-bg-card);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition);
}

.main {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
}

/* ─── Sidebar ────────────────────────────────────────── */
.sidebar__logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
  font-size: 18px;
  font-weight: 700;
  color: var(--color-primary-dark);
  letter-spacing: -0.02em;
}

.sidebar__nav {
  flex: 1;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar__footer {
  padding: 12px;
  border-top: 1px solid var(--color-border-light);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--color-text-muted);
  transition: all var(--transition);
  cursor: pointer;
}

.nav-item:hover {
  color: var(--color-text);
  background: var(--color-bg);
}

.nav-item.active {
  color: var(--color-primary);
  background: rgba(146, 80, 56, 0.06);
  font-weight: 600;
}

.nav-item svg {
  flex-shrink: 0;
  opacity: 0.7;
}

.nav-item.active svg,
.nav-item:hover svg {
  opacity: 1;
}

/* ─── Topbar ─────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  height: var(--topbar-height);
  background: rgba(250, 248, 245, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border-light);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 32px;
  z-index: 50;
}

.topbar__menu {
  display: none;
  background: none;
  border: none;
  color: var(--color-text);
  cursor: pointer;
  padding: 4px;
}

.topbar__title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  flex: 1;
}

.topbar__actions {
  display: flex;
  gap: 8px;
}

/* ─── Active Visitors Badge ──────────────────────────── */
.active-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-light);
  background: var(--color-bg-alt);
  transition: all var(--transition);
}

.active-badge.has-visitors {
  color: var(--color-success);
  background: rgba(107, 138, 94, 0.08);
}

.active-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-text-light);
  transition: background var(--transition);
}

.active-badge.has-visitors .active-dot {
  background: var(--color-success);
  box-shadow: 0 0 0 3px rgba(107, 138, 94, 0.2);
  animation: pulse-dot 2s ease infinite;
}

@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 2px rgba(107, 138, 94, 0.2); }
  50% { box-shadow: 0 0 0 5px rgba(107, 138, 94, 0.05); }
}

.topbar__refresh {
  font-size: 11px;
  color: var(--color-text-light);
  white-space: nowrap;
}

/* ─── Buttons ────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn--generate {
  background: var(--color-primary);
  color: #fff;
}

.btn--generate:hover {
  background: var(--color-primary-dark);
}

.btn--secondary {
  background: var(--color-bg-alt);
  color: var(--color-text);
}

.btn--secondary:hover {
  background: var(--color-border);
}

.btn--success {
  background: var(--color-success);
  color: #fff;
}

.btn--success:hover {
  background: #5a7a4e;
}

.btn--danger {
  background: none;
  color: var(--color-danger);
  border: 1px solid var(--color-danger);
  padding: 7px 15px;
}

.btn--danger:hover {
  background: var(--color-danger);
  color: #fff;
}

.btn--sm {
  padding: 5px 10px;
  font-size: 12px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ─── Sections ───────────────────────────────────────── */
.section {
  padding: 28px 32px;
}

.section.hidden {
  display: none;
}

.section__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.section__desc {
  color: var(--color-text-muted);
  font-size: 14px;
}

/* ─── KPI Grid ───────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}

.kpi-card:hover {
  box-shadow: var(--shadow-md);
}

.kpi-card__icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.kpi-card__icon--visitors { background: rgba(107, 138, 94, 0.1); color: var(--color-accent); }
.kpi-card__icon--leads { background: rgba(146, 80, 56, 0.08); color: var(--color-primary); }
.kpi-card__icon--clicks { background: rgba(217, 119, 6, 0.08); color: var(--color-warning); }
.kpi-card__icon--position { background: rgba(28, 25, 23, 0.05); color: var(--color-text); }

.kpi-card__data {
  flex: 1;
  min-width: 0;
}

.kpi-card__value {
  display: block;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.kpi-card__label {
  display: block;
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 4px;
}

.kpi-card__trend {
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  white-space: nowrap;
  align-self: center;
}

.kpi-card__trend.up {
  background: rgba(107, 138, 94, 0.1);
  color: var(--color-success);
}

.kpi-card__trend.down {
  background: rgba(220, 38, 38, 0.08);
  color: var(--color-danger);
}

/* ─── Cards ──────────────────────────────────────────── */
.overview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border-light);
}

.card__title {
  font-size: 14px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.card__link {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-primary);
}

.card__link:hover {
  color: var(--color-primary-dark);
}

.card__body {
  padding: 16px 20px;
}

/* ─── Empty State ────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--color-text-light);
  font-size: 13px;
}

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

.data-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  padding: 8px 12px;
  border-bottom: 1px solid var(--color-border);
}

.data-table td {
  padding: 10px 12px;
  font-size: 13px;
  border-bottom: 1px solid var(--color-border-light);
}

.data-table tbody tr:hover {
  background: var(--color-bg);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

/* ─── Draft Items ────────────────────────────────────── */
.draft-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--color-border-light);
}

.draft-item:last-child {
  border-bottom: none;
}

.draft-item__info {
  flex: 1;
  min-width: 0;
}

.draft-item__title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 2px;
}

.draft-item__meta {
  font-size: 12px;
  color: var(--color-text-muted);
}

.draft-item__actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* ─── Recommendation Items ───────────────────────────── */
.rec-item {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: flex-start;
  gap: 16px;
  transition: box-shadow var(--transition);
}

.rec-item:hover {
  box-shadow: var(--shadow-md);
}

.rec-item__badge {
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  flex-shrink: 0;
}

.rec-item__badge--gap { background: rgba(146, 80, 56, 0.1); color: var(--color-primary); }
.rec-item__badge--quickwin { background: rgba(107, 138, 94, 0.1); color: var(--color-accent); }
.rec-item__badge--brief { background: rgba(217, 119, 6, 0.1); color: var(--color-warning); }
.rec-item__badge--thin { background: rgba(220, 38, 38, 0.08); color: var(--color-danger); }

.rec-item__content {
  flex: 1;
  min-width: 0;
}

.rec-item__keyword {
  font-weight: 650;
  font-size: 15px;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
}

.rec-item__reason {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-bottom: 10px;
}

.rec-item__stats {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--color-text-light);
}

.rec-item__stats strong {
  color: var(--color-text);
  font-weight: 600;
}

/* ─── Period Toggle ──────────────────────────────────── */
.period-toggle {
  display: flex;
  gap: 4px;
  background: var(--color-bg);
  padding: 3px;
  border-radius: var(--radius-sm);
}

.period-btn {
  padding: 4px 12px;
  border: none;
  background: none;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all var(--transition);
}

.period-btn:hover {
  color: var(--color-text);
}

.period-btn.active {
  background: var(--color-bg-card);
  color: var(--color-text);
  box-shadow: var(--shadow-sm);
}

/* ─── Modal ──────────────────────────────────────────── */
.modal {
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 0;
  max-width: 520px;
  width: 90%;
}

.modal::backdrop {
  background: rgba(28, 25, 23, 0.4);
  backdrop-filter: blur(4px);
}

.modal__content {
  padding: 0;
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--color-border-light);
}

.modal__header h2 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.modal__close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.modal__close:hover {
  color: var(--color-text);
}

.modal__form {
  padding: 24px;
}

.modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 20px;
  border-top: 1px solid var(--color-border-light);
  margin-top: 20px;
}

/* ─── Forms ──────────────────────────────────────────── */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--color-text);
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--color-bg-card);
  color: var(--color-text);
  transition: border-color var(--transition);
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(146, 80, 56, 0.1);
}

.form-group input::placeholder {
  color: var(--color-text-light);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ─── Toast Notification ─────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--color-text);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  transform: translateY(100px);
  opacity: 0;
  transition: all 300ms ease;
}

.toast.visible {
  transform: translateY(0);
  opacity: 1;
}

.toast--success { background: var(--color-success); }
.toast--error { background: var(--color-danger); }

/* ─── Spinner ────────────────────────────────────────── */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ─── Responsive ─────────────────────────────────────── */
@media (max-width: 1024px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main {
    margin-left: 0;
  }

  .topbar__menu {
    display: block;
  }

  .topbar {
    padding: 0 16px;
  }

  .section {
    padding: 20px 16px;
  }

  .kpi-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .overview-grid {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .btn--generate span {
    display: none;
  }
}

@media (max-width: 480px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }
}
