/* Botões e campos */

.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-weight: 600;
  background: var(--color-accent);
  color: var(--color-accent-contrast);
  transition: opacity 0.15s ease;
}
.btn:hover { opacity: 0.9; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  border-color: var(--color-border);
  color: var(--color-text);
}

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  text-align: left;
  margin-bottom: var(--space-3);
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
}

.field input,
.field select,
.field textarea {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  background: var(--color-surface);
  color: var(--color-text);
  font-weight: 400;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 1px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--color-surface-alt);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}

/* Tela de login */

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--color-bg);
  padding: var(--space-5);
}

.login-card {
  width: min(360px, 100%);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--space-6) var(--space-5);
  text-align: center;
}

.login-logo {
  height: 40px;
  margin-bottom: var(--space-4);
}

.login-card h1 {
  font-size: 20px;
  margin-bottom: var(--space-4);
}

.login-card .btn {
  width: 100%;
  justify-content: center;
  margin-top: var(--space-2);
}

.login-error {
  margin: var(--space-3) 0 0;
  color: var(--color-danger);
  font-size: 13px;
}

.password-field {
  position: relative;
}

.password-field input {
  width: 100%;
  padding-right: 40px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: none;
  background: none;
  color: var(--color-text-muted);
  border-radius: var(--radius-sm);
}

.password-toggle:hover { color: var(--color-text); }

.password-toggle .icon-eye-off { display: none; }
.password-toggle.showing .icon-eye { display: none; }
.password-toggle.showing .icon-eye-off { display: block; }

/* Casca do app */

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--color-sidebar-bg);
  border-right: 1px solid var(--color-sidebar-border);
  padding: var(--space-4) var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-2) var(--space-5);
  color: var(--color-sidebar-text-active);
  font-weight: 700;
}

.sidebar-brand img { height: 24px; width: auto; }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }

.sidebar-nav a {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--color-sidebar-text);
  font-size: 14px;
  font-weight: 500;
  border-left: 3px solid transparent;
}

.sidebar-nav a:hover { color: var(--color-sidebar-text-active); }

.sidebar-nav a.active {
  color: var(--color-sidebar-text-active);
  background: rgba(3, 162, 254, 0.12);
  border-left-color: var(--color-accent);
}

.app-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.app-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: 0 var(--space-5);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
}

.app-header-user {
  margin-right: auto;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
}

#view-root {
  flex: 1;
  padding: var(--space-5);
  overflow-y: auto;
}

.view-placeholder {
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  text-align: center;
  color: var(--color-text-muted);
}

/* Views reais (Clientes, WhatsApp, Hermes Control) */

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}

.view-header p { margin: 0; }

.toolbar { display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; }

.panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
}

.panel-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
}

.two-col {
  display: grid;
  grid-template-columns: minmax(240px, 320px) 1fr;
  gap: var(--space-4);
  align-items: start;
}

@media (max-width: 960px) {
  .two-col { grid-template-columns: 1fr; }
}

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

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  background: none;
  width: 100%;
  text-align: left;
  color: var(--color-text);
}

.list-item:hover { background: var(--color-surface-alt); }

.list-item.active {
  background: rgba(3, 162, 254, 0.1);
  border-color: var(--color-accent);
}

.list-item-main { font-weight: 600; font-size: 14px; }
.list-item-meta { font-size: 12px; color: var(--color-text-muted); }

.empty-state {
  padding: var(--space-5);
  text-align: center;
  color: var(--color-text-muted);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.tag::before { content: ''; width: 6px; height: 6px; border-radius: 999px; background: currentColor; }

.tag-neutral { background: var(--color-surface-alt); color: var(--color-text-muted); }
.tag-info { background: rgba(3, 162, 254, 0.14); color: var(--color-accent); }
.tag-success { background: rgba(31, 157, 99, 0.14); color: var(--color-success); }
.tag-warning { background: rgba(168, 113, 10, 0.14); color: var(--color-warning); }
.tag-danger { background: rgba(214, 69, 69, 0.14); color: var(--color-danger); }

.inline-form { display: flex; gap: var(--space-2); align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { margin-bottom: 0; min-width: 160px; }

.qr-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5);
  text-align: center;
}

.qr-box canvas { border-radius: var(--radius-sm); background: #fff; padding: 12px; }

.pre-output {
  background: var(--color-sidebar-bg);
  color: #d7dceb;
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  font-size: 12px;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.hint { font-size: 12px; color: var(--color-text-muted); margin-top: var(--space-1); }

.form-error { color: var(--color-danger); font-size: 13px; margin-top: var(--space-2); }
.form-success { color: var(--color-success); font-size: 13px; margin-top: var(--space-2); }

.actions-row { display: flex; gap: var(--space-2); flex-wrap: wrap; }

/* Tarefas — kanban */

.kanban-board {
  display: flex;
  gap: var(--space-4);
  overflow-x: auto;
  padding-bottom: var(--space-2);
  align-items: flex-start;
}

.kanban-column {
  background: var(--color-surface-alt);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  min-width: 260px;
  flex: 1 1 260px;
}

.kanban-column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0 var(--space-1) var(--space-3);
}

.kanban-cards { display: flex; flex-direction: column; gap: var(--space-2); min-height: 40px; }

.kanban-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  box-shadow: var(--shadow-sm);
  cursor: grab;
}

.kanban-card.dragging { opacity: 0.4; }
.kanban-card:active { cursor: grabbing; }

.kanban-touch-ghost {
  position: fixed;
  z-index: 1000;
  pointer-events: none;
  transform: translate(-50%, -50%) rotate(-2deg);
  opacity: 0.9;
  box-shadow: var(--shadow-md);
}

.kanban-cards.drag-over {
  outline: 2px dashed var(--color-accent);
  outline-offset: -2px;
  border-radius: var(--radius-sm);
  background: rgba(3, 162, 254, 0.06);
}

.kanban-card-title { font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.kanban-card-meta { font-size: 12px; color: var(--color-text-muted); margin-bottom: 2px; }
.kanban-card-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: var(--space-2); }
.kanban-card-actions .btn { padding: 5px 10px; font-size: 12px; }

.notif-bell {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.notif-badge {
  position: absolute;
  top: -4px;
  right: -6px;
  background: var(--color-danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}

/* Dashboard */

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.stat-tile {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-accent);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}

.stat-tile.stat-warning { border-left-color: var(--color-warning); }
.stat-tile.stat-danger { border-left-color: var(--color-danger); }
.stat-tile.stat-success { border-left-color: var(--color-success); }

.stat-value { font-size: 32px; font-weight: 700; line-height: 1.1; letter-spacing: -0.02em; }
.stat-label { font-size: 13px; color: var(--color-text-muted); margin-top: 4px; }

.progress-track {
  width: 100%;
  height: 8px;
  background: var(--color-surface-alt);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill { height: 100%; background: var(--color-accent); border-radius: 999px; transition: width 0.2s ease; }
.progress-fill.progress-complete { background: var(--color-success); }

.checklist-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--color-border);
}
.checklist-item:last-child { border-bottom: none; }
.checklist-item input[type="checkbox"] { width: 18px; height: 18px; margin-top: 2px; flex-shrink: 0; }
.checklist-item-body { flex: 1; min-width: 0; }
.checklist-item-label { font-weight: 600; }
.checklist-item-label.done { color: var(--color-text-muted); text-decoration: line-through; }
.checklist-item-notes { margin-top: 4px; }

.dashboard-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--space-4);
  align-items: start;
}

@media (max-width: 860px) {
  /* grid com min-height:100vh distribuiria o espaço sobrando entre as duas
     linhas (sidebar + app-main) mesmo com conteúdo baixo; flex column faz a
     sidebar ficar do tamanho do próprio conteúdo. */
  .app-shell { display: flex; flex-direction: column; }
  .sidebar {
    flex-direction: row;
    align-items: center;
    flex: none;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--color-sidebar-border);
  }
  .sidebar-brand { display: none; }
  .sidebar-nav { flex-direction: row; }

  /* Sem isso, e-mail + sino + 2 botões numa única linha de altura fixa
     estouram um viewport de celular e o texto do e-mail sai cortado à
     esquerda da tela (achado testando em 390px de largura). */
  .app-header {
    height: auto;
    flex-wrap: wrap;
    row-gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
  }
  .app-header-user {
    order: -1;
    width: 100%;
    margin-right: 0;
    overflow-wrap: anywhere;
  }

  /* .list-item (usuários em Configurações, itens de lista em geral) empilha
     em vez de manter tudo numa linha só — com e-mail + select de papel + 2
     botões lado a lado, a linha ficava mais larga que a tela e os botões
     de ação saíam da área visível sem nenhuma forma de rolar até eles. */
  .list-item {
    flex-wrap: wrap;
    row-gap: var(--space-2);
  }
  .list-item .actions-row {
    width: 100%;
  }
}
