/* ═══════════════════════════════════════════════════════════════
   MDASS · AnáliseLP — chrome do app (topbar, sidebar, chat, listas)
   Inclui o report.css via @import para páginas que mostram o relatório.
   ═══════════════════════════════════════════════════════════════ */

@import url('report.css');

/* ── Logo MDASS ── */
/* Proporção: 320×80 (ratio 4:1). Width/height explícitos para
   evitar cálculo auto problemático em alguns browsers. */
.mdass-logo {
  height: 32px;
  width: 128px;
  display: block;
  flex-shrink: 0;
  object-fit: contain;
}
.mdass-logo-sm {
  height: 26px;
  width: 104px;
}
.mdass-logo-lg {
  height: 44px;
  width: 176px;
}

/* ── Topbar global ── */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(8,6,26,0.85);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--card-border);
  padding: 14px 32px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 20px;
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-title {
  font-size: 13px; color: var(--text1); font-weight: 600;
}
.topbar-meta { font-size: 11px; color: var(--text3); }
.topbar-right { display: flex; align-items: center; gap: 8px; }

/* ── Botões ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-family: inherit;
  font-size: 12px; font-weight: 600;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  border: 0.5px solid var(--card-border);
  background: var(--card);
  color: var(--text1);
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  text-decoration: none;
}
.btn:hover { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.18); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(135deg, var(--purple), var(--teal));
  color: #08061a;
  border: none;
}
.btn-primary:hover { opacity: 0.9; background: linear-gradient(135deg, var(--purple), var(--teal)); }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--red); border-color: rgba(248,113,113,0.25); }
.btn-danger:hover { background: var(--red-dim); border-color: rgba(248,113,113,0.4); }
.btn-sm { padding: 6px 10px; font-size: 11px; }
.btn-lg { padding: 12px 20px; font-size: 13px; }

/* ── Login ── */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  position: relative; z-index: 1;
}
.login-card {
  background: var(--surface);
  border: 0.5px solid var(--card-border);
  border-radius: 16px;
  padding: 32px 28px;
  width: 100%; max-width: 360px;
  backdrop-filter: blur(14px);
}
.login-input {
  width: 100%;
  font-family: inherit; font-size: 13px;
  padding: 12px 14px;
  background: var(--card);
  border: 0.5px solid var(--card-border);
  border-radius: 8px;
  color: var(--text1);
  outline: none;
}
.login-input:focus { border-color: var(--purple); background: rgba(167,139,250,0.05); }
.login-error {
  background: var(--red-dim);
  border: 0.5px solid rgba(248,113,113,0.3);
  color: var(--red);
  font-size: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 16px;
}

/* ── Home (lista de análises) ── */
.home-hero {
  max-width: 1100px;
  margin: 0 auto;
  padding: 48px 32px 24px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 20px; flex-wrap: wrap;
}
.home-hero h1 {
  font-size: 28px; font-weight: 700;
  background: linear-gradient(135deg, var(--text1), var(--purple) 70%, var(--teal));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.home-hero p { font-size: 13px; color: var(--text2); margin-top: 6px; max-width: 560px; line-height: 1.6; }

.reports-grid {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 32px 60px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}
.report-card {
  background: var(--card);
  border: 0.5px solid var(--card-border);
  border-radius: 12px;
  padding: 18px 20px;
  text-decoration: none;
  color: var(--text1);
  display: block;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.report-card:hover {
  border-color: rgba(167,139,250,0.3);
  background: rgba(167,139,250,0.05);
}
.report-card-client { font-size: 14px; font-weight: 700; margin-bottom: 4px; color: var(--text1); }
.report-card-url { font-size: 11px; color: var(--text3); margin-bottom: 10px; word-break: break-all; }
.report-card-meta {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px; color: var(--text2); padding-top: 10px;
  border-top: 0.5px solid var(--card-border);
}
.report-card-actions { display: flex; gap: 6px; margin-top: 10px; }

.empty-state {
  max-width: 500px; margin: 60px auto; text-align: center;
  padding: 40px 30px; border: 1px dashed var(--card-border); border-radius: 14px;
}
.empty-state h3 { font-size: 16px; color: var(--text1); margin-bottom: 8px; }
.empty-state p { font-size: 12px; color: var(--text2); margin-bottom: 18px; }

/* ── Formulário Nova Análise ── */
.form-wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 40px 32px 60px;
  position: relative; z-index: 1;
}
.form-wrap h1 {
  font-size: 22px; margin-bottom: 6px;
  background: linear-gradient(135deg, var(--text1), var(--teal));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.form-wrap .subtitle { font-size: 12px; color: var(--text2); margin-bottom: 28px; }

.field {
  margin-bottom: 18px;
}
.field label {
  display: block;
  font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text3); margin-bottom: 6px;
}
.field .hint { font-size: 11px; color: var(--text3); margin-top: 6px; line-height: 1.5; }
.field input[type="text"],
.field input[type="url"],
.field textarea,
.field select {
  width: 100%;
  font-family: inherit; font-size: 13px;
  padding: 11px 14px;
  background: var(--card);
  border: 0.5px solid var(--card-border);
  border-radius: 8px;
  color: var(--text1);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.field textarea { resize: vertical; min-height: 130px; font-family: 'JetBrains Mono', 'SF Mono', ui-monospace, monospace; font-size: 12px; line-height: 1.6; }
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--purple);
  background: rgba(167,139,250,0.05);
}

.form-actions { display: flex; gap: 10px; margin-top: 28px; }

/* ── Radio cards (tipo de negócio / tipo de análise) ── */
.radio-group { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.radio-group-2 { grid-template-columns: repeat(2, 1fr); }
.radio-card {
  background: var(--card);
  border: 0.5px solid var(--card-border);
  border-radius: 10px;
  padding: 12px 14px;
  cursor: pointer;
  display: flex; gap: 10px; align-items: flex-start;
  transition: border-color 0.15s, background 0.15s;
  position: relative;
}
.radio-card:hover { border-color: rgba(167,139,250,0.3); background: rgba(167,139,250,0.04); }
.radio-card input[type="radio"] {
  margin-top: 3px;
  accent-color: var(--purple);
  flex-shrink: 0;
}
.radio-card:has(input:checked) {
  border-color: var(--purple);
  background: rgba(167,139,250,0.08);
}
.radio-card-title { font-size: 12px; font-weight: 600; color: var(--text1); margin-bottom: 2px; }
.radio-card-sub { font-size: 10px; color: var(--text3); line-height: 1.5; }
@media (max-width: 640px) {
  .radio-group { grid-template-columns: 1fr; }
}

/* ── Loading overlay ── */
.loading-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(8,6,26,0.92);
  backdrop-filter: blur(10px);
  display: flex; align-items: center; justify-content: center;
  flex-direction: column;
  animation: fadein 0.3s ease-out;
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.loading-spinner {
  width: 56px; height: 56px;
  border: 3px solid rgba(167,139,250,0.15);
  border-top-color: var(--purple);
  border-right-color: var(--teal);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 24px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-size: 14px; color: var(--text1); font-weight: 600; margin-bottom: 6px; text-align: center; }
.loading-sub { font-size: 12px; color: var(--text3); max-width: 420px; text-align: center; line-height: 1.6; }
.loading-progress {
  margin-top: 20px; font-size: 11px; color: var(--teal);
  max-width: 500px; padding: 10px 16px;
  background: var(--teal-dim); border: 0.5px solid rgba(45,212,191,0.25);
  border-radius: 8px; text-align: center;
}

/* ── Editor layout ── */
.editor-layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 0;
  min-height: calc(100vh - 60px);
}
.editor-main {
  overflow-y: auto;
  max-height: calc(100vh - 60px);
}
.editor-sidebar {
  background: var(--surface);
  border-left: 1px solid var(--card-border);
  display: flex; flex-direction: column;
  max-height: calc(100vh - 60px);
  position: sticky; top: 60px;
}

/* Sidebar topo */
.sidebar-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--card-border);
}
.sidebar-title {
  font-size: 12px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--teal); margin-bottom: 4px;
}
.sidebar-sub { font-size: 11px; color: var(--text3); line-height: 1.5; }

/* Chat */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex; flex-direction: column; gap: 14px;
}
.msg {
  font-size: 12px;
  line-height: 1.6;
  padding: 10px 12px;
  border-radius: 10px;
  max-width: 100%;
  word-wrap: break-word;
}
.msg-user {
  background: rgba(167,139,250,0.1);
  border: 0.5px solid rgba(167,139,250,0.25);
  color: var(--text1);
  align-self: flex-end;
  max-width: 90%;
}
.msg-ai {
  background: var(--card);
  border: 0.5px solid var(--card-border);
  color: var(--text2);
  align-self: flex-start;
  max-width: 92%;
}
.msg-system {
  background: transparent;
  color: var(--text3);
  font-size: 11px;
  font-style: italic;
  align-self: center;
  padding: 4px 10px;
}
.msg-error {
  background: var(--red-dim);
  border: 0.5px solid rgba(248,113,113,0.3);
  color: var(--red);
  font-size: 11px;
  align-self: stretch;
}
.msg-thinking {
  background: var(--card);
  color: var(--text3);
  align-self: flex-start;
  display: flex; align-items: center; gap: 8px;
  font-size: 11px;
}
.thinking-dots { display: inline-flex; gap: 3px; }
.thinking-dots span {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--teal);
  animation: bounce 1.4s infinite ease-in-out both;
}
.thinking-dots span:nth-child(1) { animation-delay: -0.32s; }
.thinking-dots span:nth-child(2) { animation-delay: -0.16s; }
@keyframes bounce {
  0%, 80%, 100% { transform: scale(0); opacity: 0.3; }
  40% { transform: scale(1); opacity: 1; }
}

/* Chat input */
.chat-input-wrap {
  padding: 14px 16px;
  border-top: 1px solid var(--card-border);
}
.chat-input {
  width: 100%;
  font-family: inherit; font-size: 12px;
  padding: 10px 12px;
  background: var(--card);
  border: 0.5px solid var(--card-border);
  border-radius: 8px;
  color: var(--text1);
  outline: none;
  resize: none;
  min-height: 64px; max-height: 160px;
  line-height: 1.5;
}
.chat-input:focus { border-color: var(--purple); background: rgba(167,139,250,0.05); }
.chat-send-row {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 8px;
  font-size: 10px; color: var(--text3);
}

/* Sticky save bar (status) */
.save-status {
  font-size: 11px; color: var(--text3);
  display: flex; align-items: center; gap: 6px;
}
.save-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text3);
  transition: background 0.2s;
}
.save-dot.dirty { background: var(--amber); }
.save-dot.saving { background: var(--teal); animation: pulse 1s infinite; }
.save-dot.saved { background: var(--green); }
@keyframes pulse { 50% { opacity: 0.4; } }

/* Toast */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--surface);
  border: 0.5px solid var(--card-border);
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 12px; color: var(--text1);
  box-shadow: 0 14px 40px rgba(0,0,0,0.5);
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 200;
  max-width: 420px;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { border-color: rgba(248,113,113,0.4); color: var(--red); }
.toast.ok { border-color: rgba(74,222,128,0.4); color: var(--green); }

/* Ajuste do .page quando está no editor (sem padding gigante) */
.editor-main .page { padding: 24px 36px 40px; }

/* Responsivo editor */
@media (max-width: 980px) {
  .editor-layout { grid-template-columns: 1fr; }
  .editor-sidebar {
    position: fixed; bottom: 0; left: 0; right: 0; top: auto;
    max-height: 60vh;
    border-left: none; border-top: 1px solid var(--card-border);
    transform: translateY(calc(100% - 48px));
    transition: transform 0.25s;
  }
  .editor-sidebar.open { transform: translateY(0); }
}
