/* ============================================================
   THE WEDDING CLOSER – Tesla-Inspired Design System
   ============================================================ */

/* --- Variables --- */
:root {
  --bg-primary: #F9F6F0;
  --bg-secondary: #EDE9E1;
  --text-primary: #171a20;
  --text-secondary: #393c41;
  --text-muted: #5c5e62;
  --tesla-blue: #3e6ae1;
  --border-light: #ddd8ce;
  --success: #2e7d32;
  --danger: #b71c1c;
  --warning: #ed6c02;
  --info: #0288d1;
  --primary: #2D5016;
  --primary-hover: #4A7C28;
  --radius: 8px;
  /* Slightly more rounded for modern feel */
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --glass-bg: rgba(249, 246, 240, 0.85);
  --glass-blur: blur(12px);
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* --- Reset & Base --- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  cursor: pointer;
  font-family: inherit;
  border: none;
  outline: none;
  background: none;
}

input,
select,
textarea {
  font-family: inherit;
  outline: none;
}

svg,
.btn svg,
.nav-item svg,
.sidebar-logo svg {
  width: 1.25rem !important;
  height: 1.25rem !important;
  flex-shrink: 0;
  display: inline-block;
}

h1,
h2,
h3,
h4 {
  font-weight: 500;
  letter-spacing: -0.6px;
}

/* ============================================================
   UTILITIES
   ============================================================ */
.text-center {
  text-align: center;
}

.text-sm {
  font-size: 0.85rem;
}

.text-xs {
  font-size: 0.75rem;
}

.text-lg {
  font-size: 1.15rem;
}

.fw-500 {
  font-weight: 500;
}

.muted {
  color: var(--text-muted);
}

.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.justify-center {
  justify-content: center;
}

.justify-between {
  justify-content: space-between;
}

.gap-2 {
  gap: 0.5rem;
}

.gap-4 {
  gap: 1rem;
}

.gap-8 {
  gap: 2rem;
}

.mt-4 {
  margin-top: 1rem;
}

.mb-8 {
  margin-bottom: 2rem;
}

.w-full {
  width: 100%;
}

/* ============================================================
   BUTTONS (Tesla Style)
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 40px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
  min-width: 160px;
}

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

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

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

.btn-blue:hover {
  background-color: #3457b1;
}

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

.btn-secondary:hover {
  background-color: #e2e2e2;
}

.btn-ghost {
  border: 3px solid var(--primary);
  color: var(--primary);
}

.btn-ghost:hover {
  background-color: var(--primary);
  color: #ffffff;
}

.btn-sm {
  padding: 6px 20px;
  min-width: auto;
}

/* ============================================================
   LAYOUT – APP SHELL
   ============================================================ */
.app-shell {
  display: flex;
  min-height: 100vh;
  background: var(--bg-secondary);
}

/* Sidebar */
.sidebar {
  width: 280px;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  padding: 40px 20px;
  position: fixed;
  height: 100vh;
  z-index: 100;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-logo {
  margin-bottom: 40px;
  padding-left: 10px;
}

.sidebar-logo .logo-text {
  font-size: 18px;
  font-weight: 500;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-item {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 12px;
  transition: var(--transition);
}

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

.nav-item.active {
  background: rgba(45, 80, 22, 0.1);
  color: var(--primary);
  font-weight: 600;
}

.nav-item svg {
  width: 20px;
  height: 20px;
}

/* Main Content */
.main-content {
  margin-left: 280px;
  flex: 1;
  padding: 40px 60px;
}

.page-header {
  margin-bottom: 40px;
}

.page-title {
  font-size: 32px;
  margin-bottom: 8px;
}

.page-subtitle {
  color: var(--text-muted);
  font-size: 16px;
}

/* ============================================================
   LANDING
   ============================================================ */
.landing-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 40px;
  z-index: 1000;
  transition: var(--transition);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
}

.landing-nav .logo {
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.landing-nav-links {
  display: flex;
  gap: 24px;
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
}

.hero {
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  text-align: center;
  padding: 120px 20px 60px;
  background-size: cover;
  background-position: center;
  position: relative;
}

.hero-content {
  z-index: 1;
}

.hero h1 {
  font-size: 40px;
  font-weight: 500;
  margin-bottom: 10px;
  color: var(--text-primary);
}

.hero p {
  font-size: 14px;
  color: var(--text-secondary);
}

.hero-cta {
  display: flex;
  gap: 20px;
  margin-top: auto;
}

/* ============================================================
   CARDS & TABLES
   ============================================================ */
.card {
  background: #ffffff;
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.lead-row {
  background: #ffffff;
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-light);
  transition: var(--transition);
}

.lead-row:hover {
  background: var(--bg-secondary);
}

.lead-row:last-child {
  border-bottom: none;
}

/* ============================================================
   FORMS
   ============================================================ */
.form-input {
  background: var(--bg-secondary);
  border: none;
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 14px;
  width: 100%;
  color: var(--text-primary);
}

.form-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
  display: block;
}

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-new {
  background: #e3f2fd;
  color: #1976d2;
}

.badge-pending {
  background: #fff3e0;
  color: #ef6c00;
}

.badge-accepted {
  background: #e8f5e9;
  color: #2e7d32;
}

.badge-declined {
  background: #ffebee;
  color: #c62828;
}

/* Animation */
.animate-fade-in {
  animation: fadeIn 0.6s ease-out forwards;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================================
   RESPONSIVE (Mobile-First)
   ============================================================ */

/* --- Sidebar overlay (tablet drawer) --- */
.mobile-top-nav {
  display: none;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 99;
  backdrop-filter: blur(2px);
}

.sidebar-overlay.open {
  display: block;
}

/* --- Mobile Bottom Tab Bar ---
   JS sets display:flex inline on every render.
   Desktop-only rule below overrides it with !important.
   So "none" here is just the fallback for before JS runs. */
.mobile-tab-bar {
  display: none;
}

/* --- Desktop: hide tab bar, show full sidebar (≥ 1025px) --- */
@media (min-width: 1025px) {
  .mobile-tab-bar {
    display: none !important; /* overrides JS inline display:flex */
  }
}

/* --- Tablet: Tab-bar only, no hamburger, no sidebar (769–1024px) --- */
@media (min-width: 769px) and (max-width: 1024px) {
  /* Hide sidebar and hamburger — tab bar is the only nav */
  .sidebar {
    display: none !important;
  }

  .mobile-top-nav {
    display: none !important;
  }

  /* No sidebar offset, bottom padding for tab bar */
  .main-content {
    margin-left: 0 !important;
    padding: 20px 20px 80px !important;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 16px;
  }

  .page-title {
    font-size: 26px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .detail-grid {
    grid-template-columns: 1fr !important;
    gap: 24px !important;
  }
}

/* --- Mobile: Bottom Tab Bar (≤ 768px) --- */
@media (max-width: 768px) {
  /* No sidebar, no top hamburger nav */
  .sidebar {
    display: none !important;
  }

  .mobile-top-nav {
    display: none !important; /* fallback: JS doesn't add it to DOM on mobile anyway */
  }

  /* Show bottom tab bar */
  .mobile-tab-bar {
    display: flex !important;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 62px;
    background: #fff;
    border-top: 1px solid var(--border-light);
    z-index: 200;
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.07);
    justify-content: space-around;
    align-items: stretch;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .tab-bar-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-size: 10px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    border: none;
    background: none;
    padding: 6px 0;
    transition: color 0.2s ease;
    text-decoration: none;
  }

  .tab-bar-item svg {
    width: 22px !important;
    height: 22px !important;
  }

  .tab-bar-item.active {
    color: var(--primary);
  }

  .tab-bar-badge {
    position: absolute;
    top: 6px;
    right: calc(50% - 18px);
    background: var(--danger);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
  }

  /* Main content: no sidebar offset, extra bottom padding for tab bar */
  .main-content {
    margin-left: 0 !important;
    padding: 16px 16px 80px !important;
  }

  /* Layout adjustments */
  .page-header {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 12px;
  }

  /* Direct .btn children of page-header (e.g. Settings "Speichern") → full width */
  .page-header > .btn {
    width: 100%;
    min-width: 0;
    align-self: stretch;
  }

  .page-title {
    font-size: 22px !important;
    text-align: center;
  }

  .page-subtitle {
    font-size: 14px !important;
    text-align: center;
  }

  /* Stats: 2x2 grid on mobile */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Detail/Calendar: single column */
  .detail-grid,
  .cal-grid {
    grid-template-columns: 1fr !important;
    gap: 20px !important;
  }

  /* Calendar main card: tighter padding so cells have more room */
  .cal-month-card {
    padding: 14px !important;
  }

  /* Remove sticky on decision panel when stacked */
  .decision-panel-sticky {
    position: static !important;
  }

  /* Full-width buttons on mobile – only explicit opt-in */
  .btn-mobile-full {
    width: 100% !important;
    min-width: 0 !important;
  }

  /* Decision panel buttons volle Breite */
  .decision-panel-sticky .btn {
    width: 100%;
    min-width: 0;
  }

  /* Scrollable filter tabs */
  .filter-tabs-row {
    overflow-x: auto !important;
    flex-wrap: nowrap !important;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 6px;
    padding-right: 16px;
    scrollbar-width: none;
  }

  .filter-tabs-row::-webkit-scrollbar {
    display: none;
  }

  /* Card grid: 1 column */
  .leads-card-grid {
    grid-template-columns: 1fr !important;
  }

  /* KI fields: single column */
  .ki-fields-grid {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }

  /* Onboarding nav row: stack on mobile, primary action on top */
  .ob-nav-row {
    flex-direction: column-reverse !important;
    align-items: stretch !important;
    gap: 12px;
  }

  .ob-nav-row #next-btn {
    width: 100% !important;
    min-width: 0 !important;
  }

  .ob-nav-left {
    justify-content: space-between;
    width: 100%;
  }

  .ob-nav-left .btn {
    flex: 1;
    min-width: 0 !important;
  }

  /* Onboarding: hide step labels */
  .ob-step-label {
    display: none !important;
  }

  /* Step bubbles smaller on mobile */
  .ob-step-bubble {
    width: 28px !important;
    height: 28px !important;
    font-size: 12px !important;
  }

  /* Form inputs full width */
  input,
  select,
  textarea {
    width: 100%;
  }

  /* Reduce card padding – no !important so inline padding:0 (e.g. lead list card) wins */
  .card {
    padding: 16px;
  }

  /* Landing page */
  .landing-nav {
    padding: 15px 10px;
    flex-direction: column;
    gap: 10px;
    position: relative;
    background: #fff;
  }

  .hero {
    padding-top: 40px;
  }

  .hero h1 {
    font-size: 32px;
  }

  .hero-cta {
    flex-direction: column;
    width: 100%;
    padding: 0 20px;
  }

  .lead-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .lead-row > div:last-child {
    width: 100%;
    justify-content: space-between !important;
  }
}

/* Landing page mobile extras already merged into the block above */

/* Toast */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  left: 20px;
  z-index: 2500;
}

@media (max-width: 768px) {
  #toast-container {
    bottom: 72px; /* above tab bar */
  }
}

.toast {
  background: var(--text-primary);
  color: var(--bg-primary);
  padding: 12px 24px;
  border-radius: var(--radius);
  margin-top: 10px;
  font-size: 14px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-box {
  background: var(--bg-primary);
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  width: 100%;
  max-width: 440px;
  overflow: hidden;
}

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

.modal-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}

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

.modal-close:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 20px 24px;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.modal-actions {
  padding: 16px 24px 20px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid var(--border-light);
}