/* ================================================
   Elif Designs CRM - Stylesheet
   Aesthetic: Warm luxury editorial — cream, terracotta, deep brown
   ================================================ */

:root {
  --cream: #f9f5ef;
  --parchment: #f0e8d8;
  --terracotta: #c4704a;
  --terra-light: #e8916e;
  --terra-dark: #a05535;
  --brown-deep: #2d1f14;
  --brown-mid: #5a3e2b;
  --brown-light: #8c6a4e;
  --warm-gray: #9e8e80;
  --white: #ffffff;
  --border: #e2d5c3;
  --border-dark: #c9b99e;

  /* Status colors */
  --hot: #e05a2b;
  --warm: #e8a623;
  --cold: #5e9ec9;

  /* Follow-up */
  --overdue: #d63b3b;
  --today: #d97a0a;
  --upcoming: #3a9e6a;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 2px 12px rgba(45,31,20,0.08);
  --shadow-md: 0 4px 24px rgba(45,31,20,0.13);

  font-size: 15px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--cream);
  color: var(--brown-deep);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---- TOP NAV ---- */
.topnav {
  background: var(--brown-deep);
  color: var(--cream);
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 24px;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0,0,0,0.25);
}

.topnav-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.brand-logo {
  color: var(--terracotta);
  font-size: 18px;
}

.brand-name {
  font-family: 'Playfair Display', serif;
  font-size: 16px;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.brand-name em {
  font-style: normal;
  color: var(--warm-gray);
  font-size: 13px;
  margin-left: 4px;
  font-family: 'DM Sans', sans-serif;
}

.topnav-links {
  display: flex;
  gap: 4px;
  flex: 1;
}

.topnav-links a, .btn-nav {
  color: #c9b99e;
  text-decoration: none;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
  white-space: nowrap;
}

.topnav-links a:hover, .btn-nav:hover {
  background: rgba(255,255,255,0.08);
  color: var(--cream);
}

.topnav-links a.active, .btn-nav.active {
  background: var(--terracotta);
  color: var(--white);
}

.topnav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.btn-nav {
  color: #c9b99e;
  text-decoration: none;
}

.btn-add {
  background: var(--terracotta);
  color: var(--white);
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.15s;
}

.btn-add:hover { background: var(--terra-dark); }

.btn-logout {
  color: var(--warm-gray);
  text-decoration: none;
  font-size: 13px;
  padding: 6px 10px;
  transition: color 0.15s;
}

.btn-logout:hover { color: var(--terra-light); }

/* ---- FLASH MESSAGES ---- */
.flash {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 500;
  gap: 12px;
}

.flash-success { background: #d1f0e0; color: #1a6640; border-bottom: 2px solid #3a9e6a; }
.flash-error   { background: #fde8e8; color: #8b1a1a; border-bottom: 2px solid #d63b3b; }
.flash-info    { background: #fef3e0; color: #7a4f00; border-bottom: 2px solid #e8a623; }

.flash button {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: inherit;
  opacity: 0.6;
  line-height: 1;
}

/* ---- MAIN CONTENT ---- */
.main-content {
  flex: 1;
  padding: 24px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

/* ---- PAGE HEADER ---- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-title {
  font-family: 'Playfair Display', serif;
  font-size: 24px;
  color: var(--brown-deep);
}

/* ---- DASHBOARD STATS ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  box-shadow: var(--shadow);
  transition: transform 0.15s, box-shadow 0.15s;
  text-decoration: none;
  color: inherit;
  display: block;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-number {
  font-size: 36px;
  font-weight: 600;
  font-family: 'Playfair Display', serif;
  line-height: 1.1;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--warm-gray);
  font-weight: 500;
}

.stat-hot    .stat-number { color: var(--hot); }
.stat-warm   .stat-number { color: var(--warm); }
.stat-cold   .stat-number { color: var(--cold); }
.stat-today  .stat-number { color: var(--today); }
.stat-overdue .stat-number { color: var(--overdue); }
.stat-closed .stat-number { color: var(--upcoming); }
.stat-total  .stat-number { color: var(--terracotta); }

/* ---- TWO COLUMN LAYOUT (LEADS PAGE) ---- */
.crm-layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 20px;
  align-items: start;
}

/* ---- LEAD LIST (LEFT PANEL) ---- */
.leads-panel {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: calc(100vh - 120px);
  display: flex;
  flex-direction: column;
}

.leads-panel-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.leads-panel-header h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--brown-mid);
  margin-bottom: 10px;
}

.search-box {
  display: flex;
  gap: 6px;
}

.search-box input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--cream);
  font-family: inherit;
  color: var(--brown-deep);
}

.search-box input:focus {
  outline: none;
  border-color: var(--terracotta);
}

.search-box button {
  padding: 8px 12px;
  background: var(--terracotta);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
}

.filter-row {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.filter-row select {
  flex: 1;
  min-width: 100px;
  padding: 6px 8px;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-sm);
  font-size: 12px;
  background: var(--cream);
  color: var(--brown-deep);
  font-family: inherit;
}

.filter-row select:focus { outline: none; border-color: var(--terracotta); }

.filter-row .btn-filter {
  padding: 6px 10px;
  background: var(--brown-deep);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
}

.leads-list {
  overflow-y: auto;
  flex: 1;
}

.lead-item {
  display: block;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: background 0.1s;
}

.lead-item:hover  { background: var(--cream); }
.lead-item.active { background: var(--parchment); border-left: 3px solid var(--terracotta); }

.lead-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.lead-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--brown-deep);
}

.lead-phone {
  font-size: 12px;
  color: var(--warm-gray);
  margin-bottom: 4px;
}

.lead-item-bottom {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ---- BADGES ---- */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.badge-Hot    { background: #fde8df; color: var(--hot); }
.badge-Warm   { background: #fef6e0; color: var(--warm); }
.badge-Cold   { background: #e4f0f9; color: var(--cold); }

.followup-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-overdue  { background: var(--overdue); }
.dot-today    { background: var(--today); }
.dot-upcoming { background: var(--upcoming); }

/* ---- LEAD DETAIL (RIGHT PANEL) ---- */
.detail-panel {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.detail-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 40px;
  color: var(--warm-gray);
  text-align: center;
  gap: 12px;
}

.detail-empty .icon { font-size: 48px; }
.detail-empty p { font-size: 14px; }

.detail-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.detail-name {
  font-family: 'Playfair Display', serif;
  font-size: 22px;
  color: var(--brown-deep);
  margin-bottom: 4px;
}

.detail-phone {
  color: var(--warm-gray);
  font-size: 14px;
  margin-bottom: 8px;
}

.action-btns {
  display: flex;
  gap: 8px;
}

.btn-wa {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: #25d366;
  color: white;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}

.btn-call {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--brown-deep);
  color: white;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}

.detail-body {
  padding: 20px 24px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.detail-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field-group label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--warm-gray);
  font-weight: 600;
  margin-bottom: 5px;
}

.field-group select,
.field-group input,
.field-group textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  background: var(--cream);
  color: var(--brown-deep);
  transition: border-color 0.15s;
}

.field-group select:focus,
.field-group input:focus,
.field-group textarea:focus {
  outline: none;
  border-color: var(--terracotta);
}

.field-group textarea { resize: vertical; min-height: 60px; }

.btn-save {
  padding: 9px 20px;
  background: var(--terracotta);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
  width: 100%;
}

.btn-save:hover { background: var(--terra-dark); }

/* ---- FOLLOW-UP ---- */
.followup-indicator {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 20px;
  font-weight: 600;
}

.fi-overdue  { background: #fde8e8; color: var(--overdue); }
.fi-today    { background: #fff3e0; color: var(--today); }
.fi-upcoming { background: #e8f7f0; color: var(--upcoming); }

/* ---- NOTES SECTION ---- */
.notes-section {
  padding: 0 24px 24px;
  border-top: 1px solid var(--border);
  grid-column: 1 / -1;
}

.notes-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--warm-gray);
  padding: 16px 0 12px;
}

.note-add {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.note-add textarea {
  flex: 1;
  padding: 9px 12px;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  background: var(--cream);
  resize: none;
  height: 70px;
}

.note-add textarea:focus {
  outline: none;
  border-color: var(--terracotta);
}

.btn-note {
  padding: 9px 16px;
  background: var(--brown-deep);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  align-self: flex-end;
  white-space: nowrap;
}

.notes-timeline {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 300px;
  overflow-y: auto;
}

.note-item {
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}

.note-text {
  font-size: 13px;
  color: var(--brown-deep);
  line-height: 1.5;
  margin-bottom: 4px;
}

.note-time {
  font-size: 11px;
  color: var(--warm-gray);
}

/* ---- FORMS ---- */
.form-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  max-width: 520px;
  box-shadow: var(--shadow);
}

.form-card .field-group { margin-bottom: 16px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.btn-submit {
  padding: 11px 28px;
  background: var(--terracotta);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}

.btn-submit:hover { background: var(--terra-dark); }

.btn-secondary {
  padding: 11px 20px;
  background: var(--cream);
  color: var(--brown-mid);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
  display: inline-block;
}

/* ---- DASHBOARD RECENT TABLE ---- */
.section-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.section-card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--brown-mid);
}

.section-card-link {
  font-size: 12px;
  color: var(--terracotta);
  text-decoration: none;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  background: var(--cream);
  padding: 10px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--warm-gray);
  border-bottom: 1px solid var(--border);
}

td {
  padding: 12px 16px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  color: var(--brown-deep);
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--cream); }

td a { color: var(--terracotta); text-decoration: none; font-weight: 500; }
td a:hover { text-decoration: underline; }

/* ---- BULK UPLOAD ---- */
.upload-area {
  border: 2px dashed var(--border-dark);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  margin-bottom: 16px;
}

.upload-area:hover,
.upload-area.dragover {
  border-color: var(--terracotta);
  background: var(--parchment);
}

.upload-area input[type=file] {
  display: none;
}

.upload-area .upload-icon { font-size: 40px; margin-bottom: 10px; }
.upload-area p { color: var(--warm-gray); font-size: 14px; }
.upload-area strong { color: var(--terracotta); }

.upload-summary {
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
}

.upload-summary table { font-size: 14px; }

/* ---- LOGIN ---- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--brown-deep);
  padding: 24px;
}

.login-card {
  background: var(--white);
  border-radius: 16px;
  padding: 48px 40px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

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

.login-logo .logo-mark {
  display: inline-block;
  width: 52px;
  height: 52px;
  background: var(--brown-deep);
  border-radius: 14px;
  line-height: 52px;
  font-size: 24px;
  margin-bottom: 12px;
}

.login-logo h1 {
  font-family: 'Playfair Display', serif;
  font-size: 22px;
  color: var(--brown-deep);
}

.login-logo p {
  font-size: 13px;
  color: var(--warm-gray);
  margin-top: 4px;
}

.login-field {
  margin-bottom: 16px;
}

.login-field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--warm-gray);
  margin-bottom: 6px;
}

.login-field input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  background: var(--cream);
  color: var(--brown-deep);
  transition: border-color 0.15s;
}

.login-field input:focus {
  outline: none;
  border-color: var(--terracotta);
}

.btn-login {
  width: 100%;
  padding: 12px;
  background: var(--brown-deep);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  margin-top: 8px;
  transition: background 0.15s;
}

.btn-login:hover { background: var(--terracotta); }

/* ---- UTILITY ---- */
.btn-danger {
  padding: 7px 14px;
  background: #fde8e8;
  color: var(--overdue);
  border: 1px solid #f5c0c0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
}

.address-text {
  font-size: 12px;
  color: var(--warm-gray);
}

.footer {
  text-align: center;
  padding: 16px;
  font-size: 12px;
  color: var(--warm-gray);
  border-top: 1px solid var(--border);
}

.text-muted { color: var(--warm-gray); font-size: 13px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.gap-8 { display: flex; gap: 8px; align-items: center; }

/* Download/bulk bar */
.action-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.btn-outline {
  padding: 8px 16px;
  background: var(--white);
  color: var(--brown-mid);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}

.btn-outline:hover {
  border-color: var(--terracotta);
  color: var(--terracotta);
}

/* responsive tweaks */
@media (max-width: 900px) {
  .crm-layout { grid-template-columns: 1fr; }
  .leads-panel { max-height: 400px; }
  .detail-body { grid-template-columns: 1fr; }
}
