/* ===== GENERAL RESET ===== */
body, html {
  margin: 0;
  padding: 0;
  height: 100vh;
  background-color: #0f0f0f;
  color: #ffffff;
  font-family: 'Segoe UI', sans-serif;
}

/* ===== APP CONTAINER ===== */
.app-container {
  height: 100vh;
  display: flex;
  background-color: #0f0f0f;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: 260px;
  background-color: #171717;
  border-right: 1px solid #2a2a2a;
  display: flex;
  flex-direction: column;
  padding: 0;
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid #2a2a2a;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-icon {
  font-size: 20px;
}

.logo-text {
  font-weight: 600;
  font-size: 14px;
  color: #ffffff;
}

.sidebar-toggle {
  background: none;
  border: none;
  color: #888;
  font-size: 16px;
  cursor: pointer;
  padding: 4px;
}

.sidebar-toggle:hover {
  color: #ffffff;
}

/* ===== SIDEBAR NAVIGATION ===== */
.sidebar-nav {
  padding: 8px;
  border-bottom: 1px solid #2a2a2a;
}

.nav-item {
  width: 100%;
  background: none;
  border: none;
  color: #888;
  padding: 12px 16px;
  text-align: left;
  cursor: pointer;
  border-radius: 8px;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  transition: all 0.2s ease;
}

.nav-item:hover {
  background-color: #2a2a2a;
  color: #ffffff;
}

.nav-item.active {
  background-color: #2a2a2a;
  color: #ffffff;
}

.nav-icon {
  font-size: 16px;
  width: 16px;
  text-align: center;
}

.nav-text {
  flex: 1;
}

/* ===== SIDEBAR SECTIONS ===== */
.sidebar-section {
  padding: 16px 8px;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px 12px 16px;
  color: #888;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.section-icon {
  font-size: 14px;
}

.guide-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.guide-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  color: #888;
  cursor: pointer;
  border-radius: 6px;
  font-size: 13px;
  transition: all 0.2s ease;
}

.guide-item:hover {
  background-color: #2a2a2a;
  color: #ffffff;
}

.guide-icon {
  font-size: 14px;
  width: 14px;
  text-align: center;
}

.guide-name {
  flex: 1;
}

.guide-item.active {
  background-color: #2a2a2a;
  color: #ffffff;
}

/* ===== SIDEBAR COLLAPSED STATE ===== */
.sidebar.collapsed {
  width: 60px;
}

.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-text,
.sidebar.collapsed .section-title,
.sidebar.collapsed .guide-name {
  display: none;
}

.sidebar.collapsed .sidebar-section {
  padding: 8px;
}

.sidebar.collapsed .section-header {
  justify-content: center;
  padding: 8px;
}

.sidebar.collapsed .guide-item {
  justify-content: center;
  padding: 8px;
}

.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 12px;
}

/* ===== HISTORY SECTION ===== */
.history-search {
  padding: 0 16px 12px 16px;
}

.history-search-input {
  width: 100%;
  background-color: #2a2a2a;
  border: 1px solid #444;
  border-radius: 6px;
  color: #ffffff;
  padding: 8px 12px;
  font-size: 12px;
  outline: none;
  transition: border-color 0.2s ease;
}

.history-search-input:focus {
  border-color: #666;
}

.history-search-input::placeholder {
  color: #888;
}

.sidebar.collapsed .history-search {
  display: none;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 300px;
  overflow-y: auto;
}

.history-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 16px;
  color: #888;
  cursor: pointer;
  border-radius: 6px;
  font-size: 12px;
  transition: all 0.2s ease;
  line-height: 1.3;
}

.history-item:hover {
  background-color: #2a2a2a;
  color: #ffffff;
}

.history-item.active {
  background-color: #2a2a2a;
  color: #ffffff;
}

.history-icon {
  font-size: 12px;
  width: 12px;
  text-align: center;
  margin-top: 1px;
  flex-shrink: 0;
}

.history-content {
  flex: 1;
  min-width: 0;
}

.history-title {
  font-weight: 500;
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-date {
  font-size: 10px;
  color: #666;
  opacity: 0.8;
}

.sidebar.collapsed .history-item {
  justify-content: center;
  padding: 8px;
}

.sidebar.collapsed .history-content {
  display: none;
}

/* ===== MOBILE RESPONSIVENESS ===== */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -260px;
    top: 0;
    height: 100vh;
    z-index: 1000;
    transition: left 0.3s ease;
  }
  
  .sidebar.mobile-open {
    left: 0;
  }
  
  .main-content {
    width: 100%;
    margin-left: 0;
  }
  
  .top-controls {
    padding: 8px 16px;
  }
  
  .controls-center {
    display: none;
  }
  
  .controls-left,
  .controls-right {
    flex: 1;
  }
  
  .controls-right {
    justify-content: flex-end;
  }
  
  .chat-area {
    padding: 16px;
  }
  
  .chat-input {
    padding: 16px;
  }
  
  .input-container {
    max-width: none;
  }
  
  /* Mobile overlay */
  .mobile-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: none;
  }
  
  .mobile-overlay.active {
    display: block;
  }
  
  /* Mobile menu button */
  .mobile-menu-btn {
    display: block;
    background: none;
    border: none;
    color: #888;
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
  }
  
  .mobile-menu-btn:hover {
    color: #ffffff;
  }
}

@media (min-width: 769px) {
  .mobile-menu-btn {
    display: none;
  }
  
  .mobile-overlay {
    display: none !important;
  }
}

/* ===== MAIN CONTENT ===== */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: #0f0f0f;
}

/* ===== TOP CONTROLS ===== */
.top-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  border-bottom: 1px solid #2a2a2a;
  background-color: #171717;
}

.controls-left {
  display: flex;
  align-items: center;
}

.controls-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.app-title {
  font-weight: 600;
  font-size: 16px;
  color: #ffffff;
  letter-spacing: 0.5px;
}

.app-subtitle {
  font-size: 12px;
  color: #888;
  margin-top: -2px;
}

.controls-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ===== CHAT AREA ===== */
.chat-area {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 24px;
  background-color: #0f0f0f;
}

.welcome-message {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
}

.welcome-message h2 {
  color: #888;
  font-weight: 400;
  font-size: 24px;
  margin: 0;
}

/* Chat bubbles */
.chat-message {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 0.95rem;
  line-height: 1.5;
}

/* Text formatting for AI responses */
.chat-message strong,
.chat-message b {
  font-weight: bold;
  color: #ffffff;
}

.chat-message em,
.chat-message i {
  font-style: italic;
  color: #e0e0e0;
}

.chat-message h1,
.chat-message h2,
.chat-message h3,
.chat-message h4,
.chat-message h5,
.chat-message h6 {
  font-weight: bold;
  margin: 0.5rem 0;
  color: #ffffff;
}

.chat-message h3 {
  font-size: 1.1rem;
  border-bottom: 1px solid #444;
  padding-bottom: 0.25rem;
}

.chat-message ul,
.chat-message ol {
  margin: 0.5rem 0;
  padding-left: 1.5rem;
}

.chat-message li {
  margin: 0.25rem 0;
}

.chat-message table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.5rem 0;
}

.chat-message th,
.chat-message td {
  border: 1px solid #444;
  padding: 0.5rem;
  text-align: left;
}

.chat-message th {
  background-color: #333;
  font-weight: bold;
}

.chat-message hr {
  border: none;
  border-top: 1px solid #444;
  margin: 1rem 0;
}

.chat-message code {
  background-color: #2a2a2a;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 0.9rem;
}

.chat-message pre {
  background-color: #2a2a2a;
  padding: 1rem;
  border-radius: 8px;
  overflow-x: auto;
  margin: 0.5rem 0;
}

.chat-message blockquote {
  border-left: 4px solid #007bff;
  padding-left: 1rem;
  margin: 0.5rem 0;
  font-style: italic;
  color: #ccc;
  word-break: break-word;
  white-space: pre-wrap;
  margin: 0 10px;
  position: relative;
}

.chat-message.user {
  background-color: #2563eb;
  align-self: flex-end;
  color: white;
  border-bottom-right-radius: 4px;
}

.chat-message.ai {
  background-color: #1f1f1f;
  align-self: flex-start;
  color: #e0e0e0;
  border-bottom-left-radius: 4px;
}

/* ===== INPUT BAR ===== */
.chat-input {
  padding: 24px;
  background-color: #0f0f0f;
}

.input-container {
  display: flex;
  align-items: center;
  background-color: #2a2a2a;
  border-radius: 24px;
  padding: 4px;
  max-width: 600px;
  margin: 0 auto;
}

.chat-input input[type="text"] {
  flex: 1;
  background: none;
  border: none;
  color: white;
  padding: 12px 16px;
  font-size: 14px;
  outline: none;
}

.chat-input input[type="text"]::placeholder {
  color: #888;
}

.send-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: #ffffff;
  color: #000000;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  font-weight: bold;
  transition: all 0.2s ease;
}

.send-btn:hover {
  background-color: #e0e0e0;
}

.send-btn:disabled {
  background-color: #666;
  color: #999;
  cursor: not-allowed;
}

/* ===== SELECT DROPDOWNS & BUTTON ===== */
.form-select {
  border-radius: 12px;
  font-size: 0.9rem;
}

#themeToggle {
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 18px;
  border-radius: 50%;
  line-height: 1;
}

/* ===== SCROLLBAR ===== */
.chat-area::-webkit-scrollbar {
  width: 6px;
}

.chat-area::-webkit-scrollbar-thumb {
  background-color: #333;
  border-radius: 3px;
}

/* ===== LIGHT MODE ===== */
body.light-mode {
  background-color: #ffffff;
  color: #000000;
}

body.light-mode .app-wrapper {
  background-color: #ffffff;
}

body.light-mode .ai-banner {
  background: linear-gradient(135deg, #f8f9fa, #e9ecef);
  border-bottom: 1px solid #dee2e6;
}

body.light-mode .ai-banner h6 {
  color: #495057;
}

body.light-mode .form-select {
  background-color: #ffffff;
  color: #000000;
  border-color: #ced4da;
}

body.light-mode .chat-message.ai {
  background-color: #f8f9fa;
  color: #495057;
}

body.light-mode .chat-input {
  background-color: #ffffff;
  border-top: 1px solid #dee2e6;
}

body.light-mode .chat-input input[type="text"] {
  background-color: #ffffff;
  border: 1px solid #ced4da;
  color: #000000;
}

body.light-mode .chat-input input[type="text"]::placeholder {
  color: #6c757d;
}

body.light-mode .btn-outline-light {
  color: #495057;
  border-color: #ced4da;
}

body.light-mode .btn-outline-light:hover {
  background-color: #e9ecef;
  border-color: #adb5bd;
}

/* Light mode modal and chat history styles */
body.light-mode .modal-content {
  background-color: #fff !important;
  color: #333 !important;
}

body.light-mode .list-group-item-dark {
  background-color: #f8f9fa !important;
  color: #333 !important;
  border-color: #dee2e6 !important;
}

/* Chat History Styles */
.modal-dialog {
  max-width: 800px;
}

.list-group-item {
  border-radius: 8px !important;
  margin-bottom: 8px;
}

.chat-history-preview {
  font-size: 0.9em;
  opacity: 0.8;
}

.btn-outline-secondary:hover,
.btn-outline-danger:hover,
.btn-outline-info:hover,
.btn-outline-success:hover {
  transform: translateY(-1px);
  transition: all 0.2s ease;
}

/* History controls styling */
.btn-sm {
  font-size: 0.8rem;
  padding: 0.25rem 0.5rem;
}

/* Modal dark theme adjustments */
.modal-content.bg-dark .btn-close-white {
  filter: invert(1) grayscale(100%) brightness(200%);
}

/* === Animation Styles === */

/* Thinking animation */
.thinking-animation {
  opacity: 0.8;
  font-style: italic;
}

.thinking-dots .dots {
  display: inline-block;
  width: 20px;
  text-align: left;
}

/* Typing animation */
.typing-animation {
  opacity: 0.8;
  font-style: italic;
}

.typing-indicator .typing-dots {
  display: inline-block;
  width: 20px;
  text-align: left;
}

/* Typing cursor */
.typing-cursor {
  animation: blink 1s infinite;
  color: #007bff;
  font-weight: bold;
}

@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

/* Light mode adjustments for animations */
body.light-mode .thinking-animation,
body.light-mode .typing-animation {
  opacity: 0.7;
}

body.light-mode .typing-cursor {
  color: #0056b3;
}

/* Smooth message appearance */
.chat-message {
  animation: fadeInUp 0.3s ease-out;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
