/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #dbeafe;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --sidebar-w: 240px;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.15);
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: var(--gray-800);
  background: var(--gray-50);
  line-height: 1.5;
  font-size: 14px;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* === Login === */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
}

.login-card {
  background: white;
  padding: 40px;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 400px;
}

.login-card h1 { font-size: 28px; font-weight: 700; color: var(--primary); margin-bottom: 4px; }
.login-subtitle { color: var(--gray-500); margin-bottom: 24px; }

/* === Forms === */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 500; margin-bottom: 4px; font-size: 13px; color: var(--gray-700); }
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  background: white;
  transition: border-color 0.15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.form-group textarea { min-height: 100px; resize: vertical; }
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }
.error-text { color: var(--danger); font-size: 13px; margin-top: 8px; }

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn:hover { opacity: 0.9; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--gray-100); color: var(--gray-700); border-color: var(--gray-300); }
.btn-secondary:hover { background: var(--gray-200); }
.btn-danger { background: var(--danger); color: white; }
.btn-ghost { background: transparent; color: var(--gray-600); }
.btn-ghost:hover { background: var(--gray-100); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }
.btn-icon { padding: 6px; border-radius: 6px; }

/* === App Layout === */
#app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--gray-900);
  color: white;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 50;
}

.sidebar-header { padding: 20px; border-bottom: 1px solid var(--gray-700); }
.sidebar-header h2 { font-size: 20px; font-weight: 700; color: white; }

.sidebar-nav { flex: 1; padding: 12px 8px; overflow-y: auto; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 6px;
  color: var(--gray-300);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
  text-decoration: none;
  margin-bottom: 2px;
}
.nav-item:hover { background: var(--gray-800); color: white; text-decoration: none; }
.nav-item.active { background: var(--primary); color: white; }

.sidebar-footer { padding: 16px; border-top: 1px solid var(--gray-700); }
.user-info { display: flex; align-items: center; justify-content: space-between; }
.user-info span { font-size: 13px; color: var(--gray-300); }
.user-info .btn { color: var(--gray-400); font-size: 12px; }

.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 24px;
  min-height: 100vh;
}

/* === Page Header === */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.page-header h1 { font-size: 24px; font-weight: 700; }
.page-header-actions { display: flex; gap: 8px; align-items: center; }

/* === Cards === */
.card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-header h3 { font-size: 16px; font-weight: 600; }
.card-body { padding: 20px; }

/* === Stats Cards === */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.stat-card .stat-label { font-size: 13px; color: var(--gray-500); font-weight: 500; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; margin-top: 4px; }
.stat-card .stat-sub { font-size: 12px; color: var(--gray-400); margin-top: 2px; }

/* === Table === */
.table-container { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 10px 16px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--gray-500); background: var(--gray-50); border-bottom: 1px solid var(--gray-200); }
td { padding: 12px 16px; border-bottom: 1px solid var(--gray-100); font-size: 14px; }
tr:hover td { background: var(--gray-50); }
tr.clickable { cursor: pointer; }

/* === Badge === */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge-blue { background: var(--primary-light); color: var(--primary); }
.badge-green { background: var(--success-light); color: var(--success); }
.badge-red { background: var(--danger-light); color: var(--danger); }
.badge-yellow { background: var(--warning-light); color: #92400e; }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }

/* === Tag === */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  background: var(--gray-100);
  color: var(--gray-700);
}
.tag .tag-dot { width: 6px; height: 6px; border-radius: 50%; }
.tag .tag-remove { cursor: pointer; opacity: 0.5; font-size: 14px; margin-left: 2px; }
.tag .tag-remove:hover { opacity: 1; }
.tags-container { display: flex; flex-wrap: wrap; gap: 4px; }

/* === Pagination === */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
}
.pagination-info { font-size: 13px; color: var(--gray-500); }
.pagination-buttons { display: flex; gap: 4px; }

/* === Filters === */
.filters-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 12px 16px;
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
}
.filters-bar input, .filters-bar select {
  padding: 6px 10px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  background: white;
}
.filters-bar input:focus, .filters-bar select:focus { outline: none; border-color: var(--primary); }
.search-input { min-width: 250px; }

/* === Kanban Board === */
.kanban-board {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 20px;
  min-height: 60vh;
}
.kanban-column {
  min-width: 280px;
  max-width: 300px;
  background: var(--gray-100);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
}
.kanban-column-header {
  padding: 12px 16px;
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid;
}
.kanban-column-header .count {
  background: white;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  color: var(--gray-500);
}
.kanban-cards {
  flex: 1;
  padding: 8px;
  min-height: 100px;
  overflow-y: auto;
}
.kanban-card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 8px;
  cursor: grab;
  transition: box-shadow 0.15s;
}
.kanban-card:hover { box-shadow: var(--shadow-lg); }
.kanban-card.dragging { opacity: 0.5; }
.kanban-card .card-name { font-weight: 600; font-size: 14px; }
.kanban-card .card-company { font-size: 12px; color: var(--gray-500); }
.kanban-card .card-meta { display: flex; gap: 8px; margin-top: 8px; font-size: 11px; color: var(--gray-400); }

/* === Timeline === */
.timeline { position: relative; }
.timeline::before {
  content: '';
  position: absolute;
  left: 16px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--gray-200);
}
.timeline-item {
  position: relative;
  padding: 0 0 20px 44px;
}
.timeline-dot {
  position: absolute;
  left: 8px;
  top: 4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid white;
  z-index: 1;
}
.timeline-dot.email { background: var(--primary); }
.timeline-dot.whatsapp { background: #25d366; }
.timeline-dot.linkedin { background: #0077b5; }
.timeline-dot.phone { background: var(--warning); }
.timeline-dot.meeting { background: var(--success); }
.timeline-dot.note { background: var(--gray-400); }
.timeline-dot.activity { background: #8b5cf6; }
.timeline-content {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 12px 16px;
}
.timeline-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.timeline-header .channel { font-weight: 600; font-size: 13px; text-transform: capitalize; }
.timeline-header .date { font-size: 12px; color: var(--gray-400); }
.timeline-body { font-size: 13px; color: var(--gray-600); white-space: pre-wrap; }

/* === Contact Detail === */
.contact-layout { display: grid; grid-template-columns: 320px 1fr; gap: 24px; }
.profile-card { position: sticky; top: 24px; }
.profile-card .avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
}
.profile-card .avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.profile-info { margin-top: 16px; }
.profile-info h2 { font-size: 20px; margin-bottom: 4px; }
.profile-info .title { color: var(--gray-500); font-size: 14px; }
.profile-info .company { color: var(--gray-600); font-size: 14px; font-weight: 500; }
.profile-links { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.profile-links .link-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--gray-600);
  word-break: break-all;
}
.opted-out-banner {
  background: var(--danger-light);
  color: var(--danger);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  margin-top: 12px;
}

/* === Tabs === */
.tabs { display: flex; border-bottom: 1px solid var(--gray-200); margin-bottom: 16px; }
.tab-btn {
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-500);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.tab-btn:hover { color: var(--gray-700); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

/* === Modal === */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-content {
  background: white;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  max-width: 600px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { font-size: 18px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 24px; cursor: pointer; color: var(--gray-400); padding: 4px; }
.modal-body { padding: 20px; }
.modal-footer { padding: 16px 20px; border-top: 1px solid var(--gray-200); display: flex; justify-content: flex-end; gap: 8px; }

/* === Toast === */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  border-radius: var(--radius);
  color: white;
  font-size: 14px;
  font-weight: 500;
  z-index: 200;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s ease;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--primary); }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* === Audio Recorder === */
.audio-recorder {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}
.recording-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 600;
  color: var(--danger);
}
.recording-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--danger);
  animation: pulse 1s infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
.audio-timer { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; margin: 12px 0; }
.audio-controls { display: flex; gap: 8px; justify-content: center; margin-top: 12px; }
.audio-player { width: 100%; margin-top: 12px; }

/* === Import === */
.import-steps { display: flex; gap: 4px; margin-bottom: 24px; }
.import-step {
  flex: 1;
  padding: 12px;
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius);
  background: var(--gray-100);
  color: var(--gray-500);
}
.import-step.active { background: var(--primary); color: white; }
.import-step.done { background: var(--success-light); color: var(--success); }
.dropzone {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius);
  padding: 48px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
}
.dropzone:hover { border-color: var(--primary); background: var(--primary-light); }
.dropzone.dragover { border-color: var(--primary); background: var(--primary-light); }
.field-mapping-table { width: 100%; }
.field-mapping-table td { padding: 8px; }
.field-mapping-table select { width: 100%; padding: 6px 8px; border: 1px solid var(--gray-300); border-radius: 4px; }

/* === Empty State === */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--gray-400);
}
.empty-state svg { margin-bottom: 16px; }
.empty-state h3 { font-size: 18px; color: var(--gray-600); margin-bottom: 8px; }

/* === Grid layouts === */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

/* === Checkbox row === */
.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); }

/* === Select All Row === */
.select-all { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; font-size: 13px; }

/* === Settings Section === */
.settings-section { margin-bottom: 32px; }
.settings-section h3 { font-size: 18px; font-weight: 600; margin-bottom: 12px; }
.settings-list { display: flex; flex-direction: column; gap: 8px; }
.settings-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: white; border: 1px solid var(--gray-200);
  border-radius: var(--radius);
}
.settings-item .item-info { display: flex; align-items: center; gap: 12px; }
.settings-item .color-dot { width: 12px; height: 12px; border-radius: 50%; }
.settings-item .item-actions { display: flex; gap: 4px; }

/* === Loading === */
.loading { display: flex; align-items: center; justify-content: center; padding: 48px; }
.spinner {
  width: 32px; height: 32px; border: 3px solid var(--gray-200);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* === Responsive === */
/* === Dashboard Charts === */
.chart-bar-container { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.chart-bar-label { width: 100px; font-size: 13px; font-weight: 500; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chart-bar-track { flex: 1; height: 24px; background: var(--gray-100); border-radius: 4px; overflow: hidden; }
.chart-bar-fill { height: 100%; border-radius: 4px; transition: width 0.5s ease; min-width: 2px; }
.chart-bar-value { width: 50px; font-size: 13px; font-weight: 600; text-align: right; }

@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar .nav-item span { display: none; }
  .sidebar-header h2 { font-size: 14px; }
  .main-content { margin-left: 60px; padding: 16px; }
  .contact-layout { grid-template-columns: 1fr; }
  .kanban-board { flex-direction: column; }
  .kanban-column { min-width: 100%; max-width: 100%; }
  .chart-bar-label { width: 70px; font-size: 11px; }
}
