/* app.css — Top Level Digital */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #f5f4f0;
  --surface:   #ffffff;
  --border:    #e2e0d8;
  --text:      #1a1a18;
  --muted:     #6b6a65;
  --primary:   #1a56db;
  --primary-h: #1447b2;
  --success:   #057a55;
  --warning:   #b45309;
  --danger:    #c81e1e;
  --emily:     #7c3aed;
  --humano:    #0369a1;
  --radius:    8px;
  --shadow:    0 1px 3px rgba(0,0,0,.08);
  --nav-h:     52px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:      #18181a;
    --surface: #242428;
    --border:  #38383e;
    --text:    #e8e6de;
    --muted:   #8a8880;
  }
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
}

/* ---- NAVBAR ---- */
.navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 16px;
  z-index: 100;
  box-shadow: var(--shadow);
}

.navbar-brand {
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-right: 24px;
  flex-shrink: 0;
}

.brand-icon { color: var(--primary); font-size: 16px; }

.navbar-links {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
}

.navbar-links a {
  color: var(--muted);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  transition: background .15s, color .15s;
}

.navbar-links a:hover { background: var(--bg); color: var(--text); }
.navbar-links a.active { background: var(--bg); color: var(--text); font-weight: 500; }

.navbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--muted);
  flex-shrink: 0;
}

.btn-logout {
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  padding: 4px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  transition: background .15s;
}
.btn-logout:hover { background: var(--bg); }

/* ---- MAIN ---- */
.main-content {
  margin-top: var(--nav-h);
  padding: 0;
  height: calc(100vh - var(--nav-h));
  overflow: hidden;
}

/* sem navbar (login) */
.login-page .main-content { margin-top: 0; height: 100vh; }

/* ---- ALERTS ---- */
.alert {
  padding: 10px 16px;
  border-radius: var(--radius);
  margin: 12px 16px 0;
  font-size: 13px;
}
.alert-danger  { background: #fef2f2; border: 1px solid #fca5a5; color: #991b1b; }
.alert-success { background: #f0fdf4; border: 1px solid #86efac; color: #166534; }
.alert-warning { background: #fffbeb; border: 1px solid #fcd34d; color: #92400e; }

/* ---- LOGIN ---- */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 4px 24px rgba(0,0,0,.08);
}

.login-brand {
  text-align: center;
  margin-bottom: 28px;
}

.login-brand h1 {
  font-size: 20px;
  font-weight: 600;
  margin-top: 8px;
}

/* ---- FORMS ---- */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: var(--muted); }

input[type=text], input[type=email], input[type=password],
input[type=number], textarea, select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  transition: border-color .15s;
  outline: none;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,86,219,.12);
}

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, opacity .15s;
  text-decoration: none;
  white-space: nowrap;
}

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

.btn-primary  { background: var(--primary);  color: #fff; }
.btn-primary:hover  { background: var(--primary-h); }
.btn-success  { background: var(--success);  color: #fff; }
.btn-warning  { background: var(--warning);  color: #fff; }
.btn-danger   { background: var(--danger);   color: #fff; }
.btn-secondary { background: var(--bg); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-block { width: 100%; }

/* ---- BADGES ---- */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.badge-emily  { background: #ede9fe; color: #5b21b6; }
.badge-humano { background: #e0f2fe; color: #075985; }

/* ---- DESK LAYOUT ---- */
.desk-layout {
  display: flex;
  height: 100%;
  overflow: hidden;
}

/* sidebar */
.desk-sidebar {
  width: 300px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--surface);
}

.desk-sidebar-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.desk-sidebar-header h2 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
}

.desk-filters {
  display: flex;
  gap: 4px;
}

.filter-btn {
  padding: 4px 10px;
  border-radius: 100px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  transition: background .15s, color .15s;
}

.filter-btn.active, .filter-btn:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.conversa-lista {
  flex: 1;
  overflow-y: auto;
}

.conversa-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .1s;
}

.conversa-item:hover, .conversa-item.ativa {
  background: var(--bg);
}

.conversa-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.conversa-ultima-msg {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversa-tempo {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

/* chat area */
.desk-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

.chat-vazio {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}

.chat-ativo {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-header {
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

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

.chat-mensagens {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.msg { display: flex; flex-direction: column; max-width: 70%; }
.msg-user     { align-self: flex-start; align-items: flex-start; }
.msg-assistant { align-self: flex-end; align-items: flex-end; }
.msg-system   { align-self: center; }

.msg-bubble {
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg-user     .msg-bubble { background: var(--surface); border: 1px solid var(--border); }
.msg-assistant .msg-bubble { background: var(--primary); color: #fff; }
.msg-system   .msg-bubble { background: #fffbeb; color: #92400e; font-size: 12px; }

.msg-time { font-size: 11px; color: var(--muted); margin-top: 2px; }

.chat-input-area {
  padding: 12px 20px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
}

.chat-input-area textarea {
  flex: 1;
  resize: none;
  max-height: 120px;
}

/* ---- PAGE HEADER ---- */
.page-header {
  padding: 24px 24px 0;
}
.page-header h1 { font-size: 20px; font-weight: 600; }

/* ---- UTILITIES ---- */
.text-muted { color: var(--muted); }
.loading, .empty { padding: 20px; text-align: center; color: var(--muted); font-size: 13px; }

/* ---- TABELA ---- */
.tabela { width: 100%; border-collapse: collapse; font-size: 13px; }
.tabela th {
  text-align: left; padding: 8px 10px;
  background: var(--bg); border-bottom: 2px solid var(--border);
  font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase;
}
.tabela td { padding: 10px; border-bottom: 1px solid var(--border); }
.tabela tfoot td { border-top: 2px solid var(--border); border-bottom: none; }
.tr-link:hover td { background: var(--bg); cursor: pointer; }

/* ---- STATUS BADGES ---- */
.status-badge {
  display: inline-block; padding: 2px 10px; border-radius: 100px;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em;
}
.s-rascunho  { background: #f1efea; color: #5f5e5a; }
.s-enviado   { background: #e0f2fe; color: #075985; }
.s-aprovado  { background: #dcfce7; color: #166534; }
.s-perdido   { background: #fee2e2; color: #991b1b; }
.s-aberto    { background: #e0f2fe; color: #075985; }
.s-producao  { background: #fef9c3; color: #854d0e; }
.s-concluido { background: #dcfce7; color: #166534; }
.s-cancelado { background: #fee2e2; color: #991b1b; }

/* ---- FORM SECTION ---- */
.form-section {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 12px;
}
.section-title {
  font-size: 13px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em; margin-bottom: 12px;
  display: flex; justify-content: space-between; align-items: center;
}

/* ---- INFO GRID ---- */
.info-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px,1fr)); gap: 10px; }
.info-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 14px;
}
.info-label { font-size: 11px; color: var(--muted); text-transform: uppercase; font-weight: 600; margin-bottom: 4px; }
.info-val   { font-size: 14px; font-weight: 500; }

/* ---- AUTOCOMPLETE ---- */
.autocomplete-list {
  position: absolute; z-index: 50; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); max-height: 200px; overflow-y: auto; width: 100%;
}
.autocomplete-item {
  padding: 8px 12px; cursor: pointer; font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.autocomplete-item:hover { background: var(--bg); }
.autocomplete-item:last-child { border-bottom: none; }

/* ---- ITEM ROW ---- */
.item-row {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 12px; margin-bottom: 8px;
}

/* ---- ACTION BTN (ícones de ação em tabelas) ---- */
.action-btn {
  background: none; border: none; cursor: pointer;
  padding: 4px 6px; border-radius: 6px;
  color: var(--muted); font-size: 14px;
  text-decoration: none; display: inline-block;
  transition: background .15s;
}
.action-btn:hover { background: var(--bg); color: var(--text); }
.action-btn.danger:hover { background: #fee2e2; color: var(--danger); }

/* ---- STATUS SELECT inline (listagem) ---- */
.status-select {
  border: none; background: transparent; cursor: pointer;
  font-size: 11px; font-weight: 600; padding: 2px 8px;
  border-radius: 100px;
}
.status-select:focus { outline: none; }
