/* HERMES JOSE — EMPÓRIO CARAÍVA PREMIUM GLASSMORPHISM UI/UX */

:root {
  --bg-deep: #06090f;
  --bg-main: #0a0f1a;
  --bg-surface: rgba(15, 23, 42, 0.75);
  --bg-glass: rgba(15, 23, 42, 0.55);
  --bg-card: rgba(30, 41, 59, 0.55);
  --bg-hover: rgba(51, 65, 85, 0.55);
  --bg-input: rgba(15, 23, 42, 0.7);
  --border: rgba(148, 163, 184, 0.1);
  --border-hover: rgba(148, 163, 184, 0.2);
  --border-focus: #10b981;
  --text-1: #f1f5f9;
  --text-2: #cbd5e1;
  --text-3: #94a3b8;
  --accent: #10b981;
  --accent-2: #34d399;
  --accent-glow: rgba(16, 185, 129, 0.35);
  --green: #10b981;
  --green-glow: rgba(16, 185, 129, 0.35);
  --blue: #3b82f6;
  --blue-glow: rgba(59, 130, 246, 0.35);
  --cyan: #06b6d4;
  --amber: #f59e0b;
  --red: #ef4444;
  --radius: 16px;
  --radius-lg: 24px;
  --radius-sm: 10px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.45);
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="emerald"] {
  --bg-deep: #022c22;
  --bg-main: #064e3b;
  --bg-surface: rgba(6, 78, 59, 0.65);
  --bg-glass: rgba(6, 78, 59, 0.4);
  --bg-card: rgba(16, 185, 129, 0.15);
  --bg-hover: rgba(16, 185, 129, 0.25);
  --bg-input: rgba(2, 44, 34, 0.75);
  --border: rgba(16, 185, 129, 0.2);
  --border-hover: rgba(16, 185, 129, 0.35);
  --text-1: #f0fdf4;
  --text-2: #bbf7d0;
  --text-3: #86efac;
  --accent: #10b981;
  --accent-2: #34d399;
}

[data-theme="light"] {
  --bg-deep: #f8fafc;
  --bg-main: #f1f5f9;
  --bg-surface: rgba(255, 255, 255, 0.9);
  --bg-glass: rgba(255, 255, 255, 0.7);
  --bg-card: rgba(255, 255, 255, 0.8);
  --bg-hover: rgba(241, 245, 249, 0.95);
  --bg-input: rgba(241, 245, 249, 0.85);
  --border: rgba(0, 0, 0, 0.08);
  --border-hover: rgba(0, 0, 0, 0.15);
  --text-1: #0f172a;
  --text-2: #334155;
  --text-3: #64748b;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.12);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-deep);
  color: var(--text-1);
  min-height: 100vh;
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Background animated glow */
.bg-particles {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.bg-particles::before {
  content: '';
  position: absolute;
  top: -50%; left: -50%;
  width: 200%; height: 200%;
  background: radial-gradient(ellipse at 20% 40%, rgba(16, 185, 129, 0.08) 0%, transparent 50%),
              radial-gradient(ellipse at 80% 20%, rgba(59, 130, 246, 0.06) 0%, transparent 50%),
              radial-gradient(ellipse at 50% 80%, rgba(16, 185, 129, 0.05) 0%, transparent 50%);
  animation: bgFloat 35s ease-in-out infinite;
}

@keyframes bgFloat {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  50% { transform: translate(2%, -2%) rotate(1deg); }
}

/* Layout App */
.app-container {
  display: flex;
  width: 100vw;
  height: 100vh;
  position: relative;
  z-index: 1;
}

/* Sidebar */
.sidebar {
  width: 290px;
  min-width: 290px;
  background: var(--bg-surface);
  backdrop-filter: blur(24px);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100%;
  transition: var(--transition);
  z-index: 10;
}

.sidebar-header {
  padding: 24px 20px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

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

.brand-avatar {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #10b981, #059669);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 20px;
  box-shadow: 0 4px 16px var(--accent-glow);
}

.brand-text h1 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text-1);
}

.brand-text span {
  font-size: 11px;
  color: var(--accent);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.theme-toggle {
  display: flex;
  gap: 4px;
  background: var(--bg-card);
  padding: 4px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.theme-btn {
  background: transparent;
  border: none;
  color: var(--text-3);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  transition: var(--transition);
}

.theme-btn:hover, .theme-btn.active {
  background: var(--bg-hover);
  color: var(--accent);
}

/* Sidebar action button */
.new-chat-btn {
  margin: 16px 16px 8px;
  padding: 12px 16px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(5, 150, 105, 0.25));
  border: 1px solid var(--border-focus);
  color: #f0fdf4;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: var(--transition);
}

.new-chat-btn:hover {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.25), rgba(5, 150, 105, 0.35));
  box-shadow: 0 4px 16px var(--accent-glow);
  transform: translateY(-1px);
}

/* Sessions list */
.sessions-section {
  flex: 1;
  padding: 8px 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sessions-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-3);
  letter-spacing: 0.6px;
  padding: 8px 8px 4px;
}

.session-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 10px;
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.session-item:hover {
  background: var(--bg-hover);
  color: var(--text-1);
}

.session-item.active {
  background: var(--bg-card);
  border-color: var(--border-focus);
  color: var(--accent);
  font-weight: 600;
}

.session-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}

.session-del-btn {
  background: transparent;
  border: none;
  color: var(--text-3);
  opacity: 0;
  cursor: pointer;
  padding: 4px;
  font-size: 12px;
  transition: var(--transition);
}

.session-item:hover .session-del-btn {
  opacity: 1;
}

.session-del-btn:hover {
  color: var(--red);
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-glass);
}

.agent-info-card {
  display: flex;
  align-items: center;
  gap: 12px;
}

.agent-avatar-small {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-size: 16px;
}

.agent-status-details {
  display: flex;
  flex-direction: column;
}

.agent-name-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
}

.agent-online-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--green);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
}

/* Main Content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--bg-main);
  position: relative;
  overflow: hidden;
}

/* Topbar */
.topbar {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 5;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.mobile-menu-btn {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-1);
  font-size: 18px;
  cursor: pointer;
}

.topbar-title h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-1);
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-title p {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
}

.topbar-badges {
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--bg-card);
}

.badge-emerald {
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.25);
  background: rgba(16, 185, 129, 0.1);
}

.badge-blue {
  color: #60a5fa;
  border-color: rgba(59, 130, 246, 0.25);
  background: rgba(59, 130, 246, 0.1);
}

.badge-purple {
  color: #c084fc;
  border-color: rgba(168, 85, 247, 0.25);
  background: rgba(168, 85, 247, 0.1);
}

/* Chat Wrapper */
.chat-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.chat-messages {
  flex: 1;
  padding: 24px 32px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scroll-behavior: smooth;
}

/* Message Bubble */
.message {
  display: flex;
  gap: 14px;
  max-width: 860px;
  width: 100%;
  animation: fadeIn 0.3s ease;
}

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

.message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.msg-avatar {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  flex-shrink: 0;
}

.message.assistant .msg-avatar {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  box-shadow: 0 4px 16px var(--accent-glow);
}

.message.user .msg-avatar {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--blue);
}

.msg-bubble {
  padding: 16px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.6;
  max-width: 100%;
  word-break: break-word;
}

.message.assistant .msg-bubble {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-1);
  box-shadow: var(--shadow);
}

.message.user .msg-bubble {
  background: linear-gradient(135deg, #059669, #047857);
  color: #ffffff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 20px rgba(5, 150, 105, 0.25);
}

/* Markdown formatting inside assistant bubble */
.msg-bubble h1, .msg-bubble h2, .msg-bubble h3 {
  margin: 14px 0 8px;
  font-weight: 700;
  color: var(--text-1);
}
.msg-bubble h1 { font-size: 18px; border-bottom: 1px solid var(--border); padding-bottom: 4px; }
.msg-bubble h2 { font-size: 16px; }
.msg-bubble h3 { font-size: 14px; }

.msg-bubble p { margin-bottom: 10px; }
.msg-bubble p:last-child { margin-bottom: 0; }

.msg-bubble ul, .msg-bubble ol {
  margin: 8px 0 12px 20px;
}
.msg-bubble li { margin-bottom: 4px; }

.msg-bubble blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 12px;
  margin: 10px 0;
  color: var(--text-2);
  font-style: italic;
}

.msg-bubble table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 13px;
}

.msg-bubble th, .msg-bubble td {
  padding: 8px 12px;
  border: 1px solid var(--border);
  text-align: left;
}

.msg-bubble th {
  background: var(--bg-card);
  font-weight: 600;
  color: var(--accent);
}

.msg-bubble code {
  background: var(--bg-card);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 12px;
  color: #34d399;
}

.msg-bubble pre {
  background: #02120e;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  margin: 10px 0;
  overflow-x: auto;
  position: relative;
}

.msg-bubble pre code {
  background: transparent;
  padding: 0;
  color: #e2e8f0;
}

/* Image Card Styling */
.chat-img-card {
  margin: 16px 0;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  max-width: 520px;
}

.chat-img-preview {
  width: 100%;
  height: auto;
  max-height: 480px;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
  cursor: pointer;
}

.chat-img-preview:hover {
  transform: scale(1.02);
}

.chat-img-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(6, 9, 15, 0.85);
  font-size: 12px;
  color: var(--text-2);
}

.chat-img-download-btn {
  background: rgba(16, 185, 129, 0.2);
  border: 1px solid var(--border-focus);
  color: #6ee7b7;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
}

.chat-img-download-btn:hover {
  background: var(--accent);
  color: #fff;
}

/* Welcome Card */
.welcome-card {
  max-width: 720px;
  margin: 40px auto;
  text-align: center;
  padding: 36px 32px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: fadeIn 0.4s ease;
}

.welcome-icon {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(5, 150, 105, 0.3));
  border: 1px solid var(--border-focus);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin: 0 auto 18px;
  box-shadow: 0 8px 24px var(--accent-glow);
}

.welcome-card h3 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.welcome-card p {
  font-size: 14px;
  color: var(--text-2);
  line-height: 1.5;
  margin-bottom: 24px;
}

.welcome-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.chip {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-2);
  padding: 10px 16px;
  border-radius: 30px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 8px;
}

.chip:hover {
  border-color: var(--accent);
  color: #fff;
  background: rgba(16, 185, 129, 0.18);
  transform: translateY(-2px);
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 18px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: fit-content;
}

.typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Input Area */
.chat-input-container {
  padding: 16px 32px 24px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(20px);
}

.chat-form {
  max-width: 860px;
  margin: 0 auto;
}

.chat-input-box {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  transition: var(--transition);
}

.chat-input-box:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.chat-input-box textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-1);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  resize: none;
  max-height: 140px;
  min-height: 24px;
}

.chat-input-box textarea::placeholder {
  color: var(--text-3);
}

.send-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #10b981, #059669);
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
}

.send-btn:hover {
  box-shadow: 0 4px 16px var(--accent-glow);
  transform: scale(1.05);
}

.send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.input-hints {
  display: flex;
  justify-content: flex-end;
  gap: 14px;
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-3);
}

.input-hints kbd {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 10px;
}

/* Mobile responsive */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -290px;
    top: 0; bottom: 0;
    z-index: 100;
  }
  .sidebar.open {
    left: 0;
    box-shadow: var(--shadow-lg);
  }
  .mobile-menu-btn {
    display: block;
  }
  .chat-messages {
    padding: 16px;
  }
  .chat-input-container {
    padding: 12px 16px 16px;
  }
}
