/* Base Styles */
:root {
  --primary-color: #8A2BE2; /* Purple */
  --secondary-color: #4169E1; /* Royal Blue */
  --danger-color: #FF5252;
  --text-color: #ffffff;
  --light-bg: #1a1a1a;
  --border-color: #333333;
  --success-color: #4ecca3;
  --warning-color: #ffb142;
  --info-color: #6ab7ff;
  --font-family: 'Montserrat', 'Segoe UI', Arial, sans-serif;
  --dark-bg: #121212;
  --card-bg: linear-gradient(135deg, rgba(138, 43, 226, 0.2), rgba(65, 105, 225, 0.2));
  --navbar-bg: #121212;
}

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

body {
  font-family: var(--font-family);
  color: var(--text-color);
  line-height: 1.6;
  background-color: var(--dark-bg);
  margin: 0;
  padding: 0;
  font-weight: 300;
}

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

.card {
  background: var(--card-bg);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  margin-bottom: 24px;
  padding: 24px;
  overflow: hidden;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  margin-bottom: 0.5rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

h1 {
  font-size: 2.2rem;
}

h2 {
  font-size: 1.8rem;
  background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

h3 {
  font-size: 1.4rem;
}

p {
  margin-bottom: 1rem;
}

/* Navigation */
.navbar {
  background-color: var(--navbar-bg);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  position: sticky;
  top: 0;
  z-index: 1000;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.navbar-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1rem;
  max-width: 1200px;
  margin: 0 auto;
}

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

#userName {
  margin-right: 8px;
}

.navbar-user-menu-item {
  display: none;
}

.navbar-brand {
  font-size: 1.5rem;
  font-weight: bold;
  background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-decoration: none;
  display: flex;
  align-items: center;
}

.navbar-brand::before {
  content: "";
  display: inline-block;
  width: 24px;
  height: 24px;
  margin-right: 8px;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  border-radius: 50%;
}

.navbar-menu {
  display: flex;
  list-style: none;
}

.navbar-item {
  margin-left: 1.5rem;
}

.navbar-link {
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.3s;
  padding: 6px 12px;
  border-radius: 4px;
}

.navbar-link:hover, .navbar-link.active {
  background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  transform: translateY(-1px);
}

.navbar-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.8);
  padding: 0.5rem;
  transition: color 0.3s ease;
}

.navbar-toggle:hover {
  color: var(--primary-color);
}

/* Forms */
.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.form-control {
  display: block;
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  line-height: 1.5;
  color: #ffffff;
  background-color: rgba(255, 255, 255, 0.1);
  background-clip: padding-box;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  transition: all 0.2s ease-in-out;
}

.form-control:focus {
  border-color: var(--primary-color);
  outline: 0;
  box-shadow: 0 0 0 3px rgba(138, 43, 226, 0.25);
  background-color: rgba(255, 255, 255, 0.15);
}

/* Buttons */
.btn {
  display: inline-block;
  font-weight: 500;
  text-align: center;
  white-space: nowrap;
  vertical-align: middle;
  user-select: none;
  border: 1px solid transparent;
  padding: 0.75rem 1.25rem;
  font-size: 1rem;
  line-height: 1.5;
  border-radius: 8px;
  transition: all 0.2s ease-in-out;
  cursor: pointer;
  letter-spacing: 0.02em;
}

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  border: none;
  box-shadow: 0 4px 10px rgba(138, 43, 226, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 15px rgba(138, 43, 226, 0.4);
}

.btn-secondary {
  color: #fff;
  background-color: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(5px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-2px);
}

.btn-danger {
  color: #fff;
  background: linear-gradient(135deg, #FF5252, #FF1744);
  border: none;
  box-shadow: 0 4px 10px rgba(255, 82, 82, 0.3);
}

.btn-danger:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 15px rgba(255, 82, 82, 0.4);
}

.btn-outline {
  background: transparent;
  border: 1px solid currentColor;
  box-shadow: none;
}

.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.875rem;
}

.btn-neutral {
  color: rgba(255, 255, 255, 0.8);
  background-color: rgba(255, 255, 255, 0.1);
}

.btn-block {
  display: block;
  width: 100%;
}

/* Utilities */
.text-center {
  text-align: center;
}

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

.text-success {
  color: var(--success-color);
}

.text-danger {
  color: var(--danger-color);
}

.text-warning {
  color: var(--warning-color);
}

.text-info {
  color: var(--info-color);
}

.mb-1 {
  margin-bottom: 0.25rem;
}

.mb-2 {
  margin-bottom: 0.5rem;
}

.mb-3 {
  margin-bottom: 1rem;
}

.mb-4 {
  margin-bottom: 1.5rem;
}

.mt-1 {
  margin-top: 0.25rem;
}

.mt-2 {
  margin-top: 0.5rem;
}

.mt-3 {
  margin-top: 1rem;
}

.mt-4 {
  margin-top: 1.5rem;
}

/* Meal Items */
.meal-item {
  display: flex;
  flex-direction: column;
  margin-bottom: 1rem;
  padding: 1rem;
  border-radius: 12px;
  background: rgba(30, 30, 30, 0.7);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.meal-item:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.meal-item img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin-bottom: 0.5rem;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
  object-fit: cover;
}

.meal-info {
  flex: 1;
}

/* Charts and Visualizations */
.chart-container {
  position: relative;
  height: 300px;
  margin-bottom: 1.5rem;
}

.nutrition-bar {
  height: 20px;
  background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
  border-radius: 10px;
  margin-bottom: 0.5rem;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.nutrition-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1rem;
}

.nutrition-card {
  padding: 1.25rem;
  border-radius: 12px;
  background: rgba(30, 30, 30, 0.7);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: transform 0.2s ease;
}

.nutrition-card:hover {
  transform: translateY(-5px);
}

/* Modal Styles */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  overflow: auto;
  backdrop-filter: blur(5px);
}

.modal-content {
  background: linear-gradient(135deg, rgba(30, 30, 30, 0.9), rgba(20, 20, 20, 0.9));
  margin: 10% auto;
  padding: 25px;
  border-radius: 12px;
  max-width: 600px;
  position: relative;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transform: translateY(0);
  animation: modal-appear 0.3s ease-out;
}

@keyframes modal-appear {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-close {
  position: absolute;
  top: 15px;
  right: 15px;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  transition: all 0.2s;
}

.modal-close:hover {
  color: #fff;
  transform: rotate(90deg);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(135deg, var(--secondary-color), var(--primary-color));
}

/* Input Focus Styles */
input:focus, select:focus, textarea:focus {
  outline: none;
}

/* Chart Styling */
canvas {
  border-radius: 8px;
  background-color: rgba(30, 30, 30, 0.7);
  padding: 10px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* Image Styling */
img {
  transition: transform 0.3s ease;
}

img:hover {
  transform: scale(1.03);
}

/* Loading Spinner and Indicators */
.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  background-color: rgba(30, 30, 30, 0.7);
  border-radius: 10px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  border-top: 4px solid var(--primary-color);
  animation: spin 1s linear infinite;
  margin-bottom: 15px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading-text {
  font-size: 1.1rem;
  font-weight: 500;
  margin-bottom: 5px;
  color: var(--primary-color);
  background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.loading-subtext {
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.7);
  text-align: center;
}

/* Meal Input Selector */
.meal-input-selector {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.meal-input-selector button {
  flex: 1;
  padding: 10px;
  border-radius: 5px;
  font-weight: 600;
  transition: all 0.3s ease;
}

.meal-input-selector button.active {
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* Table Styling */
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
  background-color: rgba(30, 30, 30, 0.7);
  border-radius: 8px;
  overflow: hidden;
}

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

th {
  background-color: rgba(0, 0, 0, 0.2);
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}

/* Calories Display */
.calories-display {
  display: flex;
  align-items: baseline;
  margin-top: 5px;
}

.calories-value {
  font-size: 1.4rem;
  font-weight: bold;
  background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-right: 5px;
}

.calories-label {
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.7);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.85rem;
  letter-spacing: 0.05em;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

/* Loading Animation */
.loading {
  display: inline-block;
  width: 50px;
  height: 50px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: var(--primary-color);
  animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

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

/* Tooltip */
.tooltip {
  position: relative;
  display: inline-block;
}

.tooltip .tooltip-text {
  visibility: hidden;
  width: 120px;
  background-color: rgba(0, 0, 0, 0.8);
  color: #fff;
  text-align: center;
  border-radius: 6px;
  padding: 5px;
  position: absolute;
  z-index: 1;
  bottom: 125%;
  left: 50%;
  margin-left: -60px;
  opacity: 0;
  transition: opacity 0.3s;
}

.tooltip:hover .tooltip-text {
  visibility: visible;
  opacity: 1;
}

.nutrition-card .value {
  font-size: 1.8rem;
  font-weight: bold;
  background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.nutrition-card .label {
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.7);
  margin-top: 5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  .navbar-container {
    flex-direction: row;
    flex-wrap: wrap;
  }
  
  .navbar-brand {
    order: 2;
  }
  
  .navbar-toggle {
    display: block;
    order: 1;
  }
  
  /* Photo Upload Options */
  .photo-options {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
  }
  
  .photo-option {
    flex: 1;
  }
  
  .photo-option-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 25px;
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    color: var(--text-color);
    height: 160px;
  }
  
  .photo-option-button:hover {
    background-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
  }
  
  .photo-option-button:active {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
  }
  
  .photo-option-button svg {
    margin-bottom: 15px;
    stroke: var(--primary-color);
  }
  
  .photo-option-button span {
    font-weight: 600;
    font-size: 1.1rem;
  }
  
  .camera-option {
    background: linear-gradient(135deg, rgba(138, 43, 226, 0.3), rgba(65, 105, 225, 0.2));
  }
  
  .gallery-option {
    background: linear-gradient(135deg, rgba(65, 105, 225, 0.3), rgba(138, 43, 226, 0.2));
  }
  
  .photo-input {
    position: absolute;
    width: 0.1px;
    height: 0.1px;
    opacity: 0;
    overflow: hidden;
    z-index: -1;
  }
  
  /* Image Preview */
  .image-preview-container {
    background: rgba(30, 30, 30, 0.7);
    border-radius: 12px;
    padding: 15px;
    margin-top: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
  }
  
  .image-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
  }
  
  .image-preview-header h4 {
    margin: 0;
  }
  
  .image-preview {
    text-align: center;
    width: 300px;
    height: 250px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
  }
  
  .image-preview img {
    max-width: 100%;
    max-height: 100%;
    border-radius: 8px;
    object-fit: cover;
  }
  
  /* Upload Progress */
  .upload-progress {
    margin-top: 20px;
  }
  
  .progress-bar-container {
    width: 100%;
    height: 10px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    overflow: hidden;
  }
  
  .progress-bar {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    border-radius: 5px;
    transition: width 0.3s ease;
  }
  
  .progress-status {
    margin-top: 5px;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.8);
    text-align: center;
  }
  
  /* Upload Success */
  .upload-success {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    background-color: rgba(78, 204, 163, 0.2);
    border-radius: 8px;
    color: var(--success-color);
    font-weight: 500;
    animation: fade-in 0.5s ease-out;
  }
  
  .upload-success svg {
    stroke: var(--success-color);
    margin-right: 10px;
  }
  
  /* Helper Text */
  .helper-text {
    color: var(--info-color);
    font-size: 0.95rem;
    margin-bottom: 15px;
  }
  
  @media (max-width: 768px) {
    .navbar-toggle {
      display: block;
    }
  }
  
  @media (max-width: 480px) {
    .photo-options {
      flex-direction: column;
    }
    
    .photo-option-button {
      padding: 15px;
    }
  }
  
  /* Mobile navbar adjustments */
  .navbar-container {
    flex-wrap: wrap;
  }
  
  .navbar-toggle {
    order: 3;
    margin-left: auto;
  }
  
  .navbar-brand {
    order: 1;
  }
  
  .navbar-menu {
    display: none;
    flex-direction: column;
    position: absolute;
    top: 60px;
    left: 0;
    right: 0;
    background-color: var(--navbar-bg);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 1rem;
    order: 4;
    width: 100%;
    z-index: 100;
  }
  
  .navbar-menu.active {
    display: flex;
  }
  
  .navbar-item {
    margin: 0.5rem 0;
  }
  
  .navbar-user-desktop {
    display: none;
  }
  
  .navbar-user-menu-item {
    display: block;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
  }
  
  .navbar-menu .navbar-user-section {
    width: 100%;
    justify-content: center;
  }
  
  .nutrition-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .nutrition-grid {
    grid-template-columns: 1fr;
  }
  
  .container {
    padding: 10px;
  }
  
  .card {
    padding: 15px;
  }
}

/* Filter Elements Styling */
.filter-container {
  display: flex;
  gap: 10px;
  align-items: center;
  width: 100%;
}

.quick-select-container {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Media queries for filter elements */
@media (max-width: 768px) {
  .filter-container {
    flex-direction: column;
    align-items: stretch;
    gap: 15px;
  }
  
  .filter-container .form-control {
    width: 100%;
  }
  
  .filter-container .btn {
    width: 100%;
    margin-top: 5px;
  }
  
  .quick-select-container {
    flex-direction: column;
  }
  
  .quick-select-container .btn {
    width: 100%;
  }
}

/* Food thumbnail styling */
.food-thumbnail {
  width: 300px;
  height: 250px;
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
  object-fit: cover;
  display: block;
  margin: 0 auto;
}

/* Ensure consistent thumbnail display across the app */
#foodImagePreview {
  width: 300px;
  height: 250px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}