/* style.css — Prisma AI
   Design system: dark blue + destaque marca-texto + acento prisma (gradiente),
   tipografia Space Grotesk + Inter */

:root {
  --bg: #12172a;
  --panel: #1b2140;
  --panel-alt: #232b52;
  --panel-border: #2c3564;
  --accent: #f2c14e;
  --accent-glow: rgba(242, 193, 78, 0.35);
  --mint: #6fcf97;
  --danger: #f27272;
  --text: #eef0fa;
  --text-dim: #a8aed1;
  --bubble-user: #e9ecfb;
  --bubble-user-text: #1b2140;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  overflow: hidden;
}

#app {
  display: flex;
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  position: relative;
}

/* ---------- Overlay para Mobile ---------- */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 13, 26, 0.65);
  backdrop-filter: blur(2px);
  z-index: 99;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

/* ---------- Sidebar ---------- */
#sidebar {
  width: 280px;
  min-width: 280px;
  background: var(--panel);
  border-right: 1px solid var(--panel-border);
  display: flex;
  flex-direction: column;
  padding: 24px 18px;
  gap: 22px;
  overflow-y: auto;
  z-index: 100;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.close-sidebar-btn {
  display: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Marca: triângulo com gradiente cônico girando devagar — luz se refratando */
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  background: conic-gradient(from 0deg, #f2c14e, #6fcf97, #7c9dfa, #f27272, #f2c14e);
  animation: spin-gradient 6s linear infinite;
  box-shadow: 0 4px 16px var(--accent-glow);
}
.brand-mark::after {
  content: '';
  position: absolute;
  inset: 3px;
  background: var(--panel);
  border-radius: 6px;
  clip-path: polygon(50% 15%, 85% 85%, 15% 85%);
}

@keyframes spin-gradient {
  to { transform: rotate(360deg); }
}

.brand-text h1 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 17px;
  font-weight: 600;
  margin: 0;
  line-height: 1.2;
}

.brand-text p {
  margin: 3px 0 0;
  font-size: 12px;
  color: var(--text-dim);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.section-label {
  font-size: 12px;
  color: var(--text-dim);
  margin: 0;
}

.icon-btn {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1px solid var(--panel-border);
  background: var(--panel-alt);
  color: var(--text-dim);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }

.new-subject-form {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}
.new-subject-form.hidden { display: none; }
.new-subject-form input {
  flex: 1;
  background: var(--panel-alt);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 7px 10px;
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  outline: none;
  min-width: 0;
}
.new-subject-form input:focus { border-color: var(--accent); }
.new-subject-form button {
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  color: #1b2140;
  font-size: 12.5px;
  font-weight: 600;
  padding: 0 12px;
  cursor: pointer;
  flex-shrink: 0;
}

.subjects-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 180px;
  overflow-y: auto;
}

.subject-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.subject-item:hover { background: var(--panel-alt); }
.subject-item.active {
  background: var(--panel-alt);
  border-left-color: var(--accent);
}
.subject-name {
  font-size: 13.5px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.subject-item.active .subject-name { color: var(--accent); font-weight: 600; }
.subject-delete {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  padding: 2px 4px;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease;
  flex-shrink: 0;
}
.subject-item:hover .subject-delete { opacity: 1; }
.subject-delete:hover { color: var(--danger); }

.notebook-tabs {
  border-left: 2px solid var(--panel-border);
  padding-left: 14px;
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.action-btn {
  text-align: left;
  background: var(--panel-alt);
  border: 1px solid var(--panel-border);
  color: var(--text);
  padding: 12px 13px;
  border-radius: var(--radius-md);
  font-family: 'Inter', sans-serif;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: border-color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}
.action-btn:hover { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent-glow); }
.action-btn:active { transform: scale(0.98); }
.action-emoji { font-size: 16px; }

.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.footer-btn {
  width: 100%;
  background: transparent;
  border: 1px dashed var(--panel-border);
  color: var(--text-dim);
  padding: 11px;
  border-radius: var(--radius-md);
  font-size: 13px;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.footer-btn:hover { color: var(--text); border-color: var(--text-dim); }
.footer-btn.danger:hover { color: var(--danger); border-color: var(--danger); }

/* ---------- Header Mobile ---------- */
.mobile-header {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--panel-border);
}

.hamburger-btn {
  background: var(--panel-alt);
  border: 1px solid var(--panel-border);
  color: var(--accent);
  font-size: 18px;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mobile-title {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
}

/* ---------- Main chat ---------- */
#main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#chat-scroll { flex: 1; overflow-y: auto; padding: 30px 0; }
#chat-inner { max-width: 740px; margin: 0 auto; padding: 0 24px; display: flex; flex-direction: column; gap: 20px; }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding-top: 10vh;
  animation: fade-in 0.4s ease-out;
}
.empty-state h2 { font-family: 'Space Grotesk', sans-serif; font-size: 28px; margin: 0; }
.empty-state p { color: var(--text-dim); font-size: 14.5px; margin: 0; max-width: 470px; line-height: 1.55; }

@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg-row {
  display: flex;
  gap: 12px;
  max-width: 100%;
  animation: msg-in 0.25s ease-out;
}
@keyframes msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg-row.user { justify-content: flex-end; }
.msg-row.assistant { justify-content: flex-start; }

.avatar {
  width: 32px; height: 32px; border-radius: var(--radius-sm); flex-shrink: 0;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 13px; color: #1b2140;
  margin-top: 2px;
}

.bubble {
  padding: 13px 16px;
  border-radius: var(--radius-lg);
  font-size: 14.5px;
  line-height: 1.6;
  max-width: 78%;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.msg-row.assistant .bubble { background: var(--panel-alt); border: 1px solid var(--panel-border); color: var(--text); border-top-left-radius: 4px; }
.msg-row.user .bubble { background: var(--bubble-user); color: var(--bubble-user-text); border-top-right-radius: 4px; font-weight: 500; }
.bubble code { background: rgba(0, 0, 0, 0.25); padding: 2px 6px; border-radius: 4px; font-size: 13px; font-family: 'Space Grotesk', monospace; }
.msg-row.user .bubble code { background: rgba(0, 0, 0, 0.08); }
.bubble pre { background: #0c1022; border: 1px solid var(--panel-border); padding: 14px; border-radius: var(--radius-md); overflow-x: auto; font-size: 13px; line-height: 1.55; margin: 8px 0; }
.bubble pre code { background: none; padding: 0; }
.bubble strong { color: var(--accent); }
.msg-row.user .bubble strong { color: #7a5a00; }

.typing-row .bubble { display: flex; align-items: center; gap: 8px; color: var(--text-dim); font-size: 13.5px; }
.typing-dots { display: flex; gap: 4px; }
.typing-dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: pulse 1.2s infinite ease-in-out; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes pulse { 0%, 80%, 100% { opacity: 0.25; transform: scale(0.85); } 40% { opacity: 1; transform: scale(1.15); } }

/* ---------- Input bar ---------- */
#input-bar-wrap { border-top: 1px solid var(--panel-border); background: var(--bg); padding: 16px 24px 22px; }
#input-bar {
  max-width: 740px; margin: 0 auto; display: flex; gap: 10px; align-items: flex-end;
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius-lg);
  padding: 8px 8px 8px 17px;
  transition: border-color 0.15s ease, box-shadow 0.2s ease;
}
#input-bar:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-glow); }
#msg-input {
  flex: 1; background: transparent; border: none; outline: none; color: var(--text);
  font-family: 'Inter', sans-serif; font-size: 16px; resize: none; max-height: 160px; line-height: 1.5; padding: 9px 0;
}
#msg-input::placeholder { color: var(--text-dim); }
#send-btn {
  background: var(--accent); border: none; width: 40px; height: 40px; border-radius: var(--radius-md); cursor: pointer;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: transform 0.12s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}
#send-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 16px var(--accent-glow); }
#send-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }
#send-btn svg { width: 17px; height: 17px; }

.hint { text-align: center; font-size: 11.5px; color: var(--text-dim); margin-top: 9px; }

/* ---------- Mobile Responsive Drawer ---------- */
@media (max-width: 768px) {
  .mobile-header { display: flex; }
  .close-sidebar-btn { display: flex; }

  #sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    height: 100dvh;
    width: 280px;
    transform: translateX(-100%);
    box-shadow: 8px 0 24px rgba(0, 0, 0, 0.4);
  }

  #sidebar.open {
    transform: translateX(0);
  }

  .bubble { max-width: 88%; }
  #chat-inner, #input-bar-wrap { padding-left: 14px; padding-right: 14px; }
  #chat-scroll { padding: 18px 0; }
}