/**
 * Enhanced Mobile-First CSS Framework for Mama Fua
 * Optimized for touch interactions and mobile UX
 */

/* ==========================================================================
   Mobile-First Base Styles
   ========================================================================== */

:root {
  /* Mobile-optimized spacing */
  --mobile-padding: 16px;
  --mobile-margin: 12px;
  --mobile-border-radius: 12px;
  --mobile-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  
  /* Touch-friendly sizes */
  --touch-target-min: 44px;
  --mobile-font-size: 16px;
  --mobile-line-height: 1.5;
  
  /* Mobile colors */
  --mobile-primary: #667eea;
  --mobile-secondary: #764ba2;
  --mobile-accent: #ff6b6b;
  --mobile-success: #4ade80;
  --mobile-warning: #fbbf24;
  --mobile-error: #ef4444;
  
  /* Mobile gradients */
  --mobile-gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --mobile-gradient-accent: linear-gradient(135deg, #ff6b6b 0%, #ff8e8e 100%);
  --mobile-gradient-success: linear-gradient(135deg, #4ade80 0%, #22d3ee 100%);
}

/* Mobile viewport optimization */
html {
  font-size: var(--mobile-font-size);
  line-height: var(--mobile-line-height);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ==========================================================================
   Mobile Typography
   ========================================================================== */

@media (max-width: 768px) {
  h1 { font-size: 2rem; line-height: 1.2; margin-bottom: 1rem; }
  h2 { font-size: 1.75rem; line-height: 1.3; margin-bottom: 0.875rem; }
  h3 { font-size: 1.5rem; line-height: 1.3; margin-bottom: 0.75rem; }
  h4 { font-size: 1.25rem; line-height: 1.4; margin-bottom: 0.625rem; }
  h5 { font-size: 1.125rem; line-height: 1.4; margin-bottom: 0.5rem; }
  h6 { font-size: 1rem; line-height: 1.4; margin-bottom: 0.5rem; }
  
  p { font-size: 1rem; line-height: 1.6; margin-bottom: 1rem; }
  .lead { font-size: 1.125rem; line-height: 1.5; }
  small, .small { font-size: 0.875rem; }
}

/* ==========================================================================
   Enhanced Mobile Navigation
   ========================================================================== */

.mobile-nav-enhanced {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1050;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
}

.mobile-nav-enhanced.scrolled {
  background: rgba(255, 255, 255, 0.98);
  box-shadow: var(--mobile-shadow);
}

.mobile-nav-brand {
  display: flex;
  align-items: center;
  padding: 12px var(--mobile-padding);
}

.mobile-nav-brand img {
  height: 32px;
  width: auto;
  margin-right: 8px;
}

.mobile-nav-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--mobile-primary);
  margin: 0;
}

/* Mobile hamburger menu */
.mobile-hamburger {
  position: relative;
  width: var(--touch-target-min);
  height: var(--touch-target-min);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mobile-hamburger-lines {
  width: 24px;
  height: 18px;
  position: relative;
  transform: rotate(0deg);
  transition: 0.3s ease-in-out;
}

.mobile-hamburger-lines span {
  display: block;
  position: absolute;
  height: 3px;
  width: 100%;
  background: var(--mobile-primary);
  border-radius: 3px;
  opacity: 1;
  left: 0;
  transform: rotate(0deg);
  transition: 0.3s ease-in-out;
}

.mobile-hamburger-lines span:nth-child(1) { top: 0px; }
.mobile-hamburger-lines span:nth-child(2) { top: 7px; }
.mobile-hamburger-lines span:nth-child(3) { top: 14px; }

.mobile-hamburger.active .mobile-hamburger-lines span:nth-child(1) {
  top: 7px;
  transform: rotate(135deg);
}

.mobile-hamburger.active .mobile-hamburger-lines span:nth-child(2) {
  opacity: 0;
  left: -60px;
}

.mobile-hamburger.active .mobile-hamburger-lines span:nth-child(3) {
  top: 7px;
  transform: rotate(-135deg);
}

/* Mobile menu overlay */
.mobile-menu-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1040;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.mobile-menu-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* Mobile slide-out menu */
.mobile-menu-drawer {
  position: fixed;
  top: 0;
  right: -100%;
  width: 280px;
  height: 100vh;
  background: white;
  z-index: 1050;
  transition: right 0.3s ease;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.1);
  overflow-y: auto;
}

.mobile-menu-drawer.active {
  right: 0;
}

.mobile-menu-header {
  padding: var(--mobile-padding);
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mobile-menu-close {
  width: var(--touch-target-min);
  height: var(--touch-target-min);
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--mobile-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mobile-menu-nav {
  padding: var(--mobile-padding) 0;
}

.mobile-menu-item {
  display: block;
  padding: 16px var(--mobile-padding);
  color: #333;
  text-decoration: none;
  font-weight: 500;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;
  position: relative;
}

.mobile-menu-item:hover,
.mobile-menu-item:focus {
  background: rgba(102, 126, 234, 0.05);
  color: var(--mobile-primary);
  text-decoration: none;
}

.mobile-menu-item i {
  margin-right: 12px;
  width: 20px;
  text-align: center;
}

/* ==========================================================================
   Enhanced Mobile Buttons
   ========================================================================== */

.btn-mobile {
  min-height: var(--touch-target-min);
  padding: 12px 24px;
  border-radius: var(--mobile-border-radius);
  font-weight: 600;
  font-size: 1rem;
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  user-select: none;
  -webkit-user-select: none;
}

.btn-mobile:before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.3s ease, height 0.3s ease;
}

.btn-mobile:active:before {
  width: 300px;
  height: 300px;
}

.btn-mobile-primary {
  background: var(--mobile-gradient-primary);
  color: white;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-mobile-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
  color: white;
}

.btn-mobile-accent {
  background: var(--mobile-gradient-accent);
  color: white;
  box-shadow: 0 4px 15px rgba(255, 107, 107, 0.4);
}

.btn-mobile-accent:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255, 107, 107, 0.6);
  color: white;
}

.btn-mobile-outline {
  background: transparent;
  color: var(--mobile-primary);
  border: 2px solid var(--mobile-primary);
}

.btn-mobile-outline:hover {
  background: var(--mobile-primary);
  color: white;
}

.btn-mobile-ghost {
  background: rgba(102, 126, 234, 0.1);
  color: var(--mobile-primary);
  border: 1px solid rgba(102, 126, 234, 0.2);
}

.btn-mobile-ghost:hover {
  background: rgba(102, 126, 234, 0.2);
  color: var(--mobile-primary);
}

/* Mobile button sizes */
.btn-mobile-sm {
  min-height: 36px;
  padding: 8px 16px;
  font-size: 0.875rem;
}

.btn-mobile-lg {
  min-height: 52px;
  padding: 16px 32px;
  font-size: 1.125rem;
}

.btn-mobile-block {
  width: 100%;
  margin-bottom: var(--mobile-margin);
}

/* ==========================================================================
   Mobile Cards and Content
   ========================================================================== */

.mobile-card {
  background: white;
  border-radius: var(--mobile-border-radius);
  box-shadow: var(--mobile-shadow);
  margin-bottom: var(--mobile-margin);
  overflow: hidden;
  transition: all 0.3s ease;
}

.mobile-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.mobile-card-header {
  padding: var(--mobile-padding);
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  background: rgba(102, 126, 234, 0.02);
}

.mobile-card-body {
  padding: var(--mobile-padding);
}

.mobile-card-footer {
  padding: var(--mobile-padding);
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  background: rgba(0, 0, 0, 0.02);
}

/* ==========================================================================
   Mobile Forms
   ========================================================================== */

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

.mobile-form-label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: #333;
  font-size: 0.9rem;
}

.mobile-form-control {
  width: 100%;
  min-height: var(--touch-target-min);
  padding: 12px 16px;
  border: 2px solid #e5e7eb;
  border-radius: var(--mobile-border-radius);
  font-size: 1rem;
  transition: all 0.3s ease;
  background: white;
}

.mobile-form-control:focus {
  outline: none;
  border-color: var(--mobile-primary);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.mobile-form-control.error {
  border-color: var(--mobile-error);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.mobile-form-control.success {
  border-color: var(--mobile-success);
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.1);
}

.mobile-form-error {
  color: var(--mobile-error);
  font-size: 0.875rem;
  margin-top: 4px;
  display: flex;
  align-items: center;
}

.mobile-form-error i {
  margin-right: 4px;
}

/* Mobile select styling */
.mobile-select-wrapper {
  position: relative;
}

.mobile-select-wrapper:after {
  content: '\f107';
  font-family: 'Bootstrap Icons';
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: #6b7280;
}

.mobile-form-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 48px;
}

/* ==========================================================================
   Mobile Floating Action Button
   ========================================================================== */

.mobile-fab {
  display: none !important;
}

.mobile-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 25px rgba(102, 126, 234, 0.6);
}

.mobile-fab:active {
  transform: scale(0.95);
}

/* ==========================================================================
   Mobile Bottom Navigation
   ========================================================================== */

.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  padding: 8px 0;
  z-index: 1000;
  display: flex;
  justify-content: space-around;
  align-items: center;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

.mobile-bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 12px;
  text-decoration: none;
  color: #6b7280;
  transition: all 0.3s ease;
  min-width: 60px;
  border-radius: 12px;
}

.mobile-bottom-nav-item:hover,
.mobile-bottom-nav-item.active {
  color: var(--mobile-primary);
  background: rgba(102, 126, 234, 0.1);
  text-decoration: none;
}

.mobile-bottom-nav-item i {
  font-size: 1.25rem;
  margin-bottom: 4px;
}

.mobile-bottom-nav-item span {
  font-size: 0.75rem;
  font-weight: 500;
}

.mobile-bottom-nav-item.mobile-chat-trigger {
  background: none;
  border: none;
  cursor: pointer;
  outline: none;
}

/* ==========================================================================
   Mobile Gestures and Interactions
   ========================================================================== */

.mobile-swipeable {
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}

.mobile-pull-to-refresh {
  position: relative;
  overflow: hidden;
}

.mobile-pull-indicator {
  position: absolute;
  top: -60px;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--mobile-primary);
  transition: all 0.3s ease;
}

.mobile-pull-indicator.active {
  top: 20px;
}

/* ==========================================================================
   Mobile Animations
   ========================================================================== */

@keyframes mobile-fade-in {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes mobile-slide-up {
  from {
    opacity: 0;
    transform: translateY(100%);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes mobile-scale-in {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.mobile-animate-fade-in {
  animation: mobile-fade-in 0.5s ease-out;
}

.mobile-animate-slide-up {
  animation: mobile-slide-up 0.5s ease-out;
}

.mobile-animate-scale-in {
  animation: mobile-scale-in 0.3s ease-out;
}

/* ==========================================================================
   Mobile Utilities
   ========================================================================== */

.mobile-only {
  display: block;
}

.desktop-only {
  display: none;
}

.mobile-text-center {
  text-align: center;
}

.mobile-text-left {
  text-align: left;
}

.mobile-text-right {
  text-align: right;
}

.mobile-mt-0 { margin-top: 0; }
.mobile-mt-1 { margin-top: 8px; }
.mobile-mt-2 { margin-top: 16px; }
.mobile-mt-3 { margin-top: 24px; }
.mobile-mt-4 { margin-top: 32px; }

.mobile-mb-0 { margin-bottom: 0; }
.mobile-mb-1 { margin-bottom: 8px; }
.mobile-mb-2 { margin-bottom: 16px; }
.mobile-mb-3 { margin-bottom: 24px; }
.mobile-mb-4 { margin-bottom: 32px; }

.mobile-p-0 { padding: 0; }
.mobile-p-1 { padding: 8px; }
.mobile-p-2 { padding: 16px; }
.mobile-p-3 { padding: 24px; }
.mobile-p-4 { padding: 32px; }

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */

@media (min-width: 769px) {
  .mobile-only {
    display: none;
  }
  
  .desktop-only {
    display: block;
  }
  
  .mobile-bottom-nav {
    display: none;
  }
  
  .mobile-fab {
    display: none !important;
  }
}

@media (max-width: 480px) {
  :root {
    --mobile-padding: 12px;
    --mobile-margin: 8px;
  }
  
  .mobile-card-body,
  .mobile-card-header,
  .mobile-card-footer {
    padding: 12px;
  }
}

/* ==========================================================================
   Dark Mode Support
   ========================================================================== */

@media (prefers-color-scheme: dark) {
  .mobile-card {
    background: #1f2937;
    color: white;
  }
  
  .mobile-form-control {
    background: #374151;
    border-color: #4b5563;
    color: white;
  }
  
  .mobile-bottom-nav {
    background: #1f2937;
    border-top-color: #374151;
  }
}
