:root {
  --primary: #2563EB;
  --primary-light: #EFF6FF;
  --secondary: #F3F4F6;
  --text: #1F2937;
  --text-light: #6B7280;
  --success: #10B981;
  --warning: #F59E0B;
  --white: #FFFFFF;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Inter', system-ui, sans-serif;
}

body {
  background-color: #f9f9f9;
  color: var(--text);
  line-height: 1.6;
}

/* Chat Icon */
.chat-icon {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 60px;
  height: 60px;
  background: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow);
  z-index: 1000;
  transition: all 0.2s ease;
  will-change: transform;
}

.chat-icon:hover {
  transform: scale(1.1);
}

.chat-icon:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.notification-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: var(--warning);
  color: white;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
}

/* Chat Container */
.chat-container {
  position: fixed;
  right: 0;
  top: 0;
  height: 100vh;
  width: 380px;
  background: var(--white);
  box-shadow: -5px 0 15px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 999;
  will-change: transform;
}

.chat-container.expanded {
  transform: translateX(0);
}

.chat-header {
  padding: 16px 20px;
  background: var(--primary);
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-header h3 {
  font-size: 18px;
  font-weight: 600;
}

.close-chat {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 5px;
  border-radius: 4px;
}

.close-chat:hover {
  background: rgba(255, 255, 255, 0.1);
}

.close-chat:focus {
  outline: 2px solid white;
}

/* Chat Window */
.chat-window {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  background: var(--secondary);
  scroll-behavior: smooth;
}

.message {
  margin-bottom: 16px;
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 16px;
  line-height: 1.5;
  word-wrap: break-word;
}

.user-message {
  background: var(--primary-light);
  margin-left: auto;
  border-bottom-right-radius: 4px;
  box-shadow: var(--shadow);
}

.ai-message {
  background: var(--white);
  margin-right: auto;
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow);
}

.message-time {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 5px;
  text-align: right;
}

/* Citations */
.citation-marker {
  color: var(--primary);
  font-size: 0.8em;
  vertical-align: super;
  cursor: pointer;
  margin: 0 2px;
  font-weight: 600;
}

.citation-marker:hover {
  text-decoration: underline;
}

.citation-title-list {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed #D1D5DB;
}

.citation-list-header {
  font-size: 14px;
  color: var(--text-light);
  margin-bottom: 8px;
  font-weight: 500;
}

.citation-title-item {
  display: inline-block;
  margin: 0 8px 8px 0;
  padding: 6px 12px;
  background: var(--white);
  border-radius: 16px;
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  transition: all 0.2s;
}

.citation-title-item:hover {
  background: var(--primary-light);
}

.citation-number {
  font-weight: bold;
  color: var(--primary);
  margin-right: 5px;
}

.citation-title-text {
  color: var(--text);
}

/* Input Area */
.chat-input-container {
  padding: 16px;
  border-top: 1px solid #E5E7EB;
  background: var(--white);
}

#userInput {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid #D1D5DB;
  border-radius: 8px;
  resize: none;
  font-size: 16px;
  margin-bottom: 12px;
  min-height: 60px;
  max-height: 150px;
  transition: border-color 0.2s;
}

#userInput:focus {
  outline: none;
  border-color: var(--primary);
}

#sendButton {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s;
}

#sendButton:hover {
  background: #1D4ED8;
}

#sendButton:focus {
  outline: 2px solid #93C5FD;
}

/* Responsive Design */
@media (max-width: 768px) {
  .chat-container {
    width: 100%;
  }
  
  .chat-icon {
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
  }
  
  .notification-badge {
    width: 18px;
    height: 18px;
    font-size: 10px;
  }
}

/* Accessibility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Add these to your existing CSS */

/* Main Layout */
body {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas: "chat main citations";
  min-height: 100vh;
  margin: 0;
}

.main-content {
  grid-area: main;
  padding: 20px;
}

/* Chat Container - Now on the left */
/*.chat-container {
  grid-area: chat;
  position: relative;
  width: 380px;
  height: 100vh;
  background: var(--white);
  box-shadow: 5px 0 15px rgba(0, 0, 0, 0.1);
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 100;
}*/

.chat-container.expanded {
  transform: translateX(0);
}

/* Citation Sidebar - On the right */
.citation-sidebar {
  grid-area: citations;
  position: relative;
  width: 350px;
  height: 100vh;
  background: var(--white);
  box-shadow: -5px 0 15px rgba(0, 0, 0, 0.1);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 100;
  display: flex;
  flex-direction: column;
}

.citation-sidebar.active {
  transform: translateX(0);
}

.sidebar-header {
  padding: 16px 20px;
  background: var(--primary);
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-header h3 {
  font-size: 18px;
  font-weight: 600;
}

.close-sidebar {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 5px;
  border-radius: 4px;
}

.sidebar-content {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
}

/* Citation Detail Styles */
.citation-detail {
  padding: 15px;
  margin-bottom: 20px;
  background-color: #f9f9f9;
  border-radius: 5px;
  border-left: 3px solid var(--primary);
}

.citation-detail-title {
  color: var(--primary);
  margin-bottom: 10px;
  font-size: 18px;
}

.citation-detail-content {
  font-size: 15px;
  line-height: 1.6;
  margin-bottom: 15px;
}

.citation-source {
  margin-top: 10px;
}

.citation-source a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

.citation-source a:hover {
  text-decoration: underline;
}

.citation-meta {
  font-size: 14px;
  color: var(--text-light);
  margin-top: 10px;
}




/* Main Layout */
body {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas: "chat main";
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
}

.main-content {
  grid-area: main;
  padding: 20px;
  transition: margin 0.3s ease;
}

/* Chat Container - On the left */
.chat-container {
  grid-area: chat;
  position: fixed;
  right: 0;
  width: 380px;
  height: 100vh;
  background: var(--white);
  box-shadow: 5px 0 15px rgba(0, 0, 0, 0.1);
/*  transform: translateX(-100%);*/
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 100;
}

body.chat-expanded .chat-container {
  transform: translateX(0);
}

body.citations-visible .chat-container {
  transform: translateX(calc(-100% + 50px)); /* Peek out 50px when citations are visible */
}

/* Citation Sidebar - On the right */
.citation-sidebar {
  position: fixed;
  right: 0;
  top: 0;
  width: 35vw; /* Responsive width */
  max-width: 330px;
  min-width: 250px;
  height: 100vh;
  background: var(--white);
  box-shadow: -5px 0 15px rgba(0, 0, 0, 0.1);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 100;
  display: flex;
  flex-direction: column;
}

body.citations-visible .citation-sidebar {
  transform: translateX(0);
}

body.citations-visible .main-content {
  margin-right: 35vw; /* Match sidebar width */
}

/* Chat Icon - Updated Position */
.chat-icon {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 60px;
  height: 60px;
  background: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow);
  z-index: 1000;
  transition: all 0.2s ease;
}

body.chat-expanded .chat-icon {
  left: 400px; /* Move with chat window */
}

body.citations-visible .chat-icon {
  left: calc(400px - 35vw + 50px); /* Adjust based on sidebar width */
}

/* Responsive Adjustments */
@media (max-width: 1200px) {
  .citation-sidebar {
    width: 40vw;
  }
  
  body.citations-visible .main-content {
    margin-right: 40vw;
  }
}

@media (max-width: 768px) {
  .chat-container {
    width: 100%;
  }
  
  .citation-sidebar {
    width: 100%;
    min-width: 100%;
  }
  
  body.chat-expanded .chat-icon {
    left: auto;
    right: 30px;
  }
  
  body.citations-visible .main-content {
    margin-right: 0;
  }
}


/* Responsive Adjustments */
@media (max-width: 1200px) {
  body {
    grid-template-columns: auto 1fr;
    grid-template-areas: "chat main";
  }
  
  .citation-sidebar {
    position: fixed;
    right: 0;
    top: 0;
  }
}

@media (max-width: 768px) {
  .chat-container {
    width: 100%;
  }
  
  .citation-sidebar {
    width: 100%;
  }
}