/* NEXUS-ON Mobile-First Responsive Design */

/* ============================================
   1. BASE MOBILE STYLES
   ============================================ */

/* Mobile viewport optimization */
@viewport {
  width: device-width;
  zoom: 1.0;
}

html {
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  overscroll-behavior-y: none; /* Prevent pull-to-refresh on mobile */
  -webkit-tap-highlight-color: transparent; /* Remove tap highlight */
  touch-action: manipulation; /* Improve touch responsiveness */
}

/* ============================================
   2. NAVIGATION - Mobile First
   ============================================ */

nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  background: rgba(17, 24, 39, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding: 12px 16px;
  transition: transform 0.3s ease-out;
}

nav.nav-hidden {
  transform: translateY(-100%);
}

/* Mobile hamburger menu */
.nav-menu-button {
  display: block;
  width: 40px;
  height: 40px;
  padding: 8px;
  background: transparent;
  border: none;
  cursor: pointer;
  position: relative;
  z-index: 10000;
}

.nav-menu-button span {
  display: block;
  width: 24px;
  height: 2px;
  background: white;
  margin: 5px 0;
  transition: all 0.3s ease;
  border-radius: 2px;
}

.nav-menu-button.active span:nth-child(1) {
  transform: rotate(45deg) translate(6px, 6px);
}

.nav-menu-button.active span:nth-child(2) {
  opacity: 0;
}

.nav-menu-button.active span:nth-child(3) {
  transform: rotate(-45deg) translate(6px, -6px);
}

/* Mobile nav menu */
.nav-menu {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
  overflow-y: auto;
  padding: 80px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-menu.active {
  transform: translateX(0);
}

.nav-menu a {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  color: white;
  text-decoration: none;
  font-size: 18px;
  font-weight: 500;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.nav-menu a:active {
  transform: scale(0.98);
  background: rgba(255, 255, 255, 0.1);
}

/* Desktop nav - hide hamburger */
@media (min-width: 1024px) {
  .nav-menu-button {
    display: none;
  }
  
  .nav-menu {
    position: static;
    width: auto;
    height: auto;
    background: transparent;
    transform: translateX(0);
    padding: 0;
    flex-direction: row;
    gap: 8px;
    overflow-y: visible;
  }
  
  .nav-menu a {
    padding: 8px 16px;
    font-size: 14px;
    background: rgba(255, 255, 255, 0.03);
  }
  
  .nav-menu a:hover {
    background: rgba(255, 255, 255, 0.1);
  }
}

/* ============================================
   3. HERO SECTION - Mobile Optimized
   ============================================ */

.hero {
  min-height: 100vh;
  min-height: 100dvh; /* Dynamic viewport height for mobile */
  padding: 80px 16px 120px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.hero h1 {
  font-size: 32px;
  line-height: 1.2;
  margin-bottom: 16px;
  padding: 0 8px;
}

.hero .subtitle {
  font-size: 18px;
  line-height: 1.5;
  margin-bottom: 12px;
  padding: 0 16px;
}

.hero .tagline {
  font-size: 14px;
  margin-bottom: 32px;
  padding: 0 20px;
}

@media (min-width: 640px) {
  .hero h1 {
    font-size: 48px;
  }
  
  .hero .subtitle {
    font-size: 22px;
  }
  
  .hero .tagline {
    font-size: 16px;
  }
}

@media (min-width: 1024px) {
  .hero {
    padding: 120px 24px 120px;
  }
  
  .hero h1 {
    font-size: 64px;
  }
  
  .hero .subtitle {
    font-size: 28px;
  }
  
  .hero .tagline {
    font-size: 18px;
  }
}

/* ============================================
   4. AI CHAT INPUT - Mobile First
   ============================================ */

.chat-input-container {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding: 0 16px;
}

.chat-input-wrapper {
  position: relative;
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.chat-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.chat-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 14px 16px;
  color: white;
  font-size: 16px; /* Prevent zoom on iOS */
  font-family: inherit;
  outline: none;
  transition: all 0.2s ease;
  -webkit-appearance: none;
}

.chat-input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.chat-input:focus {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(59, 130, 246, 0.5);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* Chat control buttons */
.chat-controls {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.chat-btn {
  width: 44px;
  height: 44px;
  min-width: 44px; /* iOS minimum tap target */
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.chat-btn:active {
  transform: scale(0.95);
  background: rgba(255, 255, 255, 0.15);
}

.chat-btn-primary {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  border: none;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.chat-btn-primary:active {
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
}

.chat-btn.recording {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  animation: recording-pulse 1.5s ease-in-out infinite;
}

@keyframes recording-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
  50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

/* File input styling */
.chat-file-label {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.chat-file-label:active {
  transform: scale(0.95);
  background: rgba(255, 255, 255, 0.15);
}

.chat-file-input {
  display: none;
}

@media (min-width: 640px) {
  .chat-input-wrapper {
    padding: 16px;
    gap: 12px;
  }
  
  .chat-btn {
    width: 48px;
    height: 48px;
    min-width: 48px;
  }
  
  .chat-file-label {
    width: 48px;
    height: 48px;
    min-width: 48px;
  }
}

/* ============================================
   5. CHAT MESSAGES - Mobile Optimized
   ============================================ */

.chat-messages {
  width: 100%;
  max-width: 700px;
  margin: 0 auto 20px;
  padding: 0 16px;
  max-height: 50vh;
  max-height: 50dvh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

.chat-message {
  padding: 12px 16px;
  border-radius: 16px;
  max-width: 85%;
  word-wrap: break-word;
  animation: messageSlideIn 0.3s ease-out;
}

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

.chat-message-user {
  align-self: flex-end;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: white;
  border-bottom-right-radius: 4px;
}

.chat-message-bot {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: white;
  border-bottom-left-radius: 4px;
}

.chat-message-loading {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 12px 16px;
}

.chat-message-loading span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  animation: loadingDot 1.4s ease-in-out infinite;
}

.chat-message-loading span:nth-child(2) {
  animation-delay: 0.2s;
}

.chat-message-loading span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes loadingDot {
  0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
  40% { transform: scale(1.2); opacity: 1; }
}

@media (min-width: 640px) {
  .chat-message {
    padding: 14px 18px;
    max-width: 75%;
  }
}

@media (min-width: 1024px) {
  .chat-message {
    max-width: 65%;
  }
}

/* ============================================
   6. FEATURE CARDS - Mobile Grid
   ============================================ */

.features-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  padding: 0 16px;
  max-width: 1200px;
  margin: 0 auto;
}

@media (min-width: 640px) {
  .features-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    padding: 0 24px;
  }
}

@media (min-width: 1024px) {
  .features-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    padding: 0 32px;
  }
}

.feature-card {
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 24px 20px;
  transition: all 0.3s ease;
}

.feature-card:active {
  transform: scale(0.98);
  background: rgba(255, 255, 255, 0.05);
}

@media (min-width: 1024px) {
  .feature-card:hover {
    transform: translateY(-4px);
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(59, 130, 246, 0.3);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
  }
}

.feature-card h3 {
  font-size: 20px;
  margin-bottom: 12px;
  line-height: 1.3;
}

.feature-card p {
  font-size: 14px;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.7);
}

@media (min-width: 640px) {
  .feature-card h3 {
    font-size: 22px;
  }
  
  .feature-card p {
    font-size: 15px;
  }
}

/* ============================================
   7. BUTTONS - Touch-Optimized
   ============================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px; /* iOS minimum tap target */
  padding: 12px 24px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-primary:active {
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-secondary:active {
  background: rgba(255, 255, 255, 0.12);
}

@media (min-width: 640px) {
  .btn {
    padding: 14px 28px;
    font-size: 17px;
  }
}

/* ============================================
   8. TABLES - Mobile Scroll
   ============================================ */

.table-container {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 20px 0;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

table {
  width: 100%;
  min-width: 600px; /* Prevent over-compression */
  border-collapse: collapse;
}

th, td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

th {
  background: rgba(255, 255, 255, 0.05);
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
}

td {
  font-size: 14px;
}

@media (min-width: 768px) {
  th, td {
    padding: 14px 20px;
  }
  
  th {
    font-size: 15px;
  }
  
  td {
    font-size: 15px;
  }
}

/* ============================================
   9. DASHBOARD - Mobile Stack
   ============================================ */

.dashboard-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  padding: 80px 16px 24px;
}

@media (min-width: 768px) {
  .dashboard-container {
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    padding: 100px 24px 32px;
  }
}

@media (min-width: 1280px) {
  .dashboard-container {
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    padding: 120px 32px 40px;
  }
}

.dashboard-card {
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 20px;
}

@media (min-width: 640px) {
  .dashboard-card {
    padding: 24px;
  }
}

/* ============================================
   10. FOOTER - Mobile Optimized
   ============================================ */

footer {
  padding: 40px 16px 24px;
  text-align: center;
  background: rgba(0, 0, 0, 0.3);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

footer p {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.6);
  line-height: 1.6;
}

footer a {
  color: #3b82f6;
  text-decoration: none;
  transition: color 0.2s ease;
}

footer a:active {
  color: #60a5fa;
}

@media (min-width: 768px) {
  footer {
    padding: 60px 24px 32px;
  }
  
  footer p {
    font-size: 14px;
  }
  
  footer a:hover {
    color: #60a5fa;
  }
}

/* ============================================
   11. UTILITY CLASSES
   ============================================ */

/* Spacing */
.px-mobile {
  padding-left: 16px;
  padding-right: 16px;
}

.py-mobile {
  padding-top: 16px;
  padding-bottom: 16px;
}

.mb-mobile {
  margin-bottom: 16px;
}

.mt-mobile {
  margin-top: 16px;
}

@media (min-width: 768px) {
  .px-mobile {
    padding-left: 24px;
    padding-right: 24px;
  }
  
  .py-mobile {
    padding-top: 24px;
    padding-bottom: 24px;
  }
  
  .mb-mobile {
    margin-bottom: 24px;
  }
  
  .mt-mobile {
    margin-top: 24px;
  }
}

/* Hide on mobile */
.hide-mobile {
  display: none;
}

@media (min-width: 768px) {
  .hide-mobile {
    display: block;
  }
}

/* Hide on desktop */
.hide-desktop {
  display: block;
}

@media (min-width: 768px) {
  .hide-desktop {
    display: none;
  }
}

/* Safe area insets for notched devices */
.safe-top {
  padding-top: env(safe-area-inset-top);
}

.safe-bottom {
  padding-bottom: env(safe-area-inset-bottom);
}

.safe-left {
  padding-left: env(safe-area-inset-left);
}

.safe-right {
  padding-right: env(safe-area-inset-right);
}

/* ============================================
   12. ACCESSIBILITY - Touch & Focus
   ============================================ */

/* Focus visible for keyboard navigation */
:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

/* Larger tap targets for better accessibility */
@media (pointer: coarse) {
  button,
  a,
  input,
  select,
  textarea {
    min-height: 44px;
    min-width: 44px;
  }
}

/* Prevent text selection on buttons */
button,
.btn,
.chat-btn {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* ============================================
   13. PERFORMANCE OPTIMIZATIONS
   ============================================ */

/* GPU acceleration for animations */
.animated {
  will-change: transform, opacity;
  transform: translateZ(0);
}

/* Smooth scrolling */
html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
