/* Paradise Pools Australia CRM — Stylesheet */
/* Aesthetic: Clean coastal utility — deep navy, aqua accents, crisp whites */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --ocean:       #0077b6;
  --ocean-deep:  #023e8a;
  --aqua:        #00b4d8;
  --aqua-light:  #e0f7fb;
  --sand:        #f8f3ec;
  --white:       #ffffff;
  --text:        #1a2332;
  --text-muted:  #6b7a8d;
  --border:      #e2e8f0;
  --bg:          #f0f4f8;
  --sidebar-w:   240px;

  /* Stage colors */
  --s-new:       #64748b;
  --s-contacted: #0ea5e9;
  --s-qualified: #8b5cf6;
  --s-sitevisit: #f59e0b;
  --s-quoted:    #06b6d4;
  --s-accepted:  #10b981;
  --s-deposit:   #3b82f6;
  --s-csent:     #f97316;
  --s-csigned:   #22c55e;
  --s-ppa:       #6366f1;
}

html, body {
  height: 100%;
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

/* ─── Sidebar ───────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--ocean-deep);
  display: flex; flex-direction: column;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-header {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.logo-mark {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--aqua), var(--ocean));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}

.logo-title {
  display: block;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  color: white;
  line-height: 1.2;
}

.logo-sub {
  display: block;
  font-size: 0.72rem;
  color: rgba(255,255,255,0.4);
}

.sidebar-nav {
  padding: 0.75rem 0.75rem 0;
  display: flex; flex-direction: column; gap: 2px;
}

.nav-item {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  color: rgba(255,255,255,0.6);
  text-decoration: none;
  font-size: 0.875rem;
  transition: all 0.15s;
  position: relative;
}

.nav-item:hover { background: rgba(255,255,255,0.06); color: white; }
.nav-item.active { background: rgba(0,180,216,0.15); color: var(--aqua); }

.badge {
  margin-left: auto;
  background: #ef4444;
  color: white;
  border-radius: 99px;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.1rem 0.4rem;
  min-width: 18px; text-align: center;
}

.badge.hidden { display: none; }

.stage-filters {
  padding: 1rem 0.75rem 0;
  overflow-y: auto;
  flex: 1;
}

.filter-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.3);
  margin-bottom: 0.5rem;
  padding: 0 0.25rem;
}

.stage-filter {
  display: block;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  color: rgba(255,255,255,0.55);
  text-decoration: none;
  font-size: 0.8rem;
  transition: all 0.15s;
  margin-bottom: 1px;
}

.stage-filter:hover { background: rgba(255,255,255,0.06); color: white; }
.stage-filter.active { color: var(--aqua); background: rgba(0,180,216,0.1); }

.sidebar-footer {
  padding: 0.75rem 1rem;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex; align-items: center; gap: 0.5rem;
}

.user-info {
  flex: 1; display: flex; align-items: center; gap: 0.5rem;
  overflow: hidden;
}

.user-email {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.5);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.logout-btn {
  background: none; border: none; cursor: pointer;
  color: rgba(255,255,255,0.35);
  padding: 0.4rem; border-radius: 6px;
  transition: all 0.15s;
}
.logout-btn:hover { background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.7); }

/* ─── Mobile Header ─────────────────────────── */
.mobile-header {
  display: none;
  position: fixed; top: 0; left: 0; right: 0;
  height: 52px;
  background: var(--ocean-deep);
  align-items: center;
  padding: 0 1rem;
  gap: 1rem;
  z-index: 90;
}

.mobile-title {
  flex: 1;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  color: white;
}

.menu-btn {
  background: none; border: none; cursor: pointer;
  color: white; padding: 0.4rem;
}

/* ─── Main Content ──────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  padding: 0;
}

.view { display: none; padding: 2rem; }
.view.active { display: block; }

.view-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 1.75rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.view-title {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 1.6rem;
  color: var(--text);
  letter-spacing: -0.02em;
}

.view-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.header-actions {
  display: flex; align-items: center; gap: 0.75rem;
  flex-wrap: wrap;
}

/* ─── Buttons ───────────────────────────────── */
.btn-primary {
  display: inline-flex; align-items: center; gap: 0.4rem;
  background: var(--ocean);
  color: white; border: none;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  font-family: 'Syne', sans-serif;
  font-weight: 600; font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-primary:hover { background: var(--ocean-deep); transform: translateY(-1px); }

.btn-ghost {
  display: inline-flex; align-items: center; gap: 0.4rem;
  background: transparent; color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  font-size: 0.875rem; cursor: pointer;
  transition: all 0.15s;
}
.btn-ghost:hover { background: var(--bg); color: var(--text); }

.btn-danger {
  display: inline-flex; align-items: center; gap: 0.4rem;
  background: transparent; color: #ef4444;
  border: 1px solid #fca5a5;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  font-size: 0.875rem; cursor: pointer;
  transition: all 0.15s;
}
.btn-danger:hover { background: #fef2f2; }

/* ─── Stats Grid ────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: white;
  border-radius: 12px;
  padding: 1.25rem;
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}

.accent-aqua::before  { background: linear-gradient(90deg, var(--aqua), var(--ocean)); }
.accent-green::before { background: linear-gradient(90deg, #10b981, #059669); }
.accent-gold::before  { background: linear-gradient(90deg, #f59e0b, #d97706); }
.accent-red::before   { background: linear-gradient(90deg, #ef4444, #dc2626); }

.stat-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.5rem;
}

.stat-value {
  font-family: 'Syne', sans-serif;
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
}

.stat-sub {
  font-size: 0.75rem;
  color: #ef4444;
  margin-top: 0.25rem;
}

/* ─── Funnel ────────────────────────────────── */
.section-title {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
  margin-bottom: 1rem;
}

.funnel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
}

.funnel-item {
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}

.funnel-item:hover { border-color: var(--ocean); box-shadow: 0 2px 12px rgba(0,119,182,0.1); transform: translateY(-1px); }

.funnel-stage-name {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.funnel-count {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 1.6rem;
  color: var(--text);
}

/* ─── Stage Badge ───────────────────────────── */
.stage-badge {
  display: inline-flex; align-items: center;
  padding: 0.25rem 0.6rem;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}

/* ─── Kanban ────────────────────────────────── */
.kanban-scroll { overflow-x: auto; padding-bottom: 1rem; }

.kanban-board {
  display: flex; gap: 0.875rem;
  min-width: max-content;
  padding: 0.25rem 0.25rem 1rem;
}

.kanban-col {
  width: 230px; flex-shrink: 0;
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex; flex-direction: column;
}

.kanban-col-header {
  padding: 0.75rem 1rem;
  border-radius: 12px 12px 0 0;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.kanban-col-title {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 0.82rem;
}

.kanban-count {
  background: var(--bg);
  color: var(--text-muted);
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.1rem 0.5rem;
}

.kanban-cards {
  padding: 0.5rem;
  flex: 1;
  min-height: 80px;
  display: flex; flex-direction: column; gap: 0.4rem;
}

.kanban-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  cursor: pointer;
  transition: all 0.15s;
}

.kanban-card:hover {
  border-color: var(--ocean);
  box-shadow: 0 2px 8px rgba(0,119,182,0.12);
  transform: translateY(-1px);
}

.kanban-card-name {
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--text);
  margin-bottom: 0.2rem;
}

.kanban-card-suburb {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.kanban-card-quote {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ocean);
  margin-top: 0.35rem;
}

.kanban-card-followup {
  font-size: 0.7rem;
  color: #f59e0b;
  margin-top: 0.2rem;
  display: flex; align-items: center; gap: 0.25rem;
}

.kanban-card-followup.overdue { color: #ef4444; }

/* ─── Leads Table ───────────────────────────── */
.leads-table-wrap {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.leads-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.leads-table th {
  text-align: left;
  padding: 0.75rem 1rem;
  background: var(--bg);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.leads-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

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

.leads-table tr:hover td { background: #f8fafc; cursor: pointer; }

.lead-name { font-weight: 600; }
.lead-email { font-size: 0.78rem; color: var(--text-muted); }

.followup-due { color: #f59e0b; font-weight: 600; }
.followup-overdue { color: #ef4444; font-weight: 600; }

/* ─── Search ────────────────────────────────── */
.search-box {
  display: flex; align-items: center; gap: 0.5rem;
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 0.75rem;
  color: var(--text-muted);
}

.search-box input {
  border: none; outline: none;
  padding: 0.55rem 0;
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--text);
  width: 220px;
}

/* ─── Leads List (cards) ────────────────────── */
.leads-list {
  display: flex; flex-direction: column; gap: 0.5rem;
}

.lead-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  display: flex; align-items: center; gap: 1rem;
  cursor: pointer;
  transition: all 0.15s;
  flex-wrap: wrap;
}

.lead-card:hover {
  border-color: var(--ocean);
  box-shadow: 0 2px 12px rgba(0,119,182,0.08);
}

.lead-card-info { flex: 1; min-width: 180px; }
.lead-card-name { font-weight: 600; font-size: 0.9rem; }
.lead-card-meta { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.15rem; }
.lead-card-followup { font-size: 0.78rem; color: #f59e0b; font-weight: 600; }
.lead-card-followup.overdue { color: #ef4444; }

/* ─── Follow-up Tabs ────────────────────────── */
.followup-tabs {
  display: flex; gap: 0.4rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.fu-tab {
  padding: 0.45rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: white;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s;
}
.fu-tab:hover { border-color: var(--ocean); color: var(--ocean); }
.fu-tab.active { background: var(--ocean); color: white; border-color: var(--ocean); }

/* ─── Empty State ───────────────────────────── */
.empty-state {
  padding: 3rem;
  text-align: center;
  color: var(--text-muted);
}
.empty-icon { font-size: 2.5rem; margin-bottom: 0.75rem; }

/* ─── Modal ─────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: none; align-items: flex-start; justify-content: center;
  padding: 2rem 1rem;
  overflow-y: auto;
}
.modal-overlay.open { display: flex; }

.modal {
  background: white;
  border-radius: 16px;
  width: 100%;
  max-width: 680px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.2);
  overflow: hidden;
  animation: modalIn 0.25s cubic-bezier(0.34, 1.3, 0.64, 1);
  margin: auto;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(-20px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
}

.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); padding: 0.25rem; border-radius: 6px;
  transition: all 0.15s;
}
.modal-close:hover { background: var(--bg); color: var(--text); }

.modal-body {
  padding: 1.25rem 1.5rem;
  overflow-y: auto;
  max-height: calc(100vh - 220px);
}

.form-section {
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}
.form-section:last-child { border-bottom: none; margin-bottom: 0; }

.form-section-title {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.875rem;
}

.form-group { display: flex; flex-direction: column; gap: 0.35rem; }
.form-group.full-width { grid-column: 1 / -1; }

.form-group label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
}

.form-group input,
.form-group select,
.form-group textarea {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--text);
  background: white;
  transition: border-color 0.15s;
  outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--ocean);
  box-shadow: 0 0 0 3px rgba(0,119,182,0.1);
}

.form-group textarea { resize: vertical; }

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.75rem;
}

.footer-right { display: flex; gap: 0.75rem; }

/* ─── Stage History ─────────────────────────── */
.stage-history-list {
  display: flex; flex-direction: column; gap: 0.5rem;
  margin-top: 0.75rem;
}

.history-item {
  display: flex; align-items: center; gap: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.history-arrow { color: var(--aqua); font-size: 0.9rem; }
.history-stage { font-weight: 600; color: var(--text); }
.history-time { margin-left: auto; font-size: 0.72rem; white-space: nowrap; }

/* ─── Toast ─────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 1.5rem; right: 1.5rem;
  z-index: 999;
  display: flex; flex-direction: column; gap: 0.5rem;
}

.toast {
  background: var(--text);
  color: white;
  padding: 0.75rem 1.25rem;
  border-radius: 10px;
  font-size: 0.85rem;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  animation: toastIn 0.3s ease;
  max-width: 320px;
}

.toast.success { background: #059669; }
.toast.error   { background: #dc2626; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ─── Responsive ────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }

  .mobile-header { display: flex; }
  .main { margin-left: 0; padding-top: 52px; }
  .view { padding: 1.25rem; }

  .form-grid-2 { grid-template-columns: 1fr; }
  .modal-overlay { padding: 0.5rem; align-items: flex-end; }
  .modal { border-radius: 16px 16px 0 0; max-height: 92vh; }
  .modal-body { max-height: calc(92vh - 160px); }

  .leads-table th:nth-child(3),
  .leads-table td:nth-child(3),
  .leads-table th:nth-child(5),
  .leads-table td:nth-child(5),
  .leads-table th:nth-child(7),
  .leads-table td:nth-child(7) { display: none; }
}
