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

:root {
  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border-color: #e2e8f0;
  --border-light: #f1f5f9;
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-hover: #f1f5f9;
  --success-color: #22c55e;
  --success-bg: #dcfce7;
  --error-color: #ef4444;
  --error-bg: #fee2e2;
  --warning-color: #f59e0b;
  --warning-bg: #fef3c7;
  --sidebar-width: 240px;
  --chat-panel-width: 380px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  font-size: 14px;
}

/* App Container */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-primary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 100;
}

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

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

.logo-text {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.sidebar-toggle {
  background: none;
  border: none;
  padding: 6px;
  cursor: pointer;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.sidebar-toggle:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.sidebar-nav {
  padding: 8px 12px;
  flex: 1;
  overflow-y: auto;
}

.nav-section-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 16px 12px 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s ease;
  margin-bottom: 2px;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--primary-light);
  color: var(--primary-color);
}

.nav-item svg {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
}

.nav-badge {
  margin-left: auto;
  background: var(--primary-light);
  color: var(--primary-color);
  font-size: 12px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 10px;
}

.nav-chevron {
  margin-left: auto;
  opacity: 0.5;
}

.sidebar-bottom {
  margin-top: auto;
  padding: 8px 12px 16px;
}

.sidebar-divider {
  height: 1px;
  background: var(--border-color);
  margin: 12px 0;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.15s ease;
}

.user-profile:hover {
  background: var(--bg-hover);
}

.user-avatar-img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-secondary);
}

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

.user-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.user-email {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-chevron {
  color: var(--text-muted);
}

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

.page-content {
  display: none;
  min-height: 100vh;
}

.page-content.active {
  display: block;
}

/* Agent Welcome Page */
.agent-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 100px);
  padding: 40px 24px;
  text-align: center;
}

.agent-logo {
  margin-bottom: 24px;
}

.agent-logo img {
  width: 80px;
  height: 80px;
}

.agent-welcome h1 {
  font-size: 28px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.agent-welcome > p {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 32px;
}

.agent-input-container {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  width: 100%;
  max-width: 680px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 48px;
}

.agent-input {
  flex: 1;
  border: none;
  background: none;
  font-size: 15px;
  font-family: inherit;
  resize: none;
  outline: none;
  line-height: 1.5;
  max-height: 120px;
}

.agent-input::placeholder {
  color: var(--text-muted);
}

.agent-send-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--primary-color);
  border: none;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease;
  flex-shrink: 0;
}

.agent-send-btn:hover {
  background: var(--primary-hover);
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  width: 100%;
  max-width: 900px;
}

.quick-action-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
}

.quick-action-card:hover {
  border-color: var(--primary-color);
  box-shadow: var(--shadow-md);
}

.quick-action-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.quick-action-icon-blue {
  background: #eff6ff;
  color: #2563eb;
}

.quick-action-icon-teal {
  background: #f0fdfa;
  color: #14b8a6;
}

.quick-action-icon-orange {
  background: #fff7ed;
  color: #f97316;
}

.quick-action-icon-green {
  background: #f0fdf4;
  color: #22c55e;
}

.quick-action-card h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.quick-action-card p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* Search Results Page - Split Layout */
.search-layout {
  display: flex;
  height: 100vh;
}

.search-results-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--border-color);
}

.search-results-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
}

.search-results-header h2 {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.search-meta {
  display: flex;
  gap: 12px;
}

.meta-badge {
  font-size: 13px;
  color: var(--text-secondary);
}

.meta-badge strong {
  color: var(--text-primary);
}

.search-results-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

/* Chat Refinement Panel (Right Side) */
.chat-refinement-panel {
  width: var(--chat-panel-width);
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  flex-shrink: 0;
}

.chat-panel-header {
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-primary);
}

.chat-prompt-display {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
}

.chat-prompt-display p {
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.5;
}

.chat-filters {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}

.chat-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 8px;
}

.chat-toggle-row span {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.chat-panel-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-primary);
}

/* Criteria Table */
.criteria-table-wrapper {
  flex: 1;
  overflow: auto;
}

.criteria-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.criteria-table th {
  text-align: left;
  padding: 10px 12px;
  font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}

.criteria-table th.th-checkbox {
  width: 40px;
  padding-right: 0;
}

.criteria-table th.th-criteria {
  text-align: center;
  padding: 8px 6px;
}

.criteria-header {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  border-left: 3px solid;
}

.criteria-header.criteria-red {
  background: #fef2f2;
  color: #dc2626;
  border-left-color: #dc2626;
}

.criteria-header.criteria-orange {
  background: #fff7ed;
  color: #ea580c;
  border-left-color: #ea580c;
}

.criteria-header.criteria-yellow {
  background: #fefce8;
  color: #ca8a04;
  border-left-color: #ca8a04;
}

.criteria-header.criteria-green {
  background: #f0fdf4;
  color: #16a34a;
  border-left-color: #16a34a;
}

.criteria-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

.criteria-table td.td-criteria {
  text-align: center;
}

.criteria-table input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--primary-color);
}

.criteria-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
}

.criteria-status.match {
  color: var(--success-color);
}

.criteria-status.no-match {
  color: var(--error-color);
}

.criteria-status.enriching {
  color: var(--text-muted);
  font-size: 11px;
  width: auto;
  gap: 4px;
}

.enriching-icon {
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* Lead Cell */
.lead-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lead-icon {
  width: 24px;
  height: 24px;
  background: #0077b5;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
}

.lead-name {
  font-weight: 500;
  color: var(--text-primary);
}

.company-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.company-logo-placeholder {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
}

.company-name {
  font-weight: 500;
  color: var(--text-primary);
}

/* Toggle Switch */
.toggle-switch {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.toggle-switch input {
  display: none;
}

.toggle-slider {
  width: 44px;
  height: 24px;
  background: var(--border-color);
  border-radius: 12px;
  position: relative;
  transition: background 0.2s ease;
}

.toggle-slider::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  top: 2px;
  left: 2px;
  transition: transform 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--primary-color);
}

.toggle-switch input:checked + .toggle-slider::after {
  transform: translateX(20px);
}

.toggle-switch.small .toggle-slider {
  width: 36px;
  height: 20px;
}

.toggle-switch.small .toggle-slider::after {
  width: 16px;
  height: 16px;
}

.toggle-switch.small input:checked + .toggle-slider::after {
  transform: translateX(16px);
}

/* Filter Sections */
.filter-section {
  border-bottom: 1px solid var(--border-color);
}

.filter-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 14px 0;
  background: none;
  border: none;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
}

.filter-section-header .filter-chevron {
  transition: transform 0.2s ease;
}

.filter-section-header.collapsed .filter-chevron {
  transform: rotate(-90deg);
}

.filter-section-content {
  display: none;
  padding-bottom: 14px;
}

.filter-section-content.open {
  display: block;
}

.filter-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-primary);
}

.tag-remove {
  background: none;
  border: none;
  padding: 0;
  font-size: 16px;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
}

.tag-remove:hover {
  color: var(--error-color);
}

.filter-add-btn {
  background: none;
  border: 1px dashed var(--border-color);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.filter-add-btn:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

/* Criteria Section */
.criteria-section {
  padding-top: 16px;
}

.criteria-section-header {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.criteria-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.criteria-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-primary);
}

.criteria-bar {
  width: 3px;
  height: 16px;
  border-radius: 2px;
  flex-shrink: 0;
}

.criteria-bar-red { background: #dc2626; }
.criteria-bar-orange { background: #ea580c; }
.criteria-bar-yellow { background: #ca8a04; }
.criteria-bar-green { background: #16a34a; }

.criteria-item span:nth-child(2) {
  flex: 1;
}

.criteria-remove {
  background: none;
  border: none;
  padding: 0;
  font-size: 16px;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
}

.criteria-remove:hover {
  color: var(--error-color);
}

.criteria-add-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 10px;
  background: none;
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.criteria-add-btn:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.update-btn {
  width: 100%;
  margin-top: 20px;
}

/* Results Limit Buttons */
.results-limit {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.limit-btn {
  flex: 1;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.limit-btn:hover {
  background: var(--bg-hover);
}

.limit-btn.active {
  background: var(--text-primary);
  border-color: var(--text-primary);
  color: white;
}

.save-leads-btn {
  width: 100%;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
  white-space: nowrap;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.btn-outline {
  background: var(--bg-primary);
  border-color: var(--border-color);
  color: var(--text-primary);
}

.btn-outline:hover {
  background: var(--bg-hover);
  border-color: var(--text-muted);
}

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

.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

/* Pagination */
.results-per-page {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-secondary);
}

.results-per-page select {
  padding: 6px 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--bg-primary);
  cursor: pointer;
}

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

.pagination-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.pagination-btn:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--text-muted);
}

.pagination-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.pagination-pages {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pagination-page {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.pagination-page:hover {
  background: var(--bg-hover);
}

.pagination-page.active {
  background: var(--text-primary);
  border-color: var(--text-primary);
  color: white;
}

.pagination-ellipsis {
  padding: 0 8px;
  color: var(--text-muted);
}

/* Lists Page */
.page-lists .page-header,
.page-leads .page-header {
  padding: 24px 32px;
  border-bottom: 1px solid var(--border-color);
}

.page-lists .page-header h1,
.page-leads .page-header h1 {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 4px;
}

.page-lists .page-header p {
  color: var(--text-secondary);
}

.lists-grid {
  padding: 24px 32px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.list-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.list-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.list-card-header h3 {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  flex: 1;
  padding-right: 12px;
}

.list-count {
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.list-card-meta {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.list-card-actions {
  display: flex;
  gap: 8px;
}

/* Page Placeholder */
.page-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 50vh;
  text-align: center;
  color: var(--text-secondary);
}

.page-placeholder h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--text-primary);
  color: white;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-size: 14px;
  box-shadow: var(--shadow-md);
  z-index: 1000;
  transition: transform 0.3s ease;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

/* Scrollbar Styles */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Company logos */
.logo-google { background: #4285f4; color: white; }
.logo-loom { background: #625df5; color: white; }
.logo-adobe { background: #ff0000; color: white; }
.logo-amazon { background: #ff9900; color: white; }
.logo-microsoft { background: #00a4ef; color: white; }
.logo-shopify { background: #95bf47; color: white; }
.logo-hubspot { background: #ff7a59; color: white; }
.logo-tesla { background: #cc0000; color: white; }
.logo-slack { background: #4a154b; color: white; }

/* Responsive */
@media (max-width: 1400px) {
  .quick-actions {
    grid-template-columns: repeat(2, 1fr);
    max-width: 600px;
  }

  :root {
    --chat-panel-width: 340px;
  }
}

@media (max-width: 1200px) {
  :root {
    --sidebar-width: 220px;
    --chat-panel-width: 320px;
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .main-content {
    margin-left: 0;
  }

  .quick-actions {
    grid-template-columns: 1fr;
    max-width: 400px;
  }

  .search-layout {
    flex-direction: column;
  }

  .chat-refinement-panel {
    width: 100%;
    max-height: 50vh;
  }
}
