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

/* Variáveis de cor/layout vêm de /css/variables.css (linkado antes deste arquivo). */

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 14px;
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
}

.screen { display: flex; flex-direction: column; flex: 1; }
.hidden { display: none !important; }

/* ── Setup ─────────────────────────────────────────────────── */
#screen-setup {
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 32px 24px;
  text-align: center;
}

.setup-logo { color: var(--accent); }
.setup-logo svg { width: 48px; height: 48px; }
.setup-title { font-size: 18px; font-weight: 700; }
.setup-sub   { font-size: 13px; color: var(--text-muted); }

#screen-setup #btn-setup-retry { margin-top: 8px; }

/* ── Main screen ───────────────────────────────────────────── */
#screen-main {
  padding: 0;
}

/* ── Status bar ────────────────────────────────────────────── */
.statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

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

.statusbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.agent-name {
  font-family: var(--serif);
  font-size: 14px;
  font-weight: 700;
  background: var(--text);
  color: var(--amber);
  padding: 3px 12px;
  border-radius: 12px;
  letter-spacing: .01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.ramal-badge {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  background: var(--surface2);
  color: var(--text-muted);
  padding: 2px 10px;
  border-radius: 12px;
  letter-spacing: .03em;
  flex-shrink: 0;
}

/* Status dot */
.dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.dot-green { background: var(--green); box-shadow: 0 0 0 3px rgba(31,58,47,.25); }
.dot-red   { background: var(--red);   box-shadow: 0 0 0 3px rgba(138,47,36,.25); }
.dot-gray  { background: var(--text-muted); }
.dot-amber { background: var(--amber); box-shadow: 0 0 0 3px rgba(183,137,74,.25); }

/* ── Overlays ──────────────────────────────────────────────── */
.overlay {
  position: absolute;
  inset: 52px 0 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  z-index: 10;
}

.call-icon  { font-size: 40px; }
.call-number {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.01em;
  color: var(--text);
}
.call-label { font-size: 12px; color: var(--text-muted); }
.call-timer {
  font-family: var(--mono);
  font-size: 28px;
  font-weight: 700;
  color: var(--green);
  letter-spacing: .05em;
}

.transfer-row {
  display: flex;
  gap: 8px;
  width: 100%;
  max-width: 280px;
}

.transfer-row select {
  flex: 1;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
}

/* ── Dialpad ───────────────────────────────────────────────── */
#dialpad {
  padding: 16px 14px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.input-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.contact-search-wrap { position: relative; }

.contact-search-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
}
.contact-search-input:focus { border-color: var(--accent); }

.contact-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 6px 16px rgba(12,10,8,.12);
  max-height: 220px;
  overflow-y: auto;
  z-index: 15;
}

.contact-result-item {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.contact-result-item:last-child { border-bottom: none; }
.contact-result-item:hover { background: var(--surface2); }

.contact-result-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.contact-result-phone {
  font-size: 12px;
  color: var(--text-muted);
}

.contact-result-empty {
  padding: 10px 12px;
  font-size: 12px;
  color: var(--text-muted);
}

#phone-input {
  flex: 1;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 16px;
  outline: none;
  transition: border-color .15s;
}

#phone-input:focus { border-color: var(--accent); }

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

.digit {
  padding: 12px 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 24px;
  font-weight: 600;
  cursor: pointer;
  transition: background .1s;
  line-height: 1;
  text-align: center;
}

.digit sub {
  display: block;
  font-size: 10px;
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: .08em;
  margin-top: 2px;
}

.digit:hover  { background: var(--surface2); }
.digit:active { background: var(--accent); color: #fff; }

/* ── Buttons ───────────────────────────────────────────────── */
.btn-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  width: 100%;
}

.btn-primary, .btn-call, .btn-answer, .btn-reject,
.btn-hangup, .btn-mute, .btn-transfer {
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  padding: 11px 20px;
  transition: opacity .15s, transform .1s;
}

.btn-primary:active, .btn-call:active,
.btn-answer:active, .btn-reject:active,
.btn-hangup:active { transform: scale(.97); }

.btn-primary {
  background: var(--accent);
  color: #fff;
  width: 100%;
  max-width: 240px;
  padding: 12px;
}

.btn-call {
  background: var(--green);
  color: #fff;
  width: 100%;
  font-size: 15px;
  padding: 13px;
}

.btn-call:disabled {
  background: var(--surface2);
  color: var(--text-muted);
  cursor: not-allowed;
}

.btn-answer  { background: var(--green); color: #fff; flex: 1; }
.btn-reject  { background: var(--red);   color: #fff; flex: 1; }
.btn-hangup  { background: var(--red);   color: #fff; flex: 1; padding: 12px 28px; }
.btn-mute    { background: var(--surface2); color: var(--text); padding: 12px 18px; }
.btn-transfer { background: var(--accent);  color: #fff; white-space: nowrap; padding: 8px 14px; font-size: 13px; }

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 4px 6px;
  border-radius: 4px;
  transition: color .15s;
}
.btn-icon:hover { color: var(--text); }
.btn-icon svg { width: 16px; height: 16px; display: block; }

.icon-inline {
  width: 15px;
  height: 15px;
  vertical-align: -3px;
  margin-right: 2px;
}

.btn-link {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 15px;
  padding: 0;
  line-height: 1;
}
.btn-link:hover { color: var(--text); }

/* ── Ligar com IA (par ink/gold, mesmo código de cor usado pra "IA" em toda a interface) ── */
.btn-ai-call {
  border: 1.5px solid var(--gold-dark);
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  padding: 10px;
  width: 100%;
  background: transparent;
  color: var(--gold-dark);
  transition: background .15s, color .15s;
}
.btn-ai-call:hover { background: rgba(183,137,74,.15); }
.btn-ai-call:disabled { opacity: .4; cursor: not-allowed; }

/* ── Modal IA ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  padding: 16px;
}

.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  width: 100%;
  max-height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-card h3 { font-size: 15px; font-weight: 700; }

.modal-field { display: flex; flex-direction: column; gap: 5px; }
.modal-field label { font-size: 12px; color: var(--text-muted); }
.modal-field input:not([type="checkbox"]),
.modal-field select,
.modal-field textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  padding: 9px 11px;
  outline: none;
  transition: border-color .15s;
}
.modal-field input:focus,
.modal-field select:focus,
.modal-field textarea:focus { border-color: var(--gold-dark); }
.modal-field textarea { min-height: 80px; resize: vertical; }

.prompt-select-row { display: flex; gap: 6px; align-items: center; }
.prompt-select-row select {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  padding: 9px 11px;
  outline: none;
}
.prompt-select-row select:focus { border-color: var(--gold-dark); }
.prompt-select-row .btn-icon {
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 14px;
  padding: 8px 9px;
  flex-shrink: 0;
}

#ai-agendar-extra { display: flex; flex-direction: column; gap: 14px; }

#modal-prompt-save, #modal-prompt-del { z-index: 21; }

.modal-field label:has(input[type="checkbox"]) {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}
.modal-field input[type="checkbox"] {
  width: auto;
  accent-color: var(--gold-dark);
}

.modal-status {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  min-height: 16px;
}
.modal-status.active { color: var(--gold-dark); }
.modal-status.error  { color: var(--red); }
