/* ChatGPT Interface Styles */

:root {
  --sidebar-width: 280px;
  --primary-color: #6366F1;
  --primary-hover: #5558E3;
  --bg-main: #FFFFFF;
  --bg-secondary: #F9FAFB;
  --border-color: #E5E7EB;
  --text-primary: #1F2937;
  --text-secondary: #6B7280;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg-main);
  overflow: hidden;
  height: 100vh;
  display: flex;
}

/* ============================================
   ENHANCED SIDEBAR
   ============================================ */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100vh;
  transition: transform 0.3s ease;
  position: relative;
  z-index: 1050;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 40px;
  height: 40px;
  background: var(--gradient);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 20px;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.brand-name {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.btn-close-sidebar {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  display: none;
  transition: all 0.2s;
}

.btn-close-sidebar:hover {
  background: #E5E7EB;
  color: var(--text-primary);
}

.sidebar-body {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.sidebar-body::-webkit-scrollbar {
  width: 6px;
}

.sidebar-body::-webkit-scrollbar-thumb {
  background: #D1D5DB;
  border-radius: 3px;
}

.sidebar-menu {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: 10px;
  transition: all 0.2s;
  font-size: 15px;
}

.menu-item:hover {
  background: #E5E7EB;
  color: var(--text-primary);
}

.menu-item i {
  font-size: 18px;
}

.sidebar-auth {
  margin-top: auto;
}

.sidebar-auth .btn {
  font-size: 14px;
  font-weight: 500;
  padding: 10px;
  border-radius: 10px;
}

.sidebar-auth .btn-primary {
  background: var(--primary-color);
  border: none;
}

.sidebar-auth .btn-primary:hover {
  background: var(--primary-hover);
}

.sidebar-auth .btn-outline-secondary {
  border-color: var(--border-color);
  color: var(--text-secondary);
}

.sidebar-auth .btn-outline-secondary:hover {
  background: #E5E7EB;
  color: var(--text-primary);
  border-color: var(--border-color);
}

.sidebar-footer {
  padding: 20px;
  border-top: 1px solid var(--border-color);
}

.ai-models {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ai-models-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.ai-model-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #E5E7EB;
  border-radius: 10px;
  color: var(--primary-color);
  text-decoration: none;
  transition: all 0.2s;
  font-size: 14px;
  font-weight: 500;
}

.ai-model-item:hover {
  background: #D1D5DB;
  transform: translateX(2px);
}

.ai-icon {
  width: 32px;
  height: 32px;
  background: var(--primary-color);
  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;
  height: 100vh;
  background: var(--bg-main);
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-main);
}

.mobile-menu {
  display: none;
}

.top-center {
  flex: 1;
  display: flex;
  justify-content: center;
}

.btn-model-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-model-selector:hover {
  background: #E5E7EB;
}

.btn-icon {
  background: transparent;
  border: none;
  padding: 8px;
  cursor: pointer;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all 0.2s;
  font-size: 20px;
}

.btn-icon:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.top-actions {
  display: flex;
  gap: 8px;
}

/* ============================================
   CHAT CONTAINER
   ============================================ */
.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 40px 20px 20px;
  scroll-behavior: smooth;
}

.messages-area::-webkit-scrollbar {
  width: 8px;
}

.messages-area::-webkit-scrollbar-thumb {
  background: #D1D5DB;
  border-radius: 4px;
}

.welcome-section {
  max-width: 800px;
  margin: 0 auto;
  text-align: center;
  padding: 80px 20px;
  animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.welcome-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 24px;
  background: var(--gradient);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 40px;
  box-shadow: 0 8px 24px rgba(99, 102, 241, 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: 40px;
  font-weight: 400;
  color: var(--text-primary);
  margin-bottom: 16px;
  line-height: 1.3;
}

.welcome-subtitle {
  font-size: 16px;
  color: var(--text-secondary);
}

/* Messages */
.message {
  max-width: 800px;
  margin: 0 auto 24px;
  animation: fadeInUp 0.4s ease;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message.user {
  display: flex;
  justify-content: flex-end;
}

.message.assistant {
  display: flex;
  justify-content: flex-start;
}

.bubble {
  max-width: 80%;
  padding: 14px 18px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.6;
  word-wrap: break-word;
}

.user .bubble {
  background: var(--primary-color);
  color: white;
  border-bottom-right-radius: 4px;
  box-shadow: var(--shadow-sm);
}

.assistant .bubble {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-sm);
}

.thinking {
  font-style: italic;
  color: var(--text-secondary);
}

.error-message {
  background: #FEE2E2 !important;
  color: #991B1B !important;
  border: 1px solid #FCA5A5;
}

/* ============================================
   INPUT AREA
   ============================================ */
.input-area {
  padding: 20px;
  background: var(--bg-main);
  border-top: 1px solid var(--border-color);
}

#imagePreviewArea {
  max-width: 800px;
  margin: 0 auto 12px;
}

.image-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  animation: fadeInUp 0.3s ease;
}

.image-preview img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
}

.image-preview-info {
  flex: 1;
}

.image-preview-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.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;
    }
}

.image-preview-size {
  font-size: 12px;
  color: var(--text-secondary);
}

.image-preview-remove {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 18px;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.2s;
}

.image-preview-remove:hover {
  color: #EF4444;
  background: #FEE2E2;
}

.input-wrapper {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 24px;
  padding: 10px 12px;
  transition: all 0.3s;
}

.input-wrapper:focus-within {
  background: var(--bg-main);
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.btn-attach,
.btn-voice {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 8px;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
  font-size: 20px;
}

.btn-attach:hover,
.btn-voice:hover {
  background: #E5E7EB;
  color: var(--text-primary);
}

.chat-input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 15px;
  color: var(--text-primary);
  padding: 8px;
}

.chat-input::placeholder {
  color: var(--text-secondary);
}

.btn-send {
  background: var(--primary-color);
  border: none;
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.btn-send:hover {
  background: var(--primary-hover);
  transform: scale(1.05);
}

.btn-send:active {
  transform: scale(0.95);
}

.btn-send:disabled {
  background: #D1D5DB;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ============================================
   RESPONSIVE - TABLET
   ============================================ */
@media (max-width: 1024px) {
  :root {
    --sidebar-width: 260px;
  }

  .welcome-title {
    font-size: 32px;
  }
}

/* ============================================
   RESPONSIVE - MOBILE
   ============================================ */
@media (max-width: 991px) {
  body {
    display: block;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
    z-index: 1050;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
  }

  .sidebar.active {
    transform: translateX(0);
  }

  .btn-close-sidebar {
    display: block;
  }

  .sidebar-overlay {
    display: block;
  }

  .main-content {
    width: 100%;
  }

  .mobile-menu {
    display: flex;
  }

  .welcome-title {
    font-size: 28px;
  }

  .welcome-subtitle {
    font-size: 14px;
  }

  .bubble {
    font-size: 14px;
    max-width: 90%;
  }

  .input-wrapper {
    padding: 8px 10px;
  }

  .chat-input {
    font-size: 14px;
  }
}

@media (max-width: 480px) {
  .sidebar {
    width: 100%;
    max-width: 300px;
  }

  .welcome-title {
    font-size: 24px;
  }

  .welcome-icon {
    width: 60px;
    height: 60px;
    font-size: 30px;
  }

  .bubble {
    max-width: 95%;
  }

  .top-center {
    display: none;
  }
}

/* ============================================
   DARK MODE
   ============================================ */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-main: #1F2937;
    --bg-secondary: #111827;
    --border-color: #374151;
    --text-primary: #F9FAFB;
    --text-secondary: #9CA3AF;
  }

  .sidebar {
    background: #111827;
  }

  .brand-icon {
    background: var(--gradient);
  }

  .menu-item:hover {
    background: #1F2937;
  }

  .sidebar-auth .btn-outline-secondary:hover {
    background: #1F2937;
  }

  .ai-model-item {
    background: #1F2937;
  }

  .ai-model-item:hover {
    background: #374151;
  }

  .btn-model-selector {
    background: #111827;
    border-color: #374151;
  }

  .btn-model-selector:hover {
    background: #1F2937;
  }

  .btn-icon:hover {
    background: #111827;
  }

  .assistant .bubble {
    background: #1F2937;
  }

  .input-wrapper {
    background: #111827;
    border-color: #374151;
  }

  .input-wrapper:focus-within {
    background: #1F2937;
  }

  .btn-attach:hover,
  .btn-voice:hover {
    background: #374151;
  }
  

  .image-preview {
    background: #111827;
    border-color: #374151;
  }
}
