/*============================================================================*/
/*                               VARIABLES                                    */
/*============================================================================*/
:root {
  --background-dark: #121212;
  --text-color: #ffffff;
  --discovery-pink: #ED186B;
  --discovery-pink-transparent: rgba(237, 24, 107, 0.35);
  --pingan-orange: #F05A23;
  --pingan-orange-transparent: rgba(240, 90, 35, 0.35);
  --pingan-discovery-color-gradient: linear-gradient(to right, var(--pingan-orange) 35%, var(--discovery-pink) 65%);
  --pingan-discovery-color-gradient2: linear-gradient(to right, var(--pingan-orange) 0%, var(--discovery-pink) 100%); 
  --record-green: #10b981;
  --record-green-dark: #059669;
  --over-quota-red: #b91c1c; /* Added for progress bar */
  --ai-message-bg: rgba(48, 48, 48, 0.8); /* AI message and profile card background */
  --content-text-color: #E5E7EB; 
  --content-key-text-color: #D1D5DB; 
  --ui-font-size-normal: 0.875rem; /* Standardized font size */
  --ui-line-height-normal: 1.4;
  --ui-line-spacing-tight: 2px; /* Tighter line spacing */
  --ui-line-spacing-normal: 4px; /* Normal line spacing */
  --border-radius-small: 4px; /* Added for consistent rounded corners */
}

/*============================================================================*/
/*                           BASE STYLING & LAYOUT                            */
/*============================================================================*/
/* Base styling */
body {
  background-color: var(--background-dark);
  color: var(--text-color);
  margin: 0;
  font-family: 'Hind Vadodara', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  height: 100vh;
  overflow: hidden;
}

/* App container */
#app-container {
  display: flex;
  height: 100vh;
  width: 100%;
  position: relative;
   /* Transition properties */
  opacity: 0;
  transform: translateY(40px); /* Start slightly offset downwards */
  transition: opacity 0.35s ease-out, transform 0.35s cubic-bezier(0.25, 0.1, 0.25, 1);
  z-index: 1000;
}

/* control visibility via JS */
#app-container.visible {
  opacity: 1;
  transform: translateY(0);
  display: flex !important; /* Ensure it's flex when visible */
}

/* Ensure .hidden on #app-container truly hides it initially */
#app-container.hidden {
  display: none !important;
  opacity: 0;
}

/* Left section - Chat section (2/3) */
#chat-section {
  width: 66.67%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  overflow: hidden; /* Prevent overflow from inner elements */
}

/* Right section - Info panel section (1/3) */
#info-panels-section {
  width: 33.33%;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
  background-color: var(--background-dark);
  padding: 10px; /* Add some padding around the panels */
  gap: 10px; /* Space between panels */
  overflow-y: auto; /* Allow scrolling if content exceeds height */
}

/* App header styling */
.app-header {
  text-align: center;
  padding: 20px 0;
  font-size: 28px;
  font-weight: bold;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0; /* Prevent header from shrinking */

  /* Gradient text styling */
  background: var(--pingan-discovery-color-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.startup-header-override {
  border-bottom: none; /* No border for startup header */
  font-size: 32px; /* Slightly larger for emphasis */
  margin-bottom: 60px; /* More space below header */
}

/* Reusable custom scrollbar style */
.custom-scrollbar {
  scrollbar-width: thin; /* For Firefox */
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent; /* For Firefox */
}

/* Custom scrollbar for WebKit browsers (Chrome, Safari, Edge) */
.custom-scrollbar::-webkit-scrollbar {
  width: 4px;
}

.custom-scrollbar::-webkit-scrollbar-track {
  background: transparent;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
  background-color: rgba(255, 255, 255, 0.2);
  border-radius: 20px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background-color: rgba(255, 255, 255, 0.3);
}

/*============================================================================*/
/*                              STARTUP SCREEN                                */
/*============================================================================*/
#startup-screen {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  height: 100vh;
  width: 100vw;
  background-color: var(--background-dark);
  position: fixed;
  top: 0;
  left: 0;
  z-index: 2000; /* On top of other content */
  opacity: 1;
  transition: opacity 0.3s ease-out;
}

#startup-screen.hidden {
  opacity: 0;
  pointer-events: none; /* Disable interaction when hidden */
}

#startup-circle {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  /* Adjusted gradient for a more gradual transition */
  background: linear-gradient(135deg, var(--pingan-orange) 25%, var(--discovery-pink) 75%);
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  animation: pulse-startup 2.5s infinite ease-in-out;
  /* Updated box-shadow for blended glow */
  box-shadow:
    /* 1. Subtle Line Glow / Bright Edge - slightly transparent white */
    0 0 2px 0.5px rgba(255, 248, 240, 0.7), /* Softer edge glow */
    /* 2. Primary Orange Glow - semi-transparent for blending */
    0 0 18px 3px rgba(240, 90, 35, 0.35),   /* PingAn Orange with alpha */
    /* 3. Primary Pink Glow - semi-transparent for blending */
    0 0 18px 3px rgba(237, 24, 107, 0.35),  /* Discovery Pink with alpha */
    /* 4. Wider Softer Orange Glow - more transparent */
    0 0 45px 8px rgba(240, 90, 35, 0.15),
    /* 5. Wider Softer Pink Glow - more transparent */
    0 0 45px 8px rgba(237, 24, 107, 0.15);
}

#startup-text {
  color: var(--text-color);
  font-size: 20px;
  font-weight: 500;
  text-align: center;
}

@keyframes pulse-startup {
  0%, 100% {
    transform: scale(0.95);
    box-shadow:
      /* 1. Subtle Line Glow / Bright Edge */
      0 0 2px 0.5px rgba(255, 248, 240, 0.7),
      /* 2. Primary Orange Glow */
      0 0 18px 3px rgba(240, 90, 35, 0.35),
      /* 3. Primary Pink Glow */
      0 0 18px 3px rgba(237, 24, 107, 0.35),
      /* 4. Wider Softer Orange Glow */
      0 0 45px 8px rgba(240, 90, 35, 0.15),
      /* 5. Wider Softer Pink Glow */
      0 0 45px 8px rgba(237, 24, 107, 0.15);
  }
  50% {
    transform: scale(1);
    box-shadow:
      /* 1. Line Glow - brighter */
      0 0 3px 0.75px rgba(255, 248, 240, 0.9),
      /* 2. Primary Orange Glow - brighter/wider */
      0 0 25px 4px rgba(240, 90, 35, 0.55),
      /* 3. Primary Pink Glow - brighter/wider */
      0 0 25px 4px rgba(237, 24, 107, 0.55),
      /* 4. Wider Softer Orange Glow - brighter/wider */
      0 0 60px 10px rgba(240, 90, 35, 0.25),
      /* 5. Wider Softer Pink Glow - brighter/wider */
      0 0 60px 10px rgba(237, 24, 107, 0.25);
  }
}


/*============================================================================*/
/*                            MESSAGES CONTAINER                              */
/*============================================================================*/
/* Message container styling */
#messages {
  height: calc(100vh - 220px); /* Viewport height minus header and input controls */
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  background-color: transparent;
  gap: 12px;
}

/*============================================================================*/
/*                          COMBINED INPUT CONTROLS                           */
/*============================================================================*/
/* Combined input and controls section */
.input-controls-section {
  height: 150px; /* Fixed height for controls + input */
  background-color: transparent;
  display: flex;
  flex-direction: column;
  flex-shrink: 0; /* Prevent this section from shrinking */
  position: relative; /* Regular positioning, not absolute */
  z-index: 5;
}

/* Controls row with record button */
.controls-row {
  height: 70px;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  background: transparent; 
}

/* Talk button container */
.talk-button-container {
  display: flex;
  justify-content: center;
  z-index: 5;
}

/* Talk button styling */
#record {
  background: radial-gradient(circle at center, var(--pingan-orange), #d13800);
  border: none;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 0 25px rgba(240, 90, 35, 0.5);
  transition: all 0.3s ease;
  cursor: pointer;
}

#record:hover {
  transform: scale(1.05);
  box-shadow: 0 0 30px rgba(240, 90, 35, 0.7);
}

/* Recording state styling */
#record.recording {
  background: radial-gradient(circle at center, var(--record-green), var(--record-green-dark));
  box-shadow: 0 0 30px rgba(16, 185, 129, 0.6);
  animation: pulse 1.2s infinite;
}

#record.recording:hover {
  box-shadow: 0 0 35px rgba(16, 185, 129, 0.8);
}

/* Pulsing animation for recording */
@keyframes pulse {
  0% {
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.5);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 40px rgba(16, 185, 129, 0.8);
    transform: scale(1.08);
  }
  100% {
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.5);
    transform: scale(1);
  }
}

/* Microphone icon */
.mic-icon {
  width: 28px;
  height: 28px;
  fill: white;
}

/* Send icon during recording - smaller size */
.send-icon-recording {
  width: 22px;
  height: 22px;
  fill: white;
}

/*============================================================================*/
/*                             INPUT ROW STYLING                              */
/*============================================================================*/
/* Bottom input row */
.input-row {
  padding: 15px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-grow: 1; /* Allow to take remaining space */
}

/* Status indicator - reposition to be inside the input-controls-section */
#status {
  position: relative; /* Not absolute */
  padding: 4px;
  text-align: center;
  color: rgba(255, 255, 255, 0.4);
  font-size: 12px;
}

/* Text input wrapper to group input and send button */
.text-input-wrapper {
  display: flex;
  align-items: center;
  flex: 1;
  position: relative;
  margin-right: 10px;
}

/* Text input styling */
#input {
  flex: 1;
  background-color: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 20px;
  padding: 8px 40px 8px 15px;
  color: var(--text-color);
}

#input:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.3);
}

/* WhatsApp-style send button */
#send {
  background: transparent;
  border: none;
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  cursor: pointer;
  padding: 8px;
}

.send-icon {
  width: 24px;
  height: 24px;
  fill: var(--pingan-orange);
}

/* Connect button styling */
.connect-btn {
  background: linear-gradient(45deg, var(--pingan-orange), #ff7b00);
  border: none;
  border-radius: 20px;
  padding: 8px 15px;
  font-size: 14px;
  color: white;
  box-shadow: 0 0 10px rgba(240, 90, 35, 0.3);
  transition: all 0.3s ease;
  cursor: pointer;
  white-space: nowrap;
}

.connect-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 15px rgba(240, 90, 35, 0.4);
}

/*============================================================================*/
/*                            MESSAGE BUBBLE STYLING                          */
/*============================================================================*/
/* Base message bubble styling */
.message-bubble {
  color: white;
  border-radius: 18px;
  padding: 12px 16px;
  margin: 4px 0;
  word-wrap: break-word;
  max-width: 80%;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  line-height: 1.4;
}

/* User message styling - PingAn orange with subtle gradient and border */
.user-message {
  background: linear-gradient(
    135deg,
    rgba(240, 90, 35, 0.7) 0%,
    rgba(237, 24, 107, 0.7) 100%
  );

  /* border: 1px solid rgba(240, 90, 35, 0.3); */
  margin-left: auto;
  margin-right: 12px;
  border-bottom-right-radius: 4px;
  border-top-right-radius: 18px;
  border-top-left-radius: 18px;
  border-bottom-left-radius: 18px;
  text-align: right;
}

/* AI message styling - Discovery pink with subtle gradient and border */
.ai-message {
  background: var(--ai-message-bg);
  margin-right: auto;
  margin-left: 12px;
  border-bottom-left-radius: 4px;
  border-top-right-radius: 18px;
  border-top-left-radius: 18px;
  border-bottom-right-radius: 18px;
  text-align: left;
}

/* TAKEAWAY RECOMMENDATIONS (IN AI BUBBLE) */
.takeaway-recommendations-container {
  display: flex;
  flex-direction: column;
  gap: 12px; /* Consistent gap */
  margin-top: 10px; /* Space below summary text */
}

.takeaway-recommendation-card {
  background-color: rgba(255, 255, 255, 0.04); /* Consistent with .tracking-card */
  border: 1px solid rgba(255, 255, 255, 0.1); /* Consistent with .tracking-card */
  border-radius: 8px; /* Consistent card radius */
  padding: 12px; /* Consistent padding */
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.takeaway-recommendation-card .takeaway-image {
  width: 100%;
  max-width: 200px; /* Max width for the image in column layout */
  height: auto;
  border-radius: 6px; /* Consistent image radius */
  object-fit: cover;
  align-self: center;
  border: 1px solid rgba(255, 255, 255, 0.1); /* Consistent image border */
  margin-bottom: 5px; /* Small space below image before text */
}

.takeaway-recommendation-card .takeaway-info {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 6px; /* Space between info elements */
}

.takeaway-recommendation-card .takeaway-description {
  font-weight: 600; /* Consistent with .meal-title */
  font-size: 0.95rem; /* Consistent with .meal-title */
  color: var(--content-text-color);
  margin: 0;
}

.takeaway-recommendation-card .takeaway-store {
  font-size: 0.85rem; /* Slightly smaller for secondary info */
  color: var(--content-key-text-color);
  margin: 0;
}

.takeaway-recommendation-card .nutrition-details {
  list-style-type: none;
  padding-left: 0;
  margin: 8px 0 0 0; /* Margin above the list */
  font-size: var(--ui-font-size-normal); /* Standard font size */
}

.takeaway-recommendation-card .nutrition-details li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--ui-line-spacing-tight, 2px) 0; /* Tighter padding */
  line-height: var(--ui-line-height-normal, 1.4);
  border-bottom: 1px dashed rgba(255,255,255,0.05); /* Subtle separator */
}
.takeaway-recommendation-card .nutrition-details li:last-child {
  border-bottom: none;
}

.takeaway-recommendation-card .nutrition-details .key {
  color: var(--content-key-text-color);
  margin-right: 8px; /* Space between key and value */
  white-space: nowrap;
}

.takeaway-recommendation-card .nutrition-details .value {
  color: var(--content-text-color);
  font-weight: 500; /* Consistent with other values */
  text-align: right;
}

.takeaway-recommendation-card .takeaway-store .store-link {
  color: var(--pingan-orange); /* Or your preferred link color */
  text-decoration: underline;
  font-weight: 500; /* Make it slightly bolder */
}

.takeaway-recommendation-card .takeaway-store .store-link:hover {
  color: var(--pingan-pink); /* Or a hover color */
  text-decoration: none;
}

/* Responsive layout for wider screens */
@media (min-width: 480px) { /* Adjust breakpoint as needed */
  .takeaway-recommendation-card {
    flex-direction: row;
    align-items: flex-start; /* Align items to the top */
  }
  .takeaway-recommendation-card .takeaway-image {
    width: 100px; /* Fixed width for image */
    height: 100px; /* Fixed height for image */
    max-width: none; /* Override max-width */
    margin-bottom: 0; /* Remove bottom margin in row layout */
    margin-right: 12px; /* Add right margin for spacing */
    align-self: flex-start;
  }
}

/*============================================================================*/
/*                        COLLAPSIBLE PANELS (RIGHT SIDE)                     */
/*============================================================================*/
.collapsible-panel {
  background-color: rgba(255, 255, 255, 0.03);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.panel-header {
  padding: 12px 15px;
  width: 100%;
  text-align: left;
  border: none; 
  border-radius: 8px; 
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  font-size: 1.05rem;
  background-color: transparent; 
  position: relative; 
  transition: border-radius 0.3s ease-in-out, border-bottom 0.3s ease-in-out;
}

/* Apply gradient and text clipping to the span containing the title text */
.panel-header > span:first-child {
  /* Crucial for an inner span to correctly manage its own background for clipping */
  display: inline-block; 

  /* Use the background shorthand, like .app-header.
     This will default background-size to 'auto' and background-repeat to 'repeat'. */
  background: var(--pingan-discovery-color-gradient2);
  
  /* Text clipping properties */
  -webkit-background-clip: text;
  background-clip: text;
  
  /* Make text transparent to show the background gradient through it */
  color: transparent; 
  /* For WebKit, -webkit-text-fill-color is often more robust than just color: transparent */
  -webkit-text-fill-color: transparent;

  /* Ensure no other properties are interfering */
  text-shadow: none; /* Good to keep */
}

.panel-header .arrow-icon {
  transition: transform 0.3s ease-in-out; 
  font-size: 1em; 
  
  /* Arrow icon needs a solid color */
  color: var(--content-key-text-color); 
  -webkit-text-fill-color: currentColor; /* Ensures it uses its own 'color' value */
  
  margin-left: 8px;
  
  /* Reset any inherited background properties from the parent button */
  background-image: none;
  -webkit-background-clip: initial;
  background-clip: initial;
}

.panel-header.active {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

/* Arrow states using ::before pseudo-element */
.panel-header:not(.active) .arrow-icon::before {
  content: '▼'; 
}

.panel-header.active .arrow-icon::before {
  content: '▲'; 
}
.panel-content {
  box-sizing: border-box;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-in-out, padding-top 0.3s ease-in-out, padding-bottom 0.3s ease-in-out;
  background-color: transparent; 
  border-radius: 0 0 8px 8px;
  padding-left: 15px;
  padding-right: 15px;
  padding-top: 0;
  padding-bottom: 0;
}

.panel-content.open {
  max-height: 2500px; /* Adjust as needed, should be larger than any possible content */
  padding-top: 15px;
  padding-bottom: 15px;
}



/*============================================================================*/
/*                        NUTRITION TRACKING CARDS                            */
/*============================================================================*/
.tracking-card {
  background-color: rgba(255, 255, 255, 0.04); /* Card background, distinct from panel content bg */
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 15px;
  color: var(--content-text-color);
}

.tracking-card:last-child {
  margin-bottom: 0;
}

.card-title {
  font-size: 1 rem; /* Slightly smaller than panel header */
  font-weight: 600;
  color: var(--pingan-orange); /* Theme color for card titles */
  margin-bottom: 10px;
}

.tracking-card p {
  font-size: var(--ui-font-size-normal);
  margin-bottom: var(--ui-line-spacing-normal); /* Adjusted */
  color: var(--content-text-color); 
  line-height: var(--ui-line-height-normal);
}
.tracking-card p .text-xs { /* For sub-text like "Baseline:" */
    font-size: 0.75rem; /* Kept smaller for differentiation */
    color: var(--content-key-text-color); /* Corrected variable name */
}
.tracking-card p span { /* For values */
    color: var(--content-text-color); 
    font-weight: 500;
}

/* New styles for Daily Tracking macros */
.macros-display-container {
  display: flex;
  flex-wrap: wrap; /* Allows items to wrap to the next line */
  gap: 6px 12px; /* row-gap column-gap; adjust as needed */
  margin-top: 8px; /* Space above the macros block */
  font-size: var(--ui-font-size-normal);
  /* color: var(--content-key-text-color); /* Label color, if not part of the item text */
}

.macro-item {
  white-space: nowrap; /* Keeps "Protein: 10g (50%)" together on one line */
  color: var(--content-text-color); /* Text color for the macro item */
  /* background-color: rgba(255,255,255,0.05); /* Optional: slight background for each item */
  /* padding: 2px 6px; */
  /* border-radius: 4px; */
}

.progress-bar-container {
    width: 100%;
    background-color: rgba(0, 0, 0, 0.2); /* Darker background for progress bar track */
    border-radius: 5px;
    height: 10px;
    overflow: hidden;
    margin: 8px 0;
}

.progress-bar {
    height: 100%;
    /* background-color: will be set by JS */
    border-radius: 5px;
    transition: width 0.5s ease-in-out, background-color 0.3s ease-in-out; /* Added background-color transition */
    text-align: center;
    color: white;
    font-size: 0.7rem;
    line-height: 10px;
}


.icon-btn { /* For the camera button */
  background-color: transparent;
  border: 2px solid var(--pingan-orange);
  color: var(--pingan-orange);
  padding: 8px; /* Adjust padding */
  border-radius: 50%;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 50px; /* Explicit size */
  height: 50px;
}
.icon-btn:hover {
  background-color: var(--pingan-orange-transparent); /* Use transparent version on hover */
  color: var(--text-color);
}
.icon-btn svg {
  width: 24px; /* Adjust icon size within button */
  height: 24px;
}

.action-btn { /* For "Estimate Nutrition" button */
  background: var(--pingan-discovery-color-gradient2);
  color: white;
  padding: 10px 20px;
  border-radius: 20px;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.action-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(237, 24, 107, 0.4); /* Use theme color for shadow */
}
.action-btn.hidden {
    display: none !important; /* Ensure it's hidden */
}

#selected-files-count {
    color: var(--content-key-text-color); /* Corrected variable name */
    margin-top: 5px;
    font-size: 0.75rem; /* Consistent small size */
}

/*============================================================================*/
/*                        SERVER IMAGE SELECTOR MODAL                         */
/*============================================================================*/
.server-image-selector-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.server-image-selector-modal {
  background: var(--ai-message-bg);
  padding: 25px;
  border-radius: 12px;
  max-width: 400px; /* ✅ Reduced from 450px since no text below images */
  max-height: 85vh;
  overflow-y: auto;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* Custom scrollbar styling (unchanged) */
.server-image-selector-modal {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.server-image-selector-modal::-webkit-scrollbar {
  width: 4px;
}

.server-image-selector-modal::-webkit-scrollbar-track {
  background: transparent;
}

.server-image-selector-modal::-webkit-scrollbar-thumb {
  background-color: rgba(255, 255, 255, 0.2);
  border-radius: 20px;
}

.server-image-selector-modal::-webkit-scrollbar-thumb:hover {
  background-color: rgba(255, 255, 255, 0.3);
}

.server-image-selector-modal h3 {
  color: var(--content-text-color);
  margin: 0 0 20px 0;
  text-align: center;
  font-size: 1.1rem;
}

.server-images-grid {
  display: flex;
  flex-direction: column;
}

.server-image-item {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 15px;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.02);
  transition: background-color 0.2s, border-color 0.2s;
}

.server-image-item:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.2);
}

.server-image-item:has(input:checked) {
  background: var(--pingan-orange-transparent);
  border-color: var(--pingan-orange);
}

.server-image-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--pingan-orange);
}

.server-image-content {
  display: flex;
  justify-content: center; /* ✅ Center the image since no text below */
  align-items: center;
}

.server-image-content img {
  width: 150px;
  height: 150px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

/* ✅ Removed .server-image-time class since we're not showing filenames */

.server-image-selector-buttons {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 20px;
}

.server-image-cancel-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: var(--content-text-color);
  padding: 10px 20px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background-color 0.2s, border-color 0.2s;
}

.server-image-cancel-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.4);
}

.server-image-confirm-btn {
  background: var(--pingan-discovery-color-gradient2);
  color: white;
  padding: 10px 20px;
  border-radius: 20px;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s, box-shadow 0.2s;
}

.server-image-confirm-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(237, 24, 107, 0.4);
}

/*============================================================================*/
/*                     PROCESSED MEAL PHOTO CARDS                             */
/*============================================================================*/
#processed-meal-photos-container {
  display: flex;
  flex-direction: column;
  gap: 12px; /* Space between meal cards */
  margin-top: 15px;
}

.processed-meal-card {
  background-color: rgba(255, 255, 255, 0.04); /* Same as tracking-card bg */
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 12px;
}

.processed-meal-card .meal-title {
  font-weight: 600;
  color: var(--content-text-color); /* Use consistent text color */
  font-size: 0.95rem; /* Consistent with profile section h4 */
  margin-bottom: 8px;
}

.processed-meal-card .meal-image {
  width: 100%;
  max-height: 180px; /* Adjust as needed */
  object-fit: cover;
  border-radius: 6px;
  margin-bottom: 10px;
  border: 1px solid rgba(255,255,255,0.1); /* Subtle border for image */
}

.processed-meal-card .nutrition-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}

.processed-meal-card .total-kj {
  font-size: 1.3rem;
  font-weight: bold;
  color: var(--discovery-pink); /* Highlight total kJ */
}

.processed-meal-card .macros {
  display: flex; /* Changed from grid to flex */
  flex-wrap: wrap; /* Allow wrapping */
  gap: 8px 12px; /* Adjust gap as needed */
  font-size: var(--ui-font-size-normal); /* Standardized font size */
  color: var(--content-key-text-color); /* Use standard key text color for labels */
  margin-bottom: 8px; /* Added margin */
}
.processed-meal-card .macros > div { /* Target direct children for individual macro items */
  white-space: nowrap; /* Keep label and value together */
}
.processed-meal-card .macros span {
  color: var(--content-text-color); /* Use standard content text color for values */
  font-weight: 500;
}

.processed-meal-card .items-list-title {
  font-size: 0.9rem;
  font-weight: 500;
  margin-top: 12px;
  margin-bottom: 6px;
  color: var(--content-key-text-color); /* Corrected variable name */
}

.processed-meal-card .items-container {
    /* Container for items if needed for more styling */
}

.processed-meal-card .item-entry {
  display: flex;
  justify-content: space-between;
  font-size: var(--ui-font-size-normal); /* Standardized font size */
  padding: var(--ui-line-spacing-tight) 0; /* Tighter padding */
  border-bottom: 1px dashed rgba(255,255,255,0.05); /* Very subtle dash */
  line-height: var(--ui-line-height-normal);
}
.processed-meal-card .item-entry:last-child {
  border-bottom: none;
}
.processed-meal-card .item-name {
  color: var(--content-text-color); /* Use standard content text color */
}
.processed-meal-card .item-kj {
  color: var(--content-key-text-color); /* Use standard key text color */
}

/*============================================================================*/
/*                              PROFILE PANEL                               */
/*============================================================================*/
/* Profile data sections (dynamically generated) */

#profile-content-area > p.placeholder-text { /* Target the p tag if it's the direct child */
  color: var(--content-text-color);
  text-align: center;
  width: 100%; 
}

.profile-data-section {
  background-color: var(--ai-message-bg);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 12px;
}

.profile-data-section:last-child {
  margin-bottom: 0;
}

.profile-data-section h4 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--content-text-color); 
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.profile-data-section ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.profile-data-section ul > li + li {
    margin-top: var(--ui-line-spacing-tight); /* Adjusted for tighter spacing */
}

.profile-data-section li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--ui-font-size-normal); /* Standardized font size */
  padding: var(--ui-line-spacing-tight) 0; /* Adjusted for tighter spacing */
  line-height: var(--ui-line-height-normal);
}

.profile-data-section .profile-key {
  font-weight: 500;
  color: var(--content-key-text-color); 
  margin-right: 8px;
  white-space: nowrap;
}

.profile-data-section .profile-value {
  color: var(--content-text-color); 
  text-align: right;
  word-break: break-word;
  white-space: normal; /* Allow normal wrapping for HTML content */
  /* line-height: 1.4;  Add some line spacing for better readability */
}

/*============================================================================*/
/*                         WEEKLY REVIEW PANEL STYLES                         */
/*============================================================================*/
#weekly-review-content-area .action-btn {
  display: block; /* Make button take full width available in its container */
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 20px; /* Add some space below the button */
}

.weekly-summary-layout {
  display: flex;
  gap: 20px;
  align-items: flex-start; /* Align items to the top */
  margin-bottom: 15px;
}

.energy-ring-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 150px; /* Ensure enough space for the ring */
  position: relative; /* For absolute positioning of text */
}

.energy-ring-svg {
  width: 140px;
  height: 140px;
  margin-bottom: 10px;
}

.energy-ring-track {
  stroke: #444; /* Grey track color */
}

.energy-ring-progress {
  stroke: var(--record-green); /* Default progress color, will be changed by JS */
  stroke-linecap: round; /* Makes the ends of the progress arc rounded */
}

.energy-ring-text {
  position: absolute;
  top: 50px; /* Adjusted for 140px SVG height, roughly (140/2 - font_size/2 - stroke_width_approx) */
  left: 50%;
  transform: translateX(-50%);
  font-size: 1.4em; /* Slightly larger text for bigger ring */
  font-weight: bold;
  color: var(--text-color);
  text-align: center;
  pointer-events: none; 
}
.energy-ring-status-text {
  font-size: 0.85em; /* Adjusted size */
  color: var(--content-key-text-color);
  text-align: center;
  margin-top: 0; /* Remove default margin if any, rely on SVG margin-bottom */
}

.weekly-macros-container {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 10px; /* Space between macro bars */
}

.macro-review-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.macro-review-item .macro-name {
  width: 60px; /* Fixed width for macro names */
  font-size: 0.9em;
  color: var(--content-key-text-color);
}

.macro-review-item .progress-bar-container {
  flex-grow: 1;
  height: 16px; 
  background-color: rgba(0, 0, 0, 0.3);
  border-radius: var(--border-radius-small); /* Ensures container is rounded */
  overflow: hidden; /* Crucial for inner bar's radius to be visible correctly */
}

.macro-review-item .progress-bar {
  height: 100%;
  font-size: 0.7em; 
  line-height: 16px; 
  color: white;
  text-align: right;
  padding-right: 5px;
  box-sizing: border-box;
  border-radius: var(--border-radius-small); /* Ensures the fill itself is rounded */
}

#daily-breakdown-bars-container {
  display: flex;
  flex-direction: column;
  gap: 8px; /* Space between daily bars */
}

.daily-energy-bar-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.daily-energy-bar-item .day-label {
  width: 40px; 
  font-size: 0.9em;
  color: var(--content-key-text-color);
  flex-shrink: 0; /* Prevents the label from shrinking, helping alignment */
}

.daily-energy-bar-item .progress-bar-container {
  flex-grow: 1; 
  height: 16px; 
  background-color: rgba(0, 0, 0, 0.3);
  border-radius: var(--border-radius-small); 
  overflow: hidden; 
}
.daily-energy-bar-item .progress-bar {
  height: 100%;
  border-radius: var(--border-radius-small); 
  /* Added text styling for percentage inside the bar */
  font-size: 0.7em; 
  line-height: 16px; /* Match bar height */
  color: white;
  text-align: right;
  padding-right: 5px; /* Space from the right edge of the bar */
  box-sizing: border-box; /* Ensure padding is included in width */
  white-space: nowrap; /* Prevent text from wrapping */
}


/*============================================================================*/
/*                           USER SELECTION PANEL                             */
/*============================================================================*/
.user-selection-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 8px 0;
}

.user-selection-container label {
  font-weight: 600;
  color: var(--text-color);
  font-size: 14px;
}

.user-dropdown {
  padding: 12px 16px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background-color: var(--ai-message-bg); /* Use your existing grey background */
  color: var(--text-color);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.user-dropdown:hover {
  border-color: var(--pingan-orange);
  box-shadow: 0 4px 8px var(--pingan-orange-transparent);
}

.user-dropdown:focus {
  outline: none;
  border-color: var(--pingan-orange);
  box-shadow: 0 0 0 3px var(--pingan-orange-transparent);
}

/* Force dropdown options to use grey background and white text */
.user-dropdown option {
  background-color: var(--ai-message-bg) !important; /* Grey background like panels */
  color: var(--text-color) !important; /* White text */
  padding: 10px !important;
  font-size: 15px !important;
  border: none !important;
}

.user-dropdown option:checked {
  background-color: var(--pingan-orange) !important; /* Orange when selected */
  color: white !important;
}

.user-dropdown option:hover {
  background-color: var(--pingan-orange-transparent) !important; /* Orange tint on hover */
  color: var(--text-color) !important;
}

.user-instruction {
  font-size: 11px;
  color: var(--content-key-text-color);
  text-align: center;
  margin: 0;
  font-style: italic;
}

/* Overwrites for the startup user selection panel */
#startup-screen .user-dropdown {
  background-color: transparent;   /* remove grey */
  box-shadow: none;                 /* optional: no shadow */
}

/* Keep it transparent on hover/focus too (optional) */
#startup-screen .user-dropdown:hover,
#startup-screen .user-dropdown:focus {
  background-color: transparent;
  box-shadow: none;
}


/*============================================================================*/
/*                              DEBUG SECTION                                 */
/*============================================================================*/
/* Debug panel styling */
#debug {
  padding: 10px;
  background-color: rgba(0, 0, 0, 0.8);
  color: #00ff00;
  font-family: monospace;
  font-size: 12px;
  max-height: 200px;
  overflow-y: auto;
  white-space: pre-wrap;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1000;
}

/* General utility class for hiding elements */
.hidden {
  display: none;
}

/*============================================================================*/
/*                            RESPONSIVE DESIGN                               */
/*============================================================================*/
/* Media query for mobile screens */
@media (max-width: 768px) {
  #app-container {
    flex-direction: column;
  }
  
  #chat-section {
    width: 100%;
    height: 100%;
  }
  
  #messages {
    height: calc(100vh - 200px); /* Slightly adjusted for mobile */
  }
  
  #profile-section {
    display: none; /* Hide profile section on mobile */
  }
  
  .input-row {
    padding: 10px;
  }
  
  .connect-btn {
    padding: 6px 12px;
    font-size: 12px;
  }
}