/* ===== LeadFlow CRM — Custom Styles ===== */

:root {
  --brand-primary: #0B3D91;
  --brand-secondary: #1E5EFF;
  --success: #22C55E;
  --warning: #F59E0B;
  --danger: #EF4444;
  --surface: #F5F7FB;
}

* { -webkit-tap-highlight-color: transparent; }
::selection { background: rgba(30,94,255,.22); color: #0B3D91; }

html, body { background: var(--surface); }

/* ============ Buttons ============ */
.btn-primary {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .625rem 1rem;
  background: linear-gradient(180deg, #2769ff 0%, #0B3D91 100%);
  color: #fff; font-weight: 600; font-size: 13.5px;
  border-radius: 12px;
  box-shadow: 0 1px 0 rgba(255,255,255,.25) inset, 0 8px 24px -8px rgba(11,61,145,.5);
  transition: transform .25s ease, box-shadow .3s ease, filter .3s ease;
  border: 1px solid rgba(255,255,255,.12);
  letter-spacing: -0.005em;
}
.btn-primary:hover { transform: translateY(-1px); filter: brightness(1.05); box-shadow: 0 2px 0 rgba(255,255,255,.25) inset, 0 14px 32px -8px rgba(11,61,145,.55); }
.btn-primary:active { transform: translateY(0); }

.btn-ghost {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .55rem .9rem; font-size: 13px; font-weight: 600;
  color: #0F172A; background: rgba(255,255,255,.7);
  border: 1px solid rgba(226,232,240,.9);
  border-radius: 12px; backdrop-filter: blur(8px);
  transition: all .3s ease;
}
.btn-ghost:hover { background: #fff; border-color: rgba(30,94,255,.35); color: var(--brand-primary); transform: translateY(-1px); }

.btn-danger {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .55rem 1rem; font-size: 13.5px; font-weight: 600; color: #fff;
  background: linear-gradient(180deg, #f26666 0%, #EF4444 100%);
  border-radius: 12px; box-shadow: 0 8px 20px -8px rgba(239,68,68,.5);
  transition: all .3s ease;
}
.btn-danger:hover { transform: translateY(-1px); filter: brightness(1.05); }

/* ============ Card ============ */
.card {
  background: rgba(255,255,255,.75);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255,255,255,.7);
  border-radius: 16px;
  box-shadow: 0 1px 2px rgba(15,23,42,.04), 0 8px 24px rgba(15,23,42,.06);
  padding: 20px;
  transition: transform .3s cubic-bezier(.16,1,.3,1), box-shadow .3s ease;
}
.card:hover { box-shadow: 0 4px 12px rgba(15,23,42,.06), 0 20px 40px rgba(15,23,42,.08); }

/* ============ Form ============ */
.label { display:block; font-size:12px; font-weight:600; color:#334155; margin-bottom:6px; letter-spacing:-0.01em; }
.input {
  width:100%; padding:10px 12px; font-size:13.5px;
  background:#fff; color:#0F172A;
  border:1px solid #E2E8F0; border-radius:12px;
  transition: border-color .25s, box-shadow .25s, background .25s;
  font-family: inherit;
}
.input:focus { outline: none; border-color: var(--brand-secondary); box-shadow: 0 0 0 4px rgba(30,94,255,.15); }
.input::placeholder { color:#94A3B8; }
select.input { appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5'><polyline points='6 9 12 15 18 9'/></svg>"); background-repeat:no-repeat; background-position: right 12px center; padding-right: 34px; }

/* ============ Nav ============ */
.nav-link {
  display: flex; align-items: center; gap: .7rem;
  padding: .625rem .85rem;
  border-radius: 12px;
  color: #475569; font-weight: 500;
  transition: all .3s ease;
  position: relative;
}
.nav-link:hover { background: rgba(255,255,255,.7); color: var(--brand-primary); }
.nav-link.active {
  background: linear-gradient(180deg,#fff, rgba(238,243,255,.9));
  color: var(--brand-primary); font-weight: 600;
  box-shadow: 0 1px 2px rgba(15,23,42,.04), 0 8px 20px rgba(11,61,145,.08);
  border: 1px solid rgba(30,94,255,.15);
}
.nav-link.active::before {
  content:''; position:absolute; left:0; top:8px; bottom:8px; width:3px;
  background: linear-gradient(180deg, var(--brand-secondary), var(--brand-primary));
  border-radius: 3px;
}

/* ============ Stat card ============ */
.stat {
  position: relative; overflow: hidden;
  background: #fff;
  border: 1px solid rgba(226,232,240,.8);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 1px 2px rgba(15,23,42,.04), 0 8px 24px rgba(15,23,42,.05);
  transition: transform .3s cubic-bezier(.16,1,.3,1), box-shadow .3s ease;
}
.stat:hover { transform: translateY(-3px); box-shadow: 0 4px 12px rgba(15,23,42,.06), 0 20px 40px rgba(15,23,42,.08); }
.stat .icon {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center;
  margin-bottom: 12px;
}
.stat .val { font-family: 'JetBrains Mono', ui-monospace, monospace; font-weight: 700; font-size: 26px; line-height: 1; letter-spacing: -0.02em; }
.stat .label { font-size: 11.5px; color: #64748B; font-weight: 500; letter-spacing: .02em; margin-bottom: 4px; text-transform: uppercase; }
.stat .foot { font-size: 11px; color: #94A3B8; margin-top: 6px; font-family: 'JetBrains Mono', monospace; }

/* ============ Table ============ */
#lead-table thead th { border-bottom: 1px solid #E2E8F0; font-weight: 600; font-size: 10.5px; }
#lead-table tbody tr { border-bottom: 1px solid rgba(226,232,240,.6); transition: background .2s ease; }
#lead-table tbody tr:hover { background: rgba(238,243,255,.55); }
#lead-table tbody td { padding: 14px 16px; vertical-align: middle; color:#0F172A; font-size:13px; }
#lead-table tbody tr:last-child { border-bottom: none; }

/* ============ Badge ============ */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 600; letter-spacing: .01em;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge::before { content:''; width:6px; height:6px; border-radius:50%; background: currentColor; }
.badge-gray  { color:#475569; background:#F1F5F9; border-color:#E2E8F0; }
.badge-orange{ color:#B45309; background:#FEF3C7; border-color:#FDE68A; }
.badge-blue  { color:#1E40AF; background:#DBEAFE; border-color:#BFDBFE; }
.badge-purple{ color:#6D28D9; background:#EDE9FE; border-color:#DDD6FE; }
.badge-green { color:#166534; background:#DCFCE7; border-color:#BBF7D0; }
.badge-yellow{ color:#854D0E; background:#FEF9C3; border-color:#FDE68A; }
.badge-red   { color:#B91C1C; background:#FEE2E2; border-color:#FECACA; }

/* ============ Icon Buttons ============ */
.icon-btn {
  width: 32px; height: 32px; display: grid; place-items: center;
  border-radius: 10px; color:#64748B; background: transparent;
  transition: all .25s ease;
  border: 1px solid transparent;
}
.icon-btn:hover { background: #fff; color: var(--brand-primary); border-color:#E2E8F0; box-shadow: 0 4px 12px rgba(15,23,42,.06); }
.icon-btn.danger:hover { color: var(--danger); border-color: rgba(239,68,68,.25); }
.icon-btn.call { color: var(--success); }
.icon-btn.call:hover { color: var(--success); background: rgba(34,197,94,.08); border-color: rgba(34,197,94,.3); }
.icon-btn.wa { color: #16A34A; }
.icon-btn.wa:hover { color: #16A34A; background: rgba(34,197,94,.1); border-color: rgba(34,197,94,.35); }

/* Inline phone actions in table WA column */
.phone-actions .icon-btn { border: 1px solid rgba(226,232,240,.7); background: #fff; }
.phone-actions .icon-btn { width: 26px; height: 26px; }
.phone-actions .icon-btn svg { width: 12px; height: 12px; }

/* ============ Backdrop close ============ */
.modal-backdrop, .drawer-backdrop, .confirm-backdrop { cursor: pointer; }

/* ============ Toast ============ */
.toast {
  pointer-events: auto;
  min-width: 260px; max-width: 380px;
  padding: 12px 14px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 4px 12px rgba(15,23,42,.08), 0 20px 40px rgba(15,23,42,.12);
  display: flex; align-items: flex-start; gap: 10px;
  border-left: 4px solid var(--brand-secondary);
  animation: toastIn .35s cubic-bezier(.16,1,.3,1) both;
  font-size: 13px;
}
.toast.success { border-left-color: var(--success); }
.toast.warning { border-left-color: var(--warning); }
.toast.danger  { border-left-color: var(--danger); }
.toast .t-title { font-weight: 700; color:#0F172A; }
.toast .t-msg { color:#475569; font-size:12px; margin-top:2px; }
@keyframes toastIn { from { opacity:0; transform: translateX(20px); } to { opacity:1; transform: translateX(0); } }
@keyframes toastOut { to { opacity:0; transform: translateX(20px); } }
.toast.out { animation: toastOut .3s ease forwards; }

/* ============ Skeleton ============ */
.skeleton {
  background: linear-gradient(90deg, #eef2f7 0%, #f8fafc 50%, #eef2f7 100%);
  background-size: 1000px 100%;
  animation: shimmer 1.4s linear infinite;
  border-radius: 8px;
}

/* ============ Sidebar mobile ============ */
#sidebar.mobile-open {
  display: flex !important; position: fixed; top: 0; left: 0; z-index: 40;
  background: rgba(255,255,255,.95); backdrop-filter: blur(20px);
  border-right: 1px solid rgba(226,232,240,.9);
  animation: slideInLeft .3s ease-out both;
}
@keyframes slideInLeft { from { transform: translateX(-100%); } to { transform: translateX(0); } }

/* ============ Scrollbar ============ */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(148,163,184,.4); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(100,116,139,.6); background-clip: padding-box; }

/* ============ Print ============ */
@media print {
  aside, header, .btn-primary, .btn-ghost, #modal-lead, #drawer-lead, #toast-container, #reminder-card { display: none !important; }
  body { background: white; }
}

/* Ensure react bundle doesn't show anything */
#root { display: none; }

/* ============ Modal Sheet (Mobile-friendly) ============ */
.modal-sheet {
  border-radius: 20px 20px 0 0;
}
@media (min-width: 640px) {
  .modal-sheet { border-radius: 16px; }
}

/* Drag handle indicator on mobile */
@media (max-width: 639px) {
  .modal-sheet::before {
    content: '';
    position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
    width: 40px; height: 4px; border-radius: 999px;
    background: #CBD5E1;
    z-index: 20;
  }
  .modal-sheet { padding-top: 6px; animation: sheetIn .32s cubic-bezier(.16,1,.3,1) both; }
  @keyframes sheetIn { from { transform: translateY(100%); } to { transform: translateY(0); } }

  /* Bigger touch targets on mobile */
  .input {
    padding: 13px 14px;
    font-size: 15px;
    border-radius: 12px;
  }
  select.input { padding-right: 38px; }
  .label { font-size: 12.5px; margin-bottom: 7px; }
  .btn-primary { padding: 12px 16px; font-size: 14px; }
  .btn-ghost { padding: 11px 16px; font-size: 13.5px; }
}

/* Drawer: mobile bottom sheet, desktop right slide */
@media (max-width: 639px) {
  .drawer-panel {
    left: 0 !important; right: 0 !important; top: auto !important;
    height: 92vh !important; width: 100% !important;
    border-radius: 20px 20px 0 0;
    animation: sheetIn .32s cubic-bezier(.16,1,.3,1) both !important;
  }
  .drawer-panel::before {
    content:''; position: sticky; top: 0; display:block;
    width: 40px; height: 4px; border-radius: 999px;
    background: #CBD5E1;
    margin: 8px auto 0;
  }
}

/* ============ Timeline ============ */
.timeline { position: relative; padding-left: 26px; }
.timeline::before {
  content:''; position:absolute; left: 11px; top: 4px; bottom: 4px;
  width: 2px; background: linear-gradient(180deg, rgba(30,94,255,.2), rgba(30,94,255,.05));
  border-radius: 2px;
}
.timeline-item { position: relative; padding-bottom: 14px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot {
  position: absolute; left: -26px; top: 2px;
  width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center; color: #fff;
  box-shadow: 0 0 0 3px #fff, 0 2px 6px rgba(15,23,42,.15);
}
.timeline-dot.call { background: linear-gradient(180deg, #22C55E, #16A34A); }
.timeline-dot.wa { background: linear-gradient(180deg, #10B981, #059669); }
.timeline-dot.note { background: linear-gradient(180deg, #1E5EFF, #0B3D91); }
.timeline-dot.appointment { background: linear-gradient(180deg, #F59E0B, #B45309); }

.activity-type-btn {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 12px 8px; border-radius: 12px;
  background: #F8FAFC; border: 1.5px solid transparent;
  color: #475569; font-size: 12px; font-weight: 600;
  transition: all .25s ease; cursor: pointer;
}
.activity-type-btn:hover { background: #fff; border-color: rgba(30,94,255,.25); color: var(--brand-primary); }
.activity-type-btn.selected { background: linear-gradient(180deg,#EEF3FF,#DCE6FF); border-color: var(--brand-secondary); color: var(--brand-primary); box-shadow: 0 0 0 4px rgba(30,94,255,.1); }

/* Bottom safe area for iPhone notch */
@supports (padding: max(0px)) {
  .modal-sheet > div:last-child { padding-bottom: max(14px, env(safe-area-inset-bottom)); }
}
