/* ============================================================
   ClearYourStocks CRM — Stylesheet
   Dark theme, green accent #10B981
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #080C14;
  --sidebar:   #0D1117;
  --card:      #111827;
  --card2:     #1A2235;
  --border:    rgba(255,255,255,0.07);
  --green:     #10B981;
  --blue:      #3B82F6;
  --amber:     #F59E0B;
  --red:       #EF4444;
  --purple:    #8B5CF6;
  --cyan:      #06B6D4;
  --text:      #F9FAFB;
  --muted:     #6B7280;
  --sidebar-w: 240px;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.6;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: #2D3748; border-radius: 4px; }

/* ---- Layout ---- */
.layout { display: flex; min-height: 100vh; }
.main { flex: 1; margin-left: var(--sidebar-w); min-height: 100vh; }
.page { padding: 28px 32px; }

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  position: fixed; top: 0; left: 0; height: 100vh;
  display: flex; flex-direction: column;
  z-index: 100; overflow-y: auto;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-brand > .fas { font-size: 26px; color: var(--green); }
.brand-name { font-weight: 700; font-size: 15px; color: var(--text); }
.brand-sub { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.sidebar-nav { flex: 1; padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px;
  color: var(--muted); text-decoration: none;
  font-size: 13.5px; font-weight: 500;
  transition: all 0.15s; position: relative;
}
.nav-item:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.nav-item.active { background: rgba(16,185,129,0.12); color: var(--green); }
.nav-item .fas { width: 18px; font-size: 14px; }
.nav-badge {
  margin-left: auto; background: var(--red);
  color: #fff; font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 10px;
}
.sidebar-footer { padding: 10px 10px 16px; border-top: 1px solid var(--border); }

/* ---- Topbar ---- */
.topbar {
  height: 56px; background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 32px; position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-size: 16px; font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

/* ---- Cards ---- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px 24px;
}
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 16px; color: var(--text); }

/* ---- Stat Cards ---- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 18px 20px;
  display: flex; align-items: center; gap: 14px;
}
.stat-icon {
  width: 44px; height: 44px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.stat-val { font-size: 24px; font-weight: 700; line-height: 1; }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  background: rgba(255,255,255,0.03);
  padding: 10px 14px; text-align: left;
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.6px; color: var(--muted);
  border-bottom: 1px solid var(--border);
}
tbody tr { border-bottom: 1px solid var(--border); transition: background 0.1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,0.02); }
tbody td { padding: 12px 14px; vertical-align: middle; }

/* ---- Badges ---- */
.badge {
  display: inline-block; padding: 3px 10px;
  border-radius: 20px; font-size: 11px; font-weight: 600;
  text-transform: capitalize; white-space: nowrap;
}
.potential-star { color: var(--amber); margin-left: 4px; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px; font-size: 13px;
  font-weight: 500; cursor: pointer; text-decoration: none;
  border: none; transition: all 0.15s; white-space: nowrap;
}
.btn-primary   { background: var(--green); color: #fff; }
.btn-primary:hover { background: #0ea472; }
.btn-blue      { background: var(--blue);  color: #fff; }
.btn-blue:hover { background: #2563eb; }
.btn-ghost     { background: rgba(255,255,255,0.06); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: rgba(255,255,255,0.10); }
.btn-danger    { background: rgba(239,68,68,0.15); color: var(--red); border: 1px solid rgba(239,68,68,0.3); }
.btn-danger:hover { background: rgba(239,68,68,0.25); }
.btn-wa        { background: #25D366; color: #fff; }
.btn-wa:hover  { background: #1da750; }
.btn-sm        { padding: 5px 10px; font-size: 12px; }
.btn-xs        { padding: 3px 8px; font-size: 11px; border-radius: 6px; }

/* ---- Forms ---- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }
label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; }
input, select, textarea {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px;
  color: var(--text); font-size: 14px;
  outline: none; transition: border-color 0.15s;
  font-family: inherit; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(16,185,129,0.12); }
textarea { resize: vertical; min-height: 100px; }
select option { background: #1A2235; }

/* ---- Pipeline ---- */
.pipeline { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.pipeline-step {
  padding: 4px 14px; border-radius: 20px; font-size: 11px; font-weight: 600;
  background: rgba(255,255,255,0.05); color: var(--muted); border: 1px solid transparent;
}
.pipeline-step.done { background: rgba(16,185,129,0.15); color: var(--green); border-color: rgba(16,185,129,0.3); }
.pipeline-step.current { background: rgba(59,130,246,0.2); color: var(--blue); border-color: rgba(59,130,246,0.4); }
.pipeline-arrow { color: var(--muted); font-size: 10px; }

/* ---- Timeline ---- */
.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-item { display: flex; gap: 14px; padding: 10px 0; position: relative; }
.timeline-item::before {
  content: ''; position: absolute; left: 15px; top: 36px;
  bottom: 0; width: 1px; background: var(--border);
}
.timeline-item:last-child::before { display: none; }
.timeline-icon {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; z-index: 1;
}
.timeline-body { flex: 1; }
.timeline-action { font-size: 13px; font-weight: 500; }
.timeline-detail { font-size: 12px; color: var(--muted); }
.timeline-time { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ---- Flash Messages ---- */
.flash {
  padding: 12px 18px; border-radius: 8px; margin-bottom: 20px;
  display: flex; align-items: center; gap: 10px; font-size: 14px;
}
.flash-success { background: rgba(16,185,129,0.12); border: 1px solid rgba(16,185,129,0.3); color: var(--green); }
.flash-error   { background: rgba(239,68,68,0.12);  border: 1px solid rgba(239,68,68,0.3);  color: var(--red); }
.flash-info    { background: rgba(59,130,246,0.12);  border: 1px solid rgba(59,130,246,0.3); color: var(--blue); }

/* ---- Filters / Search ---- */
.filter-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.filter-bar input, .filter-bar select { width: auto; }
.search-input { min-width: 220px; }

/* ---- Profile Header ---- */
.profile-header {
  display: flex; align-items: flex-start; gap: 18px;
  padding: 20px; background: var(--card2);
  border: 1px solid var(--border); border-radius: 12px; margin-bottom: 20px;
}
.avatar {
  width: 52px; height: 52px; border-radius: 50%;
  background: rgba(16,185,129,0.2); color: var(--green);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 700; flex-shrink: 0; text-transform: uppercase;
}
.profile-name { font-size: 18px; font-weight: 700; }
.profile-meta { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 14px; margin-top: 4px; }
.profile-meta a { color: var(--muted); text-decoration: none; }
.profile-meta a:hover { color: var(--green); }
.profile-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- Tabs ---- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab {
  padding: 8px 18px; font-size: 13px; font-weight: 500;
  color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent;
  cursor: pointer; transition: all 0.15s; margin-bottom: -1px;
}
.tab.active, .tab:hover { color: var(--green); border-bottom-color: var(--green); }

/* ---- Email ---- */
.email-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background 0.1s; text-decoration: none; color: var(--text);
}
.email-item:hover { background: rgba(255,255,255,0.03); }
.email-item.unread .email-subject { font-weight: 700; }
.email-item.unread::before { content: ''; width: 6px; height: 6px; background: var(--green); border-radius: 50%; flex-shrink: 0; margin-top: 6px; }
.email-from { font-size: 13px; font-weight: 600; }
.email-subject { font-size: 13px; }
.email-preview { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 400px; }
.email-time { font-size: 11px; color: var(--muted); margin-left: auto; white-space: nowrap; }

/* ---- Followup Cards ---- */
.followup-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: 14px 18px; margin-bottom: 10px;
  display: flex; align-items: center; gap: 14px;
}
.followup-card.overdue { border-left: 3px solid var(--red); }
.followup-card.today   { border-left: 3px solid var(--amber); }
.followup-card.future  { border-left: 3px solid var(--blue); }

/* ---- Misc ---- */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.text-muted { color: var(--muted); }
.text-green { color: var(--green); }
.text-red   { color: var(--red); }
.text-amber { color: var(--amber); }
.gap-8 { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.empty-state { text-align: center; padding: 40px; color: var(--muted); }
.empty-state i { font-size: 36px; margin-bottom: 10px; display: block; }
a { color: var(--green); }

/* ---- Login ---- */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}
.login-box {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 16px; padding: 40px; width: 100%; max-width: 420px;
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo i { font-size: 36px; color: var(--green); }
.login-logo h1 { font-size: 22px; font-weight: 700; margin-top: 8px; }
.login-logo p { color: var(--muted); font-size: 13px; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.25s; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .page { padding: 16px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .topbar { padding: 0 16px; }
  .profile-actions { display: none; }
}
