/* Maya Desk - Internal Clinic System v1.0 */

:root {
  --primary: #2563EB;
  --primary-light: #EFF6FF;
  --primary-dark: #1D4ED8;
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --purple: #8B5CF6;
  --text: #0F172A;
  --text-light: #64748B;
  --bg: #F1F5F9;
  --white: #FFFFFF;
  --border: #E2E8F0;
  --card-shadow: 0 2px 8px rgba(0,0,0,0.08);

  /* Status colors */
  --s-novo: #EF4444;
  --s-atendimento: #2563EB;
  --s-aguardando: #F59E0B;
  --s-finalizado: #10B981;
}

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

body {
  font-family: 'Outfit', sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

/* ─── LOGIN SCREEN ─── */
.login-screen {
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0F172A 0%, #1E3A5F 100%);
}

.login-logo {
  color: white;
  font-size: 36px;
  font-weight: 700;
  margin-bottom: 8px;
}
.login-logo span { color: #60A5FA; }

.login-subtitle {
  color: #94A3B8;
  margin-bottom: 40px;
  font-size: 14px;
}

.conn-err {
  background: #FEE2E2;
  color: #DC2626;
  padding: 12px 20px;
  border-radius: 12px;
  margin-bottom: 20px;
  font-size: 13px;
  text-align: center;
}

.user-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

.user-btn {
  width: 120px;
  height: 90px;
  border: 2px solid #334155;
  background: #1E293B;
  border-radius: 16px;
  color: white;
  font-family: 'Outfit', sans-serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.user-btn:hover, .user-btn.selected {
  background: var(--primary);
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(37,99,235,0.3);
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
}

.pin-panel {
  background: #1E293B;
  border: 1px solid #334155;
  border-radius: 20px;
  padding: 24px;
  width: 280px;
}

.pin-display {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 20px;
}

.pin-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid #475569;
  transition: all 0.2s;
}
.pin-dot.filled { background: var(--primary); border-color: var(--primary); }

.pin-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.pin-key {
  height: 52px;
  background: #0F172A;
  border: 1px solid #334155;
  border-radius: 12px;
  color: white;
  font-family: 'Outfit', sans-serif;
  font-size: 20px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.pin-key:hover { background: #334155; }
.pin-key.clear { color: var(--danger); font-size: 14px; }
.pin-key.enter { background: var(--primary); border-color: var(--primary); }

.login-error {
  color: var(--danger);
  font-size: 13px;
  text-align: center;
  margin-top: 12px;
}

/* ─── MAIN APP LAYOUT ─── */
.app-layout {
  display: flex;
  height: 100vh;
}

.sidebar {
  width: 220px;
  background: #0F172A;
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  flex-shrink: 0;
}

.sidebar-logo {
  font-size: 22px;
  font-weight: 700;
  color: white;
  margin-bottom: 4px;
}
.sidebar-logo span { color: #60A5FA; }

.sidebar-user {
  font-size: 12px;
  color: #64748B;
  margin-bottom: 32px;
}

.sidebar-nav {
  list-style: none;
  flex: 1;
}

.sidebar-nav li { margin-bottom: 4px; }

.sidebar-nav button {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: #94A3B8;
  font-family: 'Outfit', sans-serif;
  font-size: 14px;
  font-weight: 500;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-nav button:hover, .sidebar-nav button.active {
  background: #1E293B;
  color: white;
}

.sidebar-nav button.active { color: #60A5FA; }

.badge-count {
  margin-left: auto;
  background: var(--danger);
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  min-width: 20px;
  text-align: center;
}

.badge-count.green { background: var(--success); }

.logout-btn {
  width: 100%;
  background: none;
  border: 1px solid #334155;
  color: #64748B;
  font-family: 'Outfit', sans-serif;
  font-size: 13px;
  padding: 10px;
  border-radius: 10px;
  cursor: pointer;
  margin-top: 16px;
  transition: all 0.15s;
}
.logout-btn:hover { border-color: var(--danger); color: var(--danger); }

/* ─── WORKSPACE ─── */
.workspace {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.leads-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.workspace-header {
  background: white;
  border-bottom: 1px solid var(--border);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.workspace-title {
  font-size: 18px;
  font-weight: 600;
  flex: 1;
}

.search-input {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 14px;
  font-family: 'Outfit', sans-serif;
  font-size: 14px;
  width: 240px;
  outline: none;
  transition: border-color 0.2s;
}
.search-input:focus { border-color: var(--primary); }

.filter-bar {
  background: white;
  border-bottom: 1px solid var(--border);
  padding: 10px 24px;
  display: flex;
  gap: 8px;
}

.filter-select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  font-family: 'Outfit', sans-serif;
  font-size: 13px;
  outline: none;
  cursor: pointer;
}

.leads-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ─── LEAD CARD ─── */
.lead-card {
  background: white;
  border-radius: 14px;
  padding: 14px 18px;
  border: 1px solid var(--border);
  box-shadow: var(--card-shadow);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 14px;
}

.lead-card:hover { border-color: var(--primary); transform: translateX(2px); }
.lead-card.selected { border-color: var(--primary); background: var(--primary-light); }
.lead-card.overdue { border-left: 4px solid var(--danger); }

.lead-priority-bar {
  width: 4px;
  height: 44px;
  border-radius: 2px;
  flex-shrink: 0;
}
.lead-priority-bar.Urgente { background: var(--danger); }
.lead-priority-bar.Importante { background: var(--warning); }
.lead-priority-bar.Normal { background: #CBD5E1; }

.lead-info { flex: 1; min-width: 0; }
.lead-name { font-size: 15px; font-weight: 600; margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lead-meta { font-size: 12px; color: var(--text-light); display: flex; gap: 12px; }
.lead-time { font-size: 11px; color: #94A3B8; margin-top: 2px; }

.lead-badges { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; flex-shrink: 0; }

.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
}

.badge-novo { background: #FEE2E2; color: #DC2626; }
.badge-atendimento { background: #DBEAFE; color: #1D4ED8; }
.badge-aguardando { background: #FEF3C7; color: #92400E; }
.badge-finalizado { background: #D1FAE5; color: #065F46; }
.badge-intent { background: var(--primary-light); color: var(--primary); }

.lead-timer { font-size: 12px; color: var(--text-light); white-space: nowrap; }
.lead-timer.urgent { color: var(--danger); font-weight: 600; }

/* ─── DETAIL PANEL ─── */
.detail-panel {
  width: 430px;
  background: white;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}

.detail-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}

.detail-name { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.detail-phone { font-size: 14px; color: var(--text-light); margin-bottom: 12px; }

.detail-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn {
  padding: 8px 14px;
  border-radius: 10px;
  font-family: 'Outfit', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: #D1FAE5; color: #065F46; }
.btn-success:hover { background: var(--success); color: white; }
.btn-warning { background: #FEF3C7; color: #92400E; }
.btn-warning:hover { background: var(--warning); color: white; }
.btn-danger { background: #FEE2E2; color: #DC2626; }
.btn-danger:hover { background: var(--danger); color: white; }
.btn-ghost { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-new { background: #0F172A; color: white; padding: 8px 16px; display: flex; align-items: center; gap: 6px; }
.btn-new:hover { background: #1E293B; }

.detail-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px;
}

.detail-section { margin-bottom: 20px; }
.detail-section h4 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-light);
  margin-bottom: 10px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.detail-item {
  background: var(--bg);
  border-radius: 8px;
  padding: 8px 12px;
}
.detail-item .label { font-size: 11px; color: var(--text-light); }
.detail-item .value { font-size: 14px; font-weight: 600; margin-top: 2px; }

.ai-summary {
  background: var(--primary-light);
  border: 1px solid #BFDBFE;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.6;
  color: #1E40AF;
}

/* History */
.history-item {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  font-size: 13px;
}

.history-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  flex-shrink: 0;
  margin-top: 5px;
}

.history-content { flex: 1; }
.history-action { font-weight: 600; color: var(--text); }
.history-meta { color: var(--text-light); font-size: 12px; margin-top: 2px; }
.history-note {
  background: #FEF9C3;
  border-radius: 6px;
  padding: 6px 10px;
  color: #78350F;
  margin-top: 4px;
  font-size: 12px;
}

/* Note input */
.note-input-area {
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.note-input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  font-family: 'Outfit', sans-serif;
  font-size: 13px;
  resize: none;
  outline: none;
  height: 60px;
  line-height: 1.4;
}
.note-input:focus { border-color: var(--primary); }

/* ─── FAST REPLIES ─── */
.fast-replies-toggle {
  width: 100%;
  background: var(--bg);
  border: none;
  border-top: 1px solid var(--border);
  padding: 10px 24px;
  text-align: left;
  font-family: 'Outfit', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
}
.fast-replies-toggle:hover { background: #E2E8F0; }
.fast-replies-list { padding: 12px 24px; max-height: 180px; overflow-y: auto; border-top: 1px solid var(--border); }
.reply-cat-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-light);
  margin-bottom: 6px;
  margin-top: 10px;
}
.reply-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 6px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.15s;
}
.reply-item:hover { border-color: var(--primary); background: var(--primary-light); }
.reply-item-title { font-weight: 600; font-size: 13px; }
.reply-item-text { color: var(--text-light); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ─── METRICS DASHBOARD ─── */
.metrics-view {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.metrics-title { font-size: 22px; font-weight: 700; margin-bottom: 24px; }

.metrics-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.metric-card {
  background: white;
  border-radius: 16px;
  padding: 20px 24px;
  box-shadow: var(--card-shadow);
}

.metric-card p { font-size: 13px; color: var(--text-light); margin-bottom: 8px; }
.metric-card h3 { font-size: 32px; font-weight: 700; line-height: 1; }
.metric-card.highlight { background: linear-gradient(135deg, var(--primary), #6366F1); color: white; }
.metric-card.highlight p { color: rgba(255,255,255,0.7); }

.user-metrics-table {
  background: white;
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--card-shadow);
  overflow-x: auto;
  margin-bottom: 24px;
}

.user-metrics-table h3 { font-size: 16px; font-weight: 700; margin-bottom: 16px; }

table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--border);
}
td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg); }

.intent-bar {
  background: white;
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--card-shadow);
}
.intent-bar h3 { font-size: 16px; font-weight: 700; margin-bottom: 16px; }
.intent-bar-item { margin-bottom: 12px; }
.intent-bar-label { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; font-weight: 500; }
.intent-bar-track { background: var(--bg); border-radius: 4px; height: 8px; }
.intent-bar-fill { height: 8px; border-radius: 4px; background: linear-gradient(90deg, var(--primary), #6366F1); transition: width 0.5s; }

/* ─── MODAL ─── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.modal {
  background: white;
  border-radius: 20px;
  padding: 28px;
  width: 420px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal h3 { font-size: 18px; font-weight: 700; margin-bottom: 20px; }
.modal-field { margin-bottom: 14px; }
.modal-field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-light);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.modal input, .modal select, .modal textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  font-family: 'Outfit', sans-serif;
  font-size: 14px;
  outline: none;
  background: white;
}
.modal input:focus, .modal select:focus, .modal textarea:focus { border-color: var(--primary); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* ─── TOAST ─── */
@keyframes slideIn {
  from { transform: translateX(120%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  background: #1E293B;
  color: white;
  padding: 14px 20px;
  border-radius: 12px;
  z-index: 999;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  font-family: 'Outfit', sans-serif;
  font-size: 14px;
  max-width: 320px;
  animation: slideIn 0.3s ease;
}

.toast-warning { background: #92400E; }
.toast-success { background: #065F46; }

/* ─── BUTTONS (extra) ─── */
.btn-doctoralia { background: #E8F5E9; color: #1B5E20; }
.btn-doctoralia:hover { background: #4CAF50; color: white; }

/* ─── UTILS ─── */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-light);
  gap: 8px;
}
.empty-state span { font-size: 48px; }

.loading { text-align: center; padding: 40px; color: var(--text-light); }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
