/* ==========================================================================
   FIERO OS v0.1.1 — Custom CSS (NO Tailwind CDN, NO external fonts).
   Dark operator theme. Served locally from /static/css/app.css.
   ========================================================================== */

:root {
  --bg: #0d1117;
  --bg-alt: #161b22;
  --bg-elev: #1c2230;
  --border: #2d333b;
  --text: #e6edf3;
  --text-dim: #9da7b3;
  --accent: #f97316;
  --accent-dim: #c2570f;
  --green: #2ea043;
  --red: #da3633;
  --yellow: #d29922;
  --blue: #388bfd;
  --radius: 8px;
  --sidebar-w: 232px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Layout --- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-alt);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  overflow-y: auto;
}

.sidebar .brand {
  padding: 18px 20px;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  color: var(--accent);
}
.sidebar .brand span { color: var(--text-dim); font-size: 11px; font-weight: 400; display: block; }

.nav { list-style: none; margin: 0; padding: 10px 0; flex: 1; }
.nav li a {
  display: block;
  padding: 9px 20px;
  color: var(--text-dim);
  border-left: 3px solid transparent;
}
.nav li a:hover { background: var(--bg-elev); color: var(--text); text-decoration: none; }
.nav li a.active { color: var(--text); border-left-color: var(--accent); background: var(--bg-elev); }

.content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-alt);
}
.topbar .title { font-size: 16px; font-weight: 600; }
.topbar .user { color: var(--text-dim); font-size: 13px; display: flex; gap: 14px; align-items: center; }

.main { padding: 24px; flex: 1; }

/* --- Cards / grid --- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.card {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.card h3 { margin: 0 0 6px; font-size: 13px; color: var(--text-dim); font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }
.card .metric { font-size: 30px; font-weight: 700; }

.section-title { font-size: 15px; font-weight: 600; margin: 26px 0 12px; }

/* --- Tables --- */
table { width: 100%; border-collapse: collapse; background: var(--bg-alt); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 13px; }
th { color: var(--text-dim); font-weight: 600; text-transform: uppercase; font-size: 11px; letter-spacing: 0.5px; background: var(--bg-elev); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-elev); }

/* --- Badges --- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge-active, .badge-open, .badge-succeeded, .badge-completed { background: rgba(46,160,67,0.18); color: var(--green); }
.badge-paused, .badge-medium, .badge-review, .badge-pending, .badge-proposed { background: rgba(210,153,34,0.18); color: var(--yellow); }
.badge-failed, .badge-blocked, .badge-critical, .badge-high { background: rgba(218,54,51,0.18); color: var(--red); }
.badge-archived, .badge-cancelled, .badge-low, .badge-draft { background: rgba(157,167,179,0.18); color: var(--text-dim); }

/* --- Forms --- */
form { max-width: 420px; }
label { display: block; margin: 12px 0 4px; color: var(--text-dim); font-size: 13px; }
input, textarea, select {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }

.btn {
  display: inline-block;
  padding: 10px 18px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
}
.btn:hover { background: var(--accent-dim); text-decoration: none; }
.btn-secondary { background: var(--bg-elev); color: var(--text); border: 1px solid var(--border); }
.btn-sm { padding: 5px 12px; font-size: 12px; }

/* --- Auth screens --- */
.auth-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.auth-box { width: 360px; background: var(--bg-alt); border: 1px solid var(--border); border-radius: 12px; padding: 32px; }
.auth-box h1 { font-size: 22px; margin: 0 0 4px; color: var(--accent); text-align: center; }
.auth-box .sub { text-align: center; color: var(--text-dim); margin-bottom: 22px; font-size: 13px; }
.auth-box .btn { width: 100%; margin-top: 18px; }

.alert { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; font-size: 13px; }
.alert-error { background: rgba(218,54,51,0.15); color: var(--red); border: 1px solid rgba(218,54,51,0.4); }
.alert-info { background: rgba(56,139,253,0.12); color: var(--blue); border: 1px solid rgba(56,139,253,0.35); }
.alert-warn { background: rgba(210,153,34,0.14); color: #d29922; border: 1px solid rgba(210,153,34,0.4); }

.muted { color: var(--text-dim); }
.mono { font-family: var(--mono); font-size: 12px; }
.empty { color: var(--text-dim); padding: 24px; text-align: center; border: 1px dashed var(--border); border-radius: var(--radius); }
.row-actions { display: flex; gap: 8px; }
.search-bar { display: flex; gap: 10px; margin-bottom: 16px; max-width: 520px; }
.search-bar input { flex: 1; }
pre.code { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 14px; overflow-x: auto; font-family: var(--mono); font-size: 12px; }



/* --- v0.1.2: user menu dropdown + account security page --- */
.user-menu { position: relative; display: inline-block; }
.user-menu > summary {
  list-style: none; cursor: pointer; user-select: none;
  padding: 6px 12px; border: 1px solid var(--border, #2a2f3a);
  border-radius: 6px; background: var(--panel, #1a1e27); font-size: 0.9rem;
}
.user-menu > summary::-webkit-details-marker { display: none; }
.user-menu[open] > summary { border-color: var(--accent, #d4a13a); }
.user-menu-dropdown {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 50;
  min-width: 220px; background: var(--panel, #1a1e27);
  border: 1px solid var(--border, #2a2f3a); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4); overflow: hidden;
}
.user-menu-dropdown a {
  display: block; padding: 10px 14px; text-decoration: none;
  color: var(--fg, #e6e8ec); font-size: 0.9rem;
}
.user-menu-dropdown a:hover { background: rgba(212,161,58,0.12); }

.sec-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 900px) { .sec-grid { grid-template-columns: 1fr; } }
.sec-card {
  background: var(--panel, #1a1e27); border: 1px solid var(--border, #2a2f3a);
  border-radius: 10px; padding: 20px;
}
.sec-card h3 { margin-top: 0; }
.sec-status { font-size: 0.85rem; padding: 3px 10px; border-radius: 999px; display: inline-block; }
.sec-status.on { background: rgba(56,161,105,0.18); color: #6ee7a8; }
.sec-status.off { background: rgba(120,120,120,0.18); color: #b8bcc4; }
.sec-status.warn { background: rgba(214,158,46,0.20); color: #f6d68a; }
.sec-status.muted { background: rgba(120,120,120,0.12); color: #9aa0aa; }
.sec-msg { padding: 10px 14px; border-radius: 6px; margin: 12px 0; font-size: 0.9rem; }
.sec-msg.ok { background: rgba(56,161,105,0.15); color: #6ee7a8; }
.sec-msg.err { background: rgba(220,53,69,0.15); color: #ff9aa5; }
.sec-form label { display: block; margin: 12px 0 4px; font-size: 0.85rem; color: #b8bcc4; }
.sec-form input[type=password], .sec-form input[type=text] {
  width: 100%; padding: 9px 12px; border-radius: 6px;
  border: 1px solid var(--border, #2a2f3a); background: #12151c; color: #e6e8ec;
}
.qr-box { text-align: center; margin: 16px 0; }
.qr-box img { background: #fff; padding: 8px; border-radius: 8px; }
.totp-secret {
  font-family: monospace; font-size: 1.05rem; letter-spacing: 2px;
  background: #12151c; padding: 8px 12px; border-radius: 6px; display: inline-block;
  word-break: break-all;
}
.recovery-list {
  list-style: none; padding: 0; margin: 12px 0; display: grid;
  grid-template-columns: 1fr 1fr; gap: 8px;
}
.recovery-list li {
  font-family: monospace; font-size: 1rem; background: #12151c;
  padding: 8px 12px; border-radius: 6px; text-align: center; letter-spacing: 1px;
}
.pw-rules { font-size: 0.8rem; color: #8b909c; margin: 8px 0 0; }


/* ==========================================================================
   FIERO OS v0.2.0 — "Falar com Fiero" chat.
   ========================================================================== */
.nav-fiero { font-weight: 600; }

.fiero-chat {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 16px;
  height: calc(100vh - 120px);
  min-height: 420px;
}

/* Conversation list */
.fiero-convs {
  background: var(--bg-alt); border: 1px solid var(--border);
  border-radius: var(--radius); display: flex; flex-direction: column; overflow: hidden;
}
.fiero-convs-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-dim);
}
.fiero-conv-list { list-style: none; margin: 0; padding: 6px; overflow-y: auto; }
.fiero-conv-list li { border-radius: 6px; }
.fiero-conv-list li.active { background: rgba(249,115,22,0.14); }
.fiero-conv-list li a {
  display: block; padding: 8px 10px; color: var(--text); text-decoration: none;
  font-size: 0.88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.fiero-conv-list li a:hover { color: var(--accent); }

/* Chat main */
.fiero-main {
  background: var(--bg-alt); border: 1px solid var(--border);
  border-radius: var(--radius); display: flex; flex-direction: column; overflow: hidden;
}
.fiero-head {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.fiero-id { display: flex; align-items: center; gap: 12px; }
.fiero-head-actions { display: flex; align-items: center; gap: 8px; }
.fiero-avatar {
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  color: #fff; font-weight: 700; font-size: 1.1rem;
}
.fiero-name { font-weight: 600; font-size: 1rem; }
.fiero-sub { font-size: 0.78rem; color: var(--text-dim); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 3px; }
.dot-online { background: var(--green); }
.ia-ativa { color: var(--green); }
.ia-degradado { color: var(--yellow); }

/* Messages */
.fiero-messages { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.fiero-welcome {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; color: var(--text-dim); font-size: 0.9rem; line-height: 1.5;
}
.fiero-welcome strong { color: var(--text); }
.msg { max-width: 78%; display: flex; flex-direction: column; gap: 4px; }
.msg-role { font-size: 0.72rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.4px; }
.msg-body { padding: 10px 14px; border-radius: 12px; line-height: 1.5; white-space: pre-wrap; word-wrap: break-word; }
.msg-user { align-self: flex-end; align-items: flex-end; }
.msg-user .msg-body { background: var(--accent); color: #fff; border-bottom-right-radius: 3px; }
.msg-assistant { align-self: flex-start; }
.msg-assistant .msg-body { background: var(--bg-elev); border: 1px solid var(--border); border-bottom-left-radius: 3px; }
.msg-tech { font-size: 0.72rem; color: var(--text-dim); }
.msg-tech summary { cursor: pointer; }
.msg-tech .mono, .msg-tech div { font-family: var(--mono); margin-top: 4px; }

/* Pending confirmation */
.fiero-pending { padding: 0 18px; }
.pending-card {
  background: rgba(210,153,34,0.10); border: 1px solid var(--yellow);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px;
}
.pending-title { font-weight: 600; color: var(--yellow); margin-bottom: 6px; }
.pending-summary { font-size: 0.9rem; line-height: 1.45; margin-bottom: 6px; white-space: pre-wrap; }
.pending-meta { font-size: 0.75rem; color: var(--text-dim); margin-bottom: 10px; }
.pending-actions { display: flex; gap: 10px; }
.btn-confirm { background: var(--green); color: #fff; }
.btn-cancel { background: transparent; border: 1px solid var(--border); color: var(--text-dim); }

/* Input */
.fiero-input { display: flex; gap: 10px; padding: 14px 16px; border-top: 1px solid var(--border); }
.fiero-input textarea {
  flex: 1; resize: none; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); padding: 11px 14px; font-family: var(--font);
  font-size: 0.95rem; line-height: 1.4; max-height: 160px;
}
.fiero-input textarea:focus { outline: none; border-color: var(--accent); }
.btn-send { background: var(--accent); color: #fff; align-self: flex-end; padding: 11px 20px; }
.btn-today { background: transparent; color: var(--accent); font-weight: 600;
  border: 1px solid var(--accent); border-radius: 8px; padding: 8px 16px;
  white-space: nowrap; font-size: 0.85rem; cursor: pointer; transition: background 0.15s, color 0.15s; }
.btn-today:hover { background: var(--accent); color: #fff; }
.btn-sm { font-size: 0.78rem; padding: 4px 10px; }
form.inline { display: inline; margin: 0; }

/* Responsive */
@media (max-width: 820px) {
  .fiero-chat { grid-template-columns: 1fr; height: calc(100vh - 100px); }
  .fiero-convs { display: none; }
  .msg { max-width: 90%; }
}


/* Admin → Modelos de IA */
.admin-links { margin-bottom: 18px; display: flex; gap: 10px; flex-wrap: wrap; }
.modelos .sec-card { margin-bottom: 8px; }
table.kv { width: 100%; border-collapse: collapse; }
table.kv th {
  text-align: left; width: 210px; padding: 6px 10px; color: var(--text-dim);
  font-weight: 500; vertical-align: top;
}
table.kv td { padding: 6px 10px; }

/* Manual panel action bar */
.panel-actions { margin-bottom: 16px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.panel-actions .btn { text-decoration: none; }
.modal-back {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55); display: none;
  align-items: center; justify-content: center; z-index: 50;
}
.modal-back.open { display: flex; }
.modal {
  background: var(--bg-alt); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; width: min(520px, 92vw); max-height: 88vh; overflow-y: auto;
}
.modal h3 { margin-top: 0; }
.modal label { display: block; margin: 12px 0 4px; font-size: 0.85rem; color: var(--text-dim); }
.modal input, .modal textarea, .modal select {
  width: 100%; padding: 9px 12px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text); font-family: var(--font);
}
.modal .modal-actions { margin-top: 18px; display: flex; gap: 10px; justify-content: flex-end; }
