:root {
  --bg-color: #0a0a0f;
  --surface-color: #111118;
  --border-color: #1e1e2e;
  --primary-accent: #00b4d8;
  --accent-hover: #857dff;
  --text-primary: #f0f0f5;
  --text-secondary: #7a7a99;
  --input-bg: #16161f;
  --error-color: #ff4d6d;
}

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

body {
  background-color: var(--bg-color);
  color: var(--text-primary);
  font-family: "Inter", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --- Animations --- */
@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fade-out {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-8px);
  }
}

@keyframes fade-in-up {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* --- Shared Forms / Inputs --- */
.system-title {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--text-primary);
}
.login-card .system-title {
  text-align: center;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
}

.token-label,
.section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
}

.token-input {
  background-color: var(--input-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 14px 16px;
  font-size: 15px;
  color: var(--text-primary);
  outline: none;
  transition: all 0.2s ease;
  width: 100%;
}

.token-input::placeholder {
  color: #4a4a5e;
}

.token-input:focus {
  border-color: var(--primary-accent);
  box-shadow: 0 0 0 2px rgba(108, 99, 255, 0.15);
}

.token-input.error {
  border-color: var(--error-color);
}
.token-input.error:focus {
  box-shadow: 0 0 0 2px rgba(255, 77, 109, 0.15);
}

.submit-btn {
  background-color: var(--primary-accent);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 14px 20px;
  font-size: 14px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
}

.submit-btn:hover {
  background-color: var(--accent-hover);
  transform: translateY(-1px);
}

.submit-btn:active {
  transform: translateY(0);
}

.submit-btn.loading {
  pointer-events: none;
  opacity: 0.9;
}
.submit-btn.loading i {
  animation: spin 1s linear infinite;
}

/* --- Login Page --- */
.page-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  animation: fade-in 0.6s ease-out forwards;
}

.page-wrapper.fade-out {
  animation: fade-out 0.4s ease-in forwards;
}

.login-card {
  background-color: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 40px 32px;
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 32px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.error-message {
  color: var(--error-color);
  font-size: 13px;
  margin-top: 0px;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transform: translateY(-4px);
  transition: all 0.3s ease;
}

.error-message.show {
  margin-top: 4px;
  max-height: 24px;
  opacity: 1;
  transform: translateY(0);
}

/* --- Prospecting App Page --- */
.app-container {
  min-height: 100vh;
  animation: fade-in 0.6s ease-out forwards;
  opacity: 0;
  display: flex;
  flex-direction: column;
}

.app-container.fade-out {
  animation: fade-out 0.4s ease-in forwards;
}

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

.header-left {
  display: flex;
  align-items: center;
  gap: 40px;
}

.header-nav {
  display: flex;
  gap: 24px;
}

.nav-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  padding: 8px 0;
  position: relative;
  transition: color 0.2s;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.nav-link:hover {
  color: var(--text-primary);
}

.nav-link.active {
  color: var(--primary-accent);
}

.nav-link.active::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 100%;
  height: 2px;
  background-color: var(--primary-accent);
  border-radius: 2px 2px 0 0;
}

.app-logo {
  text-align: left;
  font-size: 20px;
  letter-spacing: 0.1em;
}

.logout-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.logout-btn:hover {
  background: var(--input-bg);
  border-color: var(--text-secondary);
}

.main-content {
  flex: 1;
  padding: 40px;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

.custom-select {
  appearance: none;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="%237A7A99" viewBox="0 0 256 256"><path d="M213.66,101.66l-80,80a8,8,0,0,1-11.32,0l-80-80A8,8,0,0,1,53.66,90.34L128,164.69l74.34-74.35a8,8,0,0,1,11.32,11.32Z"></path></svg>');
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
}
.custom-select option {
  background-color: var(--surface-color);
  color: var(--text-primary);
}

.textarea-input {
  resize: vertical;
  min-height: 120px;
  font-family: inherit;
  line-height: 1.5;
}

.char-counter {
  font-size: 11px;
  color: var(--text-secondary);
  text-align: right;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
  transition: color 0.2s ease;
}

.char-counter.near-limit {
  color: var(--error-color);
}

.follow-up-form {
  gap: 20px;
}
.mb-8 {
  margin-top: 8px;
  margin-bottom: 8px;
}

.hidden-file-input {
  display: none;
}

.file-upload-block {
  position: relative;
  width: 100%;
}

.file-upload-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 32px 16px;
  background-color: var(--input-bg);
  border: 1px dashed var(--border-color);
  border-radius: 8px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

.file-upload-label:hover {
  border-color: var(--primary-accent);
  color: var(--text-primary);
  background-color: rgba(108, 99, 255, 0.05);
}

.upload-icon {
  font-size: 28px;
  color: var(--primary-accent);
}

#fileNameDisplay {
  font-size: 13px;
  word-break: break-all;
}

.file-upload-label.has-file {
  border-style: solid;
  border-color: var(--primary-accent);
}

.section-title {
  font-size: 28px;
  font-weight: 600;
  margin-bottom: 32px;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.prospect-form {
  background-color: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-row {
  display: flex;
  gap: 24px;
}

.flex-1 {
  flex: 1;
}

.w-32 {
  width: 120px;
}

.method-selector {
  display: flex;
  gap: 8px;
  background-color: var(--input-bg);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
}

.method-btn {
  flex: 1;
  background: transparent;
  border: none;
  padding: 10px 16px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.method-btn:hover {
  color: var(--text-primary);
}

.method-btn.active {
  background-color: var(--primary-accent);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(108, 99, 255, 0.2);
}

.nicho-selector {
  display: flex;
  gap: 12px;
}

.nicho-pill {
  cursor: pointer;
  position: relative;
}

.nicho-pill input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
}

.nicho-label {
  display: inline-block;
  padding: 8px 16px;
  background-color: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.2s ease;
  user-select: none;
}

.nicho-pill input:checked ~ .nicho-label {
  border-color: var(--primary-accent);
  background-color: rgba(108, 99, 255, 0.15);
  color: var(--primary-accent);
}

.nicho-pill input:focus-visible ~ .nicho-label {
  box-shadow: 0 0 0 2px rgba(108, 99, 255, 0.5);
}

.mt-4 {
  margin-top: 16px;
}

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

.results-container {
  min-height: 200px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 60px 20px;
  text-align: center;
  color: var(--text-secondary);
  background-color: var(--surface-color);
  border: 1px dashed var(--border-color);
  border-radius: 12px;
}

.empty-icon {
  font-size: 32px;
  opacity: 0.5;
}

.leads-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.lead-card {
  background-color: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 24px;
  opacity: 0;
  transform: translateY(16px);
  animation: fade-in-up 0.5s ease-out forwards;
}

.lead-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.lead-names {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

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

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

.lead-badge {
  background-color: rgba(108, 99, 255, 0.15);
  color: var(--accent-hover);
  padding: 6px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.lead-details {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.detail-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-secondary);
}

.detail-icon {
  color: var(--text-secondary);
  font-size: 18px;
}
.detail-item:hover .detail-icon {
  color: var(--primary-accent);
}
.detail-item a {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s;
}
.detail-item a:hover {
  color: var(--text-primary);
}

.lead-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

.lead-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.lead-field-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
}

.lead-field-value {
  font-size: 14px;
  color: var(--text-primary);
  font-weight: 400;
  line-height: 1.4;
  word-break: break-word;
}

/* AI Rewrite Button Styles */
.ai-simple-btn {
  background-color: transparent;
  color: var(--primary-accent);
  border: 1px solid rgba(108, 99, 255, 0.3);
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.ai-simple-btn:hover {
  background-color: rgba(108, 99, 255, 0.08);
  border-color: var(--primary-accent);
  color: var(--accent-hover);
}

.ai-simple-btn:active {
  transform: translateY(1px);
}

.ai-simple-btn.loading {
  opacity: 0.7;
  cursor: not-allowed;
}

.ai-simple-btn.disabled {
  opacity: 0.4;
  pointer-events: none;
  cursor: not-allowed;
  border-color: var(--border-color);
  color: var(--text-secondary);
}

/* AI Toggle switch wrapper styles */
.ai-toggle-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: rgba(108, 99, 255, 0.05);
  border: 1px solid rgba(108, 99, 255, 0.12);
  padding: 5px 12px;
  border-radius: 20px;
  transition: all 0.2s ease;
}

.ai-toggle-wrapper:hover {
  border-color: rgba(108, 99, 255, 0.3);
}

.ai-toggle-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  user-select: none;
}

.switch {
  position: relative;
  display: inline-block;
  width: 32px;
  height: 18px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(122, 122, 153, 0.3);
  transition: 0.3s ease;
  border-radius: 18px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 12px;
  width: 12px;
  left: 3px;
  bottom: 3px;
  background-color: #ffffff;
  transition: 0.3s ease;
  border-radius: 50%;
}

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

input:checked + .slider:before {
  transform: translateX(14px);
}

/* CRM Page Styles */
.crm-content {
  max-width: 1000px;
}

.crm-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.crm-filter-group .search-input-wrapper {
  position: relative;
  width: 300px;
}

.crm-filter-group .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  font-size: 16px;
}

.crm-filter-group .token-input {
  padding-left: 36px;
  padding-top: 10px;
  padding-bottom: 10px;
}

.table-container {
  background-color: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow-x: auto;
}

.crm-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.crm-table th,
.crm-table td {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

.crm-table th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  background-color: rgba(108, 99, 255, 0.03);
}

.crm-table td {
  font-size: 14px;
  color: var(--text-primary);
}

.crm-table tr:hover {
  background-color: rgba(255, 255, 255, 0.02);
}

.crm-table tr:last-child td {
  border-bottom: none;
}

/* Status Labels */
.status-badge {
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: inline-block;
}

.status-novo {
  background-color: rgba(0, 200, 83, 0.15);
  color: #00c853;
  border: 1px solid rgba(0, 200, 83, 0.3);
}

.status-contatado {
  background-color: rgba(255, 193, 7, 0.15);
  color: #ffc107;
  border: 1px solid rgba(255, 193, 7, 0.3);
}

.status-fechado {
  background-color: rgba(33, 150, 243, 0.15);
  color: #2196f3;
  border: 1px solid rgba(33, 150, 243, 0.3);
}

.status-quente {
  background-color: rgba(255, 87, 34, 0.15);
  color: #ff5722;
  border: 1px solid rgba(255, 87, 34, 0.3);
}

.status-frio {
  background-color: rgba(33, 150, 243, 0.15);
  color: var(--primary-accent); /* use the new cyan */
  border: 1px solid rgba(33, 150, 243, 0.3);
}

.status-morno {
  background-color: rgba(255, 152, 0, 0.15);
  color: #ff9800;
  border: 1px solid rgba(255, 152, 0, 0.3);
}

.status-encerrado {
  background-color: rgba(244, 67, 54, 0.15);
  color: #f44336;
  border: 1px solid rgba(244, 67, 54, 0.3);
}

.tipo-decisor {
  background-color: rgba(255, 193, 7, 0.15);
  color: #ffc107;
  border: 1px solid rgba(255, 193, 7, 0.3);
}

.tipo-gatekeeper {
  background-color: rgba(244, 67, 54, 0.15);
  color: #f44336;
  border: 1px solid rgba(244, 67, 54, 0.3);
}

/* CRM Table Actions */
.action-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px;
  border-radius: 4px;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  position: relative;
  font-size: 18px;
}

.action-btn:hover {
  color: var(--text-primary);
  background-color: rgba(255, 255, 255, 0.05);
}

.action-btn.edit-btn:hover {
  color: var(--primary-accent);
  background-color: rgba(108, 99, 255, 0.1);
}

.action-btn.save-btn {
  color: #00c853;
}

.action-btn.save-btn:hover {
  background-color: rgba(0, 200, 83, 0.1);
}

.note-indicator {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 6px;
  height: 6px;
  background-color: #00c853;
  border-radius: 50%;
}

.action-btn.delete-btn {
  color: #f44336;
}

.action-btn.delete-btn:hover {
  background-color: rgba(244, 67, 54, 0.1);
}

.prospectar-dot {
  width: 12px;
  height: 12px;
  background-color: #00c853;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 8px rgba(0, 200, 83, 0.5);
}

/* Edit Inputs within Table */
.crm-edit-input {
  width: 100%;
  background-color: var(--input-bg);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 13px;
  font-family: "Inter", sans-serif;
}

.crm-edit-input:focus {
  border-color: var(--primary-accent);
  outline: none;
}

.crm-actions-container {
  display: flex;
  justify-content: center;
  gap: 8px;
}

@media (max-width: 600px) {
  .form-row {
    flex-direction: column;
    gap: 16px;
  }
  .w-32 {
    width: 100%;
  }
  .method-selector {
    flex-direction: column;
  }
  .app-header {
    flex-direction: column;
    align-items: flex-start;
    padding: 16px 20px;
    gap: 16px;
  }
  .header-left {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
    width: 100%;
  }
  .header-nav {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
    /* Hide scrollbar for a cleaner look */
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
  .header-nav::-webkit-scrollbar {
    display: none;
  }
  .nav-link {
    white-space: nowrap;
  }
  .logout-btn {
    align-self: flex-start;
  }
  .main-content {
    padding: 24px 20px;
  }
  .lead-header {
    flex-direction: column;
    gap: 12px;
  }
  .lead-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .crm-header {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 16px !important;
  }
  .crm-filter-group {
    width: 100%;
    flex-direction: column !important;
    align-items: stretch !important;
    margin-left: 0 !important;
    gap: 12px !important;
  }
  .crm-filter-group .search-input-wrapper {
    width: 100% !important;
    flex: none !important;
  }
  .crm-filter-group div[style*="flex-grow: 1;"] {
    display: none !important;
  }
  .crm-filter-group .submit-btn,
  .crm-filter-group a.submit-btn,
  .crm-filter-group .ai-toggle-wrapper {
    width: 100% !important;
    justify-content: center !important;
    margin: 0 !important;
  }
  .table-container {
    overflow-x: auto;
  }
  .crm-table {
    min-width: 1000px; /* adjusted from 800 to fit new columns */
  }
  .floating-exit {
    display: none !important;
  }
}

#greetingBox {
  font-family: "Courier New", Courier, monospace !important;
  font-size: 20px !important;
  font-weight: bold !important;
  line-height: normal !important;
  margin-left: 0px !important;
  padding-left: 0px !important;
  margin-right: 0px !important;
  margin-bottom: 0px !important;
}

@keyframes pulse {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(213, 0, 0, 0.7);
  }
  70% {
    transform: scale(1);
    box-shadow: 0 0 0 10px rgba(213, 0, 0, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(213, 0, 0, 0);
  }
}
