/* ============================================================
   DASHBOARD LAYOUT
   ============================================================ */
.dash {
  flex: 1;
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  position: relative;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  width: 280px;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 20;
}

.sidebar-head {
  padding: 20px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-head .logo {
  font-size: 20px;
  font-weight: 900;
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-shadow: 0 0 20px rgba(255, 255, 255, 0.1);
}

.sidebar-head button {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.sidebar-head button:hover {
  background: var(--red);
  border-color: var(--red);
  box-shadow: 0 0 15px rgba(220, 38, 38, 0.4);
  transform: scale(1.05);
}

/* Chat List */
.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-list::-webkit-scrollbar {
  width: 4px;
}
.chat-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

.chat-item {
  padding: 12px 14px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  color: var(--muted);
  transition: all 0.2s ease;
  border: 1px solid transparent;
  background: transparent;
}

.chat-item:hover {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
}

.chat-item.active {
  background: rgba(220, 38, 38, 0.08);
  border-color: rgba(220, 38, 38, 0.2);
  color: var(--text);
}

.chat-item .title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  font-weight: 500;
}

.chat-item .del {
  opacity: 0;
  color: var(--muted);
  padding: 4px;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.chat-item:hover .del {
  opacity: 1;
}

.chat-item .del:hover {
  color: var(--red-bright);
  background: rgba(220, 38, 38, 0.1);
}

/* Sidebar Footer */
.sidebar-foot {
  padding: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: rgba(0, 0, 0, 0.2);
}

.sidebar-foot .subscribe-btn {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 15px rgba(220, 38, 38, 0.3);
}

.sidebar-foot .subscribe-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(220, 38, 38, 0.5);
}

.sidebar-foot button {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  transition: all 0.2s ease;
  background: transparent;
  border: none;
  cursor: pointer;
}

.sidebar-foot button:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

/* ============================================================
   MAIN CHAT AREA
   ============================================================ */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
  background: radial-gradient(circle at 50% 0%, rgba(220, 38, 38, 0.05) 0%, transparent 60%);
}

/* Top Bar */
.topbar {
  padding: 16px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  gap: 16px;
  background: rgba(20, 8, 8, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 10;
}

.menu-btn {
  display: none;
  font-size: 22px;
  color: var(--text);
  padding: 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
}

.topbar h2 {
  font-size: 16px;
  font-weight: 700;
  flex: 1;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================================
   SMOOTH MESSAGE ANIMATION (Typewriter Effect)
   ============================================================ */

/* Keyframe for the message sliding up and fading in */
@keyframes messageSlideUp {
  from {
    opacity: 0;
    transform: translateY(15px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Apply to all messages */
.msg {
  animation: messageSlideUp 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

/* Optional: Make the assistant message feel like it's "typing" by animating the text inside */
.msg.assistant {
  animation: messageSlideUp 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

/* Stagger the children inside the assistant message for a cascading effect */
.msg.assistant > * {
  opacity: 0;
  animation: messageSlideUp 0.3s ease-out forwards;
}

/* Add a slight delay for each paragraph or element inside the message */
.msg.assistant > *:nth-child(1) { animation-delay: 0.1s; }
.msg.assistant > *:nth-child(2) { animation-delay: 0.2s; }
.msg.assistant > *:nth-child(3) { animation-delay: 0.3s; }
.msg.assistant > *:nth-child(4) { animation-delay: 0.4s; }
.msg.assistant > *:nth-child(5) { animation-delay: 0.5s; }

/* Ensure the typing indicator still looks good */
.typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 14px;
  font-family: var(--mono);
  animation: messageSlideUp 0.3s ease-out;
}

.typing::after {
  content: "▋";
  animation: blink 1s infinite;
  color: var(--red-bright);
}

@keyframes blink {
  50% { opacity: 0; }
}




.topbar .email {
  font-size: 11px;
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 6px 12px;
  border-radius: 20px;
  background: rgba(220, 38, 38, 0.1);
  color: var(--red-bright);
  border: 1px solid rgba(220, 38, 38, 0.2);
}

.topbar .email.upgrade {
  background: rgba(234, 179, 8, 0.1);
  color: var(--yellow);
  border-color: rgba(234, 179, 8, 0.2);
  cursor: pointer;
  transition: all 0.2s ease;
}

.topbar .email.upgrade:hover {
  background: rgba(234, 179, 8, 0.2);
  box-shadow: 0 0 15px rgba(234, 179, 8, 0.2);
}

/* Messages Area */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  scroll-behavior: smooth;
}

.messages::-webkit-scrollbar {
  width: 6px;
}
.messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

/* Message Bubbles */
.msg {
  max-width: 800px;
  width: fit-content;
  padding: 16px 20px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.6;
  word-wrap: break-word;
  animation: slideUp 0.3s ease-out;
}

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

.msg.user {
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 15px rgba(220, 38, 38, 0.2);
}

.msg.assistant {
  background: rgba(26, 10, 10, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.05);
  color: var(--text);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

/* Inline code */
.msg code {
  font-family: var(--mono);
  font-size: 13px;
  background: #050202;
  padding: 2px 6px;
  border-radius: 4px;
  color: #ff8888;
}

/* Typing Indicator */
.typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 14px;
  font-family: var(--mono);
}

.typing::after {
  content: "▋";
  animation: blink 1s infinite;
  color: var(--red-bright);
}

@keyframes blink {
  50% { opacity: 0; }
}

/* Empty States */
.empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}

.empty-inner h3 {
  font-size: 24px;
  color: var(--text);
  margin-bottom: 8px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.empty-inner p {
  font-size: 15px;
}

/* ============================================================
   COMPOSER (INPUT AREA)
   ============================================================ */
.composer {
  padding: 20px 24px 30px;
  background: rgba(20, 8, 8, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  z-index: 10;
}

.composer-inner {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  gap: 12px;
  align-items: flex-end;
  background: var(--bg);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 8px;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.composer-inner:focus-within {
  border-color: rgba(220, 38, 38, 0.5);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1), 0 10px 30px rgba(0, 0, 0, 0.3);
}

.composer textarea {
  flex: 1;
  resize: none;
  max-height: 200px;
  min-height: 44px;
  padding: 12px 16px;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  outline: none;
}

.composer textarea::placeholder {
  color: var(--muted);
}

.composer button.send {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  color: #fff;
  flex-shrink: 0;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  box-shadow: 0 4px 15px rgba(220, 38, 38, 0.3);
}

.composer button.send:hover:not(:disabled) {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(220, 38, 38, 0.5);
}

.composer button.send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

/* ============================================================
   CODE BLOCKS (ChatGPT Style)
   ============================================================ */
.code-block-wrapper {
  margin: 16px 0;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #050202;
  width: 100%;
}

.code-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--border);
}

.code-lang {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 700;
}

.copy-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 12px;
  font-family: var(--mono);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.2s;
}

.copy-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

.msg pre {
  margin: 0;
  padding: 16px;
  overflow-x: auto;
  background: #050202;
}

.msg pre code {
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
  color: #e0e0e0;
  background: transparent;
  padding: 0;
}

/* ============================================================
   CLICKABLE LINKS
   ============================================================ */
.chat-link {
  color: var(--blue-bright);
  text-decoration: underline;
  text-decoration-color: rgba(96, 165, 250, 0.3);
  text-underline-offset: 2px;
  transition: all 0.2s;
}

.chat-link:hover {
  color: #fff;
  text-decoration-color: #fff;
}

/* ============================================================
   MARKDOWN TABLES
   ============================================================ */
.table-responsive {
  overflow-x: auto;
  margin: 16px 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  width: 100%;
}

.msg table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  background: var(--bg2);
}

.msg th {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-weight: 700;
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.msg td {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  color: var(--muted);
}

.msg tr:last-child td {
  border-bottom: none;
}

.msg tr:hover td {
  background: rgba(255, 255, 255, 0.02);
  color: var(--text);
}






/*-------------------*/


.msg-actions {
  margin-top: 8px;
  display: flex;
  gap: 6px;
}
.tts-btn {
  background: transparent;
  border: 1px solid var(--border, #2b313d);
  color: var(--muted, #8b93a1);
  border-radius: 8px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.15s;
}
.tts-btn:hover { color: var(--text, #e6e6e6); border-color: var(--red-bright, #ef4444); }
.tts-btn.playing { color: var(--red-bright, #ef4444); border-color: var(--red-bright, #ef4444); }
.tts-btn.loading { opacity: 0.5; pointer-events: none; }



/* ============================================================
   RESPONSIVE
   ============================================================ */
.backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 15;
}

.backdrop.show {
  display: block;
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    transform: translateX(-100%);
    box-shadow: 20px 0 50px rgba(0, 0, 0, 0.5);
  }

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

  .menu-btn {
    display: flex;
  }

  .messages {
    padding: 20px 16px;
  }

  .composer {
    padding: 12px 16px 20px;
  }

  .msg {
    max-width: 90%;
  }
  
  .topbar {
    padding: 12px 16px;
  }

  .msg.user {
    max-width: 95%;
  }
}

