* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #2563eb;
  --primary-light: #cbdcff;
  --primary-dark: #1e40af;
  --secondary: #64748b;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --bg-light: #f8fafc;
  --bg-dark: #1e293b;
  --text-dark: #0f172a;
  --text-light: #64748b;
  --border: #e2e8f0;
  --shadow: rgba(0, 0, 0, 0.1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  margin: 0;
  padding: 0;
  color: var(--text-dark);
  overflow: auto;
}

.chat-container {
  background: white;
  display: flex;
  flex-direction: column;
  flex: 1; /* Fill available space in parent flex container */
  min-height: 0; /* Allow flexbox to shrink below content size */
  width: 100%;
  overflow: hidden;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  -webkit-overflow-scrolling: touch; /* iOS momentum scrolling */
  overscroll-behavior-y: contain; /* Prevent pull-to-refresh */
  scroll-behavior: smooth;
}

.message {
  display: flex;
  gap: 12px;
  animation: slideIn 0.3s ease-out;
  will-change: transform;
  transform: translateZ(0); /* GPU acceleration for scroll performance */
}

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

.message.user {
  flex-direction: row-reverse;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  background: var(--bg-light);
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 50%;
}

.message.user .avatar {
  background: var(--primary-light);
  color: white;
}

.content {
  flex: 1;
  max-width: 80%;
}

.message.user .content {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.content strong {
  margin-bottom: 4px;
  color: var(--text-light);
}

.message-text {
  background: var(--bg-light);
  padding: 12px 16px;
  border-radius: 12px;
  line-height: 1.5;
}

.message.user .message-text {
  background: var(--primary-light);
}

.message-text p {
  margin: 8px 0;
}

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

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

.message-text ul,
.message-text ol {
  margin: 8px 0;
  padding-left: 24px;
}

.message-text li {
  margin: 4px 0;
  line-height: 1.5;
}

.message-text strong {
  font-weight: 600;
  color: var(--text-dark);
}

.message.user .message-text strong {
  color: white;
}

.message-text em {
  font-style: italic;
}

.message-text code {
  background: rgba(0, 0, 0, 0.05);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: "Courier New", Courier, monospace;
  font-size: 0.9em;
}

.message.user .message-text code {
  background: rgba(255, 255, 255, 0.2);
}

.message-text hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 12px 0;
}

.message-text br {
  line-height: 1.5;
}

.message-text blockquote {
  margin: 12px 0;
  padding: 12px 16px;
  background: rgba(37, 99, 235, 0.05);
  border-left: 4px solid var(--primary);
  border-radius: 4px;
  font-style: italic;
  color: var(--text-dark);
}

.message.user .message-text blockquote {
  background: rgba(255, 255, 255, 0.2);
  border-left-color: white;
  color: white;
}

.message-text h1,
.message-text h2,
.message-text h3 {
  margin: 16px 0 8px 0;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-dark);
}

.message-text h1:first-child,
.message-text h2:first-child,
.message-text h3:first-child {
  margin-top: 0;
}

.message-text h1 {
  font-size: 1.5em;
  border-bottom: 2px solid var(--border);
  padding-bottom: 8px;
}

.message-text h2 {
  font-size: 1.3em;
  color: var(--primary);
}

.message-text h3 {
  font-size: 1.1em;
  color: var(--secondary);
}

.message.user .message-text h1,
.message.user .message-text h2,
.message.user .message-text h3 {
  color: white;
}

.message.user .message-text h1 {
  border-bottom-color: rgba(255, 255, 255, 0.3);
}

.sources {
  margin-top: 8px;
  padding: 8px 12px;
  background: #fef3c7;
  border-left: 3px solid var(--warning);
  border-radius: 4px;
  font-size: 12px;
}

.sources strong {
  color: var(--warning);
}

.cache-indicator {
  margin-top: 2px;
  padding: 0 12px;
  border-radius: 4px;
  font-size: 10px;
  opacity: 0.7;
  text-align: right;
}

/* QW-5: Thinking indicator */
.message.thinking {
  opacity: 0.8;
}

.thinking-text {
  padding: 12px 16px;
}

.thinking-dots {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 4px 0;
}

.thinking-dots .dot {
  width: 8px;
  height: 8px;
  background: #5487c9;
  border-radius: 50%;
  animation: thinking-pulse 1.4s ease-in-out infinite;
}

.thinking-dots .dot:nth-child(1) {
  animation-delay: 0s;
}

.thinking-dots .dot:nth-child(2) {
  animation-delay: 0.2s;
}

.thinking-dots .dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes thinking-pulse {
  0%, 60%, 100% {
    transform: scale(0.8);
    opacity: 0.5;
  }
  30% {
    transform: scale(1.2);
    opacity: 1;
  }
}

/* Progress bar for long operations */
@media (max-width: 768px) {
  .thinking-message {
    position: relative;
  }

  .thinking-message::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, #5487c9, #4576b8);
    animation: progress-bar 6s ease-out forwards;
  }

  @keyframes progress-bar {
    0% { width: 0%; }
    50% { width: 70%; }
    100% { width: 95%; }
  }

  /* Optional shimmer loading effect */
  .thinking-message .message-text {
    background: linear-gradient(
      90deg,
      #f1f3f5 25%,
      #e5e7eb 50%,
      #f1f3f5 75%
    );
    background-size: 200% 100%;
    animation: shimmer 2s infinite;
  }

  @keyframes shimmer {
    0% {
      background-position: -200% 0;
    }
    100% {
      background-position: 200% 0;
    }
  }
}

.input-area {
  padding: 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-light);
}

/* Attachment thumbnails */
.attachment-thumbnails {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  padding: 12px;
  background: white;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.attachment-thumbnails.hidden {
  display: none;
}

.attachment-thumbnail {
  position: relative;
  width: 80px;
  height: 80px;
  border-radius: 6px;
  overflow: hidden;
  border: 2px solid var(--border);
  background: var(--bg-light);
}

.attachment-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.attachment-thumbnail .doc-icon {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 4px;
  font-size: 10px;
  color: var(--text-light);
  padding: 8px;
  text-align: center;
}

.attachment-thumbnail .doc-icon svg {
  width: 32px;
  height: 32px;
  color: var(--primary);
}

.attachment-thumbnail .remove-attachment {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.9);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
  transition: background 0.2s;
}

.attachment-thumbnail .remove-attachment:hover {
  background: rgba(220, 38, 38, 1);
}

#chat-form {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

/* Mobile: Ensure send button is not cut off */
@media (max-width: 768px) {
  #chat-form {
    gap: 8px;
  }

  .input-area {
    padding: 16px;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }
}

/* Attachment button and menu */
.attachment-container {
  position: relative;
}

.attachment-button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: #6b7280;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  padding: 0;
}

.attachment-button:hover {
  background: rgba(107, 114, 128, 0.1);
  color: #374151;
}

.attachment-button.active {
  background: rgba(107, 114, 128, 0.15);
  color: #1f2937;
}

.attachment-button svg {
  transition: transform 0.2s ease;
}

.attachment-button.active .plus-icon {
  transform: rotate(45deg);
}

.attachment-menu {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 0;
  background: white;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  overflow: hidden;
  min-width: 200px;
  z-index: 1000;
  animation: menuSlideUp 0.2s ease;
}

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

.attachment-menu.hidden {
  display: none;
}

.attachment-option {
  width: 100%;
  padding: 14px 16px;
  border: none;
  background: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  font-weight: 500;
  color: #1f2937;
  transition: all 0.15s ease;
  text-align: left;
}

.attachment-option:hover {
  background: #f9fafb;
}

.attachment-option:active {
  background: #f3f4f6;
}

.attachment-option svg {
  flex-shrink: 0;
  color: #6b7280;
  transition: color 0.15s ease;
}

.attachment-option:hover svg {
  color: #374151;
}

#message-input {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.2s;
}

#message-input:focus {
  outline: none;
  border-color: var(--primary);
}

#send-button {
  padding: 12px 24px;
  background: #5487c9;
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-shrink: 0;
}

#send-button:hover:not(:disabled) {
  background: #4576b8;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(84, 135, 201, 0.3);
}

#send-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--secondary);
}

/* Base touch feedback class */
.touch-feedback {
  position: relative;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* Material ripple effect */
.touch-feedback::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
  pointer-events: none;
}

.touch-feedback:active::after {
  width: 200%;
  height: 200%;
}

/* Mobile: Circular button with up arrow */
@media (max-width: 768px) {
  /* iOS-style subtle scale on press */
  button, .attachment-option {
    transition: transform 0.1s ease, background-color 0.15s ease;
  }

  button:active {
    transform: scale(0.96);
  }

  #send-button {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    border-radius: 22px;
    background: #5487c9;
    box-shadow: 0 2px 8px rgba(84, 135, 201, 0.3);
    position: relative;
  }

  #send-button:active {
    transform: scale(0.94);
  }

  .attachment-button:active {
    transform: scale(0.94);
  }

  /* Hide text and spinner on mobile */
  #send-button > * {
    display: none !important;
  }

  /* Add up arrow icon on mobile */
  #send-button::before {
    content: '↑';
    font-size: 24px;
    font-weight: bold;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
  }

  #send-button:hover:not(:disabled) {
    background: #4576b8;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(84, 135, 201, 0.4);
  }

  #send-button:active:not(:disabled) {
    transform: translateY(0);
    background: #3d6aa8;
  }
}

#message-input:disabled {
  background: var(--bg-light);
  cursor: not-allowed;
  opacity: 0.7;
}

.spinner {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.hidden {
  display: none;
}

/* Context panel and header styles removed for simplified UI */

/* Scrollbar styling */
.messages::-webkit-scrollbar {
  width: 8px;
}

.messages::-webkit-scrollbar-track {
  background: var(--bg-light);
}

.messages::-webkit-scrollbar-thumb {
  background: var(--secondary);
  border-radius: 4px;
}

.messages::-webkit-scrollbar-thumb:hover {
  background: var(--text-dark);
}

/* Login prompt (shown when not authenticated) */
.login-prompt {
  padding: 12px;
  margin-bottom: 8px;
}

.login-button {
  width: 100%;
  padding: 12px 16px;
  background: #f0f0f0;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  font-weight: 500;
  color: #333;
  transition: all 0.2s ease;
}

.login-button:hover {
  background: #e8e8e8;
  border-color: #d0d0d0;
}

.login-button svg {
  flex-shrink: 0;
  color: #666;
}

/* User profile (shown when authenticated, at bottom of sidebar) */
.user-profile {
  border-top: 1px solid #e5e5e5;
  background: #ffffff;
  position: relative;
  margin-top: auto;
}

.user-profile-button {
  width: 100%;
  padding: 12px 16px;
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.2s ease;
}

.user-profile-button:hover {
  background: #f9fafb;
}

.user-avatar {
  width: 32px;
  height: 32px;
  min-width: 32px; /* Prevent shrinking */
  min-height: 32px; /* Prevent shrinking */
  border-radius: 50%;
  object-fit: contain; /* Changed from cover to prevent cropping */
  flex-shrink: 0;
  background: #e0e0e0;
}

.user-info {
  flex: 1;
  text-align: left;
  min-width: 0;
}

.user-name {
  font-size: 14px;
  font-weight: 600;
  color: #1f2937;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-plan {
  font-size: 12px;
  color: #6b7280;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-menu-icon {
  flex-shrink: 0;
  color: #9ca3af;
  transition: color 0.2s ease;
}

.user-profile-button:hover .user-menu-icon {
  color: #6b7280;
}

/* User menu dropdown */
.user-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 8px;
  right: 8px;
  background: white;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  z-index: 1000;
}

.user-menu-item {
  width: 100%;
  padding: 12px 16px;
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  font-weight: 500;
  color: #1f2937;
  transition: all 0.2s ease;
  text-align: left;
}

.user-menu-item:hover {
  background: #f9fafb;
}

.user-menu-item svg {
  flex-shrink: 0;
  color: #6b7280;
}

/* Collapsed sidebar - user profile */
.sidebar.collapsed .user-profile {
  padding: 0 0 12px;
}

.sidebar.collapsed .user-profile-button {
  padding: 0;
  justify-content: center;
}

.sidebar.collapsed .user-info,
.sidebar.collapsed .user-menu-icon {
  display: none;
}

.sidebar.collapsed .user-avatar {
  margin: 0;
}

.sidebar.collapsed .login-prompt {
  padding: 0;
}

.sidebar.collapsed .login-button span {
  display: none;
}

.sidebar.collapsed .login-button {
  width: 32px;
  height: 32px;
  padding: 6px;
  justify-content: center;
  margin: 0 auto;
}

/* Responsive */
@media (max-width: 768px) {
  /* Hide chat content when sidebar is expanded on mobile */
  .chat-container {
    display: none;
    opacity: 0;
  }

  /* Show and fade in chat content when sidebar is collapsed */
  .sidebar.collapsed ~ .chat-container {
    display: flex;
    animation: fadeIn 0.3s ease-out forwards;
  }

  @keyframes fadeIn {
    from {
      opacity: 0;
    }
    to {
      opacity: 1;
    }
  }

  /* QW-3: Mobile typography optimization */
  body {
    font-size: 16px; /* Prevents iOS zoom on focus */
    -webkit-text-size-adjust: 100%;
  }

  .message-text {
    font-size: 16px;
    line-height: 1.4;
    letter-spacing: -0.01em;
    word-wrap: break-word;
    overflow-wrap: break-word;
  }

  .message-text p {
    margin: 8px 0;
  }

  #message-input {
    font-size: 16px; /* Prevents zoom */
    line-height: 1.5;
    padding: 12px 14px;
  }

  /* Better list styling */
  .message-text ul, .message-text ol {
    padding-left: 20px;
    margin: 12px 0;
  }

  .message-text li {
    margin: 6px 0;
    line-height: 1.5;
  }

  /* Code blocks */
  .message-text code {
    font-size: 14px;
    padding: 3px 6px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.06);
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
  }

  .message-text pre code {
    display: block;
    padding: 12px;
    overflow-x: auto;
    border-radius: 8px;
  }

  /* QW-4: iOS-Style Message Bubbles */
  .message-text {
    border-radius: 18px;
    padding: 10px 14px;
    max-width: 85%; /* Increased from 75% */
    word-wrap: break-word;
    font-size: 16px;
    line-height: 1.4;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  }

  /* User bubble - right aligned, blue */
  .message.user .message-text {
    background: #5487c9;
    color: white;
    border-bottom-right-radius: 4px; /* Tail effect */
    margin-left: auto;
  }

  /* Assistant bubble - left aligned, light gray */
  .message.assistant .message-text,
  .message:not(.user) .message-text {
    background: #f1f3f5;
    color: #1f2937;
    border-bottom-left-radius: 4px; /* Tail effect */
    margin-right: auto;
    position: relative;
    padding-left: 14px; /* Standard padding - text uses full width */
    padding-top: 42px; /* Space for avatar at top */
  }

  /* Message container adjustments */
  .message {
    padding: 4px 8px; /* Reduced horizontal padding from 16px to 8px */
    gap: 8px;
  }

  .message.user {
    padding-right: 12px; /* Slightly more padding on right for user messages */
  }

  /* Avatar sizing */
  .avatar {
    width: 28px;
    height: 28px;
    min-width: 28px;
    min-height: 28px;
    align-self: flex-start;
    margin-top: 4px;
    flex-shrink: 0; /* Prevent avatar from shrinking */
  }

  /* Assistant messages - avatar positioned inside bubble at top-left */
  .message:not(.user) {
    flex-direction: row;
    align-items: flex-start;
  }

  .message:not(.user) .avatar {
    position: absolute;
    left: 8px;
    top: 8px;
    width: 28px;
    height: 28px;
    z-index: 1;
  }

  /* User avatar stays outside on right */
  .message.user .avatar {
    width: 28px;
    height: 28px;
    align-self: flex-end;
    margin-bottom: 4px;
    margin-left: 6px;
  }

  /* Ensure user avatar image is not cropped */
  .message.user .avatar img {
    object-fit: contain;
    width: 100%;
    height: 100%;
  }

  /* Content wrapper */
  .content {
    max-width: 90%; /* Increased from 85% */
    display: flex;
    flex-direction: column;
  }

  .message.user .content {
    align-items: flex-end;
  }

  /* Hide names on mobile for cleaner look */
  .content strong {
    display: none;
  }

  /* Tighter spacing for sequential messages from same sender */
  .message + .message.user {
    margin-top: 4px;
  }

  .message:not(.user) + .message:not(.user) {
    margin-top: 4px;
  }

  /* Larger spacing when sender changes */
  .message.user + .message:not(.user),
  .message:not(.user) + .message.user {
    margin-top: 16px;
  }

  /* Hide avatar on sequential messages */
  .message.user + .message.user .avatar,
  .message:not(.user) + .message:not(.user) .avatar {
    visibility: hidden;
  }

  /* HP-4: Keyboard-Safe Input Area */
  .input-area {
    position: sticky;
    bottom: 0;
    background: white;
    padding: 12px 16px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    border-top: 1px solid #e2e8f0;
    z-index: 100;
    transform: translateZ(0);
    will-change: transform;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .messages {
    padding-bottom: 80px;
    scroll-behavior: smooth;
    transition: padding-bottom 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  #message-input:focus {
    border-color: #5487c9;
    box-shadow: 0 0 0 3px rgba(84, 135, 201, 0.1);
  }

  /* MP-1: Pull-to-Refresh indicator */
  .pull-refresh-indicator {
    position: absolute;
    top: -60px;
    left: 50%;
    transform: translateX(-50%) translateY(0);
    opacity: 0;
    padding: 12px 24px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    font-size: 14px;
    color: #5487c9;
    font-weight: 500;
    transition: opacity 0.2s ease;
    z-index: 1000;
    pointer-events: none;
  }

  .pull-refresh-indicator span {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .pull-refresh-indicator.refreshing::before {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid #5487c9;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
    margin-right: 8px;
  }
}

/* ========================================
   FT-5: Table Styles - Desktop
   ======================================== */

/* Table Container */
.table-responsive {
  overflow-x: auto;
  margin: 16px 0;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Table Base Styles */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  font-size: 14px;
  line-height: 1.5;
}

/* Table Header */
.data-table thead {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.data-table th {
  padding: 12px 16px;
  font-weight: 600;
  text-align: left;
  border-bottom: 2px solid #5a67d8;
  white-space: nowrap;
}

/* Table Body */
.data-table tbody tr {
  border-bottom: 1px solid #e2e8f0;
  transition: background-color 0.15s ease;
}

.data-table tbody tr:nth-child(even) {
  background: #f8fafc;
}

.data-table tbody tr:hover {
  background: #edf2f7;
  cursor: pointer;
}

.data-table td {
  padding: 12px 16px;
  vertical-align: top;
}

/* Cell content formatting */
.data-table td strong,
.data-table th strong {
  color: #2d3748;
  font-weight: 600;
}

.data-table td code {
  background: #f1f3f5;
  padding: 2px 6px;
  border-radius: 3px;
  font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
  font-size: 12px;
}

.data-table td em {
  font-style: italic;
  color: #4a5568;
}

/* Empty state */
.data-table tbody tr td[colspan] {
  text-align: center;
  color: #a0aec0;
  font-style: italic;
  padding: 24px;
}

/* ========================================
   FT-9: Pro/Con Table Specific Styles
   ======================================== */

/* Pro/Con Table Container */
.pro-con-table {
  border: 2px solid #e2e8f0;
}

/* Pro/Con Headers */
.pro-con-table thead {
  background: transparent;
}

.pro-header {
  background: linear-gradient(135deg, #48bb78 0%, #38a169 100%) !important;
  color: white !important;
  border-bottom: 2px solid #38a169 !important;
}

.con-header {
  background: linear-gradient(135deg, #f56565 0%, #e53e3e 100%) !important;
  color: white !important;
  border-bottom: 2px solid #e53e3e !important;
}

/* Pro/Con Cells */
.pro-cell {
  background: #f0fff4;
  border-right: 1px solid #c6f6d5;
}

.con-cell {
  background: #fff5f5;
}

.pro-con-table tbody tr:hover .pro-cell {
  background: #e6ffed;
}

.pro-con-table tbody tr:hover .con-cell {
  background: #fff1f1;
}

/* Remove zebra striping from pro/con tables */
.pro-con-table tbody tr:nth-child(even) .pro-cell {
  background: #f0fff4;
}

.pro-con-table tbody tr:nth-child(even) .con-cell {
  background: #fff5f5;
}

/* ========================================
   FT-6: Mobile Responsive Tables
   ======================================== */

@media (max-width: 768px) {
  /* Mobile table optimizations */
  .table-responsive {
    margin: 12px 0;
    border-radius: 6px;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    position: relative;
  }

  /* ============================================
     ROW-TO-CARD MOBILE TABLE TRANSFORMATION
     Converts horizontal scroll tables to vertical card layout
     ============================================ */

  .table-responsive {
    overflow-x: visible; /* Disable horizontal scroll */
    -webkit-overflow-scrolling: auto;
  }

  .data-table {
    display: block;
    width: 100%;
    min-width: auto; /* Remove min-width constraint */
    border: none;
    font-size: 14px;
  }

  /* Hide table header on mobile - labels come from data-label */
  .data-table thead {
    display: none;
  }

  .data-table tbody {
    display: block;
    width: 100%;
  }

  /* Each row becomes a card */
  .data-table tbody tr {
    display: block;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    margin-bottom: 12px;
    padding: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    overflow: hidden;
  }

  .data-table tbody tr:nth-child(even) {
    background: white; /* Override zebra striping for cards */
  }

  /* First cell becomes the card header (feature name) */
  .data-table tbody td:first-child {
    display: block;
    width: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: 600;
    font-size: 13px;
    padding: 10px 14px;
    text-align: left;
    border-bottom: none;
    position: static; /* Remove sticky positioning */
    box-shadow: none;
  }

  .data-table tbody td:first-child strong {
    display: inline !important;
    color: white;
    font-weight: 600;
  }

  /* Other cells stack vertically with product labels */
  .data-table tbody td:not(:first-child) {
    display: flex;
    flex-direction: column;
    width: 100%;
    padding: 10px 14px;
    border-bottom: 1px solid #f1f3f5;
    text-align: left;
    min-height: auto;
  }

  .data-table tbody td:not(:first-child):last-child {
    border-bottom: none;
  }

  /* Show data-label as product identifier */
  .data-table tbody td:not(:first-child)::before {
    content: attr(data-label);
    display: block;
    font-weight: 600;
    font-size: 11px;
    color: #667eea;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
  }

  /* Ensure table cell strong elements are visible */
  .data-table td strong,
  .data-table th strong {
    display: inline !important;
    color: #2d3748;
    font-weight: 600;
  }

  /* ============================================
     PRO/CON TABLE CARD LAYOUT
     Special handling for two-column pro/con tables
     ============================================ */

  .pro-con-table tbody tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    padding: 0;
    border-radius: 12px;
  }

  .pro-con-table tbody td {
    display: flex;
    flex-direction: column;
    padding: 12px 14px;
    border-bottom: none;
  }

  .pro-con-table tbody td:first-child {
    background: #f0fdf4; /* Light green for pros */
    color: #166534;
    border-radius: 12px 0 0 12px;
  }

  .pro-con-table tbody td:first-child::before {
    color: #16a34a;
  }

  .pro-con-table tbody td:last-child {
    background: #fef2f2; /* Light red for cons */
    color: #991b1b;
    border-radius: 0 12px 12px 0;
  }

  .pro-con-table tbody td:last-child::before {
    color: #dc2626;
  }

  .pro-con-table tbody td::before {
    content: attr(data-label);
    display: block;
    font-weight: 700;
    font-size: 12px;
    margin-bottom: 6px;
  }

  /* Remove horizontal scroll indicator */
  .table-responsive::after {
    display: none;
  }
}
