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

/* Theme variables - Set dynamically by themes.js */
/* Default fallback values (Light Mode) */
:root {
  --primary-color: #ff8c42;
  --primary-hover: #ff7a29;
  --secondary-color: #6b7280;
  --accent-color: #ffa366;
  --accent-hover: #ff8c42;
  --background: #f5f6f8;
  --surface: #ffffff;
  --surface-hover: #f0f1f3;
  --border: #e1e4e8;
  --text-primary: #1f2937;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --error: #ef4444;
  --success: #10b981;
  --warning: #ffa366;
  --info: #3b82f6;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.1);

  /* Status color variants for backgrounds and text */
  --primary-bg: rgba(255, 140, 66, 0.1);
  --primary-text: #ff8c42;
  --danger-bg: rgba(239, 68, 68, 0.1);
  --danger-text: #ef4444;
  --warning-bg: rgba(255, 163, 102, 0.1);
  --warning-text: #ffa366;
  --success-bg: rgba(16, 185, 129, 0.1);
  --success-text: #10b981;
  --info-bg: rgba(59, 130, 246, 0.1);
  --info-text: #3b82f6;
  --sidebar-bg: #2d3748;
  --sidebar-surface: #374151;
  --sidebar-border: rgba(255, 255, 255, 0.1);
  --sidebar-text: #f9fafb;
  --sidebar-text-secondary: rgba(249, 250, 251, 0.75);
  --code-bg: #f0f1f3;
  --code-text: #ff8c42;
  --code-block-bg: #1e1e1e;
  --code-block-text: #d4d4d4;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', sans-serif;
  background: var(--background);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
}

/* Top Navigation */
.top-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: var(--background);
  border-bottom: 1px solid var(--border);
  z-index: 1000;
}

.nav-container {
  width: 100%;
  height: 100%;
  padding: 0 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-sizing: border-box;
}

.logo {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
}

.logo svg {
  color: var(--primary-color);
}

.chat-icon-btn {
  margin-left: 4px;
  opacity: 0.8;
}

.chat-icon-btn:hover {
  opacity: 1;
  background: var(--surface-hover);
}

.nav-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

/* Buttons */
.btn-primary {
  background: var(--primary-color);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-primary-large {
  background: var(--primary-color);
  color: white;
  border: none;
  padding: 14px 32px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 24px;
}

.btn-primary-large:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.2s;
}

.btn-google:hover {
  background: var(--surface-hover);
  box-shadow: var(--shadow);
}

.btn-block {
  width: 100%;
}

.icon-btn {
  background: transparent;
  border: none;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover:not(:disabled) {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.icon-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Delete Button - Red styling for delete icons only */
.icon-btn.delete-btn,
.btn-icon.delete-btn {
  color: var(--error);
}

.icon-btn.delete-btn:hover,
.btn-icon.delete-btn:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--error);
  color: var(--error);
}

/* Danger button - Professional styling with theme inheritance */
.btn-danger {
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--error);
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--error);
  color: var(--error);
}

.btn-danger svg {
  color: var(--error);
}

/* Specific delete/trash button styling in tables and lists */
button.permanent-delete-btn,
button[id*="emptyTrash"] {
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

button.permanent-delete-btn:hover,
button[id*="emptyTrash"]:hover {
  background: rgba(239, 68, 68, 0.05);
  border-color: var(--error);
}

button.permanent-delete-btn svg,
button[id*="emptyTrash"] svg {
  color: var(--error);
  width: 14px;
  height: 14px;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-secondary:hover {
  background: var(--surface-hover);
}

/* Theme Toggle Button */
.theme-toggle {
  background: transparent;
  border: none;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-primary);
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
}

.theme-toggle:hover {
  background: var(--surface-hover);
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  align-items: center;
  justify-content: center;
  z-index: 2000;
  animation: fadeIn 0.2s;
}

.modal.show {
  display: flex;
}

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

.modal-content {
  background: var(--surface);
  border-radius: 16px;
  width: 90%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s;
  color: var(--text-primary);
}

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

.modal-header {
  padding: 24px 24px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 24px;
  font-weight: 600;
}

.close-btn {
  background: none;
  border: none;
  font-size: 32px;
  color: var(--text-secondary);
  cursor: pointer;
  line-height: 1;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: all 0.2s;
}

.close-btn:hover {
  background: var(--surface-hover);
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 16px 24px 24px;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* Delete Modal - More square and professional */
.delete-modal {
  max-width: 480px;
  width: 480px;
  border-radius: 12px;
}

.delete-modal .modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}

.delete-modal .modal-header h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
}

.delete-modal .modal-body {
  padding: 20px 24px;
}

.delete-modal .modal-footer {
  padding: 16px 24px 20px;
  border-top: 1px solid var(--border);
  background: var(--background);
}

/* Forms */
.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.form-group input {
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  transition: all 0.2s;
  font-family: inherit;
  background: var(--surface);
  color: var(--text-primary);
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(255, 140, 66, 0.15);
}

.divider {
  display: flex;
  align-items: center;
  margin: 20px 0;
  color: var(--text-secondary);
  font-size: 14px;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.divider span {
  padding: 0 16px;
}

/* Alerts */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
}

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

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

/* Landing Page Specific */
.landing-page .app-container {
  margin-top: 60px;
  height: calc(100vh - 60px);
}

.landing .sidebar {
  opacity: 0.6;
  pointer-events: none;
}

.landing .input-area.disabled {
  opacity: 0.6;
}

.landing-prompt {
  padding: 20px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
}

.conversation-item-sample {
  padding: 12px 16px;
  margin: 8px 12px;
  border-radius: 8px;
  background: var(--surface);
  opacity: 0.7;
}

.conversation-item-sample .conversation-title {
  font-weight: 500;
  color: var(--text-primary);
  font-size: 14px;
  margin-bottom: 4px;
}

.conversation-item-sample .conversation-date {
  font-size: 12px;
  color: var(--text-secondary);
}

/* Welcome Screen */
.welcome-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  padding: 40px 20px;
}

.welcome-icon {
  width: 80px;
  height: 80px;
  background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
  box-shadow: var(--shadow-lg);
}

.welcome-icon svg {
  color: white;
}

.welcome-screen h1 {
  font-size: 32px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.welcome-screen p {
  font-size: 18px;
  color: var(--text-secondary);
  max-width: 500px;
  margin-bottom: 32px;
}

/* Chat Preview Animation */
.chat-preview {
  width: 100%;
  max-width: 500px;
  margin: 32px 0;
  padding: 20px;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.preview-message {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  align-items: flex-start;
}

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

.preview-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.user-preview .preview-avatar {
  background: var(--primary-color);
}

.ai-preview .preview-avatar {
  background: var(--accent-color);
}

.preview-bubble {
  background: white;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
  color: var(--text-primary);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  max-width: 80%;
}

.user-preview .preview-bubble {
  background: var(--primary-color);
  color: white;
}

.ai-preview .preview-bubble {
  background: white;
  border: 1px solid var(--border);
}

/* Animations */
@keyframes bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

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

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes pulseSlow {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.02);
  }
}

.animate-bounce {
  animation: bounce 2s ease-in-out infinite;
}

.animate-fade-in {
  animation: fadeIn 0.8s ease-out;
}

.animate-fade-in-delay {
  animation: fadeIn 0.8s ease-out 0.2s both;
}

.animate-slide-in-left {
  animation: slideInLeft 0.6s ease-out 0.4s both;
}

.animate-slide-in-right {
  animation: slideInRight 0.6s ease-out 0.7s both;
}

.animate-pulse-slow {
  animation: pulseSlow 2s ease-in-out infinite;
}

.input-hint {
  text-align: center;
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 12px;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .nav-container {
    padding: 0 16px;
  }

  .logo span {
    display: none;
  }

  .modal-content {
    width: 95%;
    margin: 20px;
  }

  .welcome-screen h1 {
    font-size: 24px;
  }

  .welcome-screen p {
    font-size: 16px;
  }
}

/* Futuristic AI Robot Icon Animations */
.ai-robot-icon {
  filter: drop-shadow(0 0 20px rgba(255, 140, 66, 0.3));
}

@keyframes pulseRing {
  0%, 100% {
    opacity: 0.3;
    transform: scale(1);
  }
  50% {
    opacity: 0.6;
    transform: scale(1.05);
  }
}

@keyframes antennaPulse {
  0%, 100% {
    opacity: 0.8;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.3);
    filter: brightness(1.5);
  }
}

@keyframes eyeGlow {
  0%, 100% {
    opacity: 0.8;
  }
  50% {
    opacity: 1;
    filter: brightness(1.2);
  }
}

@keyframes blinkBar {
  0%, 90%, 100% {
    opacity: 0.7;
  }
  45% {
    opacity: 0.3;
  }
}

@keyframes sensorBlink {
  0%, 100% {
    opacity: 0.6;
  }
  50% {
    opacity: 1;
    transform: scale(1.2);
  }
}

@keyframes scanLine {
  0% {
    stroke-dasharray: 0, 200;
    stroke-dashoffset: 0;
  }
  50% {
    stroke-dasharray: 100, 200;
    stroke-dashoffset: -50;
  }
  100% {
    stroke-dasharray: 0, 200;
    stroke-dashoffset: -100;
  }
}

@keyframes particleFloat {
  0% {
    transform: translateY(0) translateX(0);
    opacity: 0;
  }
  10% {
    opacity: 0.8;
  }
  90% {
    opacity: 0.8;
  }
  100% {
    transform: translateY(-30px) translateX(5px);
    opacity: 0;
  }
}

.pulse-ring {
  animation: pulseRing 3s ease-in-out infinite;
}

.antenna-pulse {
  animation: antennaPulse 2s ease-in-out infinite;
}

.eye-glow-left,
.eye-glow-right {
  animation: eyeGlow 3s ease-in-out infinite;
}

.blink-bar {
  animation: blinkBar 1.5s ease-in-out infinite;
}

.sensor-blink {
  animation: sensorBlink 2s ease-in-out infinite;
}

.scan-line {
  stroke-dasharray: 200;
  animation: scanLine 4s linear infinite;
}

.particle-float {
  animation: particleFloat 3s ease-in-out infinite;
}

/* =================================================================
   Theme Modal
   ================================================================= */

.theme-modal .modal-content {
  max-width: 900px;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.theme-modal .modal-body {
  overflow-y: auto;
  padding: 24px;
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
  padding: 4px;
}

.theme-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.theme-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  border-color: var(--primary-color);
}

.theme-card.active {
  border-color: var(--primary-color);
  background: var(--surface-hover);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.theme-card.active::before {
  content: '✓';
  position: absolute;
  top: 12px;
  right: 12px;
  width: 24px;
  height: 24px;
  background: var(--primary-color);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 14px;
  z-index: 1;
}

.theme-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.theme-card-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.theme-card-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.theme-card-badge.light {
  background: rgba(251, 191, 36, 0.15);
  color: #f59e0b;
}

.theme-card-badge.dark {
  background: rgba(99, 102, 241, 0.15);
  color: #6366f1;
}

.theme-card-badge.custom {
  background: rgba(168, 85, 247, 0.15);
  color: #a855f7;
}

.theme-card-description {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 16px;
  line-height: 1.5;
  min-height: 40px;
}

/* Custom Theme Controls */
.custom-theme-controls {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.custom-color-picker {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.custom-color-picker label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.custom-color-picker input[type="color"] {
  width: 100%;
  height: 50px;
  border: 2px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  background: transparent;
  transition: all 0.2s ease;
}

.custom-color-picker input[type="color"]:hover {
  border-color: var(--primary-color);
  transform: scale(1.02);
}

.custom-color-picker input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.custom-color-picker input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 6px;
}

.custom-color-picker input[type="color"]::-moz-color-swatch {
  border: none;
  border-radius: 6px;
}

.apply-custom-theme {
  width: 100%;
  margin-top: 4px;
  padding: 12px;
  font-size: 14px;
  font-weight: 600;
}

.theme-card-preview {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.theme-color-swatch {
  height: 50px;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  position: relative;
  overflow: hidden;
}

.theme-color-swatch::after {
  content: attr(data-label);
  position: absolute;
  bottom: 2px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 9px;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  font-weight: 500;
  letter-spacing: 0.3px;
}

.theme-card-colors {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  font-size: 11px;
  padding: 12px;
  background: var(--background);
  border-radius: 8px;
}

.theme-color-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.theme-color-dot {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
}

.theme-color-label {
  font-size: 10px;
  color: var(--text-secondary);
  flex: 1;
}

@media (max-width: 768px) {
  .theme-grid {
    grid-template-columns: 1fr;
  }

  .theme-modal .modal-content {
    max-width: 95vw;
    max-height: 90vh;
  }
}
