/* ============================================================
   LeadJet — Stylesheet
   Design: Clean Industrial · Dark Sidebar · Orange Accent
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Syne:wght@600;700;800&display=swap');

/* ── CSS Variables ─────────────────────────────────────────── */
:root {
  --sidebar-bg:      #111827;
  --sidebar-hover:   #1f2937;
  --sidebar-active:  #ea580c;
  --sidebar-text:    #9ca3af;
  --sidebar-text-on: #f9fafb;
  --sidebar-w:       240px;

  --accent:          #ea580c;
  --accent-dark:     #c2410c;
  --accent-light:    #fed7aa;

  --bg:              #f3f4f6;
  --card:            #ffffff;
  --border:          #e5e7eb;
  --border-light:    #f3f4f6;

  --text:            #111827;
  --text-2:          #374151;
  --text-muted:      #6b7280;
  --text-light:      #9ca3af;

  --success:         #059669;
  --success-bg:      #d1fae5;
  --danger:          #dc2626;
  --danger-bg:       #fee2e2;
  --warning:         #d97706;
  --warning-bg:      #fef3c7;
  --info:            #2563eb;
  --info-bg:         #dbeafe;

  --shadow-sm:       0 1px 2px rgba(0,0,0,.07);
  --shadow:          0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:       0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.05);
  --shadow-lg:       0 10px 15px rgba(0,0,0,.08), 0 4px 6px rgba(0,0,0,.05);

  --radius:          8px;
  --radius-sm:       4px;
  --radius-lg:       12px;

  --font-body:       'Outfit', sans-serif;
  --font-head:       'Syne', sans-serif;

  --transition:      150ms ease;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; font-size: 15px; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
img { max-width: 100%; }
input, textarea, select, button { font-family: var(--font-body); }

/* ── App Layout ────────────────────────────────────────────── */
.app {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
}
.sidebar-logo {
  padding: 20px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.sidebar-logo .brand {
  font-family: var(--font-head);
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.3;
}
.sidebar-logo .brand span {
  display: block;
  font-size: .65rem;
  font-weight: 400;
  color: var(--sidebar-text);
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-top: 2px;
}
.sidebar-logo .logo-icon {
  width: 38px; height: 38px;
  background: #fff;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 10px;
  padding: 4px;
  box-sizing: border-box;
}
.sidebar-logo .logo-icon img {
  width: 100%; height: 100%;
  object-fit: contain;
  display: block;
}

.sidebar-nav { flex: 1; padding: 10px 0; }
.nav-label {
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--sidebar-text);
  padding: 12px 18px 4px;
  font-weight: 600;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  color: var(--sidebar-text);
  font-size: .88rem;
  font-weight: 500;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all var(--transition);
  text-decoration: none;
}
.nav-item:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text-on);
}
.nav-item.active {
  background: rgba(234,88,12,.12);
  color: var(--sidebar-text-on);
  border-left-color: var(--accent);
}
.nav-item .nav-icon {
  width: 18px; height: 18px;
  opacity: .7;
  flex-shrink: 0;
}
.nav-item.active .nav-icon { opacity: 1; }

.sidebar-footer { padding: 12px 0; border-top: 1px solid rgba(255,255,255,.06); }
.nav-item.logout { color: #f87171; }
.nav-item.logout:hover { background: rgba(220,38,38,.1); color: #fca5a5; }

/* ── Main Content ───────────────────────────────────────────── */
.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Top Bar ─────────────────────────────────────────────────── */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0; z-index: 50;
  box-shadow: var(--shadow-sm);
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-title {
  font-family: var(--font-head);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-user {
  display: flex; align-items: center; gap: 8px;
  font-size: .82rem; color: var(--text-muted);
}
.topbar-user .avatar {
  width: 30px; height: 30px;
  background: var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 700; color: #fff;
}
.city-badge {
  font-size: .7rem; font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--info-bg);
  color: var(--info);
}

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

/* ── Page Content ────────────────────────────────────────────── */
.page-content {
  padding: 24px;
  flex: 1;
}

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; justify-content: space-between;
}
.card-title {
  font-family: var(--font-head);
  font-size: .95rem; font-weight: 700;
  color: var(--text);
}
.card-body { padding: 20px; }
.card-body.no-pad { padding: 0; }

/* ── Stat Cards ──────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 8px;
}
.stat-card .stat-label {
  font-size: .75rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-muted);
}
.stat-card .stat-value {
  font-family: var(--font-head);
  font-size: 1.7rem; font-weight: 800;
  color: var(--text); line-height: 1;
}
.stat-card .stat-value.accent { color: var(--accent); }
.stat-card .stat-value.green  { color: var(--success); }
.stat-card .stat-sub {
  font-size: .75rem; color: var(--text-muted);
}
.stat-card .stat-icon {
  font-size: 1.4rem; margin-bottom: 2px;
}

/* ── User Info Strip ─────────────────────────────────────────── */
.user-info-strip {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 20px;
  display: flex; flex-wrap: wrap; gap: 24px;
  box-shadow: var(--shadow);
}
.user-info-strip .info-item { display: flex; flex-direction: column; gap: 2px; }
.user-info-strip .info-label { font-size: .7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.user-info-strip .info-value { font-size: .9rem; color: var(--text); font-weight: 600; }

/* ── Tables ──────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .85rem; }
thead tr { background: #f9fafb; }
thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr {
  border-bottom: 1px solid var(--border-light);
  transition: background var(--transition);
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #fafafa; }
tbody td {
  padding: 10px 14px;
  color: var(--text-2);
  vertical-align: middle;
}
.total-row td {
  font-weight: 700;
  color: var(--text);
  background: #f9fafb;
  border-top: 2px solid var(--border);
}

/* Matrix table (leads by month) */
.matrix-table th { text-align: center; }
.matrix-table td { text-align: center; font-size: .8rem; color: var(--accent); font-weight: 600; }
.matrix-table .lead-label { text-align: left; font-weight: 500; }

/* ── Status Badges ───────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: .7rem; font-weight: 700;
  letter-spacing: .03em;
}
.badge-lead     { background: var(--info-bg);    color: var(--info); }
.badge-prospect { background: var(--warning-bg); color: var(--warning); }
.badge-client   { background: var(--success-bg); color: var(--success); }
.badge-inactive { background: var(--danger-bg);  color: var(--danger); }
.badge-active   { background: var(--success-bg); color: var(--success); }
.badge-karachi  { background: #ede9fe; color: #7c3aed; }
.badge-lahore   { background: #fce7f3; color: #be185d; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 18px;
  border: none; border-radius: var(--radius);
  font-family: var(--font-body); font-size: .85rem; font-weight: 600;
  cursor: pointer; transition: all var(--transition);
  white-space: nowrap; text-decoration: none;
}
.btn-sm { padding: 5px 12px; font-size: .78rem; }
.btn-lg { padding: 11px 24px; font-size: .95rem; }

.btn-primary  { background: var(--accent);   color: #fff; }
.btn-primary:hover  { background: var(--accent-dark); }
.btn-secondary { background: var(--bg); color: var(--text-2); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger   { background: var(--danger);   color: #fff; }
.btn-danger:hover  { background: #b91c1c; }
.btn-success  { background: var(--success);  color: #fff; }
.btn-success:hover  { background: #047857; }
.btn-ghost    { background: transparent; color: var(--accent); border: 1.5px solid var(--accent); }
.btn-ghost:hover { background: var(--accent-light); }

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

/* ── Forms ───────────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 20px;
}
.form-grid.single { grid-template-columns: 1fr; }
.form-grid.three  { grid-template-columns: 1fr 1fr 1fr; }

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

label {
  font-size: .78rem; font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .05em;
}
label .req { color: var(--danger); margin-left: 2px; }

input[type="text"],
input[type="email"],
input[type="date"],
input[type="password"],
input[type="number"],
input[type="tel"],
select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: .88rem;
  color: var(--text);
  background: #fff;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(234,88,12,.1);
}
input:read-only, input:disabled, select:disabled, textarea:read-only {
  background: #f9fafb; color: var(--text-muted); cursor: not-allowed;
}
textarea { resize: vertical; min-height: 60px; }
select { appearance: none; cursor: pointer; }

.field-hint { font-size: .72rem; color: var(--text-light); }
.field-err  { font-size: .72rem; color: var(--danger); }

/* ── Code Field ──────────────────────────────────────────────── */
.code-display {
  display: inline-flex; align-items: center; gap: 8px;
  background: #f9fafb;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  padding: 8px 14px;
  font-size: .88rem; font-weight: 600;
  color: var(--text-muted);
  letter-spacing: .05em;
}

/* ── Follow-up Section ───────────────────────────────────────── */
.followup-section { margin-top: 8px; }
.followup-row {
  display: grid;
  grid-template-columns: 36px 180px 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 10px 14px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  margin-bottom: 6px;
  background: #fafafa;
  transition: background var(--transition);
}
.followup-row:hover { background: #f5f5f5; }
.followup-row.locked {
  background: #f9fafb;
  border-color: var(--border-light);
  opacity: .75;
}
.followup-num {
  width: 32px; height: 32px;
  background: var(--sidebar-bg);
  color: #fff;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700;
  flex-shrink: 0; margin-top: 2px;
}
.followup-row.locked .followup-num {
  background: var(--text-muted);
}
.lock-badge {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: .68rem; color: var(--text-muted);
  margin-top: 8px;
}

/* ── Section Dividers ────────────────────────────────────────── */
.section-sep {
  display: flex; align-items: center; gap: 12px;
  margin: 24px 0 16px;
}
.section-sep .sep-label {
  font-family: var(--font-head);
  font-size: .82rem; font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.section-sep::before,
.section-sep::after {
  content: ''; flex: 1;
  height: 1px; background: var(--border);
}

/* ── Modals ──────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  display: none; align-items: center; justify-content: center;
  z-index: 200; padding: 20px;
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn .2s ease;
}
@keyframes modalIn {
  from { transform: scale(.95); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
.modal-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title {
  font-family: var(--font-head);
  font-size: 1rem; font-weight: 700;
}
.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 1.2rem; padding: 2px 6px;
  border-radius: 4px; transition: all var(--transition);
}
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-body  { padding: 20px; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
}

/* ── Toast Notifications ─────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 20px; right: 20px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 300;
}
.toast {
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: .85rem; font-weight: 500;
  box-shadow: var(--shadow-md);
  min-width: 240px; max-width: 380px;
  opacity: 0;
  transform: translateX(20px);
  transition: all .3s ease;
  border-left: 4px solid;
}
.toast.show { opacity: 1; transform: translateX(0); }
.toast-success { background: #fff; color: var(--success); border-color: var(--success); }
.toast-error   { background: #fff; color: var(--danger);  border-color: var(--danger);  }
.toast-warning { background: #fff; color: var(--warning);  border-color: var(--warning);  }
.toast-info    { background: #fff; color: var(--info);    border-color: var(--info);    }

/* ── Login Page ──────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  position: relative;
  overflow: hidden;
}
.login-page::before {
  content: '';
  position: absolute; inset: 0;
  background: repeating-linear-gradient(
    90deg, rgba(234,88,12,.04) 0px, rgba(234,88,12,.04) 1px,
    transparent 1px, transparent 60px),
    repeating-linear-gradient(
    0deg, rgba(234,88,12,.04) 0px, rgba(234,88,12,.04) 1px,
    transparent 1px, transparent 60px);
}
.login-box {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 400px;
  padding: 36px 32px 28px;
  position: relative;
}
.login-logo {
  text-align: center; margin-bottom: 28px;
}
.login-logo .logo-img {
  display: block;
  max-width: 220px;
  width: 80%;
  height: auto;
  margin: 0 auto 10px;
}
.login-logo .sub {
  font-size: .8rem; color: var(--text-muted); margin-top: 2px;
}
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-form .btn { width: 100%; margin-top: 4px; }
.login-form input { padding: 11px 14px; font-size: .9rem; }
.login-error {
  background: var(--danger-bg); color: var(--danger);
  padding: 10px 14px; border-radius: var(--radius);
  font-size: .82rem; display: none;
}
.login-error.show { display: block; }

/* ── Sidebar Overlay (mobile) ────────────────────────────────── */
#sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 99;
}

/* ── Utility ─────────────────────────────────────────────────── */
.flex         { display: flex; }
.flex-center  { display: flex; align-items: center; }
.gap-8        { gap: 8px; }
.gap-12       { gap: 12px; }
.mb-4         { margin-bottom: 4px; }
.mb-8         { margin-bottom: 8px; }
.mb-16        { margin-bottom: 16px; }
.mb-20        { margin-bottom: 20px; }
.mb-24        { margin-bottom: 24px; }
.mt-16        { margin-top: 16px; }
.mt-20        { margin-top: 20px; }
.text-right   { text-align: right; }
.text-center  { text-align: center; }
.text-muted   { color: var(--text-muted); }
.text-sm      { font-size: .8rem; }
.font-bold    { font-weight: 700; }
.currency     { font-weight: 700; color: var(--success); }
.spinner      { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  text-align: center; padding: 40px 20px;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: 10px; }
.empty-state p { font-size: .88rem; }

/* ── Section Header Row ──────────────────────────────────────── */
.section-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; flex-wrap: wrap; gap: 10px;
}
.section-title {
  font-family: var(--font-head);
  font-size: 1rem; font-weight: 700; color: var(--text);
}

/* ── Filter Row ──────────────────────────────────────────────── */
.filter-row {
  display: flex; flex-wrap: wrap; gap: 10px;
  margin-bottom: 16px;
}
.filter-row select,
.filter-row input { width: auto; min-width: 140px; padding: 7px 12px; font-size: .82rem; }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 900px) {
  .form-grid.three { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  #sidebar-overlay.active { display: block; }
  .hamburger { display: flex; }
  .main { margin-left: 0; }
  .page-content { padding: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full-width { grid-column: 1; }
  .followup-row { grid-template-columns: 36px 1fr; }
  .followup-row .followup-date { grid-column: 2; }
  .followup-row .followup-status { grid-column: 1 / -1; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .modal { margin: 10px; max-height: 95vh; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .login-box { padding: 24px 18px 20px; }
}

/* ============================================================
   Skeleton loading screens (performance UX)
   ============================================================ */

@keyframes shimmer {
  0%   { background-position: -800px 0; }
  100% { background-position:  800px 0; }
}

.skeleton {
  display: inline-block;
  background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
  background-size: 800px 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: 4px;
  color: transparent !important;
  user-select: none;
}

.skeleton-stat {
  height: 2rem; width: 60px;
  display: block; border-radius: 6px;
}

.skeleton-row td {
  padding: 12px 14px !important;
}

.skeleton-cell {
  height: 14px; border-radius: 3px;
  display: block;
}

.skeleton-w-full { width: 100%; }
.skeleton-w-3q   { width: 75%;  }
.skeleton-w-half { width: 50%;  }
.skeleton-w-q    { width: 25%;  }

/* Clickable client code → opens follow-up history modal */
.code-link { cursor: pointer; font-weight: 600; }
.code-link code { color: var(--accent); }
.code-link:hover code { text-decoration: underline; }
