/* ============================================================
   ZATHURA SOLUTIONS – UNIVERSAL STYLESHEET
   Mobile-first, works on all screen sizes
   ============================================================ */

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Tokens ── */
:root {
  --primary:      #1a4fa0;
  --primary-dark: #0d2d6b;
  --primary-light:#3a6fd8;
  --bg:           #f0f4fb;
  --sidebar-bg:   #0d2d6b;
  --sidebar-text: #c8d8f8;
  --white:        #ffffff;
  --text:         #1e293b;
  --text-muted:   #64748b;
  --border:       #dde3f0;
  --danger:       #ef4444;
  --success:      #22c55e;
  --warning:      #f59e0b;
  --info:         #3b82f6;
  --shadow:       0 2px 16px rgba(26,79,160,0.10);
  --radius:       10px;
  --sidebar-w:    240px;
  --topbar-h:     58px;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, Arial, sans-serif;
  background: var(--bg); color: var(--text);
  min-height: 100vh; min-height: 100dvh;
  overflow-x: hidden;
}

/* ── Auth ── */
.auth-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; min-height: 100dvh;
  background: linear-gradient(135deg, #0d2d6b 0%, #1a4fa0 55%, #3a6fd8 100%);
  padding: 16px;
}
.auth-container { width: 100%; max-width: 400px; }
.auth-card {
  background: var(--white); border-radius: 16px;
  padding: 36px 28px; box-shadow: 0 8px 40px rgba(13,45,107,0.28);
}
.logo-wrap { text-align: center; margin-bottom: 18px; }
.logo { max-width: 150px; max-height: 80px; object-fit: contain; }
.auth-card h2 { text-align: center; font-size: 1.35rem; color: var(--primary-dark); margin-bottom: 4px; }
.subtitle { text-align: center; color: var(--text-muted); font-size: 0.86rem; margin-bottom: 22px; }
.form-error { color: var(--danger); font-size: 0.83rem; text-align: center; margin-bottom: 10px; min-height: 18px; }
.field-error { font-size: 0.75rem; color: var(--danger); margin-top: 3px; display: block; }
.input-icon-wrap { position: relative; }
.input-icon-wrap input { padding-right: 40px; }
.toggle-pw {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  cursor: pointer; color: var(--text-muted); user-select: none;
}

/* ── Form ── */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--text); margin-bottom: 5px; }
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%; padding: 10px 12px;
  border: 1.5px solid var(--border); border-radius: var(--radius);
  font-size: 0.92rem; color: var(--text); background: #f8faff;
  transition: border 0.18s; outline: none;
  /* prevent iOS zoom on focus */
  font-size: max(16px, 0.92rem);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--primary); background: #fff; }
.form-group textarea { resize: vertical; min-height: 76px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px; border-radius: var(--radius);
  font-size: 0.88rem; font-weight: 600; cursor: pointer; border: none;
  transition: all 0.18s; text-decoration: none; white-space: nowrap;
  line-height: 1.2; -webkit-tap-highlight-color: transparent;
}
.btn-primary   { background: var(--primary);  color: #fff; }
.btn-primary:hover   { background: var(--primary-dark); }
.btn-success   { background: var(--success);  color: #fff; }
.btn-success:hover   { background: #16a34a; }
.btn-danger    { background: var(--danger);   color: #fff; }
.btn-danger:hover    { background: #b91c1c; }
.btn-warning   { background: var(--warning);  color: #fff; }
.btn-warning:hover   { background: #d97706; }
.btn-secondary { background: #64748b;         color: #fff; }
.btn-secondary:hover { background: #475569; }
.btn-outline   { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover   { background: var(--primary); color: #fff; }
.btn-sm   { padding: 5px 11px; font-size: 0.78rem; border-radius: 7px; }
.btn-full { width: 100%; padding: 11px; font-size: 0.95rem; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; pointer-events: none; }

/* ── Layout ── */
.app-layout { display: flex; min-height: 100vh; min-height: 100dvh; }

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg); color: var(--sidebar-text);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; height: 100%; height: 100dvh;
  z-index: 500;
  transition: transform 0.26s cubic-bezier(.4,0,.2,1);
  will-change: transform;
}
.sidebar-logo {
  padding: 16px 14px 12px; border-bottom: 1px solid rgba(255,255,255,0.08);
  text-align: center; flex-shrink: 0;
}
.sidebar-logo img { max-width: 120px; max-height: 58px; object-fit: contain; }
.sidebar-user {
  padding: 11px 14px; border-bottom: 1px solid rgba(255,255,255,0.08); flex-shrink: 0;
}
.sidebar-user .user-name {
  font-weight: 700; font-size: 0.9rem; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user .user-role {
  font-size: 0.7rem; color: var(--sidebar-text); opacity: 0.6;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.sidebar-nav { flex: 1; padding: 8px 0; overflow-y: auto; overflow-x: hidden; }
.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 3px; }
.nav-section {
  padding: 8px 14px 3px; font-size: 0.66rem;
  text-transform: uppercase; letter-spacing: 1px; opacity: 0.4;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 16px; cursor: pointer;
  font-size: 0.87rem; color: var(--sidebar-text);
  transition: all 0.16s; border-left: 3px solid transparent;
  -webkit-tap-highlight-color: transparent;
  /* bigger tap target on mobile */
  min-height: 44px;
}
.nav-item:hover  { background: rgba(255,255,255,0.07); color: #fff; }
.nav-item.active { background: rgba(255,255,255,0.12); color: #fff; border-left-color: #3a6fd8; }
.nav-item .nav-icon { width: 17px; height: 17px; flex-shrink: 0; opacity: 0.75; transition: opacity 0.16s; }
.nav-item:hover .nav-icon, .nav-item.active .nav-icon { opacity: 1; }
.sidebar-footer {
  padding: 10px 12px; border-top: 1px solid rgba(255,255,255,0.08); flex-shrink: 0;
}
.sidebar-footer .btn-outline {
  width: 100%; color: var(--sidebar-text);
  border-color: rgba(255,255,255,0.2); background: transparent;
  padding: 8px 12px; font-size: 0.8rem;
}
.sidebar-footer .btn-outline:hover {
  background: rgba(255,255,255,0.1); color: #fff;
  border-color: rgba(255,255,255,0.4);
}

/* ── Sidebar overlay (mobile) ── */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.5); z-index: 499;
  -webkit-tap-highlight-color: transparent;
}
.sidebar-overlay.show { display: block; }

/* ── Main content ── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1; display: flex; flex-direction: column;
  min-height: 100vh; min-height: 100dvh; min-width: 0;
}

/* ── Topbar ── */
.topbar {
  background: var(--white); border-bottom: 1px solid var(--border);
  padding: 0 20px; height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 400; gap: 10px;
}
.topbar-left  { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.topbar-title {
  font-size: 1rem; font-weight: 700; color: var(--primary-dark);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ── Hamburger ── */
.hamburger {
  display: none; flex-direction: column; gap: 5px;
  cursor: pointer; padding: 8px; border: none; background: none;
  flex-shrink: 0; border-radius: 6px;
  -webkit-tap-highlight-color: transparent;
  min-width: 40px; min-height: 40px; align-items: center; justify-content: center;
}
.hamburger span {
  display: block; width: 20px; height: 2px;
  background: var(--primary-dark); border-radius: 2px; transition: all 0.22s;
}
.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── Page content ── */
.page-content { padding: 20px; flex: 1; }
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px; flex-wrap: wrap; gap: 10px;
}
.page-header h1 { font-size: 1.25rem; font-weight: 800; color: var(--primary-dark); }

/* ── Cards ── */
.card {
  background: var(--white); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; flex-wrap: wrap; gap: 8px;
}
.card-title { font-size: 0.95rem; font-weight: 700; color: var(--primary-dark); }

/* ── Stats grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px; margin-bottom: 18px;
}
.stat-card {
  background: var(--white); border-radius: var(--radius);
  padding: 16px 14px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 4px;
  border-left: 4px solid var(--primary);
}
.stat-card.green  { border-left-color: var(--success); }
.stat-card.orange { border-left-color: var(--warning); }
.stat-card.red    { border-left-color: var(--danger); }
.stat-card.blue   { border-left-color: var(--info); }
.stat-card.purple { border-left-color: #8b5cf6; }
.stat-label { font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; }
.stat-value { font-size: 1.8rem; font-weight: 800; color: var(--primary-dark); line-height: 1.1; }
.stat-sub   { font-size: 0.72rem; color: var(--text-muted); }

/* ── Table ── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 6px; }
table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
thead th {
  background: #f0f4fb; color: var(--primary-dark); font-weight: 700;
  padding: 10px 11px; text-align: left; border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
tbody td { padding: 9px 11px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8faff; }

/* ── Badges ── */
.badge {
  display: inline-block; padding: 3px 8px; border-radius: 20px;
  font-size: 0.72rem; font-weight: 600; white-space: nowrap;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info    { background: #dbeafe; color: #1e40af; }
.badge-gray    { background: #f1f5f9; color: #475569; }
.badge-purple  { background: #ede9fe; color: #5b21b6; }
.badge-orange  { background: #ffedd5; color: #9a3412; }

/* ── Modal ── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.5); z-index: 600;
  align-items: flex-end; justify-content: center;
  padding: 0;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--white); width: 100%; max-width: 520px;
  max-height: 92vh; max-height: 92dvh;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  border-radius: 18px 18px 0 0;
  padding: 20px 18px 28px;
  box-shadow: 0 -4px 32px rgba(0,0,0,0.18);
  /* slide up animation */
  animation: slideUp 0.22s ease;
}
@keyframes slideUp { from { transform: translateY(40px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px;
}
/* drag handle */
.modal::before {
  content: ''; display: block; width: 36px; height: 4px;
  background: var(--border); border-radius: 4px;
  margin: 0 auto 16px;
}
.modal-title { font-size: 1rem; font-weight: 700; color: var(--primary-dark); }
.modal-close {
  background: none; border: none; font-size: 1.4rem; cursor: pointer;
  color: var(--text-muted); line-height: 1; padding: 4px 8px; border-radius: 6px;
  min-width: 36px; min-height: 36px; display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--bg); }
.modal-footer { display: flex; gap: 10px; justify-content: stretch; margin-top: 16px; }
.modal-footer .btn { flex: 1; }

/* ── Search bar ── */
.search-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.search-bar input,
.search-bar select {
  padding: 9px 11px; border: 1.5px solid var(--border); border-radius: var(--radius);
  font-size: max(16px, 0.84rem); outline: none; background: #f8faff; min-width: 0;
}
.search-bar input { flex: 1; min-width: 140px; }
.search-bar select { min-width: 120px; }
.search-bar input:focus, .search-bar select:focus { border-color: var(--primary); }

/* ── Tabs ── */
.tabs {
  display: flex; gap: 0; border-bottom: 2px solid var(--border);
  margin-bottom: 16px; overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: 9px 16px; cursor: pointer; font-size: 0.86rem; font-weight: 600;
  color: var(--text-muted); border-bottom: 2px solid transparent;
  margin-bottom: -2px; transition: all 0.16s; white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Call / Approach panel ── */
.call-panel {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: #fff; border-radius: var(--radius); padding: 20px; margin-bottom: 16px;
}
.call-panel h3 { font-size: 0.9rem; margin-bottom: 4px; opacity: 0.85; }
.call-panel .lead-name { font-size: 1.3rem; font-weight: 800; margin-bottom: 2px; }
.call-panel .lead-phone { font-size: 0.9rem; opacity: 0.8; margin-bottom: 12px; }
.call-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.call-actions .btn {
  background: rgba(255,255,255,0.15); color: #fff;
  border: 1.5px solid rgba(255,255,255,0.3);
}
.call-actions .btn:hover { background: rgba(255,255,255,0.28); }

/* ── View toggle ── */
.view-toggle { display: flex; gap: 6px; margin-bottom: 16px; }
.view-toggle button {
  flex: 1; padding: 9px 14px; border: 1.5px solid var(--border);
  background: var(--white); border-radius: var(--radius);
  cursor: pointer; font-weight: 600; font-size: 0.84rem;
  transition: all 0.16s; color: var(--text-muted);
  -webkit-tap-highlight-color: transparent;
}
.view-toggle button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.view-toggle button:hover:not(.active) { border-color: var(--primary); color: var(--primary); }

/* ── Commission amount input ── */
.amount-input-wrap { position: relative; }
.amount-input-wrap::before {
  content: '₹'; position: absolute; left: 12px; top: 50%;
  transform: translateY(-50%); font-weight: 700; color: var(--text-muted); pointer-events: none;
}
.amount-input-wrap input { padding-left: 28px; }

/* ── Two-col grid ── */
.two-col-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ── Utility ── */
.hidden   { display: none !important; }
.text-muted { color: var(--text-muted); font-size: 0.82rem; }
.mt-10 { margin-top: 10px; }
.mt-20 { margin-top: 20px; }
.flex  { display: flex; }
.gap-8 { gap: 8px; }
.gap-10 { gap: 10px; }
.align-center    { align-items: center; }
.justify-between { justify-content: space-between; }

/* ── Conversion status ── */
.status-likely        { color: #16a34a; font-weight: 600; }
.status-notlikely     { color: #d97706; font-weight: 600; }
.status-hasproduct    { color: #7c3aed; font-weight: 600; }
.status-notinterested { color: #dc2626; font-weight: 600; }
.status-converted     { color: #059669; font-weight: 600; }
.status-callback      { color: #2563eb; font-weight: 600; }
.status-notanswered   { color: #64748b; font-weight: 600; }
.status-wrong         { color: #9f1239; font-weight: 600; }

/* ── Disabled lead row ── */
tr.lead-disabled td { opacity: 0.45; }
tr.lead-disabled td:last-child { opacity: 1; }

/* ── Nav icon ── */
.nav-icon {
  width: 17px; height: 17px; flex-shrink: 0;
  color: var(--sidebar-text); opacity: 0.75;
  transition: opacity 0.16s; display: inline-block; vertical-align: middle;
}
.nav-item:hover .nav-icon, .nav-item.active .nav-icon { opacity: 1; color: #fff; }
.sidebar-footer .nav-icon { color: var(--sidebar-text); opacity: 0.8; }

/* ============================================================
   RESPONSIVE BREAKPOINTS
   ============================================================ */

/* Tablet */
@media (max-width: 900px) {
  .two-col-grid { grid-template-columns: 1fr; }
}

/* Mobile */
@media (max-width: 768px) {
  /* Sidebar hidden off-screen */
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: 6px 0 28px rgba(0,0,0,0.3); }

  /* Full-width content */
  .main-content { margin-left: 0; }

  /* Show hamburger */
  .hamburger { display: inline-flex; }

  .topbar { padding: 0 14px; }
  .page-content { padding: 14px; }

  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-value { font-size: 1.5rem; }

  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: 1; }

  table { font-size: 0.8rem; }
  thead th, tbody td { padding: 8px 9px; }

  .page-header { flex-direction: column; align-items: flex-start; }

  /* Modal full-width bottom sheet on mobile */
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal { border-radius: 18px 18px 0 0; max-width: 100%; }

  .search-bar { gap: 6px; }
  .search-bar input, .search-bar select { font-size: 16px; } /* prevent iOS zoom */
}

/* Small phones */
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .auth-card { padding: 22px 16px; }
  .card { padding: 14px; }
  .topbar-title { font-size: 0.9rem; }

  /* Stack action buttons in table */
  td[style*="white-space:nowrap"] { white-space: normal !important; }
  td[style*="white-space:nowrap"] .btn { margin-bottom: 3px; }
}

/* Very small (320px) */
@media (max-width: 360px) {
  .stats-grid { grid-template-columns: 1fr; }
  .btn-sm { padding: 6px 8px; font-size: 0.75rem; }
}
