/* 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;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* 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-items: 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-p-rec {
  background: repeating-linear-gradient(
    45deg,
    var(--color-p),
    var(--color-p) 6px,
    #065f46 6px,
    #065f46 12px
  );
}
.fill-f { background: linear-gradient(90deg, #d97706, var(--color-f)); }
.fill-f-rec {
  background: repeating-linear-gradient(
    45deg,
    var(--color-f),
    var(--color-f) 6px,
    #92400e 6px,
    #92400e 12px
  );
}
.fill-c { background: linear-gradient(90deg, #0891b2, var(--color-c)); }
.fill-c-rec {
  background: repeating-linear-gradient(
    45deg,
    var(--color-c),
    var(--color-c) 6px,
    #155e75 6px,
    #155e75 12px
  );
}
.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;
  }
}

/* Toast Notification System */
.toast-container {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  min-width: 280px;
  max-width: 400px;
  padding: 1rem 1.25rem;
  border-radius: 12px;
  background: rgba(30, 41, 59, 0.75);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #f8fafc;
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transform: translateX(120%);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.35s ease;
  opacity: 0;
}

.toast.show {
  transform: translateX(0);
  opacity: 1;
}

.toast.success {
  border-left: 4px solid #10b981;
}

.toast.error {
  border-left: 4px solid #ef4444;
}

.toast.info {
  border-left: 4px solid #6366f1;
}

.toast-icon {
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toast-content {
  flex: 1;
  font-weight: 500;
  line-height: 1.4;
}

.toast-close {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.4);
  cursor: pointer;
  font-size: 1rem;
  padding: 0;
  margin-left: 0.5rem;
  transition: color 0.2s ease;
  line-height: 1;
}

.toast-close:hover {
  color: rgba(255, 255, 255, 0.8);
}

/* ================= ADMIN SIDEBAR SUB-TABS ================= */
.admin-layout {
  display: flex;
  gap: 1.5rem;
  width: 100%;
  align-items: flex-start;
}

.admin-sidebar {
  width: 220px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1.25rem 1rem;
  border-radius: 12px;
  flex-shrink: 0;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

.admin-sidebar-title {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding-left: 0.75rem;
  margin-bottom: 0.75rem;
}

.sidebar-tab-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.8rem 1rem;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  text-align: left;
  font-size: 0.95rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  font-weight: 500;
  box-sizing: border-box;
}

.sidebar-tab-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  transform: translateX(2px);
}

.sidebar-tab-btn.active {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.2) 0%, rgba(168, 85, 247, 0.2) 100%);
  color: #fff;
  border-left: 3px solid #818cf8;
  padding-left: calc(1rem - 3px);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.1);
  transform: none;
}

.admin-main-content {
  flex: 1;
  min-width: 0;
}

.subtab-content {
  display: block;
}

.subtab-content.hidden {
  display: none !important;
}

/* Responsive adjustment for admin panel */
@media (max-width: 900px) {
  .admin-layout {
    flex-direction: column;
    align-items: stretch;
  }
  
  .admin-sidebar {
    width: 100%;
    flex-direction: row;
    padding: 0.75rem;
    overflow-x: auto;
    gap: 0.5rem;
    align-items: center;
  }
  
  .admin-sidebar-title {
    display: none;
  }
  
  .sidebar-tab-btn {
    width: auto;
    white-space: nowrap;
    padding: 0.6rem 1rem;
  }
  
  .sidebar-tab-btn.active {
    border-left: none;
    border-bottom: 3px solid #818cf8;
    padding-left: 1rem;
    padding-bottom: calc(0.6rem - 3px);
  }
}

/* Drag and Drop Sorting Styles */
.food-table tbody tr[draggable="true"] {
  transition: transform 0.2s ease, opacity 0.2s ease, background-color 0.2s ease;
}
.food-table tbody tr.dragging {
  opacity: 0.4;
  background: rgba(99, 102, 241, 0.15) !important;
  outline: 2px dashed rgba(99, 102, 241, 0.4);
}
.drag-handle {
  cursor: grab;
  color: rgba(255, 255, 255, 0.35);
  font-size: 1.1rem;
  user-select: none;
  transition: color 0.2s ease;
}
.drag-handle:hover {
  color: #818cf8;
}
.drag-handle:active {
  cursor: grabbing;
}

/* Language Selector */
.lang-select {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #f3f4f6;
  border-radius: 6px;
  padding: 0.25rem 0.5rem;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  transition: all 0.2s ease;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.lang-select:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.25);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.05);
}

.lang-select option {
  background: #111827; /* Dark background matching the theme for options dropdown */
  color: #f3f4f6;
}

/* Language Selector Icon Wrapper */
.lang-select-wrapper {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.lang-globe-icon {
  color: rgba(255, 255, 255, 0.5);
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.lang-select-wrapper:hover .lang-globe-icon {
  color: rgba(255, 255, 255, 0.9);
  filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.2));
}

/* ===================================================================
   MOBILE / SMALL SCREEN ADAPTATIONS (phones, <= 640px)
   =================================================================== */
@media (max-width: 640px) {
  /* Tame the background blur orbs so they don't over-saturate tiny screens */
  .glow-orb { filter: blur(90px); opacity: 0.2; }
  #orb-1 { width: 300px; height: 300px; }
  #orb-2 { width: 320px; height: 320px; }

  /* --- Header: compact, single row, never overflow --- */
  .main-header {
    padding: 0.7rem 1rem;
    width: 100%;
    margin: 0 0 1rem 0;
    border-radius: 0 0 14px 14px;
    gap: 0.6rem;
  }
  .logo-icon { font-size: 1.2rem; margin-right: 0.3rem; }
  .header-logo .logo-text { font-size: 1.15rem; }
  .user-profile { gap: 0.5rem; }
  .username-badge {
    max-width: 88px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0.3rem 0.6rem;
    font-size: 0.78rem;
  }
  .lang-select { padding: 0.2rem 0.35rem; font-size: 0.78rem; }
  /* Hide the globe glyph on phones to save horizontal room */
  .lang-globe-icon { display: none; }

  /* --- Tab bar: 2x2 wrapped grid instead of a cramped single row --- */
  .tab-nav-bar {
    width: 100%;
    margin: 0 0 1rem 0;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0.35rem;
    border-radius: 14px;
  }
  .tab-button {
    flex: 1 1 calc(50% - 0.4rem);
    padding: 0.6rem 0.4rem;
    font-size: 0.82rem;
    gap: 0.3rem;
    line-height: 1.15;
  }

  /* --- Layout grids: tighter outer padding --- */
  .content-grid,
  .weight-grid,
  .settings-grid {
    padding: 0.85rem;
    gap: 1.1rem;
  }

  /* --- Cards: slimmer interior padding --- */
  .card { margin-bottom: 1.25rem; border-radius: 14px; }
  .card-header { padding: 1rem 1.1rem; }
  .card-header h2 { font-size: 1.05rem; }
  .card-body { padding: 1.1rem; }

  /* --- The big net-calorie hero number --- */
  .net-cal-val { font-size: 2.5rem; }
  .net-cal-val .unit { font-size: 1rem; }
  .fat-change-val { font-size: 1rem; margin-bottom: 1rem; }
  .macro-grid-mini { flex-direction: column; gap: 0.5rem; align-items: flex-start; }

  /* --- Forms: keep the 3 macro inputs on one row, tighter gaps --- */
  .form-row {
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    gap: 0.75rem;
  }
  .grid-form { gap: 1rem; }

  /* iOS zooms in on focus for any input < 16px; force 16px on phones */
  input[type="text"],
  input[type="password"],
  input[type="email"],
  input[type="number"],
  input[type="date"],
  input[type="time"],
  select,
  textarea {
    font-size: 16px;
  }

  /* --- Tables: denser cells + smooth momentum scroll --- */
  .table-container { -webkit-overflow-scrolling: touch; }
  .food-table { font-size: 0.8rem; }
  .food-table th,
  .food-table td { padding: 0.6rem 0.45rem; }

  /* --- Auth box: less padding so it isn't squeezed on phones --- */
  .auth-box { padding: 1.75rem 1.5rem; }
  .auth-header { margin-bottom: 1.5rem; }
  .auth-header .logo-text { font-size: 2rem; }

  /* --- Toasts: span the width instead of a fixed 280px min --- */
  .toast-container {
    top: 0.85rem;
    left: 0.85rem;
    right: 0.85rem;
  }
  .toast {
    min-width: 0;
    max-width: 100%;
    width: 100%;
  }

  /* --- Footer --- */
  .footer { padding: 1.5rem 1rem; }
}


/* Extra-narrow phones (<= 380px): shrink the hero + tab labels a touch more */
@media (max-width: 380px) {
  .net-cal-val { font-size: 2.1rem; }
  .tab-button { font-size: 0.76rem; padding: 0.55rem 0.3rem; }
  .header-logo .logo-text { font-size: 1.05rem; }
}

/* Developer Guide Styles */
details.dev-guide-details summary::-webkit-details-marker {
  display: none;
}
details.dev-guide-details summary {
  list-style: none;
}
details.dev-guide-details[open] .arrow {
  transform: rotate(180deg);
}


