/* ============================================================
   Elixir CRM – Stylesheet
   ============================================================ */

:root {
  --sidebar-width: 240px;
  --sidebar-bg: #111118;
  --sidebar-border: rgba(255,255,255,0.06);
  --accent: #c9a84c;          /* warm gold */
  --accent-light: #f0d080;
  --text-muted-sidebar: rgba(255,255,255,0.45);
  --topbar-height: 56px;
}

/* ---- Reset / Base ----------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f4f5f7;
  color: #1a1a2e;
  font-size: 14.5px;
  min-height: 100vh;
}

/* ---- Wrapper ---------------------------------------------- */
#wrapper {
  min-height: 100vh;
}

/* ============================================================
   Sidebar
   ============================================================ */
#sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  flex-shrink: 0;
  transition: width .25s ease;
  z-index: 100;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 22px 20px 18px;
  border-bottom: 1px solid var(--sidebar-border);
}

.brand-icon {
  font-size: 22px;
  color: var(--accent);
}

.brand-name {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.sidebar-nav {
  list-style: none;
  padding: 16px 0;
  margin: 0;
  flex: 1;
}

.nav-section-label {
  padding: 14px 20px 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--text-muted-sidebar);
}

.nav-item a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 20px;
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: all .18s;
  font-size: 14px;
}

.nav-item a:hover {
  color: #fff;
  background: rgba(255,255,255,0.06);
}

.nav-item.active a {
  color: var(--accent-light);
  border-left-color: var(--accent);
  background: rgba(201,168,76,0.1);
}

.nav-item a i {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

/* ---- Sidebar footer --------------------------------------- */
.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 1;
  min-width: 0;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #111;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.user-name {
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  color: var(--text-muted-sidebar);
  font-size: 11px;
}

.sidebar-logout {
  color: rgba(255,255,255,0.4);
  font-size: 18px;
  text-decoration: none;
  padding: 4px;
  transition: color .18s;
}
.sidebar-logout:hover { color: #ff6b6b; }

/* ============================================================
   Content wrapper
   ============================================================ */
#content-wrapper {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ---- Top bar ---------------------------------------------- */
.topbar {
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid #e9ebee;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-size: 15px;
  font-weight: 600;
  color: #1a1a2e;
  flex: 1;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-toggle {
  background: none;
  border: none;
  font-size: 20px;
  color: #555;
  padding: 4px 6px;
  line-height: 1;
  display: none;
}

/* ---- Main content area ------------------------------------ */
.main-content {
  padding: 28px 28px 40px;
  flex: 1;
}

/* ============================================================
   Cards
   ============================================================ */
.card {
  border: 1px solid #e9ebee;
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.card-header {
  background: #fff;
  border-bottom: 1px solid #e9ebee;
  border-radius: 10px 10px 0 0 !important;
  padding: 14px 20px;
  font-weight: 600;
  font-size: 14px;
}

/* ---- Stat cards ------------------------------------------- */
.stat-card {
  background: #fff;
  border: 1px solid #e9ebee;
  border-radius: 10px;
  padding: 20px 22px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.stat-icon.gold   { background: #fdf3dc; color: var(--accent); }
.stat-icon.blue   { background: #dbeafe; color: #2563eb; }
.stat-icon.green  { background: #d1fae5; color: #059669; }
.stat-icon.red    { background: #fee2e2; color: #dc2626; }

.stat-body {}
.stat-number { font-size: 26px; font-weight: 700; line-height: 1; }
.stat-label  { font-size: 12px; color: #6b7280; margin-top: 4px; }

/* ============================================================
   Tables
   ============================================================ */
.table {
  font-size: 14px;
}

.table th {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #6b7280;
  background: #f9fafb;
  border-bottom: 2px solid #e9ebee;
}

.table tbody tr:hover { background: #f9fafb; }

.table td { vertical-align: middle; }

/* ============================================================
   Badges
   ============================================================ */
.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 6px;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn-gold {
  background: var(--accent);
  color: #111;
  border: none;
  font-weight: 600;
}

.btn-gold:hover {
  background: var(--accent-light);
  color: #111;
}

/* ============================================================
   Forms
   ============================================================ */
.form-label {
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 5px;
}

.form-control, .form-select {
  border-color: #d1d5db;
  font-size: 14px;
  border-radius: 7px;
  padding: 8px 12px;
}

.form-control:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(201,168,76,0.2);
}

/* ============================================================
   Calendar
   ============================================================ */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: #e9ebee;
  border: 1px solid #e9ebee;
  border-radius: 10px;
  overflow: hidden;
}

.cal-day-header {
  background: #f9fafb;
  text-align: center;
  padding: 10px 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6b7280;
}

.cal-day {
  background: #fff;
  min-height: 110px;
  padding: 8px;
  position: relative;
}

.cal-day.today { background: #fffbeb; }
.cal-day.other-month { background: #fafafa; }
.cal-day.other-month .cal-day-num { color: #d1d5db; }

.cal-day-num {
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 4px;
  display: inline-block;
  width: 26px;
  height: 26px;
  line-height: 26px;
  text-align: center;
  border-radius: 50%;
}

.cal-day.today .cal-day-num {
  background: var(--accent);
  color: #111;
}

.cal-event {
  display: block;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-decoration: none;
  font-weight: 500;
}

.cal-event.birthday  { background: #fde68a; color: #78350f; }
.cal-event.reunion   { background: #bfdbfe; color: #1e3a5f; }
.cal-event.rehearsal { background: #d9f99d; color: #365314; }
.cal-event.corporate { background: #e0e7ff; color: #3730a3; }
.cal-event.other     { background: #e5e7eb; color: #374151; }

.cal-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.cal-nav h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  min-width: 200px;
  text-align: center;
}

/* ============================================================
   Lead detail layout
   ============================================================ */
.lead-detail-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
}

@media (max-width: 900px) {
  .lead-detail-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   Login page
   ============================================================ */
.login-wrapper {
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  width: 380px;
  background: #fff;
  border-radius: 16px;
  padding: 40px 36px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo .brand-icon {
  font-size: 36px;
  color: var(--accent);
  display: block;
  margin-bottom: 6px;
}

.login-logo .brand-name {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #1a1a2e;
}

.login-subtitle {
  font-size: 13px;
  color: #6b7280;
  text-align: center;
  margin-bottom: 28px;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {
  #sidebar {
    position: fixed;
    left: -260px;
    transition: left .25s ease;
  }
  #sidebar.open { left: 0; }
  .sidebar-toggle { display: block; }
  .main-content { padding: 16px 16px 40px; }
}

/* ---- Google Calendar overlay events ---------------------- */
.gcal-event {
  border-left: 3px solid transparent;
  opacity: 0.9;
}

.gcal-event.internal {
  background: #e0e7ff;
  color: #3730a3;
  border-left-color: #6366f1;
}

.gcal-event.public {
  background: #dcfce7;
  color: #166534;
  border-left-color: #22c55e;
}

/* Conflict highlight */
.cal-day.has-conflict {
  background: #fff8f0 !important;
  outline: 2px solid #f59e0b;
  outline-offset: -2px;
}

.conflict-badge {
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 13px;
  cursor: help;
}

.cal-day { position: relative; }

/* Source dots */
.cal-source-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 3px;
  vertical-align: middle;
  flex-shrink: 0;
}

.cal-source-dot.crm      { background: #c9a84c; }
.cal-source-dot.internal { background: #6366f1; }
.cal-source-dot.public   { background: #22c55e; }

/* Legend dots */
.cal-legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.cal-legend-dot.crm      { background: #c9a84c; }
.cal-legend-dot.internal { background: #6366f1; }
.cal-legend-dot.public   { background: #22c55e; }

.gcal-event.conflict-example {
  background: #fff8f0;
  color: #92400e;
  border-left-color: #f59e0b;
}

/* ---- Page header helper ----------------------------------- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}

/* ---- Filter bar ------------------------------------------ */
.filter-bar {
  background: #fff;
  border: 1px solid #e9ebee;
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 18px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.filter-bar .form-control,
.filter-bar .form-select {
  max-width: 200px;
}
