/* Global Reset & Base Variable Design Tokens */
:root {
  --bg-primary: #0b0c16;
  --bg-secondary: rgba(18, 20, 38, 0.4);
  --glass-bg: rgba(25, 28, 50, 0.45);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-highlight: rgba(255, 255, 255, 0.15);
  
  --text-primary: #f1f3f9;
  --text-secondary: #94a3b8;
  
  --color-primary: #6366f1; /* Indigo */
  --color-primary-hover: #4f46e5;
  --color-accent: #a855f7; /* Purple */
  
  --color-p: #10b981; /* Emerald/Protein */
  --color-f: #f59e0b; /* Amber/Fat */
  --color-c: #06b6d4; /* Cyan/Carb */
  --color-danger: #ef4444;
  
  --font-display: 'Outfit', 'Inter', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
}

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

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-body);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

/* Background Glowing Orbs */
#glow-container {
  position: fixed;
  width: 100vw;
  height: 100vh;
  top: 0;
  left: 0;
  z-index: -1;
  pointer-events: none;
}

.glow-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(140px);
  opacity: 0.25;
}

#orb-1 {
  width: 450px;
  height: 450px;
  background: radial-gradient(circle, var(--color-primary) 0%, rgba(0,0,0,0) 70%);
  top: -10%;
  right: -5%;
}

#orb-2 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, var(--color-accent) 0%, rgba(0,0,0,0) 70%);
  bottom: -15%;
  left: -5%;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Utilities */
.hidden { display: none !important; }
.text-center { text-align: center; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }
.align-end { align-items: flex-end; }
.flex-row { display: flex; }
.mt-4 { margin-top: 1.5rem; }
.mt-1 { margin-top: 0.25rem; }
.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.85rem; }
.text-secondary { color: var(--text-secondary); }
.span-2 { grid-column: span 2; }

/* Glassmorphism Common Style */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  box-shadow: 0 10px 30px 0 rgba(0, 0, 0, 0.3);
}

/* Main Layout Grid */
.content-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 2rem;
  max-width: 1300px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem;
  flex: 1;
}

@media (max-width: 1024px) {
  .content-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
    padding: 1rem;
  }
}

/* Header design */
.main-header {
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-center: center;
  border-bottom: 1px solid var(--glass-border);
  border-radius: 0 0 16px 16px;
  max-width: 1300px;
  width: 95%;
  margin: 0 auto 1.5rem auto;
}

.logo-text {
  font-family: var(--font-display);
  font-weight: 800;
  background: linear-gradient(135deg, #fff 0%, #a5b4fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.02em;
}

.logo-icon {
  font-size: 1.5rem;
  margin-right: 0.5rem;
}

.header-logo {
  display: flex;
  align-items: center;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.username-badge {
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  padding: 0.35rem 0.8rem;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
}

/* Card layout */
.card {
  border-radius: 16px;
  margin-bottom: 2rem;
  overflow: hidden;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
  box-shadow: 0 15px 40px 0 rgba(99, 102, 241, 0.12);
}

.card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--glass-border);
}

.card-header h2 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.card-body {
  padding: 1.5rem;
}

/* Big Highlight Outcome Card */
.outcome-card {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.18) 0%, rgba(168, 85, 247, 0.15) 100%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  position: relative;
}

.outcome-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0) 100%);
  pointer-events: none;
}

.badge-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  font-weight: 600;
}

.net-cal-val {
  font-family: var(--font-display);
  font-size: 3.2rem;
  font-weight: 800;
  margin: 0.5rem 0;
  text-shadow: 0 0 20px rgba(168, 85, 247, 0.3);
}

.net-cal-val.deficit {
  color: #10b981; /* Green for calorie deficit (losing weight) */
  text-shadow: 0 0 20px rgba(16, 185, 129, 0.3);
}

.net-cal-val.surplus {
  color: #ef4444; /* Red for surplus */
  text-shadow: 0 0 20px rgba(239, 68, 68, 0.3);
}

.net-cal-val .unit {
  font-size: 1.2rem;
  font-weight: 500;
}

.fat-change-val {
  font-size: 1.1rem;
  font-weight: 600;
  color: #e2e8f0;
  background: rgba(255, 255, 255, 0.06);
  padding: 0.5rem 1rem;
  border-radius: 10px;
  display: inline-block;
  margin-bottom: 1.5rem;
}

.macro-grid-mini {
  display: flex;
  justify-content: space-around;
  background: rgba(0, 0, 0, 0.2);
  padding: 0.8rem;
  border-radius: 12px;
}

.macro-mini-item {
  display: flex;
  align-items: center;
  font-size: 0.85rem;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 0.5rem;
}

.intake-dot { background-color: var(--color-primary); }
.exp-dot { background-color: var(--color-accent); }

/* Forms & Inputs */
.grid-form {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 1rem;
}

.form-divider {
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.5rem;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.1);
  padding-bottom: 0.3rem;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.input-group label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="time"],
select {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  padding: 0.65rem 0.8rem;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
  min-width: 0; /* Prevent inputs from overflowing their container */
}

input:focus, select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 8px 0 rgba(99, 102, 241, 0.35);
}

/* Buttons */
.btn {
  font-family: var(--font-display);
  font-weight: 600;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  cursor: pointer;
  border: none;
  outline: none;
  transition: transform 0.1s ease, background 0.3s ease, box-shadow 0.3s ease;
  display: inline-flex;
  justify-content: center;
  align-items: center;
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-accent) 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #7477fa 0%, #b76bf7 100%);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
}

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

.btn-nav {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  color: white;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  padding: 0;
}

.btn-nav:hover {
  background: rgba(255, 255, 255, 0.12);
}

.btn-text {
  background: transparent;
  color: var(--color-primary);
  padding: 0.25rem 0.5rem;
}

.btn-text:hover {
  color: var(--color-accent);
  text-decoration: underline;
}

.btn-danger-sm {
  background: transparent;
  border: none;
  color: var(--color-danger);
  cursor: pointer;
  font-size: 1.1rem;
}

.btn-danger-sm:hover {
  transform: scale(1.2);
}

.btn-edit-sm {
  background: transparent;
  border: none;
  color: var(--color-primary);
  cursor: pointer;
  font-size: 1rem;
  transition: transform 0.2s ease, color 0.2s ease;
}

.btn-edit-sm:hover {
  transform: scale(1.2);
  color: var(--color-accent);
}

/* Date card special styling */
.date-card {
  margin-bottom: 1.5rem;
}

.date-display {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.date-display span {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.2rem;
}

#date-picker {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  border: none;
  background: transparent;
  text-align: center;
  padding: 0;
  cursor: pointer;
}

/* Nutrient Progress Bars */
.progress-item {
  margin-bottom: 1.2rem;
}

.progress-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  margin-bottom: 0.4rem;
}

.progress-bar-bg {
  width: 100%;
  height: 10px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 5px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.fill-p { background: linear-gradient(90deg, #059669, var(--color-p)); }
.fill-f { background: linear-gradient(90deg, #d97706, var(--color-f)); }
.fill-c { background: linear-gradient(90deg, #0891b2, var(--color-c)); }
.fill-ratio { background: linear-gradient(90deg, #7c3aed, var(--color-accent)); }

/* Carb Energy Card Widget */
.carb-energy-card {
  margin-top: 1.8rem;
  background: rgba(0,0,0,0.25);
  border-radius: 12px;
  padding: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.02);
}

.carb-energy-card span:first-child {
  font-weight: 600;
  font-size: 0.9rem;
}

.carb-energy-card .ratio-val {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--color-accent);
}

.carb-energy-card .progress-bar-bg {
  height: 6px;
  margin: 0.6rem 0;
}

/* Tables */
.table-container {
  overflow-x: auto;
}

.food-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.85rem;
}

.food-table th {
  padding: 0.8rem 0.6rem;
  border-bottom: 1.5px solid rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  font-weight: 500;
}

.food-table td {
  padding: 0.8rem 0.6rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  color: var(--text-primary);
  vertical-align: middle;
}

.food-table tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.food-table .meal-badge {
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  display: inline-block;
  vertical-align: middle;
}

.meal-1 { background: rgba(99, 102, 241, 0.15) !important; color: #a5b4fc !important; }
.meal-2 { background: rgba(16, 185, 129, 0.15) !important; color: #6ee7b7 !important; }
.meal-3 { background: rgba(245, 158, 11, 0.15) !important; color: #fde047 !important; }
.meal-4 { background: rgba(168, 85, 247, 0.15) !important; color: #f3e8ff !important; }

.food-table .meal-time-badge {
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-left: 0.4rem;
  font-family: var(--font-body);
  background: rgba(255, 255, 255, 0.05);
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  display: inline-block;
  vertical-align: middle;
}

/* Chart and Weight */
.chart-container {
  position: relative;
  width: 100%;
  height: 220px;
}

/* Authentication Box styling */
.auth-box {
  max-width: 400px;
  width: 90%;
  margin: auto;
  padding: 2.5rem;
  border-radius: 20px;
  background: rgba(25, 28, 50, 0.5);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  box-shadow: 0 20px 50px 0 rgba(0, 0, 0, 0.4);
}

.auth-header {
  text-align: center;
  margin-bottom: 2rem;
}

.auth-header .logo-text {
  font-size: 2.4rem;
}

.auth-header .subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 0.5rem;
}

.toggle-auth {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 1.5rem;
}

.toggle-auth a {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 600;
}

.toggle-auth a:hover {
  text-decoration: underline;
}

.error-msg {
  color: var(--color-danger);
  font-size: 0.8rem;
  margin-top: -0.4rem;
  margin-bottom: 0.8rem;
  min-height: 1.2rem;
}

/* Footer */
.footer {
  text-align: center;
  padding: 2rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  border-top: 1px solid var(--glass-border);
  margin-top: auto;
}

/* Tab Navigation System */
.tab-nav-bar {
  display: flex;
  gap: 0.8rem;
  max-width: 1300px;
  width: 95%;
  margin: 0 auto 1.5rem auto;
  background: rgba(0, 0, 0, 0.2);
  padding: 0.4rem;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
}

.tab-button {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 0.7rem 1.5rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.tab-button:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.03);
}

.tab-button.active {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-accent) 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

/* Weight Grid Layout */
.weight-grid {
  display: grid;
  grid-template-columns: 1.25fr 0.75fr;
  gap: 2rem;
  max-width: 1300px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem;
}

.weight-sidebar {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.large-chart {
  height: 400px;
}

@media (max-width: 1024px) {
  .weight-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
    padding: 1rem;
  }
  .large-chart {
    height: 300px;
  }
}

/* Placeholder styling to differentiate from actual values */
input::placeholder,
textarea::placeholder {
  color: rgba(255, 255, 255, 0.35);
  opacity: 1; /* For Firefox */
}

/* Settings Grid Layout */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
  align-items: start;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem;
}

@media (max-width: 1024px) {
  .settings-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
    padding: 1rem;
  }
}
