/* ImmoFlow CRM - Core Design System & CSS Variables */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700;800&display=swap');

:root {
  --bg-primary: #09090b;
  --bg-secondary: #121214;
  --bg-card: rgba(24, 24, 27, 0.7);
  --bg-tertiary: #202024;
  
  --accent-primary: #6366f1; /* Indigo */
  --accent-secondary: #8b5cf6; /* Violet */
  --accent-gradient: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
  
  --text-primary: #f4f4f5;
  --text-secondary: #a1a1aa;
  --text-muted: #61616a;
  
  --color-success: #10b981; /* Emerald */
  --color-warning: #f59e0b; /* Amber */
  --color-error: #f43f5e; /* Rose */
  --color-info: #0ea5e9; /* Sky */

  --border-color: rgba(63, 63, 70, 0.4);
  --border-focus: rgba(99, 102, 241, 0.6);
  
  --radius-xl: 20px;
  --radius-lg: 14px;
  --radius-md: 10px;
  --radius-sm: 6px;
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
  
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-title: 'Outfit', sans-serif;
  
  --sidebar-width: 260px;
  --header-height: 70px;
  
  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  overflow-x: hidden;
  height: 100vh;
  display: flex;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Global App Shell Layout */
#app-container {
  display: flex;
  width: 100vw;
  height: 100vh;
}

/* Sidebar Navigation */
aside.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100%;
  flex-shrink: 0;
  z-index: 10;
}

.sidebar-logo {
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border-color);
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: var(--accent-gradient);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 20px;
  color: white;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}

.logo-text {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 22px;
  background: linear-gradient(135deg, #ffffff 30%, #a1a1aa 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
}

.sidebar-menu {
  padding: 16px 12px;
  list-style: none;
  overflow-y: auto;
  flex-grow: 1;
}

.menu-section {
  padding: 8px 12px 4px;
  font-size: 10px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
  letter-spacing: 1px;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-md);
  margin-bottom: 4px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.menu-item:hover, .menu-item.active {
  color: white;
  background-color: var(--bg-tertiary);
}

.menu-item.active {
  background: rgba(99, 102, 241, 0.15);
  border-left: 3px solid var(--accent-primary);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding-left: 11px;
}

.menu-icon {
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border-color);
  background: rgba(0,0,0,0.2);
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  border: 2px solid var(--accent-primary);
}

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

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: white;
}

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

/* Main Dashboard Panel */
main.main-panel {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  position: relative;
}

header.app-header {
  height: var(--header-height);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  background-color: var(--bg-secondary);
  flex-shrink: 0;
}

.header-title h1 {
  font-family: var(--font-title);
  font-size: 22px;
  font-weight: 600;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.badge-wrapper {
  position: relative;
  cursor: pointer;
}

.badge-icon {
  font-size: 20px;
  color: var(--text-secondary);
  padding: 8px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  transition: var(--transition-fast);
}

.badge-icon:hover {
  color: white;
  background: rgba(255, 255, 255, 0.1);
}

.badge-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  background: var(--color-error);
  border-radius: 50%;
  border: 1px solid var(--bg-primary);
}

/* Content Container */
.content-body {
  flex-grow: 1;
  padding: 32px;
  overflow-y: auto;
  position: relative;
  background-image: radial-gradient(circle at 80% 20%, rgba(99, 102, 241, 0.05) 0%, transparent 40%),
                    radial-gradient(circle at 10% 80%, rgba(139, 92, 246, 0.04) 0%, transparent 40%);
}

.view-section {
  display: none;
  animation: fadeIn var(--transition-normal);
}

.view-section.active-view {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Glassmorphism Cards */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-glass);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: var(--transition-fast);
}

.btn-primary {
  background: var(--accent-gradient);
  color: white;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.5);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.05);
}

.btn-success {
  background: var(--color-success);
  color: white;
}

.btn-success:hover {
  opacity: 0.9;
}

/* Grid Layouts */
.grid-4 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  margin-bottom: 24px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 24px;
  margin-bottom: 24px;
}

/* KPI Widget */
.kpi-card {
  display: flex;
  align-items: center;
  gap: 16px;
}

.kpi-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.kpi-info {
  display: flex;
  flex-direction: column;
}

.kpi-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.kpi-value {
  font-size: 22px;
  font-weight: 700;
  font-family: var(--font-title);
  color: white;
  margin: 2px 0;
}

.kpi-trend {
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

.trend-up { color: var(--color-success); }
.trend-down { color: var(--color-error); }

/* Dashboard layout specific */
.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

@media (max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

/* Lists and Feeds */
.activity-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 400px;
  overflow-y: auto;
  padding-right: 8px;
}

.activity-item {
  display: flex;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
  font-size: 13px;
}

.activity-icon-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 4px;
  flex-shrink: 0;
}

.activity-time {
  color: var(--text-muted);
  font-size: 11px;
  white-space: nowrap;
}

/* Kanban Board for CRM */
.kanban-board {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 16px;
  height: calc(100vh - 210px);
  align-items: flex-start;
}

.kanban-column {
  width: 280px;
  flex-shrink: 0;
  background: rgba(18, 18, 20, 0.6);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  max-height: 100%;
}

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

.column-title-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.column-title {
  font-size: 14px;
  font-weight: 600;
  color: white;
}

.column-count {
  font-size: 11px;
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 10px;
  color: var(--text-secondary);
}

.kanban-list {
  padding: 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-grow: 1;
  min-height: 150px;
}

.kanban-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  cursor: grab;
  transition: transform var(--transition-fast), border-color var(--transition-fast);
}

.kanban-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent-primary);
}

.kanban-card:active {
  cursor: grabbing;
}

.card-lead-name {
  font-size: 14px;
  font-weight: 600;
  color: white;
  margin-bottom: 6px;
}

.card-lead-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.card-lead-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 8px;
  border-top: 1px dashed var(--border-color);
}

.score-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 8px;
}

.score-high { background: rgba(16, 185, 129, 0.15); color: var(--color-success); }
.score-medium { background: rgba(245, 158, 11, 0.15); color: var(--color-warning); }
.score-low { background: rgba(113, 113, 122, 0.15); color: var(--text-secondary); }

.priority-indicator {
  font-size: 10px;
  text-transform: uppercase;
  font-weight: 700;
}

.priority-Hot { color: var(--color-error); }
.priority-Warm { color: var(--color-warning); }
.priority-Cold { color: var(--color-info); }

/* Details Drawer / Slide-in Modal */
.drawer {
  position: fixed;
  top: 0;
  right: -550px;
  width: 500px;
  height: 100vh;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
  z-index: 100;
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}

.drawer.open {
  right: 0;
}

.drawer-header {
  padding: 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.drawer-title {
  font-family: var(--font-title);
  font-size: 18px;
  font-weight: 600;
}

.drawer-body {
  padding: 24px;
  overflow-y: auto;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.drawer-footer {
  padding: 24px;
  border-top: 1px solid var(--border-color);
  background: rgba(0, 0, 0, 0.2);
  display: flex;
  gap: 12px;
}

.drawer-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
}

.drawer-close:hover {
  color: white;
}

/* Form Styles */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-control {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  color: white;
  font-family: var(--font-sans);
  font-size: 13px;
  transition: border-color var(--transition-fast);
}

.form-control:focus {
  outline: none;
  border-color: var(--accent-primary);
}

/* Timeline in Lead Detail */
.lead-timeline {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-left: 12px;
  border-left: 2px solid var(--border-color);
  margin-top: 10px;
}

.timeline-event {
  position: relative;
}

.timeline-event::before {
  content: '';
  position: absolute;
  left: -19px;
  top: 5px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--bg-secondary);
  border: 2px solid var(--accent-primary);
}

.event-time {
  font-size: 10px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.event-text {
  font-size: 12px;
  color: var(--text-secondary);
}

/* WhatsApp Simulator Screen */
.phone-mockup {
  width: 100%;
  max-width: 380px;
  height: 600px;
  background: #000;
  border-radius: 40px;
  border: 12px solid #202024;
  margin: 0 auto;
  overflow: hidden;
  box-shadow: var(--shadow-md);
  position: relative;
  display: flex;
  flex-direction: column;
}

.phone-header {
  background: #075e54;
  padding: 16px;
  padding-top: 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: white;
}

.phone-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #ccc;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 12px;
  color: #333;
}

.phone-user-details {
  display: flex;
  flex-direction: column;
}

.phone-user-name {
  font-size: 13px;
  font-weight: 600;
}

.phone-user-status {
  font-size: 9px;
  opacity: 0.8;
}

.phone-chat-body {
  flex-grow: 1;
  background: #efe7dd;
  background-image: radial-gradient(#d3d3d3 1px, transparent 0);
  background-size: 12px 12px;
  padding: 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-bubble {
  max-width: 75%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 12px;
  line-height: 1.4;
  position: relative;
  color: #333;
}

.chat-bubble.bubble-ai {
  background: white;
  align-self: flex-start;
  border-top-left-radius: 0;
}

.chat-bubble.bubble-user {
  background: #dcf8c6;
  align-self: flex-end;
  border-top-right-radius: 0;
}

.chat-bubble.bubble-system {
  background: rgba(0, 0, 0, 0.05);
  color: #555;
  align-self: center;
  max-width: 90%;
  font-size: 10px;
  text-align: center;
  border-radius: 4px;
  padding: 4px 8px;
}

.bubble-time {
  font-size: 8px;
  color: #888;
  text-align: right;
  margin-top: 2px;
}

.phone-footer {
  background: #f0f0f0;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.phone-input {
  flex-grow: 1;
  border: none;
  background: white;
  padding: 8px 12px;
  border-radius: 20px;
  font-size: 12px;
  outline: none;
  color: #333;
}

.phone-send-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #075e54;
  color: white;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* Interactive Building View Grid */
.projects-tabs {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

.project-tab {
  padding: 10px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  font-weight: 500;
  font-size: 13px;
  transition: var(--transition-fast);
}

.project-tab.active {
  background: var(--accent-gradient);
  color: white;
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}

.building-layout {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 20px 0;
  background: rgba(0,0,0,0.1);
  padding: 24px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
}

.floor-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.floor-label {
  width: 60px;
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 600;
  text-align: right;
}

.units-grid {
  display: flex;
  gap: 8px;
  flex-grow: 1;
}

.unit-cell {
  flex: 1;
  height: 50px;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition-fast);
  color: white;
}

.unit-cell:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.unit-cell.status-Available { background: rgba(16, 185, 129, 0.2); border-color: rgba(16, 185, 129, 0.4); color: #34d399; }
.unit-cell.status-Reserved { background: rgba(245, 158, 11, 0.2); border-color: rgba(245, 158, 11, 0.4); color: #fbbf24; }
.unit-cell.status-Sold { background: rgba(99, 102, 241, 0.2); border-color: rgba(99, 102, 241, 0.4); color: #818cf8; }
.unit-cell.status-Maintenance { background: rgba(244, 63, 94, 0.2); border-color: rgba(244, 63, 94, 0.4); color: #f43f5e; }

.unit-cell-code {
  font-size: 12px;
  font-weight: 700;
}

.unit-cell-details {
  font-size: 9px;
  opacity: 0.8;
}

.building-legend {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-top: 16px;
  font-size: 11px;
}

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

.legend-color {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

/* Modal Styling */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 99;
  display: none;
  align-items: center;
  justify-content: center;
}

.modal-overlay.open {
  display: flex;
}

.modal-content {
  width: 90%;
  max-width: 600px;
}

/* Mortgage Calculator */
.calculator-slider-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.slider-header {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.slider-value {
  color: white;
  font-weight: 700;
}

.calculator-results {
  background: rgba(0,0,0,0.2);
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  margin-top: 20px;
}

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

.result-item {
  display: flex;
  flex-direction: column;
}

.result-label {
  font-size: 11px;
  color: var(--text-secondary);
}

.result-val {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-success);
  font-family: var(--font-title);
  margin-top: 4px;
}

/* Canvas Digital Signature Pad */
#signature-pad {
  border: 1px dashed var(--border-color);
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  cursor: crosshair;
}

/* Portal timeline / progress bars */
.progress-bar-container {
  width: 100%;
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 8px;
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent-gradient);
}

.portal-nav {
  display: flex;
  gap: 12px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 12px;
  margin-bottom: 20px;
}

.portal-nav-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
}

.portal-nav-btn.active {
  background: rgba(255, 255, 255, 0.05);
  color: white;
}

/* Toast Notifications */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: rgba(24, 24, 27, 0.95);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-color);
  color: white;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  transform: translateX(120%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toast.show {
  transform: translateX(0);
}

.toast-success { border-left: 4px solid var(--color-success); }
.toast-warning { border-left: 4px solid var(--color-warning); }
.toast-info { border-left: 4px solid var(--color-info); }
.toast-error { border-left: 4px solid var(--color-error); }
