/* Chat page styling aligned with metrics look */

/* Card base (same as teacher) */
.card {
  background: white;
  border-radius: 12px;
  padding: 20px 24px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  margin-bottom: 20px;
}

/* Context Tools - Gemini Style */
.context-tools {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  align-items: center;
}

.tool-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background: transparent;
  border: 1px solid rgb(73 69 69 / 10%);
  border-radius: 16px;
  padding: 6px 28px 6px 10px;
  font-size: 13px;
  color: #6c6161;
  cursor: pointer;
  transition: all 0.15s ease;
  font-weight: 400;
  position: relative;
  background-color: rgba(255, 255, 255, 0.08);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='M7 10l5 5 5-5' stroke='%23e3e3e3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  background-size: 16px;
}

.tool-select:hover:not(:disabled) {
  background-color: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
}

.tool-select:focus {
  outline: none;
  background-color: rgba(255, 255, 255, 0.15);
  border-color: rgba(124, 19, 49, 0.4);
}

.tool-select:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.tool-select option {
  padding: 10px;
  background: #2f2f2f;
  color: #e3e3e3;
}

/* Responsive */
@media (max-width: 768px) {
  .context-tools {
    flex-wrap: wrap;
  }
}

.card h2 {
  color: #7c1331;
  font-size: 22px;
  margin: 0 0 10px 0;
}

/* Forms */
.form {
  display: grid;
  gap: 12px;
}

label {
  display: block;
  font-size: 12px;
  color: #666;
  margin-bottom: 6px;
}

input,
textarea,
select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 2px solid #ddd;
  background: white;
  color: #333;
}

textarea {
  min-height: 80px;
  resize: vertical;
}

/* Buttons */
button {
  appearance: none;
  border: none;
  background: #7c1331;
  color: #fff;
  padding: 10px 14px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}

button:hover {
  background: #5568d3;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-secondary {
  background: #ffffff;
  color: #333;
  border: 1px solid #ddd;
}

/* Layout helpers */
.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* Messages */
.msgs {
  height: 60vh;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px;
  border: 1px solid #eee;
  border-radius: 8px;
  background: #fafafa;
}

.msg {
  padding: 12px 16px;
  border-radius: 10px;
  max-width: 80%;
  border: 1px solid #e5e7eb;
  line-height: 1.6;
}

/* Message content formatting */
.msg h1, .msg h2, .msg h3 {
  color: #7c1331;
  margin: 8px 0 6px 0;
  font-size: 1em;
  font-weight: 600;
}

.msg h2 {
  font-size: 1.1em;
}

.msg h3 {
  font-size: 1em;
}

.msg p {
  margin: 8px 0;
}

.msg ul {
  margin: 8px 0;
  padding-left: 20px;
}

.msg li {
  margin: 4px 0;
}

.msg code {
  background: rgba(124, 19, 49, 0.1);
  padding: 2px 4px;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 0.9em;
}

.msg pre {
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 6px;
  padding: 12px;
  margin: 8px 0;
  overflow-x: auto;
}

.msg pre code {
  background: none;
  padding: 0;
  font-size: 0.85em;
}

.msg strong {
  font-weight: 600;
  color: #7c1331;
}

.user {
  align-self: flex-end;
  background: #eef2ff;
  border-color: #c7d2fe;
}

.bot {
  align-self: flex-start;
  background: #f1f5f9;
  border-color: #e2e8f0;
}

.muted {
  color: #666;
  font-size: 12px;
}

/* Form links */
.form-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #eee;
}

.form-links a {
  color: #7c1331;
  text-decoration: none;
  font-size: 13px;
  transition: color 0.2s;
}

.form-links a:hover {
  color: #5568d3;
  text-decoration: underline;
}

footer {
  text-align: center;
  color: #666;
  font-size: 12px;
}

/* Chat Layout with Sidebar */
.chat-layout {
  display: flex;
  gap: 20px;
  height: calc(100vh - 200px);
  min-height: 600px;
}

.conversations-sidebar {
  width: 280px;
  background: #f8f9fa;
  border-radius: 12px;
  padding: 16px;
  overflow-y: auto;
  flex-shrink: 0;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid #e0e0e0;
}

.sidebar-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: #333;
  margin: 0;
}

.btn-new-chat {
  background: #7c1331;
  color: white;
  border: none;
  border-radius: 8px;
  width: 32px;
  height: 32px;
  font-size: 18px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-new-chat:hover {
  background: #5a0e23;
  transform: scale(1.05);
}

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

.loading-conversations,
.empty-conversations {
  text-align: center;
  color: #999;
  padding: 20px;
  font-size: 14px;
}

.conversation-group {
  margin-bottom: 16px;
}

.conversation-group-title {
  font-size: 12px;
  font-weight: 600;
  color: #666;
  text-transform: uppercase;
  margin-bottom: 8px;
  padding-left: 4px;
}

.conversation-item {
  padding: 12px;
  background: white;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  border: 2px solid transparent;
  position: relative;
}

.conversation-item:hover {
  background: #f0f0f0;
  border-color: #7c1331;
}

.conversation-item.active {
  background: #7c1331;
  color: white;
  border-color: #7c1331;
}

.conversation-item.active .conversation-name,
.conversation-item.active .conversation-meta {
  color: white;
}

.conversation-name {
  font-size: 14px;
  font-weight: 500;
  color: #333;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-meta {
  font-size: 11px;
  color: #999;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.conversation-materia {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.conversation-delete {
  background: transparent;
  border: none;
  color: #ff4444;
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
  opacity: 0;
  transition: opacity 0.2s;
  margin-left: 8px;
}

.conversation-item:hover .conversation-delete {
  opacity: 1;
}

.conversation-delete:hover {
  color: #cc0000;
  transform: scale(1.2);
}

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Responsive */
@media (max-width: 1024px) {
  .chat-layout {
    flex-direction: column;
    height: auto;
  }
  
  .conversations-sidebar {
    width: 100%;
    height: 200px;
    max-height: 300px;
  }
}

@media (max-width: 768px) {
  .conversations-sidebar {
    display: none;
  }
}
