/* =========================================
   Las Lomas Serenas CRM – Custom Styles
   ========================================= */

:root {
  --sidebar-bg: #0D1F13;
  --sidebar-header-bg: #091510;
  --sidebar-text: #86A893;
  --sidebar-text-hover: #E8F5EC;
  --sidebar-active-bg: rgba(45,122,66,0.22);
  --sidebar-active-text: #5DC47A;
  --sidebar-active-border: #2D7A42;
  --sidebar-width: 240px;
  --primary: #2D7A42;
  --primary-dark: #1B5E2E;
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --purple: #8B5CF6;
  --cyan: #06B6D4;
  --content-bg: #F0F4F1;
  --card-bg: #FFFFFF;
  --border: #D9E5DB;
  --text-main: #1A2E1E;
  --text-muted: #5A7A62;
}

/* ── Reset & Base ── */
* { box-sizing: border-box; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--content-bg);
  color: var(--text-main);
  margin: 0;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  z-index: 1050;
  transition: transform 0.3s ease;
}

.sidebar-header {
  background: var(--sidebar-header-bg);
  padding: 20px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-logo { display: flex; align-items: center; gap: 12px; }

.logo-icon {
  width: 38px; height: 38px;
  background: var(--primary);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 16px;
  flex-shrink: 0;
}

.logo-title { display: block; color: #F1F5F9; font-weight: 700; font-size: 15px; line-height: 1.2; }
.logo-sub   { display: block; color: var(--sidebar-text); font-size: 11px; }

.sidebar-toggle {
  background: none; border: none; color: var(--sidebar-text);
  font-size: 16px; cursor: pointer; padding: 4px;
}

/* ── Sidebar Nav ── */
.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #475569;
  padding: 0 8px 8px;
  margin-top: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
  transition: all 0.2s;
  margin-bottom: 2px;
  border-left: 3px solid transparent;
}

.nav-item:hover {
  background: rgba(255,255,255,0.06);
  color: var(--sidebar-text-hover);
}

.nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  border-left-color: var(--sidebar-active-border);
  font-weight: 600;
}

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

/* ── Sidebar Footer ── */
.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  gap: 10px;
}

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

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

.user-details { min-width: 0; }
.user-name { display: block; color: #F1F5F9; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { display: block; color: var(--sidebar-text); font-size: 11px; }

.logout-btn {
  color: #64748B; font-size: 16px;
  text-decoration: none;
  padding: 6px;
  border-radius: 6px;
  transition: color 0.2s;
  flex-shrink: 0;
}
.logout-btn:hover { color: var(--danger); }

/* ── Main Content ── */
.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  background: var(--content-bg);
}

.page-header {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 18px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.page-header h4 { margin: 0; font-weight: 700; font-size: 18px; color: var(--text-main); }
.page-header .text-muted { font-size: 13px; }

.page-body { padding: 24px 28px; }

/* ── Stat Cards ── */
.stat-card {
  background: #fff;
  border-radius: 12px;
  padding: 20px 24px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: box-shadow 0.2s;
}
.stat-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.08); }

.stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.stat-icon.blue   { background: rgba(45,122,66,0.12);   color: #2D7A42; }
.stat-icon.green  { background: rgba(16,185,129,0.12);  color: #10B981; }
.stat-icon.orange { background: rgba(245,158,11,0.12);  color: #F59E0B; }
.stat-icon.red    { background: rgba(239,68,68,0.12);   color: #EF4444; }
.stat-icon.purple { background: rgba(139,92,246,0.12);  color: #8B5CF6; }
.stat-icon.cyan   { background: rgba(6,182,212,0.12);   color: #06B6D4; }

.stat-value { font-size: 26px; font-weight: 800; color: var(--text-main); line-height: 1; }
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ── Cards ── */
.crm-card {
  background: #fff;
  border-radius: 12px;
  border: 1px solid var(--border);
  overflow: hidden;
}
.crm-card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.crm-card-header h6 { margin: 0; font-weight: 700; font-size: 15px; }
.crm-card-body { padding: 20px; }

/* ── Tables ── */
.crm-table { width: 100%; border-collapse: collapse; }
.crm-table th {
  background: #F8FAFC;
  padding: 11px 16px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.crm-table td {
  padding: 13px 16px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-main);
  vertical-align: middle;
}
.crm-table tbody tr:hover { background: #F8FAFC; }
.crm-table tbody tr:last-child td { border-bottom: none; }

/* ── Badges ── */
.stage-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-identity           { background: rgba(45,122,66,0.12);   color: #2D7A42; }
.badge-contacted          { background: rgba(245,158,11,0.12);  color: #b45309; }
.badge-lead               { background: rgba(6,182,212,0.12);   color: #0E7490; }
.badge-prospect           { background: rgba(139,92,246,0.12);  color: #7C3AED; }
.badge-qualified_prospect { background: rgba(234,88,12,0.12);   color: #c2410c; }
.badge-unanswered        { background: rgba(16,185,129,0.12);  color: #059669; }
.badge-close             { background: rgba(16,185,129,0.12);  color: #059669; }
.badge-sale               { background: rgba(5,150,105,0.15);   color: #047857; }
.badge-upsell             { background: rgba(124,58,237,0.15);  color: #6D28D9; }
/* legacy slugs */
.badge-new            { background: rgba(45,122,66,0.12);   color: #2D7A42; }
.badge-visit_scheduled{ background: rgba(6,182,212,0.12);   color: #0E7490; }
.badge-offer_made     { background: rgba(139,92,246,0.12);  color: #7C3AED; }
.badge-closed_won     { background: rgba(16,185,129,0.12);  color: #059669; }
.badge-closed_lost    { background: rgba(239,68,68,0.12);   color: #DC2626; }

.badge-available { background: rgba(16,185,129,0.12);  color: #059669; }
.badge-reserved  { background: rgba(245,158,11,0.12);  color: #b45309; }
.badge-sold      { background: rgba(100,116,139,0.12); color: #475569; }

/* ── Pipeline Kanban ── */
.pipeline-filters {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 12px;
}
.pipeline-filters-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.pipeline-filters-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
}
.pipeline-filters-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.pipeline-filter-action {
  border: 1px solid var(--border);
  background: #F8FAFC;
  color: var(--text-main);
  font-size: 12px;
  font-weight: 600;
  border-radius: 7px;
  padding: 4px 9px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.pipeline-filter-action:hover {
  background: #E2E8F0;
}
.pipeline-filter-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.pipeline-filter-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: #F8FAFC;
  cursor: pointer;
  user-select: none;
}
.pipeline-filter-check {
  width: 13px;
  height: 13px;
  margin: 0;
  accent-color: var(--primary);
  cursor: pointer;
}
.pipeline-filter-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.pipeline-filter-name {
  font-size: 12px;
  color: var(--text-main);
  font-weight: 600;
}
.pipeline-filter-item:has(.pipeline-filter-check:not(:checked)) {
  opacity: 0.55;
}

.kanban-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.kanban-nav-dots {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.kanban-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid transparent;
  padding: 0;
  cursor: pointer;
  opacity: 0.35;
  transition: opacity 0.2s, transform 0.2s;
}
.kanban-dot:hover  { opacity: 0.7; transform: scale(1.2); }
.kanban-dot.active { opacity: 1;   transform: scale(1.3); border-color: rgba(0,0,0,0.15); }

.kanban-nav-arrows {
  display: flex;
  gap: 6px;
}
.kanban-arrow-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.15s, box-shadow 0.15s;
}
.kanban-arrow-btn:hover:not(:disabled)  { background: var(--primary); color: #fff; border-color: var(--primary); }
.kanban-arrow-btn:disabled { opacity: 0.3; cursor: default; }

.kanban-wrapper {
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  overflow-y: visible;
  padding-bottom: 12px;
}
.kanban-wrapper::-webkit-scrollbar { height: 7px; }
.kanban-wrapper::-webkit-scrollbar-track { background: #E2E8F0; border-radius: 4px; }
.kanban-wrapper::-webkit-scrollbar-thumb { background: #94A3B8; border-radius: 4px; }

.kanban-board {
  display: flex;
  gap: 12px;
  padding-bottom: 8px;
  min-width: max-content;
}

.kanban-col {
  flex: 0 0 200px;
  background: #F8FAFC;
  border-radius: 12px;
  border: 1px solid var(--border);
  overflow: hidden;
}

.kanban-col-header {
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.kanban-col-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 700;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.col-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.kanban-count {
  background: #E2E8F0;
  color: var(--text-muted);
  border-radius: 20px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
}

.kanban-cards { padding: 8px; display: flex; flex-direction: column; gap: 7px; min-height: 60px; }

.kanban-card {
  background: #fff;
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 9px 10px;
  cursor: grab;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.kanban-card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  border-color: #CBD5E1;
  transform: translateY(-1px);
}
.kanban-card.dragging {
  opacity: 0.4;
  cursor: grabbing;
  transform: scale(0.98);
}
.kanban-cards.drag-over {
  background: rgba(45,122,66,0.07);
  outline: 2px dashed var(--primary);
  outline-offset: -4px;
  border-radius: 8px;
}
.kanban-card-name { font-size: 13px; font-weight: 600; color: var(--text-main); }
.kanban-card-budget { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ── Funnel Bars ── */
.funnel-bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.funnel-bar-label { width: 140px; font-size: 13px; font-weight: 500; flex-shrink: 0; text-align: right; }
.funnel-bar-track { flex: 1; background: #E2E8F0; border-radius: 6px; height: 28px; overflow: hidden; }
.funnel-bar-fill { height: 100%; border-radius: 6px; transition: width 0.8s ease; display: flex; align-items: center; padding-left: 10px; }
.funnel-bar-count { font-size: 13px; font-weight: 700; margin-left: 8px; flex-shrink: 0; }

/* ── Stage Conversion ── */
.stage-conversion-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.stage-conversion-row:last-child {
  margin-bottom: 0;
}
.stage-conversion-name {
  width: 180px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  flex-shrink: 0;
}
.stage-conversion-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.stage-conversion-track {
  flex: 1;
  height: 12px;
  background: #E2E8F0;
  border-radius: 999px;
  overflow: hidden;
}
.stage-conversion-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.6s ease;
}
.stage-conversion-meta {
  width: 140px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
}
.stage-conversion-rate {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
}
.stage-conversion-count {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

/* ── Activity Timeline ── */
.activity-timeline { position: relative; }
.activity-item {
  display: flex;
  gap: 14px;
  padding-bottom: 20px;
  position: relative;
}
.activity-item:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 15px;
  top: 32px;
  bottom: 0;
  width: 2px;
  background: var(--border);
}
.activity-icon-wrap {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}
.activity-icon-wrap.call    { background: rgba(45,122,66,0.12);   color: #2D7A42; }
.activity-icon-wrap.email   { background: rgba(245,158,11,0.12);  color: #D97706; }
.activity-icon-wrap.visit   { background: rgba(139,92,246,0.12);  color: #7C3AED; }
.activity-icon-wrap.note    { background: rgba(16,185,129,0.12);  color: #059669; }
.activity-icon-wrap.task    { background: rgba(6,182,212,0.12);   color: #0E7490; }

.activity-body { flex: 1; }
.activity-title { font-size: 14px; font-weight: 600; color: var(--text-main); }
.activity-meta  { font-size: 12px; color: var(--text-muted); }
.activity-desc  { font-size: 13px; color: #475569; margin-top: 4px; }

/* ── Apartment Cards ── */
.apt-card {
  background: #fff;
  border-radius: 12px;
  border: 1px solid var(--border);
  overflow: hidden;
  transition: all 0.2s;
}
.apt-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.1); transform: translateY(-2px); }
.apt-card-thumb {
  height: 130px;
  display: flex; align-items: center; justify-content: center;
  font-size: 3rem;
}
.apt-card-body { padding: 14px 16px; }
.apt-card-unit { font-size: 15px; font-weight: 700; }
.apt-card-price { font-size: 16px; font-weight: 800; color: var(--primary); }
.apt-card-meta { font-size: 12px; color: var(--text-muted); }

/* ── Buttons ── */
.btn-crm {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  text-decoration: none;
}
.btn-crm-primary { background: var(--primary); color: #fff; }
.btn-crm-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-crm-light { background: #F1F5F9; color: var(--text-main); border: 1px solid var(--border); }
.btn-crm-light:hover { background: #E2E8F0; }
.btn-crm-danger { background: rgba(239,68,68,0.1); color: var(--danger); }
.btn-crm-danger:hover { background: var(--danger); color: #fff; }
.btn-crm-success { background: rgba(16,185,129,0.1); color: var(--success); }
.btn-crm-success:hover { background: var(--success); color: #fff; }

/* ── Login Page ── */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #0D1F13 0%, #1B5E2E 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 44px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

/* ── Inputs ── */
.crm-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text-main);
  background: #fff;
  transition: border-color 0.2s;
  outline: none;
}
.crm-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(45,122,66,0.12); }
.crm-label { font-size: 13px; font-weight: 600; color: var(--text-main); display: block; margin-bottom: 6px; }

/* ── Filters row ── */
.filter-row {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 20px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}
.filter-row .crm-input { width: auto; flex: 1; min-width: 160px; }
.filter-row select.crm-input { min-width: 140px; flex: none; }

/* ── Source badge ── */
.source-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  background: #F1F5F9;
  color: #64748B;
}

/* ── Modal ── */
.modal-content { border-radius: 14px; border: none; box-shadow: 0 20px 60px rgba(0,0,0,0.2); }
.modal-header { padding: 20px 24px 16px; border-bottom: 1px solid var(--border); }
.modal-body   { padding: 20px 24px; }
.modal-footer { padding: 16px 24px 20px; border-top: 1px solid var(--border); }
.modal-title  { font-weight: 700; font-size: 16px; }

/* ── Avatar initials ── */
.lead-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
  flex-shrink: 0;
}

/* Tamaño del los inputs */
.max-w {
  max-width: 65px;
}

/* ── Responsive ── */
@media (max-width: 991px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
  }
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1040;
  }
  .sidebar-overlay.show { display: block; }
  .pipeline-filters-head {
    flex-direction: column;
    align-items: flex-start;
  }
  .stage-conversion-row {
    flex-wrap: wrap;
    gap: 8px;
  }
  .stage-conversion-name,
  .stage-conversion-meta {
    width: 100%;
  }
}
