/* styles.css - Complete Mobile-Optimized Styles for Multi-AI Chat */

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

html {
  -webkit-tap-highlight-color: transparent;
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: background-color 0.3s ease, color 0.3s ease;
  margin: 0;
  padding: 0;
}

.header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  transition: border-color 0.3s ease;
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
}

.logo-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.menu-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  margin-right: 12px;
}

.menu-btn:hover {
  background: var(--border);
  color: var(--text);
}

.logo-section img {
  height: 32px;
  filter: brightness(0) invert(1);
  transition: filter 0.3s ease;
}

body[data-theme="day"] .logo-section img {
  filter: brightness(0) invert(0);
}

.ai-selector {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.ai-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.ai-btn svg {
  width: 24px;
  height: 24px;
  opacity: 0.5;
  transition: opacity 0.2s;
}

.ai-btn:hover svg {
  opacity: 0.8;
}

.ai-btn.active {
  border-color: currentColor;
}

.ai-btn.active svg {
  opacity: 1;
}

.ai-btn.openai { color: var(--openai); }
.ai-btn.claude { color: var(--claude); }
.ai-btn.grok { color: var(--grok); }

.model-select {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  outline: none;
  cursor: pointer;
  transition: all 0.3s ease;
}

.clear-btn, .theme-btn, .manage-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  text-decoration: none;
}

.clear-btn:hover {
  background: #ef4444;
  border-color: #ef4444;
  color: white;
}

.theme-btn:hover, .manage-btn:hover {
  background: var(--border);
  color: var(--text);
}

/* Chat Container */
.chat-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  position: relative;
}

.welcome {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  color: var(--text-muted);
  text-align: center;
}

.welcome h1 {
  font-size: 32px;
  font-weight: 600;
  color: var(--text);
}

.file-btn, .stop-btn {
  position: absolute;
  bottom: 8px;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.file-btn {
  right: 56px;
}

.stop-btn {
  right: 56px;
  display: none;
  background: #ef4444;
  color: white;
}

.stop-btn.active {
  display: flex;
}

.stop-btn:hover {
  background: #dc2626;
}

.file-btn:hover {
  background: var(--surface);
  color: var(--text);
}

.file-preview {
  margin-top: 8px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: none;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  transition: all 0.3s ease;
}

.file-preview.active {
  display: flex;
}

.file-preview img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.file-preview .remove-file {
  margin-left: auto;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.2s;
}

.file-preview .remove-file:hover {
  background: var(--border);
  color: var(--text);
}

.message {
  display: flex;
  gap: 12px;
  animation: slideIn 0.3s ease;
  position: relative;
}

@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: 10px;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid var(--border);
  transition: all 0.3s ease;
}

.avatar svg {
  width: 20px;
  height: 20px;
}

.message-content {
  max-width: 70%;
  padding: 12px 16px;
  border-radius: 16px;
  line-height: 1.5;
  position: relative;
  transition: all 0.3s ease;
}

.message-content:hover .copy-btn {
  opacity: 1;
}

.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: none;
  background: var(--border);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: all 0.2s;
  font-size: 12px;
}

.copy-btn:hover {
  background: var(--surface);
  color: var(--text);
}

.copy-btn.copied {
  background: #10a37f;
  color: white;
}

.message-content .image-thumbnail {
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: 8px;
  margin: 8px 0;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.2s;
}

.message-content .image-thumbnail:hover {
  transform: scale(1.02);
  border-color: var(--text-muted);
}

.message.user .message-content {
  background: var(--surface);
  border: 1px solid var(--border);
}

.message.assistant .message-content {
  background: transparent;
}

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

.message-content li {
  margin: 6px 0;
  line-height: 1.6;
}

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

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

.image-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.image-modal.active {
  display: flex;
}

.image-modal img {
  max-width: 90%;
  max-height: 90%;
  border-radius: 12px;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
}

.image-modal-close {
  position: absolute;
  top: 20px;
  right: 30px;
  font-size: 40px;
  color: white;
  cursor: pointer;
  background: rgba(0, 0, 0, 0.5);
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.image-modal-close:hover {
  background: rgba(0, 0, 0, 0.8);
  transform: scale(1.1);
}

.input-area {
  padding: 16px 24px 80px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  transition: border-color 0.3s ease;
}

.input-wrapper {
  max-width: 800px;
  margin: 0 auto;
  position: relative;
}

.input-box {
  width: 100%;
  min-height: 56px;
  max-height: 200px;
  padding: 16px 56px 16px 16px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  resize: none;
  outline: none;
  overflow-y: auto;
  transition: all 0.3s ease;
  -webkit-user-select: text;
  user-select: text;
  touch-action: manipulation;
}

.input-box:focus {
  border-color: var(--text-muted);
}

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

.send-btn {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: none;
  background: var(--text);
  color: var(--bg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.send-btn:hover {
  transform: scale(1.05);
}

.send-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: scale(1);
}

.cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--text);
  animation: blink 1s infinite;
  vertical-align: middle;
}

@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

/* Export Controls with Auth Buttons */
.export-controls {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: row;
  gap: 8px;
  z-index: 500;
  background: transparent;
  border: none;
}

.export-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
  white-space: nowrap;
  text-decoration: none;
}

.export-btn:hover {
  background: var(--border);
  transform: translateY(-1px);
}

.export-btn:active {
  transform: translateY(0);
}

.export-btn.success {
  background: #10a37f;
  border-color: #10a37f;
  color: white;
}

.export-btn.processing {
  opacity: 0.6;
  cursor: wait;
}

.export-btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.export-btn span {
  display: inline;
}

.auth-btn {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.auth-btn:hover {
  background: var(--border);
  color: var(--text);
}

.signup-btn {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

.signup-btn:hover {
  background: var(--border);
  color: var(--text);
}

/* Safe color classes for AI responses */
.ai-info {
  background: #eff6ff;
  color: #1e40af;
  padding: 12px 16px;
  border-radius: 8px;
  border-left: 4px solid #3b82f6;
  margin: 12px 0;
}

.ai-warning {
  background: #fefce8;
  color: #854d0e;
  padding: 12px 16px;
  border-radius: 8px;
  border-left: 4px solid #eab308;
  margin: 12px 0;
}

.ai-success {
  background: #f0fdf4;
  color: #166534;
  padding: 12px 16px;
  border-radius: 8px;
  border-left: 4px solid #22c55e;
  margin: 12px 0;
}

.ai-error {
  background: #fef2f2;
  color: #991b1b;
  padding: 12px 16px;
  border-radius: 8px;
  border-left: 4px solid #ef4444;
  margin: 12px 0;
}

.ai-code {
  background: #1e293b;
  color: #e2e8f0;
  padding: 12px;
  border-radius: 8px;
  overflow-x: auto;
  font-family: 'Courier New', monospace;
  margin: 12px 0;
}

.ai-highlight {
  background: #fef3c7;
  color: #92400e;
  padding: 2px 6px;
  border-radius: 4px;
}

.ai-quote {
  border-left: 4px solid #9333ea;
  padding-left: 16px;
  margin: 12px 0;
  color: var(--text);
  font-style: italic;
}

/* Dark mode adjustments for color classes */
body[data-theme="day"] .ai-code {
  background: #1e293b;
  color: #e2e8f0;
}

body[data-theme="night"] .ai-info {
  background: #1e3a5f;
  color: #93c5fd;
  border-left-color: #60a5fa;
}

body[data-theme="night"] .ai-warning {
  background: #422006;
  color: #fde047;
  border-left-color: #facc15;
}

body[data-theme="night"] .ai-success {
  background: #14532d;
  color: #86efac;
  border-left-color: #4ade80;
}

body[data-theme="night"] .ai-error {
  background: #450a0a;
  color: #fca5a5;
  border-left-color: #f87171;
}

body[data-theme="night"] .ai-highlight {
  background: #422006;
  color: #fde047;
}

/* Fix bold text readability in AI responses */
.message-content strong {
  color: inherit;
  font-weight: 600;
}

/* Ensure bold text is dark in light-background elements */
.ai-info strong,
.ai-warning strong,
.ai-success strong,
.ai-error strong {
  color: inherit;
}

/* For night mode - ensure bold text works on light backgrounds */
body[data-theme="night"] .message-content strong {
  color: inherit;
}

/* MOBILE RESPONSIVE STYLES */
@media (max-width: 768px) {
  html {
    height: 100%;
    overflow: hidden;
  }
  
  body {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }
  
  @supports (-webkit-touch-callout: none) {
    body {
      height: -webkit-fill-available;
    }
  }
  
  .header {
    flex-direction: column;
    gap: 16px !important;
    align-items: stretch;
    padding: 10px 12px;
    overflow: visible;
    max-width: 100vw;
    box-sizing: border-box;
    position: relative;
    flex-shrink: 0;
  }
  
  .logo-section {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    padding-bottom: 8px;
    margin-bottom: 4px;
  }
  
  .menu-btn {
    position: absolute;
    left: 12px;
    top: 12px;
    width: 40px;
    height: 40px;
    border-radius: 8px;
  }
  
  .logo-section img {
    height: 22px;
  }
  
  .ai-selector {
    display: grid;
    grid-template-columns: 2fr 2fr 1fr 1fr;
    gap: 6px;
    row-gap: 10px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }
  
  .ai-btn {
    width: 100%;
    height: 40px;
    border-radius: 8px;
    padding: 0;
    grid-row: 1;
  }
  
  .ai-btn:nth-child(1) { grid-column: 1 / 2; }
  .ai-btn:nth-child(2) { grid-column: 2 / 3; }
  .ai-btn:nth-child(3) { grid-column: 3 / 5; }
  
  .ai-btn svg {
    width: 20px;
    height: 20px;
  }
  
  .model-select {
    grid-column: 1 / 3;
    grid-row: 2;
    padding: 8px 10px;
    font-size: 12px;
    height: 38px;
  }
  
  .theme-btn {
    grid-column: 3 / 4;
    grid-row: 2;
    width: 100%;
    height: 38px;
    border-radius: 8px;
  }
  
  .clear-btn {
    grid-column: 4 / 5;
    grid-row: 2;
    width: 100%;
    height: 38px;
    border-radius: 8px;
  }
  
  .manage-btn {
    display: none;
  }
  
  .clear-btn svg, .theme-btn svg {
    width: 16px;
    height: 16px;
  }
  
  .chat-container {
    padding: 12px 8px 8px;
    overflow-y: auto;
    overflow-x: hidden;
    max-width: 100vw;
    box-sizing: border-box;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: auto;
  }
  
  .welcome h1 {
    font-size: 20px;
    padding: 0 8px;
  }
  
  .welcome p {
    font-size: 13px;
    padding: 0 8px;
  }
  
  .message-content {
    max-width: 80%;
    font-size: 14px;
  }
  
  .avatar {
    width: 30px;
    height: 30px;
  }
  
  .avatar svg {
    width: 16px;
    height: 16px;
  }
  
  .input-area {
    padding: 8px 10px 76px;
    overflow: visible;
    max-width: 100vw;
    box-sizing: border-box;
    padding-bottom: max(76px, calc(env(safe-area-inset-bottom) + 76px));
    flex-shrink: 0;
    position: relative;
  }
  
  .input-box {
    font-size: 16px !important;
    padding: 12px 96px 12px 12px;
    min-height: 46px;
  }
  
  .input-box:focus {
    font-size: 16px !important;
  }
  
  .input-wrapper {
    max-width: 100%;
    box-sizing: border-box;
  }
  
  .send-btn {
    width: 36px;
    height: 36px;
    right: 6px;
    bottom: 6px;
  }
  
  .file-btn, .stop-btn {
    width: 36px;
    height: 36px;
    right: 46px;
    bottom: 6px;
  }
  
  .file-preview {
    font-size: 12px;
  }
  
  .file-preview img {
    width: 50px;
    height: 50px;
  }
  
  /* Mobile Export Controls */
  .export-controls {
    bottom: 14px;
    left: 50%;
    transform: translateX(-50%);
    flex-direction: row;
    gap: 6px;
  }
  
  .export-btn span {
    display: none;
  }
  
  .export-btn {
    width: 44px;
    height: 44px;
    padding: 10px;
    justify-content: center;
  }
  
  .export-btn svg {
    width: 20px;
    height: 20px;
  }
}

/* Extra small screens */
@media (max-width: 480px) {
  .header {
    padding: 8px 10px;
    gap: 14px !important;
  }
  
  .logo-section {
    padding-bottom: 8px;
    margin-bottom: 4px;
  }
  
  .menu-btn {
    left: 10px;
    top: 10px;
    width: 38px;
    height: 38px;
  }
  
  .logo-section img {
    height: 20px;
  }
  
  .ai-selector {
    grid-template-columns: 2fr 2fr 1fr 1fr;
    gap: 5px;
    row-gap: 8px;
  }
  
  .ai-btn {
    height: 38px;
  }
  
  .ai-btn svg {
    width: 18px;
    height: 18px;
  }
  
  .model-select, #personalitySelect {
    font-size: 11px;
    height: 36px;
    padding: 6px 8px;
  }
  
  .model-select {
    grid-column: 1 / 3;
  }
  
  .theme-btn, .clear-btn {
    height: 36px;
  }
  
  .welcome h1 {
    font-size: 18px;
  }
  
  .message-content {
    max-width: 88%;
    font-size: 13px;
    padding: 8px 10px;
  }
  
  .chat-container {
    padding: 10px 8px;
  }
  
  .input-area {
    padding: 8px 8px 68px;
    padding-bottom: max(68px, calc(env(safe-area-inset-bottom) + 68px));
  }
  
  .input-box {
    padding: 10px 88px 10px 10px;
    min-height: 42px;
    font-size: 16px !important;
  }
  
  .send-btn {
    width: 34px;
    height: 34px;
    right: 5px;
    bottom: 5px;
  }
  
  .file-btn, .stop-btn {
    width: 34px;
    height: 34px;
    right: 42px;
    bottom: 5px;
  }
  
  .export-controls {
    bottom: 12px;
    gap: 4px;
  }
  
  .export-btn {
    width: 40px;
    height: 40px;
    padding: 8px;
  }
  
  .export-btn svg {
    width: 18px;
    height: 18px;
  }
}

/* Landscape mode */
@media (max-width: 768px) and (orientation: landscape) {
  .header {
    flex-direction: row;
    flex-wrap: wrap;
  }
  
  .logo-section {
    order: 1;
    flex: 0 0 auto;
  }
  
  .menu-btn {
    position: relative;
    left: auto;
    top: auto;
  }
  
  .ai-selector {
    order: 2;
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }
  
  .ai-btn {
    width: 40px;
    flex: 0 0 auto;
  }
  
  .model-select {
    flex: 1;
    min-width: 120px;
  }
  
  .clear-btn, .theme-btn {
    width: 40px;
    flex: 0 0 auto;
  }
	


/* Auth Modal Styles */
.auth-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 10000;
  backdrop-filter: blur(4px);
}

.auth-modal-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg);
  border-radius: 16px;
  padding: 40px;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.auth-modal h2 {
  text-align: center;
  margin-bottom: 30px;
  color: var(--text);
  font-size: 24px;
  font-weight: 600;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: var(--text);
  font-size: 14px;
}

.form-group input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.3s;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
}

.form-group input:focus {
  outline: none;
  border-color: #1b6ac9;
}

.form-group input.error {
  border-color: #dc2626;
}

.error-message {
  color: #dc2626;
  font-size: 12px;
  margin-top: 4px;
  display: none;
}

.auth-modal .btn {
  width: 100%;
  margin-bottom: 15px;
  padding: 14px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.3s;
  font-family: inherit;
}

.auth-modal .btn-primary {
  background: #1b6ac9;
  color: white;
}

.auth-modal .btn-primary:hover {
  background: #1557b3;
  transform: translateY(-1px);
}

.modal-toggle {
  text-align: center;
  margin-top: 20px;
}

.modal-toggle a {
  color: #1b6ac9;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
}

.modal-toggle a:hover {
  text-decoration: underline;
}

.close-auth-modal {
  position: absolute;
  top: 15px;
  right: 20px;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.2s;
}

.close-auth-modal:hover {
  background: var(--border);
  color: var(--text);
}

.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 20px;
  font-weight: 500;
  font-size: 14px;
}

.alert-error {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
}

body[data-theme="night"] .alert-error {
  background: rgba(220, 38, 38, 0.1);
  border-color: rgba(220, 38, 38, 0.3);
}

.alert-success {
  background: #f0fdf4;
  color: #16a34a;
  border: 1px solid #bbf7d0;
}

body[data-theme="night"] .alert-success {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.3);
}

/* Mobile responsive for auth modals */
@media (max-width: 768px) {
  .auth-modal-content {
    padding: 30px 20px;
    max-width: 90%;
  }

  .auth-modal h2 {
    font-size: 20px;
    margin-bottom: 24px;
  }

  .form-group {
    margin-bottom: 16px;
  }

  .auth-modal .btn {
    padding: 12px;
  }
}

@media (max-width: 480px) {
  .auth-modal-content {
    padding: 24px 16px;
  }

  .auth-modal h2 {
    font-size: 18px;
  }
}	
	
}