/* ============================================
   ROOT VARIABLES - Color Theme
   ============================================ */
:root {
  --copilot-primary: #0F6CBD;
  --copilot-primary-hover: #0D5BAB;
  --copilot-primary-light: #E8F4FF;
  --copilot-secondary: #6B7280;
  --copilot-bg: #F3F4F6;
  --copilot-surface: #FFFFFF;
  --copilot-border: #E5E7EB;
  --copilot-text: #1F2937;
  --copilot-text-muted: #6B7280;
  --copilot-success: #10B981;
  --copilot-warning: #F59E0B;
  --copilot-error: #EF4444;
  --copilot-error-bg: #FEE2E2;
  --copilot-error-border: #FCA5A5;
  --copilot-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --copilot-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --copilot-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --copilot-shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
  --sidebar-width: 280px;
}

/* ============================================
   GLOBAL STYLES
   ============================================ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 
               'Ubuntu', 'Cantarell', 'Helvetica Neue', sans-serif;
  background: var(--copilot-bg);
  color: var(--copilot-text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  display: flex;
}

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
  width: var(--sidebar-width);
  background: var(--copilot-surface);
  border-right: 1px solid var(--copilot-border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: relative;
  transition: transform 0.3s ease;
  z-index: 1050;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--copilot-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-logo {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 20px;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.sidebar-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--copilot-text);
}

.btn-close-sidebar {
  border: none;
  background: transparent;
  color: var(--copilot-text-muted);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  display: none;
  transition: all 0.2s ease;
}

.btn-close-sidebar:hover {
  background: var(--copilot-bg);
  color: var(--copilot-text);
}

.sidebar-body {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--copilot-text-muted);
  text-decoration: none;
  border-radius: 10px;
  transition: all 0.2s ease;
  font-size: 15px;
}

.sidebar-nav-item:hover {
  background: var(--copilot-bg);
  color: var(--copilot-text);
}

.sidebar-nav-item i {
  font-size: 18px;
}

.sidebar-actions {
  margin-top: auto;
}

.sidebar-actions .btn {
  font-size: 14px;
  font-weight: 500;
  padding: 10px;
  border-radius: 10px;
}

.sidebar-footer {
  padding: 20px;
  border-top: 1px solid var(--copilot-border);
}

.ai-models-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ai-models-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--copilot-text);
  margin: 0;
}

.ai-model-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--copilot-bg);
  border-radius: 10px;
  color: var(--copilot-primary);
  text-decoration: none;
  transition: all 0.2s ease;
  font-size: 14px;
  font-weight: 500;
}

.ai-model-link:hover {
  background: var(--copilot-primary-light);
  transform: translateX(2px);
}

.ai-model-icon {
  width: 32px;
  height: 32px;
  background: var(--copilot-primary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 16px;
}

/* Sidebar Overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1040;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
  opacity: 1;
}

/* ============================================
   MAIN CONTENT
   ============================================ */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ============================================
   HEADER SECTION
   ============================================ */
.copilot-header {
  background: var(--copilot-surface);
  border-bottom: 1px solid var(--copilot-border);
  box-shadow: var(--copilot-shadow-sm);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.copilot-logo {
  width: 40px;
  height: 40px;
  background: var(--copilot-gradient);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 20px;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.copilot-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--copilot-text);
  letter-spacing: -0.3px;
}

.btn-icon {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--copilot-text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 18px;
}

.btn-icon:hover {
  background: var(--copilot-bg);
  color: var(--copilot-text);
  transform: scale(1.05);
}

.btn-icon:active {
  transform: scale(0.95);
}

/* ============================================
   CHAT MESSAGES AREA
   ============================================ */
#chatMessages {
  background: var(--copilot-bg);
  scroll-behavior: smooth;
}

#chatMessages::-webkit-scrollbar {
  width: 8px;
}

#chatMessages::-webkit-scrollbar-track {
  background: transparent;
}

#chatMessages::-webkit-scrollbar-thumb {
  background: #D1D5DB;
  border-radius: 4px;
}

#chatMessages::-webkit-scrollbar-thumb:hover {
  background: #9CA3AF;
}

/* ============================================
   WELCOME SECTION
   ============================================ */
.welcome-section {
  max-width: 800px;
  margin: 0 auto;
  padding: 60px 20px;
  animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.welcome-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto;
  background: var(--copilot-gradient);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 40px;
  box-shadow: 0 8px 24px rgba(102, 126, 234, 0.3);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

.welcome-title {
  font-size: 32px;
  font-weight: 400;
  color: var(--copilot-text);
  line-height: 1.3;
}

.welcome-subtitle {
  font-size: 16px;
  color: var(--copilot-text-muted);
  max-width: 500px;
  margin: 0 auto;
}

/* ============================================
   SUGGESTION CARDS
   ============================================ */
.suggestion-cards {
  max-width: 700px;
  margin: 0 auto;
}

.suggestion-card {
  background: var(--copilot-surface);
  border: 1px solid var(--copilot-border);
  border-radius: 12px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

.suggestion-card:hover {
  border-color: var(--copilot-primary);
  box-shadow: var(--copilot-shadow-md);
  transform: translateY(-2px);
  background: var(--copilot-primary-light);
}

.suggestion-card:active {
  transform: translateY(0);
}

.suggestion-card i {
  font-size: 20px;
  color: var(--copilot-primary);
  min-width: 20px;
}

.suggestion-card span {
  font-size: 15px;
  color: var(--copilot-text);
  font-weight: 500;
}

/* ============================================
   MESSAGES CONTAINER
   ============================================ */
#messagesContainer {
  max-width: 900px;
  margin: 0 auto;
}

.message {
  margin-bottom: 24px;
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message-user {
  display: flex;
  justify-content: flex-end;
}

.message-assistant {
  display: flex;
  justify-content: flex-start;
}

.message-bubble {
  max-width: 80%;
  padding: 14px 18px;
  border-radius: 18px;
  line-height: 1.6;
  font-size: 15px;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.message-user .message-bubble {
  background: var(--copilot-primary);
  color: white;
  border-bottom-right-radius: 4px;
  box-shadow: var(--copilot-shadow-sm);
}

.message-assistant .message-bubble {
  background: var(--copilot-surface);
  color: var(--copilot-text);
  border: 1px solid var(--copilot-border);
  border-bottom-left-radius: 4px;
  box-shadow: var(--copilot-shadow-sm);
}

.message-bubble img {
  max-width: 250px;
  border-radius: 12px;
  margin-bottom: 10px;
  display: block;
  box-shadow: var(--copilot-shadow-md);
}

/* ============================================
   THINKING INDICATOR
   ============================================ */
.thinking-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--copilot-text-muted);
  font-style: italic;
  padding: 14px 18px;
}

.thinking-dots {
  display: flex;
  gap: 4px;
}

.thinking-dots span {
  width: 8px;
  height: 8px;
  background: var(--copilot-primary);
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out;
}

.thinking-dots span:nth-child(1) {
  animation-delay: -0.32s;
}

.thinking-dots span:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes bounce {
  0%, 80%, 100% {
    transform: scale(0);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ============================================
   ERROR MESSAGES
   ============================================ */
.error-message {
  background: var(--copilot-error-bg) !important;
  color: #991B1B !important;
  border-color: var(--copilot-error-border) !important;
}

.error-message::before {
  content: "⚠️ ";
  margin-right: 4px;
}

/* ============================================
   FOOTER INPUT AREA
   ============================================ */
.copilot-footer {
  background: var(--copilot-surface);
  border-top: 1px solid var(--copilot-border);
  padding: 20px 0;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.03);
}

.input-wrapper {
  max-width: 900px;
  margin: 0 auto;
}

.input-box {
  background: var(--copilot-surface);
  border: 1px solid var(--copilot-border);
  border-radius: 24px;
  padding: 12px;
  box-shadow: var(--copilot-shadow-md);
  transition: all 0.2s ease;
}

.input-box:focus-within {
  border-color: var(--copilot-primary);
  box-shadow: 0 4px 16px rgba(15, 108, 189, 0.15);
}

.input-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding: 0 4px;
}

/* ============================================
   MODEL SELECTOR
   ============================================ */
.model-selector {
  position: relative;
}

.btn-model {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--copilot-bg);
  border: 1px solid var(--copilot-border);
  border-radius: 20px;
  font-size: 14px;
  color: var(--copilot-text);
  transition: all 0.2s ease;
  cursor: pointer;
}

.btn-model:hover {
  background: #E5E7EB;
  border-color: #D1D5DB;
}

.btn-model i {
  font-size: 14px;
}

.dropdown-menu {
  border-radius: 12px;
  border: 1px solid var(--copilot-border);
  box-shadow: var(--copilot-shadow-lg);
  padding: 8px;
}

.dropdown-item {
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.dropdown-item:hover {
  background: var(--copilot-primary-light);
  color: var(--copilot-primary);
}

.dropdown-item.active {
  background: var(--copilot-primary);
  color: white;
}

/* ============================================
   INPUT FIELD
   ============================================ */
.input-field-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 0 4px;
}

.input-field {
  flex: 1;
  border: none;
  background: transparent;
  resize: none;
  font-size: 15px;
  line-height: 1.5;
  padding: 8px 12px;
  max-height: 150px;
  overflow-y: auto;
  color: var(--copilot-text);
}

.input-field:focus {
  outline: none;
  box-shadow: none;
}

.input-field::placeholder {
  color: var(--copilot-text-muted);
}

.input-field::-webkit-scrollbar {
  width: 6px;
}

.input-field::-webkit-scrollbar-thumb {
  background: #D1D5DB;
  border-radius: 3px;
}

.input-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ============================================
   SEND BUTTON
   ============================================ */
.btn-send {
  width: 40px;
  height: 40px;
  background: var(--copilot-primary);
  color: white;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(15, 108, 189, 0.3);
}

.btn-send:hover {
  background: var(--copilot-primary-hover);
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(15, 108, 189, 0.4);
}

.btn-send:active {
  transform: scale(0.95);
}

.btn-send:disabled {
  background: #D1D5DB;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ============================================
   IMAGE PREVIEW
   ============================================ */
#imagePreviewArea {
  margin-bottom: 12px;
}

.image-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--copilot-bg);
  border-radius: 12px;
  border: 1px solid var(--copilot-border);
  animation: slideIn 0.3s ease-out;
}

.image-preview img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: var(--copilot-shadow-sm);
}

.image-preview-info {
  flex: 1;
}

.image-preview-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--copilot-text);
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-preview-size {
  font-size: 12px;
  color: var(--copilot-text-muted);
}

.image-preview-remove {
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  color: var(--copilot-text-muted);
  cursor: pointer;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.image-preview-remove:hover {
  background: var(--copilot-surface);
  color: var(--copilot-error);
  transform: scale(1.1);
}

/* ============================================
   FOOTER NOTE
   ============================================ */
.footer-note {
  padding: 8px 0 0;
}

.footer-note small {
  font-size: 12px;
  color: var(--copilot-text-muted);
}

/* ============================================
   RESPONSIVE DESIGN - TABLET
   ============================================ */
@media (max-width: 1024px) {
  :root {
    --sidebar-width: 260px;
  }
}

/* ============================================
   RESPONSIVE DESIGN - MOBILE
   ============================================ */
@media (max-width: 991px) {
  body {
    display: block;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
    z-index: 1050;
  }

  .sidebar.active {
    transform: translateX(0);
  }

  .btn-close-sidebar {
    display: block;
  }

  .sidebar-overlay {
    display: block;
  }

  .main-content {
    width: 100%;
  }

  .welcome-section {
    padding: 40px 15px;
  }

  .welcome-title {
    font-size: 24px;
  }

  .welcome-subtitle {
    font-size: 14px;
  }

  .suggestion-cards .col-md-6 {
    padding: 0 8px;
  }

  .suggestion-card {
    padding: 12px 16px;
  }

  .message-bubble {
    max-width: 90%;
    font-size: 14px;
    padding: 12px 16px;
  }

  .input-controls {
    flex-wrap: wrap;
  }

  .btn-model {
    font-size: 13px;
  }

  .copilot-title {
    font-size: 18px;
  }
}

@media (max-width: 480px) {
  .welcome-icon {
    width: 60px;
    height: 60px;
    font-size: 30px;
  }

  .welcome-title {
    font-size: 20px;
  }

  .message-bubble {
    max-width: 95%;
  }

  .sidebar {
    width: 100%;
    max-width: 300px;
  }
}

/* ============================================
   DARK MODE SUPPORT
   ============================================ */
@media (prefers-color-scheme: dark) {
  :root {
    --copilot-bg: #1F2937;
    --copilot-surface: #111827;
    --copilot-border: #374151;
    --copilot-text: #F9FAFB;
    --copilot-text-muted: #9CA3AF;
    --copilot-primary-light: #1e3a5f;
  }

  .copilot-logo,
  .welcome-icon {
    background: var(--copilot-gradient);
  }

  .suggestion-card:hover {
    box-shadow: 0 4px 12px rgba(15, 108, 189, 0.3);
    background: var(--copilot-primary-light);
  }

  .message-assistant .message-bubble {
    background: #1F2937;
    border-color: #374151;
  }

  .btn-model {
    background: #1F2937;
    border-color: #374151;
  }

  .btn-model:hover {
    background: #374151;
  }

  .input-field {
    color: var(--copilot-text);
  }

  .image-preview {
    background: #1F2937;
    border-color: #374151;
  }

  .dropdown-menu {
    background: #1F2937;
    border-color: #374151;
  }

  .dropdown-item:hover {
    background: var(--copilot-primary-light);
  }

  .sidebar {
    background: #111827;
    border-right-color: #374151;
  }

  .sidebar-header {
    border-bottom-color: #374151;
  }

  .sidebar-nav-item:hover {
    background: #1F2937;
  }

  .sidebar-footer {
    border-top-color: #374151;
  }

  .ai-model-link {
    background: #1F2937;
  }

  .ai-model-link:hover {
    background: var(--copilot-primary-light);
  }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.text-gradient {
  background: var(--copilot-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}


.back-to-home-btn {
    position: fixed;
    top: 80px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    color: #374151;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 1002;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.back-to-home-btn:hover {
    background: #6366f1;
    color: white;
    border-color: #6366f1;
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.back-to-home-btn svg {
    width: 20px;
    height: 20px;
}

@media (max-width: 768px) {
    .back-to-home-btn {
        top: 70px;
        right: 15px;
        padding: 10px 16px;
        font-size: 13px;
    }
    
    .back-to-home-btn svg {
        width: 18px;
        height: 18px;
    }
}

@media (max-width: 480px) {
    .back-to-home-btn {
        top: 60px;
        right: 10px;
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .back-to-home-btn span {
        display: none;
    }
    
    .back-to-home-btn svg {
        width: 20px;
        height: 20px;
    }
}
.fade-in {
  animation: fadeIn 0.5s ease-out;
}

.slide-in {
  animation: slideIn 0.3s ease-out;
}