/* Modern ChatGPT-Style Interface for Aurelia */
/* Clean Light Theme with Orange Accents */

:root {
  /* Colors */
  --primary-orange: #ff7f00;
  --primary-orange-hover: #e6720a;
  --primary-orange-light: #fff4e6;
  
  /* Backgrounds */
  --bg-primary: #ffffff;
  --bg-secondary: #f7f7f8;
  --bg-tertiary: #ececf1;
  --bg-panel: #ffffff;
  --bg-panel-hover: #f9f9f9;
  
  /* Text Colors */
  --text-primary: #212121;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --text-white: #ffffff;
  
  /* Borders & Shadows */
  --border-light: #e5e7eb;
  --border-medium: #d1d5db;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  
  /* Typography */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  
  /* Spacing */
  --header-height: 60px;
  --composer-height: 120px;
  --border-radius: 12px;
  --border-radius-sm: 8px;
  --border-radius-lg: 16px;
}

/* Reset & Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  height: 100%;
  scroll-behavior: smooth;
}

body {
  height: 100vh;
  height: 100dvh; /* Use dynamic viewport height on mobile */
  font-family: var(--font-family);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-primary);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* App Layout */
.app-layout {
  display: flex;
  height: 100vh;
  height: 100dvh; /* Use dynamic viewport height on mobile */
  width: 100vw;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 260px;
  height: 100vh;
  height: 100dvh; /* Use dynamic viewport height on mobile */
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: relative;
  z-index: 100;
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border-light);
}

.new-chat-btn {
  width: 100%;
  background: var(--primary-orange);
  color: var(--text-white);
  border: none;
  border-radius: var(--border-radius-sm);
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.new-chat-btn:hover {
  background: var(--primary-orange-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.conversations-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.conversation-item {
  padding: 12px 16px;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  margin-bottom: 4px;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.conversation-item:hover {
  background: var(--bg-panel-hover);
  border-color: var(--border-light);
}

.conversation-item.active {
  background: var(--primary-orange-light);
  border-color: var(--primary-orange);
}

.conversation-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 4px;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-preview {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-time {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border-light);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 28px;
  height: 28px;
  background: var(--text-muted);
  color: var(--text-white);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
}

.user-name {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Main Content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
  height: 100dvh; /* Use dynamic viewport height on mobile */
  overflow: hidden;
}

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
  transition: all 0.2s ease;
  margin-right: 12px;
  display: none; /* Hidden on desktop */
}

.sidebar-toggle:hover {
  background: var(--bg-panel-hover);
  color: var(--text-primary);
}

/* Header */
.chat-header {
  height: var(--header-height);
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.header-content {
  max-width: 768px;
  margin: 0 auto;
  height: 100%;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.assistant-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.assistant-avatar {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary-orange), #ff9500);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: var(--text-white);
  font-size: 16px;
  box-shadow: var(--shadow-sm);
}

.assistant-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.assistant-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.assistant-status {
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-dot {
  width: 8px;
  height: 8px;
  background: #10b981;
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Chat Container */
.chat-container {
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.conversation-area {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  scroll-behavior: smooth;
}

.conversation-area::-webkit-scrollbar {
  width: 6px;
}

.conversation-area::-webkit-scrollbar-track {
  background: transparent;
}

.conversation-area::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: 3px;
}

.conversation-area::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Message List */
.message-list {
  max-width: 768px;
  margin: 0 auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Message Bubbles */
.msg {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  max-width: 100%;
  margin-bottom: 20px;
}

.msg.user {
  flex-direction: row-reverse;
  justify-content: flex-start;
}

.msg.assistant {
  justify-content: flex-start;
}

.msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 12px;
  flex-shrink: 0;
  margin-top: 2px;
}

.msg.user .msg-avatar {
  background: var(--text-muted);
  color: var(--text-white);
}

.msg.assistant .msg-avatar {
  background: linear-gradient(135deg, var(--primary-orange), #ff9500);
  color: var(--text-white);
}

.msg-content {
  max-width: 70%;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.msg-bubble {
  position: relative;
  padding: 12px 16px;
  border-radius: 18px;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.msg.assistant .msg-bubble {
  background: var(--bg-panel);
  border: 1px solid var(--border-light);
  border-radius: 18px 18px 18px 4px;
}

.msg.user .msg-bubble {
  background: var(--primary-orange);
  color: var(--text-white);
  border-radius: 18px 18px 4px 18px;
  margin-left: auto;
}

.msg.assistant .msg-bubble:hover {
  background: var(--bg-panel-hover);
  box-shadow: var(--shadow-md);
}

.msg-text {
  font-size: 14px;
  line-height: 1.6;
  margin: 0;
  word-wrap: break-word;
  text-rendering: optimizeLegibility;
  font-variant-ligatures: common-ligatures;
}

.msg-text p {
  margin: 12px 0;
  line-height: 1.6;
}

.msg-text p:first-child {
  margin-top: 0;
}

.msg-text p:last-child {
  margin-bottom: 0;
}

.msg.user .msg-text {
  color: var(--text-white);
}

.msg-time {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
  opacity: 0.7;
}

.msg.user .msg-time {
  color: var(--text-muted);
  text-align: right;
}

.msg.assistant .msg-time {
  text-align: left;
}

/* Formatted Content in Messages */
.msg-text h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 16px 0 12px 0;
  line-height: 1.3;
}

.msg-text h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 14px 0 10px 0;
  line-height: 1.3;
  border-bottom: 2px solid var(--primary-orange);
  padding-bottom: 6px;
}

.msg-text h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--primary-orange);
  margin: 12px 0 8px 0;
  line-height: 1.3;
}

.msg-text h4 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 10px 0 6px 0;
  line-height: 1.3;
}

.msg-text h5 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 8px 0 4px 0;
  line-height: 1.3;
}

.msg-text h6 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 6px 0 4px 0;
  line-height: 1.3;
}

.msg.user .msg-text h1,
.msg.user .msg-text h2,
.msg.user .msg-text h3,
.msg.user .msg-text h4,
.msg.user .msg-text h5,
.msg.user .msg-text h6 {
  color: var(--text-white);
}

.msg-text strong {
  font-weight: 600;
  color: var(--primary-orange);
}

.msg.user .msg-text strong {
  color: var(--text-white);
  font-weight: 700;
}

.msg-text em {
  font-style: italic;
  color: var(--text-secondary);
}

.msg.user .msg-text em {
  color: rgba(255, 255, 255, 0.9);
}

.msg-text ul, .msg-text ol {
  margin: 16px 0;
  padding-left: 24px;
  line-height: 1.6;
}

.msg-text ul {
  list-style-type: disc;
}

.msg-text ol {
  list-style-type: decimal;
}

.msg-text li {
  margin: 8px 0;
  line-height: 1.6;
  padding-left: 4px;
}

.msg-text li:first-child {
  margin-top: 0;
}

.msg-text li:last-child {
  margin-bottom: 0;
}

.msg-text a {
  color: var(--primary-orange);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: all 0.2s ease;
}

.msg-text a:hover {
  border-bottom-color: var(--primary-orange);
}

.msg.user .msg-text a {
  color: var(--text-white);
  border-bottom-color: rgba(255, 255, 255, 0.5);
}

.msg.user .msg-text a:hover {
  border-bottom-color: var(--text-white);
}

/* Tables */
.msg-text table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  border-radius: var(--border-radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.msg-text th,
.msg-text td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
}

.msg-text th {
  background: var(--bg-secondary);
  font-weight: 600;
  color: var(--text-primary);
  font-size: 13px;
}

.msg-text td {
  background: var(--bg-panel);
}

.msg-text tr:hover td {
  background: var(--bg-panel-hover);
}

/* Code */
.msg-text code {
  background: var(--bg-secondary);
  color: var(--text-primary);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', monospace;
  font-size: 13px;
}

.msg-text pre {
  background: var(--bg-secondary);
  border-radius: var(--border-radius-sm);
  padding: 16px;
  margin: 16px 0;
  overflow-x: auto;
  border: 1px solid var(--border-light);
}

.msg-text pre code {
  background: none;
  padding: 0;
}

/* Brand Tagline */
.msg-text .brand-tagline {
  display: block;
  text-align: center;
  margin: 16px 0;
  padding: 12px 20px;
  background: var(--primary-orange-light);
  border: 1px solid var(--primary-orange);
  border-radius: var(--border-radius-sm);
  font-weight: 600;
  color: var(--primary-orange);
  font-size: 13px;
}

/* Typing Indicator */
.typing {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 13px;
  padding: 2px 0;
}

.typing-dots {
  display: flex;
  gap: 3px;
  align-items: center;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background: var(--primary-orange);
  border-radius: 50%;
  animation: typing 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) { animation-delay: 0ms; }
.typing-dot:nth-child(2) { animation-delay: 160ms; }
.typing-dot:nth-child(3) { animation-delay: 320ms; }

@keyframes typing {
  0%, 60%, 100% { 
    opacity: 0.3;
    transform: scale(0.8);
  }
  30% { 
    opacity: 1;
    transform: scale(1.1);
  }
}

/* Quick Prompts */
.quick-prompts {
  width: 100%;
  padding: 0px 20px 32px 20px;
  margin-top: -30px;
}

.prompt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.prompt-button {
  background: linear-gradient(135deg, var(--bg-panel), var(--bg-secondary));
  border: 1px solid var(--border-light);
  border-radius: var(--border-radius-lg);
  padding: 15px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: left;
  font-family: inherit;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

.prompt-button::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--primary-orange);
  transform: scaleX(0);
  transition: transform 0.3s ease;
}

.prompt-button:hover {
  background: linear-gradient(135deg, var(--bg-panel), var(--primary-orange-light));
  border-color: var(--primary-orange);
  box-shadow: 0 8px 25px rgba(255, 127, 0, 0.15), var(--shadow-lg);
  transform: translateY(-2px);
}

.prompt-button:hover::before {
  transform: scaleX(1);
}

.prompt-button:active {
  transform: translateY(-1px);
}

.prompt-icon {
  font-size: 16px;
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  background: linear-gradient(135deg, var(--primary-orange), var(--primary-orange-hover));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  transition: all 0.3s ease;
}

.prompt-button:hover .prompt-icon {
  transform: scale(1.1);
  box-shadow: var(--shadow-md);
}

.prompt-text {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
}

/* Composer Container */
.composer-container {
  background: var(--bg-panel);
  border-top: 1px solid var(--border-light);
  box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
}

.composer-wrapper {
  max-width: 768px;
  margin: 0 auto;
  padding: 20px;
}

.message-composer {
  margin-bottom: 8px;
}

.input-container {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-panel);
  border: 1px solid var(--border-light);
  border-radius: 24px;
  padding: 12px 20px;
  transition: all 0.3s ease;
  box-shadow: var(--shadow-sm);
}

.input-container:focus-within {
  border-color: var(--primary-orange);
  box-shadow: 0 0 0 3px rgba(255, 127, 0, 0.1), var(--shadow-md);
  background: var(--bg-primary);
}

.message-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  font-family: inherit;
  resize: none;
  min-height: 20px;
  max-height: 120px;
}

.message-input:focus {
  outline: none !important;
  border: none !important;
  box-shadow: none !important;
}

.message-input::placeholder {
  color: var(--text-muted);
}

.send-button {
  width: 32px;
  height: 32px;
  background: var(--primary-orange);
  border: none;
  border-radius: 50%;
  color: var(--text-white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
  outline: none;
}

.send-button:hover {
  background: var(--primary-orange-hover);
  transform: scale(1.08);
  box-shadow: var(--shadow-md);
}

.send-button:active {
  transform: scale(0.92);
}

.send-button:focus {
  outline: none !important;
  box-shadow: 0 0 0 3px rgba(255, 127, 0, 0.3) !important;
}

.composer-footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 11px;
  text-align: left;
  padding: 1px 20px;
}

.composer-footer strong {
  color: #a6a6a6;
  font-weight: 600;
}

/* Responsive Design */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    height: 100dvh; /* Use dynamic viewport height on mobile */
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }
  
  .sidebar.open {
    transform: translateX(0);
  }
  
  .sidebar-toggle {
    display: block !important; /* Show on mobile */
  }

  .composer-footer {
    display: none;
  }

  .main-content {
    width: 100%;
  }
  
  .header-content,
  .message-list,
  .quick-prompts,
  .composer-wrapper {
    padding-left: 16px;
    padding-right: 16px;
  }
  
  /* Header mobile optimization */
  .chat-header {
    padding: 12px 0;
  }
  
  .header-content {
    gap: 12px;
  }
  
  .msg-content {
    max-width: 85%;
  }
  
  .prompt-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  
  .prompt-button {
    padding: 16px 20px;
    gap: 12px;
  }
  
  .prompt-icon {
    width: 40px;
    height: 40px;
    font-size: 20px;
  }
  
  .prompt-text {
    font-size: 14px;
  }
  
  .assistant-name {
    font-size: 15px;
  }
  
  .assistant-status {
    font-size: 11px;
  }
  
  /* Assistant info mobile optimization */
  .assistant-info {
    gap: 8px;
    flex-direction: row-reverse; /* Move avatar to right */
  }
  
  .assistant-avatar {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }
  
  .assistant-name {
    font-size: 15px;
  }
  
  .assistant-details {
    text-align: right; /* Align text to right since avatar is on right */
  }
  
  /* Mobile overlay */
  .sidebar.open::after {
    content: '';
    position: fixed;
    top: 0;
    left: 260px;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: -1;
  }
}

@media (max-width: 480px) {
  .msg-content {
    max-width: 90%;
  }
  
  .msg-bubble {
    padding: 10px 14px;
    border-radius: 16px;
  }
  
  .msg.assistant .msg-bubble {
    border-radius: 16px 16px 16px 3px;
  }
  
  .msg.user .msg-bubble {
    border-radius: 16px 16px 3px 16px;
  }
  
  .input-container {
    padding: 10px 16px;
    border-radius: 20px;
  }
  
  .send-button {
    width: 28px;
    height: 28px;
  }
  
  /* Assistant info for small mobile devices */
  .assistant-info {
    gap: 6px;
    flex-direction: row-reverse; /* Keep avatar on right */
  }
  
  .assistant-avatar {
    width: 28px;
    height: 28px;
    font-size: 12px;
  }
  
  .assistant-name {
    font-size: 14px;
  }
  
  .assistant-status {
    font-size: 10px;
  }
  
  .status-dot {
    width: 6px;
    height: 6px;
  }
  
  /* Extra small mobile optimization */
  .assistant-details {
    min-width: 0; /* Allow text to wrap if needed */
    text-align: right; /* Align text to right since avatar is on right */
  }
  
  .assistant-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .composer-wrapper {
    padding: 16px;
  }
  
  .msg-avatar {
    width: 24px;
    height: 24px;
    font-size: 11px;
  }
}

/* Smooth Animations */
.msg {
  animation: messageSlideIn 0.3s ease-out;
}

@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Focus States - Clean and Modern */
* {
  outline: none !important;
}

*:focus {
  outline: none !important;
}

.prompt-button:focus {
  box-shadow: 0 0 0 3px rgba(255, 127, 0, 0.2) !important;
  border-color: var(--primary-orange) !important;
}

/* Send button focus is handled above */
/* Input focus is handled in input-container:focus-within */

/* Selection */
::selection {
  background: var(--primary-orange-light);
  color: var(--primary-orange);
}