/* Mobile Styles for CalorieTally
 * Complete redesign of mobile navigation and sidebar
 */

/* ===== MOBILE NAVIGATION ===== */
.mobile-toggle {
  display: none;
  position: fixed;
  top: 25px;
  left: 15px;
  z-index: 1200;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: all 0.3s ease;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.mobile-toggle:hover {
  background: var(--bg-elevated);
  transform: scale(1.05);
}

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

/* Top bar adjustments */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 70px;
  padding: 0 20px;
  position: relative;
  background-color: var(--bg-dark);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
}

/* Mobile logo - removed as not needed */
.mobile-logo {
  display: none;
}

/* Page title centered on mobile */
@media (max-width: 768px) {
  .page-title {
    flex: 1;
    text-align: center;
    margin-left: 60px; /* Space for hamburger menu */
    margin-right: 60px; /* Balance the layout */
  }
}

/* ===== REDESIGNED MOBILE SIDEBAR ===== */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1050;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

/* ===== BOTTOM NAVIGATION ===== */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background-color: var(--bg-card);
  box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.2);
  z-index: 1000;
  padding: 10px 0 5px;
  border-top: 1px solid var(--border-light);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.bottom-nav-items {
  display: flex;
  justify-content: space-around;
  align-items: center;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px;
  border-radius: 12px;
  transition: all 0.3s ease;
  color: var(--text-secondary);
  text-decoration: none;
  position: relative;
  overflow: hidden;
}

.bottom-nav-item::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 3px;
  background-color: var(--primary);
  transition: width 0.3s ease;
  border-radius: 3px 3px 0 0;
}

.bottom-nav-item.active {
  color: var(--primary);
}

.bottom-nav-item.active::before {
  width: 60%;
}

.bottom-nav-item.active i {
  transform: translateY(-5px);
}

.bottom-nav-item i {
  font-size: 22px;
  margin-bottom: 5px;
  transition: transform 0.3s ease;
}

.bottom-nav-item span {
  font-size: 12px;
  font-weight: 500;
  transition: all 0.3s ease;
  opacity: 0.8;
}

.bottom-nav-item:hover i {
  transform: translateY(-5px);
}

.bottom-nav-item:hover span {
  opacity: 1;
}

/* ===== RESPONSIVE ADJUSTMENTS ===== */
@media (max-width: 992px) {
  /* Tablet adjustments */
  .hero-banner {
    padding: 25px;
    min-height: 230px;
  }

  .hero-greeting {
    font-size: 1.8rem;
  }

  .hero-stats-wrapper {
    flex-wrap: wrap;
    gap: 15px;
  }

  .hero-stat {
    min-width: calc(50% - 10px);
    padding: 15px;
  }

  .progress-grid {
    gap: 15px;
  }

  .macros-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
  }

  /* User menu adjustments on tablets */
  .user-menu .user-info {
    display: none;
  }
}

@media (max-width: 768px) {
  /* Mobile landscape adjustments */
  body {
    padding-bottom: 65px; /* Space for bottom navigation */
    overflow-x: hidden;
  }

  .app-wrapper {
    display: block;
    overflow-x: hidden;
  }

  /* Mobile sidebar styles */
  .sidebar {
    width: 85%;
    max-width: 300px;
    transform: translateX(-100%);
    background: var(--bg-card);
    transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1);
    height: 100vh;
    height: 100dvh; /* Use dynamic viewport height for mobile */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
  }

  .sidebar.active {
    transform: translateX(0);
  }

  .desktop-toggle {
    display: none !important;
  }

  .sidebar-header {
    padding: 24px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .menu-item {
    padding: 16px 20px !important;
    margin: 4px 16px !important;
    font-size: 16px;
  }

  .menu-item.active {
    background: linear-gradient(135deg, rgba(240, 27, 66, 0.2), rgba(240, 27, 66, 0.1));
  }

  .menu-icon {
    width: 28px !important;
    height: 28px !important;
    font-size: 20px;
  }

  .sidebar-footer {
    padding: 20px 16px 20px 16px; /* Add modest bottom padding for mobile browser navigation */
    padding-bottom: max(20px, env(safe-area-inset-bottom, 0px)); /* Dynamic adjustment for mobile devices */
  }

  /* Fix logout button trimming on mobile */
  .logout-form {
    margin: 0;
    width: 100%;
  }

  .logout-btn {
    padding: 16px 20px !important;
    margin: 4px 16px !important;
    width: calc(100% - 32px) !important;
    font-size: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    justify-content: flex-start;
  }

  .main-content {
    margin-left: 0 !important;
    width: 100%;
  }

  /* Show mobile navigation elements */
  .mobile-toggle {
    display: flex;
  }

  .mobile-bottom-nav {
    display: block;
  }

  /* Hide desktop user menu on mobile */
  .user-menu {
    display: none !important;
  }

  /* Adjust hero section */
  .hero-banner {
    padding: 20px;
    min-height: 200px;
    margin-bottom: 20px;
  }

  .hero-greeting {
    font-size: 1.5rem;
  }

  .hero-stats-wrapper {
    gap: 10px;
  }

  .hero-stat {
    min-width: calc(50% - 5px);
    padding: 12px;
  }

  .stat-value {
    font-size: 22px;
  }

  /* Dashboard components */
  .progress-grid {
    display: flex;
    flex-direction: column;
    gap: 15px;
  }

  .summary-card {
    padding: 20px 15px;
  }

  .meals-timeline-card {
    padding: 20px 15px;
  }

  .macros-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .add-meal-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
  }

  .add-meal-btn {
    height: auto;
    min-height: 90px;
    flex-direction: row;
    align-items: center;
    text-align: left;
    padding: 15px;
  }

  .add-meal-icon {
    font-size: 24px;
    margin-bottom: 0;
    margin-right: 15px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
  }

  .icon-voice {
    background-color: rgba(220, 53, 69, 0.1);
  }

  .icon-photo {
    background-color: rgba(76, 175, 80, 0.1);
  }

  .icon-text {
    background-color: rgba(33, 150, 243, 0.1);
  }

  .meal-group {
    padding: 15px;
  }

  .meal-group-header {
    margin-bottom: 10px;
    padding-bottom: 10px;
  }

  .meal-items {
    gap: 10px;
  }

  .meal-item {
    padding: 10px;
  }

  .meal-macro {
    padding: 3px 8px;
    font-size: 12px;
  }

  /* Chart adjustments */
  .chart-card {
    padding: 20px 15px;
  }

  .chart-container {
    height: 250px;
  }

  /* Form improvements */
  input, select, textarea, .form-control {
    font-size: 16px !important; /* Prevents iOS zoom */
  }

  .form-label {
    font-size: 14px;
  }

  .btn {
    padding: 12px 15px;
    font-size: 15px;
  }

  /* Floating button positioning */
  .floating-add-btn {
    bottom: 75px;
    width: 55px;
    height: 55px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(45deg, var(--primary), var(--primary-light));
    box-shadow: 0 5px 20px rgba(240, 27, 66, 0.3);
    transition: all 0.3s ease;
  }

  .floating-add-btn:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 8px 25px rgba(240, 27, 66, 0.4);
  }

  .floating-add-btn i {
    font-size: 26px;
  }
}

@media (max-width: 480px) {
  /* Mobile portrait adjustments */
  .hero-banner {
    padding: 15px;
    min-height: 180px;
  }

  .hero-greeting {
    font-size: 1.3rem;
  }

  .hero-date {
    font-size: 0.9rem;
  }

  .hero-stats-wrapper {
    flex-direction: column;
  }

  .hero-stat {
    min-width: 100%;
  }

  .summary-card {
    padding: 15px 12px;
  }

  .card-title {
    font-size: 16px;
  }

  .card-icon {
    width: 28px;
    height: 28px;
    font-size: 16px;
  }

  .meal-item {
    flex-direction: column;
  }

  .meal-info {
    flex-direction: column;
    align-items: flex-start;
  }

  .meal-macros {
    margin: 10px 0;
  }

  .meal-actions {
    align-self: flex-end;
  }

  /* Page title adjustments for small screens */
  .page-title {
    font-size: 20px;
  }
}

/* Fix for Firefox scrollbar */
@-moz-document url-prefix() {
  .sidebar {
    scrollbar-width: thin;
    scrollbar-color: var(--border-light) transparent;
  }
}

/* Bottom nav indicator animation */
.bottom-nav-indicator {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 3px;
  background-color: var(--primary);
  border-radius: 3px 3px 0 0;
  transition: width 0.3s ease;
}

.bottom-nav-item.active .bottom-nav-indicator {
  width: 60%;
}

/* Mobile animations */
@keyframes icon-bounce {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

.icon-bounce {
  animation: icon-bounce 0.5s ease;
}

@keyframes button-press {
  0% { transform: scale(1); }
  50% { transform: scale(0.95); }
  100% { transform: scale(1); }
}

.button-press {
  animation: button-press 0.3s ease;
}