/* ============================================================
   ATHENA — CONTROLE DE TAREFAS
   Folha de estilos principal
   ============================================================ */

/* ── VARIÁVEIS / TEMA ────────────────────────────────────── */
:root {
  --bg:       #0f1117;
  --surface:  #161b27;
  --surface2: #1e2535;
  --border:   #2a3347;
  --accent:   #f5a623;
  --accent2:  #4fc3f7;
  --green:    #4caf6e;
  --red:      #e05252;
  --purple:   #9c7ef7;
  --orange:   #f5a623;
  --text:     #e8eaf0;
  --muted:    #6b7a99;
}

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

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

/* ── LOGIN ───────────────────────────────────────────────── */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
  background:
    radial-gradient(ellipse at 60% 40%, rgba(245,166,35,.07) 0%, transparent 60%),
    radial-gradient(ellipse at 20% 80%, rgba(79,195,247,.05) 0%, transparent 50%),
    var(--bg);
}
.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: 16px;
  padding: 2.5rem;
  width: 100%;
  max-width: 380px;
  animation: slideUp .3s ease;
}
.login-logo { text-align: center; margin-bottom: 2rem; }
.login-logo .icon { font-size: 2.5rem; display: block; margin-bottom: .5rem; }
.login-logo h1 { font-size: 1.3rem; font-weight: 800; color: var(--accent); letter-spacing: .1em; }
.login-logo p  { font-size: .75rem; color: var(--muted); margin-top: .2rem; }

.login-field { display: flex; flex-direction: column; gap: .4rem; margin-bottom: 1rem; }
.login-field label { font-size: .72rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.login-field input {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: .65rem .9rem;
  border-radius: 8px;
  font-family: inherit;
  font-size: .9rem;
  transition: .2s;
}
.login-field input:focus { outline: none; border-color: var(--accent); }

.login-btn {
  width: 100%;
  background: var(--accent);
  color: #000;
  border: none;
  padding: .75rem;
  border-radius: 8px;
  font-family: inherit;
  font-size: .9rem;
  font-weight: 800;
  cursor: pointer;
  transition: .2s;
  margin-top: .5rem;
}
.login-btn:hover { background: #e59510; }

.login-err {
  background: rgba(224,82,82,.12);
  border: 1px solid rgba(224,82,82,.3);
  color: #e05252;
  padding: .6rem .9rem;
  border-radius: 8px;
  font-size: .82rem;
  text-align: center;
  margin-bottom: .8rem;
  display: none;
}
.login-err.show { display: block; }

.athena-title {
  font-family: 'Audiowide', sans-serif;
  font-size: 28px;
  color: #f5a623;
  letter-spacing: 3px;
  text-align: center;
}

/* ── APP / TOPBAR ────────────────────────────────────────── */
#app { display: none; }

.topbar {
  background: var(--surface);
  border-bottom: 2px solid var(--accent);
  padding: 0 2rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-logo { font-size: 1rem; font-weight: 800; letter-spacing: .08em; color: var(--accent); text-transform: uppercase; }
.topbar-nav  { display: flex; gap: .4rem; }

.nav-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: .35rem .9rem;
  border-radius: 6px;
  font-family: inherit;
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  transition: .2s;
}
.nav-btn:hover,
.nav-btn.active { border-color: var(--accent); color: var(--accent); background: rgba(245,166,35,.07); }

.topbar-user { margin-left: auto; display: flex; align-items: center; gap: .8rem; }
.user-info { font-size: .78rem; color: var(--muted); text-align: right; line-height: 1.3; }
.user-info strong { color: var(--text); display: block; }
.role-badge { font-size: .65rem; padding: .1rem .4rem; border-radius: 10px; background: rgba(245,166,35,.15); color: var(--accent); font-weight: 700; }

/* ── SSE STATUS ──────────────────────────────────────────── */
.sse-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; transition: .3s; }
.sse-dot.online  { background: var(--green); box-shadow: 0 0 6px var(--green); }
.sse-dot.offline { background: var(--red); }

/* ── NOTIFICAÇÃO SSE ─────────────────────────────────────── */
.sse-notify {
  position: fixed;
  top: 70px;
  right: 1.5rem;
  z-index: 500;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent2);
  border-radius: 10px;
  padding: .75rem 1.1rem;
  font-size: .8rem;
  max-width: 320px;
  transform: translateX(120%);
  opacity: 0;
  transition: .35s cubic-bezier(.4,0,.2,1);
  box-shadow: 0 4px 20px rgba(0,0,0,.4);
}
.sse-notify.show { transform: translateX(0); opacity: 1; }
.sse-notify-title { font-weight: 700; color: var(--accent2); margin-bottom: .2rem; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; }
.sse-notify-msg  { color: var(--text); }

.btn-logout {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: .35rem .8rem;
  border-radius: 6px;
  font-family: inherit;
  font-size: .75rem;
  cursor: pointer;
  transition: .2s;
}
.btn-logout:hover { border-color: var(--red); color: var(--red); }

/* ── STATSBAR ────────────────────────────────────────────── */
.statsbar {
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  padding: .6rem 2rem;
  display: flex;
  gap: 2rem;
  align-items: center;
  flex-wrap: wrap;
}
.stat       { display: flex; align-items: center; gap: .5rem; font-size: .82rem; font-weight: 600; }
.stat-label { color: var(--muted); }
.stat-val   { font-size: 1rem; font-family: 'JetBrains Mono', monospace; }
.stat-val.green  { color: var(--green); }
.stat-val.red    { color: var(--red); }
.stat-val.blue   { color: var(--accent2); }
.stat-val.orange { color: var(--orange); }

/* ── LAYOUT PRINCIPAL ────────────────────────────────────── */
.main { padding: 1.5rem 2rem; }
.section        { display: none; }
.section.active { display: block; }

/* ── TOOLBAR ─────────────────────────────────────────────── */
.toolbar        { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.toolbar-title  { font-size: 1.05rem; font-weight: 800; color: var(--text); flex: 1; }
.toolbar2-title { font-size: 1.05rem; font-weight: 700; color: var(--text); flex: 1; }

.search-box {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: .42rem .85rem;
  border-radius: 8px;
  font-family: inherit;
  font-size: .82rem;
  width: 200px;
  transition: .2s;
}
.search-box:focus { outline: none; border-color: var(--accent); }

.btn-add {
  background: var(--accent);
  color: #000;
  border: none;
  padding: .45rem 1.1rem;
  border-radius: 8px;
  font-family: inherit;
  font-size: .82rem;
  font-weight: 700;
  cursor: pointer;
  transition: .2s;
}
.btn-add:hover { background: #e59510; }

/* ── TABELA ──────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: 10px; border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: .8rem; }
thead tr { background: var(--surface2); }
thead th {
  padding: .7rem 1rem;
  text-align: left;
  color: var(--muted);
  font-weight: 700;
  letter-spacing: .06em;
  font-size: .72rem;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); transition: .15s; }
tbody tr:hover { background: rgba(255,255,255,.025); }
tbody td { padding: .6rem 1rem; vertical-align: middle; }

.id-cell   { font-family: 'JetBrains Mono', monospace; color: var(--muted); font-size: .78rem; }
.dias-cell { font-family: 'JetBrains Mono', monospace; font-weight: 700; }
.dias-cell.urgent { color: var(--red); }
.dias-cell.warn   { color: var(--orange); }
.dias-cell.ok     { color: var(--green); }

/* Highlight de linha atualizada em tempo real */
@keyframes rowFlash {
  0%   { background: rgba(79,195,247,.18); }
  100% { background: transparent; }
}
.row-flash { animation: rowFlash 1.5s ease; }

/* ── BADGES ──────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: .18rem .6rem;
  border-radius: 20px;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .04em;
  white-space: nowrap;
}
.badge-n3         { background: rgba(255,107,107,.15); color: #ff6b6b;  border: 1px solid rgba(255,107,107,.3); }
.badge-n2         { background: rgba(255,209,102,.15); color: #ffd166;  border: 1px solid rgba(255,209,102,.3); }
.badge-n1         { background: rgba(6,214,160,.15);   color: #06d6a0;  border: 1px solid rgba(6,214,160,.3); }
.badge-inprogress { background: rgba(79,195,247,.15);  color: #06d6a0;  border: 1px solid rgba(79,195,247,.3); }
.badge-customer   { background: rgba(156,126,247,.15); color: #9c7ef7;  border: 1px solid rgba(156,126,247,.3); }
.badge-support    { background: rgba(245,166,35,.15);  color: #f5a623;  border: 1px solid rgba(245,166,35,.3); }
.badge-notstarted { background: rgba(224,82,82,.15);   color: #e05252;  border: 1px solid rgba(224,82,82,.3); }
.badge-done       { background: rgba(76,175,110,.15);  color: #4caf6e;  border: 1px solid rgba(76,175,110,.3); }
.badge-scheduled  { background: rgba(79,195,247,.15);  color: #4fc3f7;  border: 1px solid rgba(79,195,247,.3); }
.badge-admin      { background: rgba(245,166,35,.15);  color: var(--accent); border: 1px solid rgba(245,166,35,.3); }
.badge-user       { background: rgba(107,122,153,.15); color: var(--muted);  border: 1px solid rgba(107,122,153,.3); }
.badge-ativo      { background: rgba(76,175,110,.15);  color: #4caf6e;  border: 1px solid rgba(76,175,110,.3); }
.badge-inativo    { background: rgba(224,82,82,.15);   color: #e05252;  border: 1px solid rgba(224,82,82,.3); }

/* ── BOTÕES DE AÇÃO ──────────────────────────────────────── */
.actions  { display: flex; gap: .35rem; }
.btn-icon {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  width: 27px;
  height: 27px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: .78rem;
  transition: .2s;
}
.btn-icon:hover     { border-color: var(--accent); color: var(--accent); }
.btn-icon.del:hover { border-color: var(--red);    color: var(--red); }
.btn-icon.fin:hover { border-color: var(--green);  color: var(--green); }

/* ── MODAIS ──────────────────────────────────────────────── */
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  backdrop-filter: blur(4px);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: 12px;
  padding: 2rem;
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp .2s ease;
}
.modal-title { font-size: 1rem; font-weight: 800; margin-bottom: 1.4rem; color: var(--accent); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; }
.form-group { display: flex; flex-direction: column; gap: .35rem; }
.form-group.full { grid-column: 1 / -1; }
.form-group label { font-size: .72rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.form-group input,
.form-group select,
.form-group textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: .5rem .75rem;
  border-radius: 8px;
  font-family: inherit;
  font-size: .82rem;
  transition: .2s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { outline: none; border-color: var(--accent); }
.form-group select option  { background: var(--surface2); }
.form-group textarea { resize: vertical; min-height: 72px; }

.modal-actions { display: flex; gap: .7rem; justify-content: flex-end; margin-top: 1.3rem; }
.btn-cancel {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: .5rem 1.1rem;
  border-radius: 8px;
  font-family: inherit;
  font-size: .82rem;
  cursor: pointer;
  transition: .2s;
}
.btn-cancel:hover { border-color: var(--red); color: var(--red); }
.btn-save {
  background: var(--accent);
  color: #000;
  border: none;
  padding: .5rem 1.4rem;
  border-radius: 8px;
  font-family: inherit;
  font-size: .82rem;
  font-weight: 700;
  cursor: pointer;
  transition: .2s;
}
.btn-save:hover { background: #e59510; }

/* ── CARDS ───────────────────────────────────────────────── */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1rem; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.1rem;
  transition: .2s;
  position: relative;
}
.card:hover      { border-color: var(--accent); transform: translateY(-2px); }
.card-title      { font-size: .9rem; font-weight: 800; margin-bottom: .25rem; }
.card-sub        { font-size: .75rem; color: var(--muted); margin-bottom: .7rem; }
.card-meta       { font-size: .72rem; color: var(--muted); }
.card-actions    { position: absolute; top: .75rem; right: .75rem; display: flex; gap: .3rem; }

/* ── TOAST ───────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 999;
  background: var(--green);
  color: #000;
  padding: .65rem 1.3rem;
  border-radius: 8px;
  font-weight: 700;
  font-size: .82rem;
  transform: translateY(100px);
  opacity: 0;
  transition: .3s;
  max-width: 360px;
}
.toast.show  { transform: translateY(0); opacity: 1; }
.toast.error { background: var(--red); color: #fff; }

/* ── MISC ────────────────────────────────────────────────── */
.empty       { text-align: center; padding: 3.5rem; color: var(--muted); font-size: .88rem; }
.divider     { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }
.section-sub { font-size: .72rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: .6rem; }
.obs-cell    { max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .75rem; color: var(--muted); }
.tarefa-cell { max-width: 230px; }
.tarefa-cell span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── FILTROS ─────────────────────────────────────────────── */
.filter-row  { display: flex; gap: .5rem; flex-wrap: wrap; }
.filter-chip {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: .28rem .75rem;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
  cursor: pointer;
  transition: .2s;
}
.filter-chip:hover,
.filter-chip.active              { border-color: var(--accent); color: var(--accent); background: rgba(245,166,35,.07); }
.filter-chip.chip-done:hover,
.filter-chip.chip-done.active    { border-color: var(--green);  color: var(--green);  background: rgba(76,175,110,.07); }

/* ── MODAL HISTÓRICO ─────────────────────────────────────── */
.hist-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.72);
  backdrop-filter: blur(5px);
  z-index: 300;
  align-items: flex-start;
  justify-content: center;
  padding: 3rem 1rem;
  overflow-y: auto;
}
.hist-overlay.open { display: flex; }

.hist-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent2);
  border-radius: 14px;
  width: 100%;
  max-width: 620px;
  display: flex;
  flex-direction: column;
}
.hist-head {
  padding: 1.1rem 1.4rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}
.hist-head-title { font-size: .9rem; font-weight: 800; color: var(--accent2); }
.hist-head-sub   { font-size: .72rem; color: var(--muted); margin-top: .15rem; }
.hist-head-close {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: .2rem .4rem;
  border-radius: 4px;
  flex-shrink: 0;
  transition: .2s;
}
.hist-head-close:hover { color: var(--red); }

.hist-body {
  padding: 1rem 1.4rem;
  max-height: 400px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: .7rem;
}
.hist-empty { text-align: center; padding: 2.5rem; color: var(--muted); font-size: .82rem; }

.hist-msg       { display: flex; flex-direction: column; gap: .25rem; animation: slideUp .18s ease; }
.hist-msg-meta  { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.hist-msg-user  { font-size: .7rem; font-weight: 800; color: var(--accent); background: rgba(245,166,35,.1); padding: .1rem .45rem; border-radius: 10px; }
.hist-msg-time  { font-size: .67rem; color: var(--muted); font-family: 'JetBrains Mono', monospace; }
.hist-msg-del   { margin-left: auto; background: transparent; border: none; color: transparent; cursor: pointer; font-size: .72rem; padding: .1rem .3rem; border-radius: 4px; transition: .2s; }
.hist-msg:hover .hist-msg-del { color: var(--muted); }
.hist-msg-del:hover { color: var(--red) !important; }
.hist-msg-text  { font-size: .82rem; color: var(--text); background: var(--surface2); padding: .55rem .85rem; border-radius: 0 8px 8px 8px; border: 1px solid var(--border); white-space: pre-wrap; line-height: 1.55; }

.hist-foot {
  padding: .9rem 1.4rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: .6rem;
  align-items: flex-end;
}
.hist-foot-row { display: flex; gap: .6rem; align-items: flex-end; width: 100%; }

.hist-input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: .5rem .75rem;
  border-radius: 8px;
  font-family: inherit;
  font-size: .82rem;
  resize: none;
  transition: .2s;
  line-height: 1.4;
  min-height: 38px;
  max-height: 110px;
  overflow-y: auto;
}
.hist-input:focus { outline: none; border-color: var(--accent2); }

.hist-send {
  background: var(--accent2);
  color: #000;
  border: none;
  padding: .5rem 1rem;
  border-radius: 8px;
  font-family: inherit;
  font-size: .82rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: .2s;
  flex-shrink: 0;
}
.hist-send:hover    { background: #3ab0e0; }
.hist-send:disabled { opacity: .4; cursor: not-allowed; }

.msgs-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(79,195,247,.18);
  color: var(--accent2);
  border-radius: 10px;
  font-size: .62rem;
  font-weight: 700;
  padding: .05rem .38rem;
  min-width: 16px;
  font-family: 'JetBrains Mono', monospace;
  margin-left: .2rem;
}

/* ── ANEXOS ──────────────────────────────────────────────── */
.hist-attach-preview {
  display: flex;
  align-items: center;
  gap: .5rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .4rem .7rem;
  font-size: .75rem;
  animation: slideUp .15s ease;
  width:100%;
}
.hist-attach-preview img { height: 38px; width: 38px; object-fit: cover; border-radius: 4px; border: 1px solid var(--border); }
.hist-attach-icon  { font-size: 1.4rem; line-height: 1; }
.hist-attach-info  { display: flex; flex-direction: column; gap: .1rem; flex: 1; min-width: 0; }
.hist-attach-name  { font-weight: 700; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; }
.hist-attach-size  { color: var(--muted); }
.hist-attach-remove {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: .85rem;
  padding: .1rem .3rem;
  border-radius: 4px;
  transition: .2s;
  flex-shrink: 0;
}
.hist-attach-remove:hover { color: var(--red); }

.btn-clip {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  transition: .2s;
  flex-shrink: 0;
}
.btn-clip:hover    { border-color: var(--accent2); color: var(--accent2); }
.btn-clip.has-file { border-color: var(--accent2); color: var(--accent2); background: rgba(79,195,247,.1); }

.hist-msg-anexo     { margin-top: .4rem; }
.hist-msg-anexo-img {
  max-width: 100%;
  max-height: 260px;
  border-radius: 8px;
  border: 1px solid var(--border);
  display: block;
  cursor: pointer;
  transition: .2s;
}
.hist-msg-anexo-img:hover { opacity: .9; }
.hist-msg-anexo-file {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .4rem .75rem;
  font-size: .78rem;
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
  transition: .2s;
}
.hist-msg-anexo-file:hover { border-color: var(--accent2); color: var(--accent2); }
.hist-msg-anexo-file span  { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }

/* ── RESPONSIVO ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .main       { padding: 1rem; }
  .form-grid  { grid-template-columns: 1fr; }
  .topbar     { padding: 0 1rem; gap: .8rem; }
}
