/* Reset and Base Styles */
:root {
  --primary-color: #007bff; /* Bright blue accent */
  --primary-dark: #0056b3;  /* Darker blue for hover */
  --primary-light: #66b3ff; /* Lighter blue for highlights */
  --accent-color: #28a745;  /* Green accent (keep for success) */
  --accent-dark: #1e7e34;   /* Darker green */
  --accent-light: #5cb85c;  /* Lighter green */
  --bg-dark: #000000;    /* Pure black background */
  --bg-medium: #1a1a1a;   /* Very dark gray for cards/panels */
  --bg-light: #333333;    /* Dark gray for buttons/inputs */
  --text-light: #ffffff;  /* Pure white text */
  --text-medium: #cccccc; /* Light gray text */
  --text-muted: #888888;  /* Muted gray text */
  --border-color: #333333; /* Dark borders */
  --border-light: #444444; /* Slightly lighter borders */
  --danger-color: #dc3545;  /* Red for errors */
  
  --border-radius: 0.5rem; 
  --box-shadow: 0 4px 6px -1px rgba(255, 255, 255, 0.1), 0 2px 4px -1px rgba(255, 255, 255, 0.05);
  --sidebar-width: 280px;
  --chat-width: 350px;
  /* Define mobile header height variable */
  --mobile-header-height: 55px; /* Adjust as needed */
}

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

html, body {
  height: 100%;
  width: 100%;
  font-family: 'Inter', sans-serif; /* Using Inter as a clean sans-serif */
  background-color: var(--bg-dark);
  color: var(--text-medium);
  line-height: 1.5;
  overflow: hidden; /* Prevent body scrolling */
  display: flex;
  flex-direction: column; /* Stack mobile header and app container */
}

/* App Container Layout */
.app-container {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr var(--chat-width);
  height: 100%; /* Fill remaining height */
  width: 100%;
  overflow: hidden; /* Prevent scrolling */
}

/* Sidebar Styles */
.sidebar {
  background-color: var(--bg-medium);
  border-right: 1px solid var(--border-color);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  overflow: hidden; /* Prevent sidebar itself from scrolling */
  transition: transform 0.3s ease; /* For mobile slide-in */
}

.sidebar-header {
  padding-bottom: 1rem;
  /* border-bottom: 1px solid var(--border-color); REMOVED - User info has border */
  margin-bottom: 1rem;
  flex-shrink: 0; /* Prevent shrinking */
}

.sidebar-header h2 {
  color: var(--primary-light);
  font-size: 1.5rem;
  font-weight: 700;
  text-align: center;
  letter-spacing: -0.5px;
  margin-bottom: 0.5rem; /* Add some space below title */
}

.sidebar-logo {
  max-width: 150px; /* Slightly smaller than login logo */
  height: auto;
  display: block;
  margin: 0 auto 0.5rem auto; /* Center and add bottom margin */
}

/* User Info Styling in Sidebar */
.user-info {
    padding: 10px;
    text-align: center;
    border-bottom: 1px solid var(--border-color); /* Use theme variable */
    margin-bottom: 1rem; /* Space below user info */
    flex-shrink: 0; /* Prevent shrinking */
}

.user-info img {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    margin-bottom: 5px;
    border: 2px solid var(--primary-light); /* Add a border */
}

.user-info div[style*="background-color"] { /* Target the placeholder div */
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: var(--primary-color); /* Use theme color */
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 5px;
    font-size: 1.5em;
    border: 2px solid var(--primary-light);
}

.user-info h4 {
    margin: 5px 0;
    color: var(--text-light);
}

.user-info p {
    font-size: 0.8em;
    color: var(--text-muted);
    margin: 0;
}

.user-info a.btn-secondary {
    margin-top: 10px;
    display: inline-block;
    padding: 5px 10px;
    font-size: 0.85rem;
}


.sidebar-content {
  /* REMOVED flex: 1 and overflow-y: auto */
  margin-bottom: 1rem;
  display: flex; /* Make this a flex container */
  flex-direction: column; /* Stack actions and nav vertically */
  flex-grow: 1; /* Allow content to grow */
  overflow: hidden; /* Prevent content from overflowing sidebar */
}

.sidebar-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem; /* Reduced gap for tighter buttons */
  margin-bottom: 1.5rem;
  flex-shrink: 0; /* Prevent shrinking */
}

.sidebar-actions .btn {
  width: 100%;
  text-align: center;
  padding: 0.6rem 1rem; /* Slightly reduce padding */
}

.sidebar-actions .btn.active {
    background-color: var(--primary-dark);
    border-color: var(--primary-light);
    color: var(--text-light);
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.5);
}

.navigation-header {
  flex-shrink: 0; /* Prevent shrinking */
}

.navigation-header h3 {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem; /* Reduced margin */
  padding-left: 0.5rem; /* Indent slightly */
}

.workout-nav {
    margin-top: 0.5rem; /* Space above the list */
    flex-grow: 1; /* Allow nav to take remaining space */
    overflow-y: auto; /* Make ONLY the nav scrollable */
    padding-right: 5px; /* Space for scrollbar */
    /* Optional: Add a background to make the list stand out */
    /* background-color: rgba(0, 0, 0, 0.1); */
    /* border-radius: var(--border-radius); */
    /* padding: 0.5rem; */
}

/* Custom scrollbar for workout-nav (optional) */
.workout-nav::-webkit-scrollbar {
  width: 8px;
}

.workout-nav::-webkit-scrollbar-track {
  background: transparent;
}

.workout-nav::-webkit-scrollbar-thumb {
  background-color: var(--border-light);
  border-radius: 10px;
  border: 2px solid var(--bg-medium); 
}

.workout-nav ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.3rem; /* Tighter spacing for list items */
}

.workout-nav li {
  padding: 0.5rem 1rem; /* Slightly reduce padding */
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
  font-size: 0.9rem; /* Slightly smaller font */
  color: var(--text-medium);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border: 1px solid transparent;
}

.workout-nav li:hover {
  background-color: var(--bg-light);
  color: var(--text-light);
}

.workout-nav li.active {
  background-color: var(--primary-color);
  color: var(--text-light);
  font-weight: 500;
}

.date-group-header {
  color: var(--text-muted);
  font-size: 0.85rem; /* Slightly smaller */
  font-weight: 600;
  padding: 0.6rem 0.5rem 0.4rem; /* Adjust padding */
  margin-top: 0.75rem; /* Reduced margin */
  border-bottom: 1px dashed var(--border-light);
  cursor: pointer;
  transition: color 0.2s;
  position: sticky; /* Make date headers stick */
  top: 0;
  background-color: var(--bg-medium); /* Match sidebar background */
  z-index: 1; /* Ensure header is above list items */
}

.date-group-header:hover {
  color: var(--primary-light);
}

.sidebar-footer {
  margin-top: auto; /* Push footer to bottom */
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
  flex-shrink: 0; /* Prevent shrinking */
}

/* Main Content Styles */
.main-content {
  background-color: var(--bg-dark);
  overflow: hidden;
  position: relative; /* For positioning messages */
  height: 100%;
  display: flex; 
  flex-direction: column; 
}

.main-header {
  /* Keeping this minimal for now */
  min-height: 10px;
  flex-shrink: 0;
}

.content-scroll-container {
    flex: 1;
    overflow-y: auto; /* Allow scrolling by default for history and other views */
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
}

/* Prevent scrolling only when workout form is active */
.content-scroll-container:has(#workout-form-section:not(.hidden)) {
    overflow: hidden; /* Prevent scrolling only when workout form is visible */
}

/* Fallback for browsers that don't support :has() - manually control via JavaScript */
.content-scroll-container.workout-form-active {
    overflow: hidden; /* Prevent scrolling when workout form is active */
}

section {
  padding: 0; /* Remove default padding */
  margin-bottom: 2rem;
}

section:last-child {
    margin-bottom: 0;
}

section h2 {
  color: var(--primary-light);
  font-size: 1.6rem;
  margin-bottom: 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

/* Hide sections by default */
section.hidden {
  display: none;
}

/* Form Styles */
form:not(#workout-form) {
  background-color: var(--bg-medium);
  padding: 1.5rem;
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--text-light);
}

input[type="text"],
input[type="date"],
textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 1rem;
  background-color: var(--bg-light);
  color: var(--text-light);
  font-family: 'Inter', sans-serif;
}

textarea {
  min-height: 120px;
  resize: vertical;
}

/* Workout date display styling */
.workout-date-display {
  background-color: var(--bg-light);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 0.75rem;
  color: var(--text-medium);
  font-size: 1rem;
  font-weight: 500;
}

#workout-date-text {
  color: var(--accent-color);
  font-weight: 600;
}

/* Workout Form Header Layout */
.workout-form-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 10px;
  flex-shrink: 0;
  padding: 1rem;
  background-color: var(--bg-dark);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 10;
}

.workout-form-header h2 {
  margin: 0;
  color: var(--primary-color);
  font-size: 1.5rem;
  font-weight: 700;
}

.workout-form-header .workout-date-display {
  background-color: var(--bg-medium);
  border: 1px solid var(--primary-color);
  border-radius: var(--border-radius);
  padding: 6px 12px;
  color: var(--primary-light);
  font-size: 0.9em;
  font-weight: 500;
  white-space: nowrap;
}

/* Compact form styling */
.form-group.compact {
  margin-bottom: 15px;
}

.form-group.compact label {
  font-size: 0.9rem;
  margin-bottom: 5px;
}

.form-group.compact input[type="text"] {
  padding: 8px 12px;
  font-size: 0.95rem;
}

/* Mobile responsive header */
@media (max-width: 768px) {
  .workout-form-header {
    flex-direction: row; /* Align title and date horizontally */
    justify-content: space-between;
    align-items: center;
    padding: 0 1rem; /* Use padding for spacing */
    margin-bottom: 1rem; /* Space below header */
    border-bottom: none; /* No border needed */
    background-color: transparent; /* No background needed */
  }
  
  .workout-form-header .workout-date-display {
    background: none;
    border: none;
    padding: 0;
    font-size: 0.9rem; /* Match label styling */
    font-weight: 500;
    color: var(--text-light); /* Match label styling */
  }
}

/* Ensure the workout form doesn't scroll, only the exercises container does */
#workout-form-section {
  display: flex;
  flex-direction: column;
  flex: 1; /* Take available space in content container */
  overflow: hidden; /* Prevent form from scrolling */
  min-height: 0; /* Allow flex shrinking */
  height: 100%; /* Take full height */
}

#workout-panel {
  /* Styles moved to the desktop media query to prevent mobile conflicts */
}

#workout-form {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-height: 0;
  height: 100%; /* Take full height */
  padding: 0; /* Remove padding from form */
  background-color: var(--bg-medium);
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
  position: relative; /* For absolute positioning of buttons if needed */
}

/* Style the form content wrapper */
#workout-form > input[type="hidden"] {
  display: none;
}

#workout-form > .form-group.compact {
  flex-shrink: 0;
  padding: 1rem 1.5rem 0 1.5rem;
}

/* Make the exercises form group take available space */
.form-group:has(#exercises-container) {
  flex: 1; /* Take remaining space */
  display: flex;
  flex-direction: column;
  min-height: 0; /* Allow flex shrinking */
  overflow: hidden;
  padding: 1rem 1.5rem;
}

.form-group:not(:has(#exercises-container)) {
    flex-shrink: 0;
}

.exercises-container {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1rem;
    background-color: var(--bg-dark);
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 200px;
    max-height: 100%;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.exercises-container:focus-within {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25);
}

.exercises-placeholder {
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  padding: 2rem;
  border: 2px dashed var(--border-color);
  border-radius: var(--border-radius);
  background-color: var(--bg-medium);
}

.exercise-card {
  background-color: var(--bg-medium);
  border: 1px solid var(--border-light);
  border-radius: var(--border-radius);
  padding: 1rem;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.exercise-card:hover {
  border-color: var(--primary-color);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.exercise-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-color);
}

.exercise-card-name {
  font-weight: 600;
  color: var(--text-light); /* White color for exercise names */
  font-size: 1.1rem;
  margin: 0;
}

.exercise-card-summary {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0;
}

.exercise-sets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.set-detail-card {
  background-color: var(--bg-dark);
  padding: 0.75rem;
  border-radius: calc(var(--border-radius) / 2);
  font-size: 0.9rem;
  color: var(--text-medium);
  border: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.set-number {
  font-weight: 600;
  color: var(--primary-light);
  margin-right: 0.5rem;
}

.set-details {
  flex-grow: 1;
}

.exercise-count {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: normal;
}

/* Custom scrollbar for exercises container */
.exercises-container::-webkit-scrollbar {
  width: 8px;
}

.exercises-container::-webkit-scrollbar-track {
  background: var(--bg-medium);
  border-radius: 4px;
}

.exercises-container::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 4px;
}

.exercises-container::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Mobile responsiveness */
@media (max-width: 768px) {
  .exercises-container {
    min-height: 250px;
    max-height: 400px;
  }
  
  .exercise-sets-grid {
    grid-template-columns: 1fr;
  }
  
  .exercise-card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }
}

input[type="text"]:focus,
input[type="date"]:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3); /* White glow */
}

.form-buttons {
  display: flex;
  gap: 1rem;
  flex-shrink: 0; /* Don't shrink buttons */
  padding: 1rem 1.5rem 1.5rem 1.5rem;
  border-top: 1px solid var(--border-color);
  background-color: var(--bg-medium); /* Match form background */
  margin-top: auto; /* Push to bottom */
  z-index: 10; /* Ensure buttons are on top */
}

/* Quick Exercise Toolbar */
.quick-exercise-toolbar {
    margin-bottom: 1.5rem;
    background-color: rgba(0, 0, 0, 0.1);
    padding: 1rem;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-light);
}

.quick-exercise-toolbar h4 {
    color: var(--text-medium);
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.exercise-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.exercise-btn {
    background-color: var(--bg-light);
    color: var(--text-light);
    border: 1px solid var(--border-light);
    padding: 0.5rem 1rem;
    border-radius: 9999px; /* Pill shape */
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.exercise-btn:hover {
    background-color: var(--border-light);
    border-color: var(--text-muted);
    transform: translateY(-1px);
}

.exercise-btn.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-dark);
    transform: scale(1.05);
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3);
}

/* Workout History Styles */
.workout-card {
  background-color: var(--bg-medium);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 1.5rem;
  margin-bottom: 1rem;
  box-shadow: var(--box-shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.workout-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 15px -3px rgba(255, 255, 255, 0.15), 0 4px 6px -2px rgba(255, 255, 255, 0.1);
}

.workout-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-light);
}

.workout-header h3 {
  color: var(--text-light);
  font-size: 1.2rem;
  margin: 0;
  font-weight: 600;
}

.workout-date {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.workout-exercises {
  margin-top: 1rem;
}

.workout-exercises h4 {
  color: var(--text-medium);
  font-size: 1rem;
  margin-bottom: 0.75rem;
}

.workout-exercises ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.workout-exercises li {
  background-color: var(--bg-dark);
  padding: 1rem;
  margin-bottom: 0.75rem;
  border-radius: var(--border-radius);
  border: 1px solid var(--border-light);
}

.workout-notes {
  margin-top: 1rem;
}

.workout-notes h4 {
  color: var(--text-medium);
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

.workout-notes p {
  background-color: var(--bg-dark);
  padding: 0.75rem;
  border-radius: var(--border-radius);
  color: var(--text-medium);
  font-size: 0.95rem;
  line-height: 1.6;
}

.workout-actions {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
}

/* Buttons */
.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--border-radius);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s, box-shadow 0.2s, transform 0.1s;
  text-decoration: none;
  display: inline-block;
}

.btn-primary {
  background-color: var(--primary-color);
  color: white;
}

.btn-primary:hover {
  background-color: var(--primary-dark);
      box-shadow: 0 4px 8px rgba(255, 255, 255, 0.2);
}

.btn-primary:active {
    transform: translateY(1px);
}

.btn-secondary {
  background-color: var(--bg-light);
  color: var(--text-light);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background-color: var(--border-light);
  box-shadow: 0 2px 4px rgba(255, 255, 255, 0.1);
}

/* Modals */
.modal {
  display: none; /* Hidden by default */
  position: fixed;
  z-index: 1001; /* Above overlay */
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.8); 
  align-items: center;
  justify-content: center;
}

.modal-content {
  background-color: var(--bg-medium);
  margin: auto;
  padding: 2rem;
  border: 1px solid var(--border-color);
  width: 90%;
  max-width: 500px;
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
  animation: modalFadeIn 0.3s ease-out;
}

.modal-content h3 {
  color: var(--primary-light);
  margin-top: 0;
  margin-bottom: 1.5rem;
  font-size: 1.4rem;
}

.modal-buttons {
  margin-top: 1.5rem;
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
}

.danger-btn {
  background-color: var(--danger-color);
}

.danger-btn:hover {
  background-color: #dc2626;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Message Styles */
.loading-message, .nav-loading {
  text-align: center;
  color: var(--text-muted);
  padding: 1.5rem;
  font-style: italic;
}

.main-message {
    margin: 1rem 1.5rem;
    padding: 1rem;
    border-radius: var(--border-radius);
    text-align: center;
    font-weight: 500;
}

.error-message {
  color: #fca5a5;
  border: 1px solid #ef4444;
  background-color: rgba(239, 68, 68, 0.1);
}

.success-message {
  color: var(--accent-light);
  border: 1px solid var(--accent-color);
  background-color: rgba(100, 116, 139, 0.1);
}

.info-message {
  color: #93c5fd;
  border: 1px solid #3b82f6;
  background-color: rgba(59, 130, 246, 0.1);
}

/* Simple chat activity indicator - styled like system messages */
.chat-activity-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background-color: var(--bg-light);
  color: var(--text-light) !important;
  margin: 5px auto;
  font-size: 0.9em;
  padding: 8px 12px;
  border-radius: 8px;
  opacity: 1.0;
  text-align: center;
  max-width: 60%;
}

.chat-activity-indicator .activity-spinner {
  flex-shrink: 0;
  color: var(--text-light);
}



.debug-info {
  background-color: rgba(239, 68, 68, 0.1);
  border: 1px solid #ef4444;
  padding: 0.75rem;
  margin-bottom: 1rem;
  border-radius: var(--border-radius);
  color: #fca5a5;
  font-size: 0.9rem;
}

.input-help {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 0.35rem;
  font-style: italic;
}

/* Toggle for potential light/dark mode later */
.light-mode {
  /* Light mode variables would go here */
}

/* View States */
.view-hidden {
  display: none !important;
}

/* Welcome Section */
.welcome-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  height: 70vh;
  max-width: 600px;
  margin: 0 auto;
  padding: 2rem;
}

.welcome-container h2 {
  color: #ffffff !important; /* Pure white for Welcome to CoreTraXis */
  margin-bottom: 1.5rem;
  border-bottom: none;
}

.welcome-container p {
  font-size: 1.1rem;
  color: var(--text-medium);
  line-height: 1.6;
}


/* Workout detail card for selected workout */
.workout-detail-card {
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 2rem;
  background-color: var(--bg-medium);
  margin-bottom: 1.5rem;
  box-shadow: var(--box-shadow);
}

.workout-detail-card .workout-header {
  margin-bottom: 1.5rem;
}

.workout-detail-card .workout-header h2 {
  color: var(--primary-light);
  font-size: 1.6rem;
  margin-bottom: 0.5rem;
  border-bottom: none;
  padding-bottom: 0;
}

.workout-detail-card .workout-date {
  color: var(--text-muted);
  font-size: 1rem;
}

.workout-detail-card h3 {
  color: var(--text-light);
  font-size: 1.3rem;
  margin: 1.5rem 0 1rem;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 0.5rem;
}

.workout-detail-card .workout-exercises ul {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); /* Responsive grid */
    gap: 1.25rem;
    padding: 0;
    list-style: none;
    margin: 1rem 0;
}

.workout-detail-card .exercise-item {
    background-color: var(--bg-dark);
    border: 1px solid var(--border-light);
    border-radius: var(--border-radius);
    padding: 1.25rem;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.workout-detail-card .exercise-sets {
    flex: 1;
    margin-top: 0.75rem;
}

/* Adjust card heights to be equal in each row */
.workout-card {
    margin-bottom: 2rem;
}

.workout-exercises h4,
.workout-detail-card .workout-exercises h3 {
    margin-bottom: 1.25rem;
}

.workout-detail-card .exercise-name {
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--primary-light);
  margin-bottom: 0.5rem;
}

.workout-detail-card .exercise-details,
.workout-detail-card .exercise-weights {
  font-size: 0.95rem;
  color: var(--text-medium);
  margin-top: 0.5rem;
}

.workout-detail-card .workout-notes p {
  background-color: var(--bg-dark);
  padding: 1rem;
  border-radius: var(--border-radius);
  color: var(--text-medium);
  line-height: 1.6;
}

.workout-detail-card .workout-actions {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
}

.exercise-sets {
  margin-top: 0.5rem;
}

.set-detail {
  background-color: var(--bg-dark);
  border: 1px solid var(--border-light);
  border-radius: var(--border-radius);
  padding: 0.5rem 0.75rem;
  margin: 0.25rem 0;
  font-size: 0.9rem;
  color: var(--text-medium);
}

.workout-detail-card .set-detail {
  background-color: var(--bg-medium);
  border-color: var(--border-color);
}

.exercise-name {
  font-weight: 600;
  color: var(--primary-light);
  margin-bottom: 0.25rem;
}

.exercise-summary {
  display: flex;
  gap: 1rem;
  margin: 0.5rem 0;
  color: var(--text-medium);
  font-size: 0.9rem;
}

.avg-reps, .sets-count {
  background-color: var(--bg-dark);
  padding: 0.35rem 0.75rem;
  border-radius: var(--border-radius);
  border: 1px solid var(--border-light);
}

.exercise-sets {
  margin-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.workout-detail-card .avg-reps,
.workout-detail-card .sets-count {
  background-color: var(--bg-medium);
  border-color: var(--border-color);
}

.workout-exercises ul {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.25rem;
    padding: 0;
    list-style: none;
    margin: 1rem 0;
}

.workout-exercises li {
    background-color: var(--bg-dark);
    border: 1px solid var(--border-light);
    border-radius: var(--border-radius);
    padding: 1.25rem;
}

/* Ensure single items don't stretch across both columns */
.workout-exercises li:only-child {
    grid-column: 1;
}

/* Adjust card heights to be equal in each row */
.workout-exercises li {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.exercise-sets {
    flex: 1;
    margin-top: 0.75rem;
}

/* Ensure consistent spacing within cards */
.exercise-name {
    margin-bottom: 0.75rem;
}

.exercise-summary {
    margin: 0.75rem 0;
}

/* Chat Pane */
.chat-pane {
    display: flex;
    flex-direction: column;
    width: 100%; 
    flex-grow: 1; /* Allow chat to take full height */
    background-color: var(--bg-dark);
    border-top: none; /* No top border needed now */
    overflow: hidden; /* Keep overflow hidden within chat pane */
}

@media (min-width: 1024px) {
    .chat-pane {
        width: var(--chat-width);
        flex-grow: 0; /* Reset grow */
        min-height: auto; /* Reset min height */
        max-height: none; /* Reset max height */
        border-left: 1px solid var(--border-color);
        border-top: none; /* Remove top border */
    }
}

.chat-header {
    padding: 1rem;
    background-color: var(--bg-dark);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    position: relative;
    min-height: 60px;
}

.chat-header h2 {
    color: #ffffff !important; /* Pure white for CoreTraXis Assistant */
    font-size: 1.25rem;
    margin: 0;
    font-weight: 600;
    border-bottom: none;
    padding-bottom: 0;
    width: 100%;
    text-align: center;
}

.chat-messages {
    flex: 1; /* Take up available space */
    overflow-y: auto; /* Allow ONLY messages to scroll */
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 100%;
    margin: 0 auto;
}

.message {
    margin: 10px;
    padding: 10px 15px;
    border-radius: 10px;
    max-width: 80%;
    word-wrap: break-word;
}

/* Mobile-specific centering for chat messages */
@media (max-width: 1023px) {
    .chat-messages {
        max-width: 600px; /* Limit chat width on mobile for better readability */
        margin: 0 auto; /* Center the chat conversation */
        padding: 1rem 1.5rem; /* Add more side padding */
    }
    
    .message {
        margin: 10px 0; /* Remove side margins, keep top/bottom */
    }
}

/* Desktop: Keep existing behavior */
@media (min-width: 1024px) {
    .chat-messages {
        max-width: none; /* Reset max-width for desktop */
        margin: 0; /* Reset margin for desktop */
        padding: 1rem; /* Reset padding for desktop */
    }
    
    .message {
        margin: 10px; /* Keep original margins on desktop */
    }
}

.user-message {
    background-color: #4A90E2;
    color: white;
    margin-left: auto;
    border-radius: 15px 15px 0 15px;
}

.assistant-message {
    background-color: var(--bg-light);
    color: var(--text-light);
    margin-right: auto;
    border-radius: 15px 15px 15px 0;
}

.system-message {
    background-color: var(--bg-light);
    color: var(--text-light) !important;
    margin: 5px auto;
    font-size: 0.9em;
    padding: 8px 12px;
    border-radius: 8px;
    opacity: 1.0;
    text-align: center;
    max-width: 60%;
}

/* Use .error-message class for consistency */

/* Set-related message styling enhancements */
.assistant-message .message-content .exercise-name {
    display: inline-block;
    background-color: rgba(52,152,219,0.4);
    color: #fff;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 16px;
}

.assistant-message .message-content .total-sets-label {
    font-weight: 500;
    font-size: 14px;
}

.assistant-message .message-content .sets-count-pill {
    background-color: rgba(52,152,219,0.4);
    color: #fff;
    padding: 0 4px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 16px;
}

.assistant-message .message-content .set-data {
    display: inline-block;
    background-color: rgba(52,152,219,0.4);
    color: #fff;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 16px;
    margin-right: 4px;
}
/* .error-message-chat {
    background-color: #34495E;
    color: #ECF0F1;
    margin: 5px auto;
    font-size: 0.9em;
    padding: 8px 12px;
    border-radius: 8px;
    text-align: center;
    max-width: 60%;
} */

.message .timestamp {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    text-align: right;
}

.chat-input {
    display: flex;
    gap: 0.5rem;
    padding: 1rem;
    background-color: var(--bg-medium);
    border-top: 1px solid var(--border-color);
    flex-shrink: 0; /* Prevent input area from shrinking */
}

#message-input {
    flex: 1;
    padding: 0.75rem;
    border: none;
    border-radius: 0.5rem;
    background-color: var(--bg-light);
    color: var(--text-light);
    resize: none;
    min-height: 2.5rem;
    max-height: 6rem;
}

#message-input:focus {
    outline: none;
    border-color: transparent;
    box-shadow: none;
}

#send-message {
    padding: 0.75rem 1.5rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

#send-message:hover {
    background-color: var(--primary-dark);
}

#send-message:disabled {
    background-color: var(--border-color);
    cursor: not-allowed;
}


/* Responsive Design - Mobile First Refinements */
.home-button {
    display: none;
}

/* Styling for the Delete Workout button */
.delete-workout-btn {
    background-color: #dc3545; /* Bootstrap danger red */
    color: white;
    border: none; 
    padding: 8px 15px; 
    border-radius: 4px; 
    cursor: pointer;
    transition: background-color 0.2s ease;
    display: inline-block; /* Ensure it behaves like a button */
    font-size: 0.9rem; /* Adjust size */
}

.delete-workout-btn:hover {
    background-color: #c82333; /* Darker red for hover */
}

/* Workout History Container */
#workout-history-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  height: 100%; /* Take full available height */
  overflow-y: auto; /* Allow the container to scroll for sticky positioning */
  max-height: 100%;
  min-height: 0;
}

#workout-list {
  flex: 1; /* Take remaining space */
  overflow: visible; /* Let parent container handle scrolling */
  min-height: 0; /* Allow flex shrinking */
}

/* Custom scrollbar for workout history container */
#workout-history-container::-webkit-scrollbar {
  width: 8px;
}

#workout-history-container::-webkit-scrollbar-track {
  background: var(--bg-dark);
  border-radius: 4px;
}

#workout-history-container::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 4px;
}

#workout-history-container::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* History Filter Controls - Compact Version */
.history-filter-controls {
  position: sticky;
  top: 0;
  z-index: 10; /* Ensure it stays above workout cards */
  background-color: var(--bg-medium);
  border-radius: var(--border-radius);
  padding: 0.5rem; /* Reduced from 1rem */
  margin-bottom: 0.75rem; /* Reduced from 1.5rem */
  box-shadow: var(--box-shadow);
  flex-shrink: 0; /* Prevent filters from shrinking */
}

/* Filter Header with Toggle Button */
.filter-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
}

/* Filter toggle button - mobile only */
.filter-toggle-btn {
  background: none;
  border: none;
  color: var(--primary-light);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: var(--border-radius);
  transition: all 0.2s ease;
  font-size: 0.9rem;
}

.filter-toggle-btn:hover {
  background-color: var(--bg-light);
  color: var(--text-light);
}

.filter-toggle-btn .toggle-icon {
  display: inline-block;
  transition: transform 0.3s ease;
  font-size: 0.8rem;
  margin-left: 0.25rem;
}

/* Rotate icon when expanded */
.filter-toggle-btn.expanded .toggle-icon {
  transform: rotate(180deg);
}

/* Filter content container */
.filter-content {
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.3s ease;
}

/* Collapsed state - mobile only */
@media (max-width: 768px) {
  .filter-content.collapsed {
    max-height: 0;
    opacity: 0;
    margin-bottom: 0;
  }
  
  .filter-content:not(.collapsed) {
    max-height: 500px; /* Generous max height for smooth animation */
    opacity: 1;
  }
}

/* On desktop, always show filters */
@media (min-width: 769px) {
  .filter-toggle-btn {
    display: none !important;
  }
  
  .filter-content {
    max-height: none !important;
    opacity: 1 !important;
  }
  
  .filter-header {
    margin-bottom: 0.4rem;
  }
}

.history-filter-controls h4 {
  color: var(--text-light);
  margin: 0;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 0.25rem; /* Reduced from 0.5rem */
  font-size: 0.9rem; /* Smaller font */
}

.filter-section {
  margin-bottom: 0.25rem; /* Reduced from 0.5rem */
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.5rem; /* Reduced from 1rem */
  margin-bottom: 0.5rem; /* Reduced from 1rem */
}

.date-filter-row {
  margin-bottom: 0.5rem; /* Reduced from 1.25rem */
}

.filter-row .form-group {
  flex: 1;
  min-width: 140px; /* Reduced from 200px */
  margin-bottom: 0;
}

.filter-row .form-group label {
  font-size: 0.8rem; /* Smaller labels */
  margin-bottom: 0.25rem; /* Reduced spacing */
}

.filter-row select,
.filter-row input[type="date"] {
  width: 100%;
  padding: 0.4rem 0.5rem; /* Reduced from 0.75rem */
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 0.9rem; /* Smaller font */
  background-color: var(--bg-light);
  color: var(--text-light);
  font-family: 'Inter', sans-serif;
  height: 2.2rem; /* Set consistent height */
}

.filter-row select:focus,
.filter-row input[type="date"]:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25);
}

.filter-row button {
  padding: 0.4rem 0.75rem; /* Reduced from 0.75rem 1rem */
  margin-bottom: 0;
  white-space: nowrap;
  font-size: 0.9rem; /* Smaller font */
  height: 2.2rem; /* Match input height */
}

.filter-actions {
  display: flex;
  justify-content: flex-start;
  gap: 0.5rem; /* Reduced from 1rem */
  margin-top: 0.25rem; /* Reduced from 0.5rem */
}

#clear-filters {
  background-color: var(--primary-dark);
  min-width: 80px; /* Reduced from 120px */
  transition: all 0.2s ease-in-out;
  color: white;
  font-size: 0.85rem; /* Smaller font */
  padding: 0.35rem 0.6rem; /* More compact padding */
}

#clear-filters:hover {
  background-color: var(--accent-color);
}

#clear-filters:active {
  background-color: var(--primary-dark);
  transform: translateY(2px);
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.5);
}

#clear-filters.active {
  background-color: var(--primary-color);
  color: var(--text-light);
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.5);
}

/* Enhanced workout card styles */
.workout-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 0.75rem;
  background-color: var(--bg-dark);
  border-radius: var(--border-radius);
}

.summary-stat {
  display: flex;
  flex-direction: column;
  min-width: 120px;
  flex: 1;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.stat-value {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-light);
}

.exercise-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.exercise-volume {
  font-size: 0.9rem;
  color: var(--primary-light);
  font-weight: 500;
}

.filtered-count {
  margin-top: 1rem;
  text-align: right;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-style: italic;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border-light);
}

/* Add a simple overlay for when sidebar/content is open */
.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000; /* Below sidebar, above main content potentially */
}

.overlay.show {
    display: block;
}

/* Mobile Header Styles */
.mobile-header {
    display: flex; /* Use flex for alignment */
    justify-content: space-between; /* Space out items */
    align-items: center; /* Vertically align items */
    padding: 0.5rem 0.75rem; /* Padding */
    background-color: var(--bg-medium); /* Background color */
    border-bottom: 1px solid var(--border-color); /* Separator line */
    position: sticky; /* Keep it at the top */
    top: 0;
    z-index: 1002; /* Above other elements */
    height: var(--mobile-header-height); /* Assign height */
}

.mobile-nav-btn {
    background: none; /* Transparent background */
    border: none; /* No border */
    color: var(--primary-light); /* Text color */
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.mobile-nav-btn span { /* Style for icon */
    font-size: 1.2rem;
}

.mobile-nav-btn:hover {
    color: var(--text-light);
}

.mobile-title {
    color: #ffffff !important; /* Pure white for CoreTraXis Assistant */
    font-weight: 600;
    font-size: 1.1rem;
}

/* Hide mobile header on larger screens */
@media (min-width: 1024px) {
    .mobile-header {
        display: none;
    }
}

/* App Container - Mobile First Layout */
.app-container {
  display: flex; /* Use flexbox for stacking */
  flex-direction: column; /* Stack vertically by default */
  flex-grow: 1; /* Allow app container to grow and fill body */
  overflow: hidden; /* Prevent the container itself from scrolling */
  height: calc(100% - var(--mobile-header-height)); /* Adjust height */
}

/* Sidebar Behavior - Mobile First */
.sidebar {
    position: fixed;
    top: var(--mobile-header-height); /* Position below mobile header */
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    max-width: 80%; /* Limit width on mobile */
    transform: translateX(-100%);
    transition: transform 0.3s ease-in-out;
    z-index: 1001;
    /* padding-top: calc(var(--mobile-header-height, 50px) + 1rem); REMOVED - Now positioned below */
    padding-top: 1rem; /* Restore original padding */
}

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

/* Main Content & Chat Pane Behavior - Mobile */
.main-content {
    width: 100%;
    height: 100%; /* Take full height */
    overflow-y: auto; /* Allow scrolling */
    display: none; /* Initially hidden */
}

.chat-pane {
    width: 100%;
    height: 100%; /* Take full height */
    display: flex; /* Ensure chat takes full height as flex */
    flex-direction: column; /* Stack chat elements vertically */
    overflow: hidden; /* Keep chat pane contained */
}

/* Container state for showing content view */
.app-container.show-content-view .main-content {
    display: block; /* Show main content when view toggled */
}

.app-container.show-content-view .chat-pane {
    display: none; /* Hide chat when main content is shown */
}

/* Default state - show chat */
.app-container:not(.show-content-view) .chat-pane {
    display: flex; /* Show chat by default */
}

.app-container:not(.show-content-view) .main-content {
    display: none; /* Hide main content by default */
}

/* Desktop Layout Overrides */
@media (min-width: 1024px) {
    .app-container {
        display: grid;
        grid-template-columns: var(--sidebar-width) 1fr var(--chat-width);
        overflow: hidden; /* Revert overflow for grid */
        flex-direction: row; /* Revert to row layout */
        height: 100vh; /* Revert to full viewport height */
    }
    
    .sidebar {
        position: static; /* Revert fixed positioning */
        transform: translateX(0); /* Always visible */
        max-width: none; /* Remove max width */
        padding-top: 1rem; /* Reset padding */
        height: 100%; /* Fill grid row height */
        order: 0; /* Reset order */
        border-right: 1px solid var(--border-color); /* Add back border */
    }

    .main-content {
        display: block !important; /* Always show main content */
        order: 0; /* Reset order */
        height: 100%; /* Ensure it fills grid area */
        overflow-y: auto; /* Allow main content to scroll */
    }

    .chat-pane {
        display: flex !important; /* Always show chat pane */
        order: 0; /* Reset order */
        height: 100%; /* Ensure it fills grid area */
        overflow: hidden; /* Keep chat pane contained */
    }

    .overlay {
        display: none !important; /* Overlay not needed on desktop */
    }

    #workout-panel {
        grid-column: 1 / 2;
        display: flex !important;
        flex-direction: column;
        flex: 1;
        overflow: hidden;
        min-height: 0;
        height: 100%;
    }
    
    #exercise-history-panel {
        grid-column: 2 / 3;
        display: flex !important; 
        height: calc(100vh - 4rem);
        min-height: 500px;
    }
} 

.connection-indicator{
    width:10px;height:10px;border-radius:50%;
    background:#fbbf24;          /* amber = "connecting" (default) */
    margin-left:8px;display:inline-block;
}
.connected    { background:#10b981; }   /* green   */
.disconnected { background:#ef4444; }   /* red     */

/* Chat Message Action Buttons */
.message-content {
  margin-bottom: 8px;
}

.message-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
  opacity: 0.7;
  transition: opacity 0.2s ease;
  max-width: 280px;
  margin-left: auto;
}

/* Menu-only actions (single button) - position on the right */
.message-actions.menu-only {
  display: flex;
  justify-content: flex-end;
  max-width: none;
}

/* Cancel + Menu layout (two buttons centered on same row) */
.message-actions.cancel-menu-layout {
  display: flex !important;
  justify-content: center !important;
  align-items: flex-start !important;
  gap: 12px !important;
  max-width: none !important;
  margin: 8px auto 0 auto !important;
  width: 100% !important;
}

.message-actions.cancel-menu-layout .action-btn {
  vertical-align: top !important;
}

.message:hover .message-actions {
  opacity: 1;
}

.action-btn {
  background-color: var(--bg-light);
  border: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 14px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Icon-style action buttons (circular) */
.action-btn.action-icon {
  border-radius: 50%;
  width: 32px;
  height: 32px;
}

/* Base text-style action buttons (rectangular) */
.action-btn.action-text {
  border-radius: 8px;
  padding: 8px 12px;
  min-width: 64px;
  height: 36px;
  font-weight: 600;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Primary action buttons - main workflow actions (NEXT, DONE) */
.action-btn.action-primary {
  background: #666666;
  color: #fff;
  border: none;
}

/* Secondary action buttons - supporting actions (REPEAT) */
.action-btn.action-secondary {
  background: var(--bg-light);
  color: var(--text-light);
  border: 2px solid var(--border-light);
}

.action-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.action-btn.action-primary:hover {
  background-color: rgba(255, 255, 255, 0.1); /* Subtle light gray fill */
}

.action-btn.action-secondary:hover {
  background-color: rgba(255, 255, 255, 0.08); /* Subtle light gray fill */
  border-color: var(--border-light);
  color: var(--text-light);
}

/* Enhanced active states */
.action-btn.action-primary:active,
.action-btn.action-secondary:active {
  filter: brightness(0.9);
  transform: translateY(1px);
}

/* Menu dropdown container */
.action-menu {
  position: relative;
  display: inline-block;
}

/* Dropdown content */
.dropdown-content {
  display: none;
  position: absolute;
  bottom: 100%;
  right: 0;
  background-color: #ffffff;
  min-width: 180px;
  box-shadow: 0 8px 16px rgba(0,0,0,0.2);
  border-radius: 8px;
  z-index: 1000;
  border: 1px solid #e1e9f2;
  margin-bottom: 8px;
}

/* Show dropdown when active */
.action-menu.active .dropdown-content {
  display: block;
}

/* Dropdown items */
.dropdown-item {
  color: #333;
  padding: 12px 16px;
  text-decoration: none;
  display: block;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 6px;
  margin: 4px;
  transition: background-color 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Dropdown item hover */
.dropdown-item:hover {
  background-color: #f0f4f8;
  color: #005bbb;
}

/* Cancel workout item styling */
.cancel-workout-item {
  color: #dc2626 !important; /* Red text */
  border: 1px solid transparent;
}

.cancel-workout-item:hover {
  background-color: #fef2f2 !important; /* Light red background */
  color: #dc2626 !important; /* Keep red text */
  border-color: #fca5a5; /* Light red border */
}

/* Cancel holding state */
.cancel-holding {
  background-color: #dc2626 !important; /* Red background */
  color: white !important; /* White text */
  animation: pulse-red 0.5s infinite alternate;
}

@keyframes pulse-red {
  0% { opacity: 0.8; }
  100% { opacity: 1; }
}

/* Undo button styling */
.undo-btn {
  background-color: #f59e0b !important; /* Amber background */
  color: white !important;
  border-color: #d97706 !important; /* Darker amber border */
}

.undo-btn:hover {
  background-color: #d97706 !important; /* Darker amber on hover */
  border-color: #b45309 !important;
}

/* Menu button styling - use same size as other text buttons */
.action-btn.menu-btn {
  /* Removed custom font-size to match other action-text buttons */
}

/* Previous sets expand/collapse functionality */
.previous-sets-container {
  margin: 0;
}

.previous-sets-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.toggle-sets {
  background: none;
  border: 1px solid var(--border-light);
  color: var(--text-light);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.toggle-sets:hover {
  background-color: rgba(255, 255, 255, 0.08);
  border-color: var(--border-light);
}

.previous-sets-content {
  transition: all 0.2s ease-out;
  overflow: hidden;
}

.previous-sets-content.expanded {
  display: block !important;
}

/* ADD EXERCISE button styling - light blue fill with darker hover */
.action-btn.next-btn {
  background-color: rgba(52, 152, 219, 0.2) !important; /* Lighter blue default */
}

.action-btn.next-btn:hover {
  background-color: rgba(52, 152, 219, 0.4) !important; /* Darker blue hover */
}

/* REPEAT SET button styling - light green fill with darker hover */
.action-btn.repeat-btn {
  background-color: rgba(34, 197, 94, 0.2) !important; /* Lighter green default */
}

.action-btn.repeat-btn:hover {
  background-color: rgba(34, 197, 94, 0.4) !important; /* Darker green hover */
}

/* SAVE button styling - same green as repeat button */
.action-btn.action-save {
  background-color: rgba(34, 197, 94, 0.2) !important; /* Same green as repeat button */
  color: #fff;
  border: none;
}

.action-btn.action-save:hover {
  background-color: rgba(34, 197, 94, 0.4) !important; /* Same green hover as repeat button */
}

/* Cancel and Delete button styling - light red fill with darker hover */
.action-btn.cancel-btn,
.action-btn.delete-btn {
  background-color: rgba(239, 68, 68, 0.2) !important; /* Lighter red default */
}

.action-btn.cancel-btn:hover,
.action-btn.delete-btn:hover {
  background-color: rgba(239, 68, 68, 0.4) !important; /* Darker red hover */
}

/* Removed old delete-btn:hover - now handled by .action-btn.delete-btn:hover above */

.action-btn:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Only show action buttons on assistant messages */
.user-message .message-actions,
.system-message .message-actions {
  display: none;
}

/* Make sure action buttons work well on mobile */
@media (max-width: 768px) {
  .action-btn.action-icon {
    width: 28px;
    height: 28px;
    font-size: 12px;
  }
  
  .action-btn.action-text {
    font-size: 0.8rem;
    padding: 6px 8px;
    min-width: 50px;
    height: 32px;
    letter-spacing: 0.2px;
  }
  
  .message-actions {
    gap: 4px;
  }
  
  /* Mobile dropdown adjustments */
  .dropdown-content {
    min-width: 160px;
    box-shadow: 0 6px 12px rgba(0,0,0,0.25);
  }
  
  .dropdown-item {
    padding: 10px 12px;
    font-size: 0.85rem;
  }
}

/* Suggestion buttons container */
.suggestion-buttons {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
}

/* Individual suggestion buttons */
.suggestion-btn {
    background: linear-gradient(135deg, #4A90E2 0%, #357ABD 100%);
    border: 1px solid #2E5A87;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 500;
    color: #ffffff !important;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    width: 100%;
    white-space: normal;
    word-wrap: break-word;
    line-height: 1.3;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    max-width: 100%;
}

/* Additional specificity for suggestion button text */
.message .suggestion-btn,
.suggestion-buttons .suggestion-btn {
    color: #ffffff !important;
}

.suggestion-btn:hover {
    background: linear-gradient(135deg, #357ABD 0%, #2E5A87 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.3);
}

.suggestion-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(74, 144, 226, 0.2);
}

/* Exercise selection buttons container */
.exercise-buttons {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
}

/* Individual exercise buttons */
.exercise-btn {
    background: linear-gradient(135deg, #e0f2fe 0%, #b3e5fc 100%);
    border: 1px solid #4fc3f7;
    border-radius: 10px;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 600;
    color: #01579b;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    width: 100%;
    white-space: normal;
    word-wrap: break-word;
    line-height: 1.3;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    max-width: 100%;
}

.exercise-btn:hover {
    background: linear-gradient(135deg, #b3e5fc 0%, #81d4fa 100%);
    border-color: #29b6f6;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(66, 165, 245, 0.25);
}

.exercise-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(66, 165, 245, 0.15);
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    .suggestion-buttons {
        gap: 8px;
        margin-top: 12px;
        width: 100%;
    }
    
    .suggestion-btn {
        padding: 12px 16px;
        font-size: 14px;
        border-radius: 10px;
        min-height: 44px;
        line-height: 1.3;
        width: 100%;
        max-width: 100%;
    }
}

/* Large screen layout - keep vertical stacking to fit message width */
@media (min-width: 768px) {
    .suggestion-buttons {
        /* Keep vertical layout to respect message bubble width */
        flex-direction: column;
        gap: 10px;
        max-width: 100%;
    }
    
    .suggestion-btn {
        width: 100%;
        max-width: 100%;
        min-width: auto;
        font-size: 14px;
        padding: 12px 16px;
    }
}

/* Exercise History Panel Styles */
.workout-form-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden; /* Prevent container from scrolling */
}

/* Mobile/Desktop Responsive Classes */
.mobile-only {
    display: block;
}

.desktop-only {
    display: none;
}

@media (min-width: 768px) {
    .mobile-only {
        display: none !important;
    }
    
    .desktop-only {
        display: block !important;
    }
    
    .workout-form-container {
        display: grid;
        grid-template-columns: 1fr 350px;
        gap: 1.5rem;
        height: 100%; /* Changed from calc(100vh - 3rem) */
        align-items: start;
        overflow: hidden; /* Prevent container from scrolling */
    }
    
    /* Ensure workout panel takes full space on desktop */
    #workout-panel {
        display: flex !important; /* Changed to flex */
        flex-direction: column;
        grid-column: 1;
        height: 100%;
        overflow: hidden;
    }
    
    /* Position history panel in second column */
    #exercise-history-panel {
        grid-column: 2;
        position: sticky;
        top: 1rem;
        height: calc(100vh - 4rem);
    }
}

/* Mobile Tabs */
.mobile-tabs {
    display: flex;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

@media (min-width: 768px) {
    .mobile-tabs {
        display: none !important;
    }
}

.tab-btn {
    flex: 1;
    padding: 0.6rem;
    background: var(--bg-medium);
    border: none;
    color: var(--text-medium);
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
    font-size: 0.9rem;
}

.tab-btn.active {
    color: var(--primary-light);
    border-bottom-color: var(--primary-color);
    background: var(--bg-light);
}

.tab-btn:hover {
    background: var(--bg-light);
    color: var(--text-light);
}

/* Tab Content */
.tab-content {
    /* This rule is now handled inside the mobile media query for clarity */
}

.tab-content.active {
   /* This rule is now handled inside the mobile media query for clarity */
}

/* History Panel Styles */
.history-panel {
    background-color: var(--bg-medium);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    height: 100%;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

@media (min-width: 768px) {
    .history-panel {
        height: calc(100vh - 4rem);
        min-height: 500px;
    }
}

@media (max-width: 767px) {
    .history-panel {
        max-height: 70vh;
    }
}

/* History Panel Header */
.history-header {
    flex-shrink: 0;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
}

.history-panel h3 {
    color: var(--primary-light);
    margin: 0 0 0.5rem 0;
    font-size: 1.2rem;
}

.exercise-subtitle {
    margin: 0;
    font-size: 0.95rem;
    color: var(--text-medium);
    font-weight: 500;
}

.exercise-subtitle .exercise-name {
    color: var(--text-light);
    font-weight: 600;
}

/* History Content Area */
.history-content-scrollable {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.history-entry {
    background-color: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1rem;
    margin-bottom: 1rem;
    transition: all 0.2s;
}

.history-entry:hover {
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

.history-entry:last-child {
    margin-bottom: 0;
}

.history-date {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.history-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.history-sets {
    color: var(--accent-color);
    font-weight: 600;
}

.history-volume {
    color: var(--text-medium);
    font-size: 0.9rem;
}

.history-sets-detail {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.history-set {
    background-color: var(--bg-light);
    padding: 0.4rem 0.6rem;
    border-radius: 4px;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-light);
}

.history-loading {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem;
    font-style: italic;
}

.history-error {
    text-align: center;
    color: var(--danger-color);
    padding: 1rem;
    background-color: rgba(239, 68, 68, 0.1);
    border-radius: var(--border-radius);
    border: 1px solid var(--danger-color);
}

.history-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem;
    font-style: italic;
    background-color: var(--bg-dark);
    border-radius: var(--border-radius);
    border: 1px dashed var(--border-color);
}

/* Mobile History Panel Adjustments */
@media (max-width: 767px) {
    #history-panel {
        max-height: 400px;
    }
    
    .history-sets-detail {
        grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    }
    
    .history-set {
        font-size: 0.8rem;
        padding: 0.3rem 0.5rem;
    }
}

@media (max-width: 768px) {
    /* --- Mobile Tab Layout Rules --- */
    #workout-form-section {
        display: flex;
        flex-direction: column;
        height: 100%;
        overflow: hidden;
    }

    .workout-form-container {
        display: flex;
        flex-direction: column;
        flex: 1;
        min-height: 0;
    }

    .tab-content {
        display: none; /* Hide all panels by default on mobile */
        flex: 1;
        min-height: 0;
        overflow-y: auto; /* Allow individual panels to scroll */
    }

    .tab-content.active {
        display: flex; /* Show only the active panel */
        flex-direction: column;
    }
    
    #workout-panel.active {
        overflow: hidden; /* The form inside handles its own scrolling */
    }

    /* --- New Mobile Layout Overrides --- */
    #workout-form {
        background-color: transparent; /* Remove the card background from the form wrapper */
        box-shadow: none;
        padding: 0;
    }

    #workout-form > .form-group.compact {
        padding: 1rem 1rem 0 1rem; /* Adjust padding for title outside card */
    }

    .form-group:has(#exercises-container) {
        flex: 1;
        padding: 1rem;
        background-color: var(--bg-medium);
        border-radius: var(--border-radius) var(--border-radius) 0 0; /* Top corners rounded */
        margin-bottom: 0;
    }
    
    .form-buttons {
        background-color: var(--bg-medium);
        border-radius: 0 0 var(--border-radius) var(--border-radius); /* Bottom corners rounded */
        padding: 1rem;
        border-top: 1px solid var(--border-color);
    }
    
    .exercises-container {
        flex-grow: 1; /* Ensure it takes up available space */
    }

    /* Mobile responsive adjustments for workout history */
    .history-filter-controls {
        margin-bottom: 0.5rem; /* Further reduced for mobile */
        padding: 0.4rem; /* Even more compact on mobile */
    }
}

/* Additional mobile fixes for horizontal movement */
@media (max-width: 768px) {
    /* Prevent horizontal overflow in filter controls */
    .filter-row .form-group {
        flex: 1;
        min-width: 0; /* Remove fixed min-width that can cause overflow */
        margin-bottom: 0;
    }
    
    .filter-row select,
    .filter-row input[type="date"] {
        min-width: 0; /* Ensure inputs can shrink */
        width: 100%;
    }
    
    /* Prevent horizontal overflow in workout summary stats */
    .summary-stat {
        min-width: 0; /* Remove fixed min-width */
        flex: 1;
    }
    
    /* Ensure workout cards don't cause horizontal scrolling */
    .workout-card {
        width: 100%;
        box-sizing: border-box;
        max-width: 100%;
        overflow-x: hidden;
    }
    
    /* Prevent workout history container from horizontal scrolling */
    #workout-history-container {
        overflow-x: hidden; /* Prevent horizontal scrolling */
        width: 100%;
        max-width: 100%;
    }
    
    /* Ensure all child elements respect container width */
    #workout-list {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }
    
    /* Fix any flex items that might overflow */
    .filter-row {
        flex-wrap: wrap;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    /* Ensure filter actions don't overflow */
    .filter-actions {
        width: 100%;
        max-width: 100%;
        flex-wrap: wrap;
    }
}

/* ===== MICRO-INPUTS FOR WORKOUT COMPLETION ===== */

.workout-completion-enhanced {
    background: var(--bg-medium);
    border-radius: var(--border-radius);
    padding: 16px;
    margin: 8px 0;
    border: 1px solid var(--border-color);
    position: relative;
    overflow: visible;
}

.workout-completion-enhanced h4 {
    color: var(--text-light);
    margin: 0 0 12px 0;
    font-size: 16px;
    font-weight: 600;
}

.micro-inputs-section {
    background: var(--bg-dark);
    border-radius: calc(var(--border-radius) * 0.75);
    padding: 14px;
    margin: 12px 0 16px 0;
    border: 1px solid var(--border-light);
    position: relative;
    overflow: visible;
}

.micro-inputs-section h5 {
    margin: 0 0 8px 0;
    color: var(--text-medium);
    font-size: 13px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.micro-input-row {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    margin: 10px 0;
    gap: 6px;
}

.micro-label {
    font-size: 14px;
    color: var(--text-medium);
    font-weight: 500;
    text-align: left;
}

.micro-dropdown {
    background: var(--bg-light);
    border: 1px solid var(--border-light);
    border-radius: 4px;
    color: var(--text-light);
    padding: 8px 30px 8px 12px;
    font-size: 13px;
    font-weight: 500;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    cursor: pointer;
    transition: all 0.2s ease;
    appearance: none;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 16px 16px;
}

.micro-dropdown:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

.micro-dropdown:hover {
    border-color: var(--border-light);
    background: var(--bg-medium);
}

.micro-dropdown option {
    background: var(--bg-light);
    color: var(--text-light);
    padding: 4px;
}

.save-options-section {
    margin-top: 16px;
}

.save-options-section p {
    color: var(--text-light);
    font-size: 14px;
    font-weight: 500;
    margin: 0 0 8px 0;
}

.save-options-section ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.save-options-section li {
    color: var(--text-medium);
    font-size: 13px;
    margin: 4px 0;
    padding-left: 16px;
    position: relative;
}

.save-options-section li::before {
    content: "•";
    color: var(--primary-color);
    position: absolute;
    left: 0;
    font-weight: bold;
}

/* Micro-Inputs Summary (after save) */
.micro-inputs-summary {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 14px;
    background: var(--bg-dark);
    border: 1px solid rgba(40, 167, 69, 0.4);
    border-radius: calc(var(--border-radius) * 0.75);
    margin: 12px 0 16px 0;
}

.summary-icon {
    font-size: 16px;
    margin-top: 1px;
    flex-shrink: 0;
    color: var(--accent-color);
}

.summary-text {
    flex: 1;
}

.summary-text p {
    margin: 0 0 8px 0;
    color: var(--text-medium);
    font-size: 13px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.feedback-summary-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.feedback-summary-list li {
    color: var(--text-light);
    font-size: 13px;
    font-weight: 500;
    margin: 6px 0;
    padding: 6px 10px;
    background: var(--bg-light);
    border: 1px solid var(--border-light);
    border-radius: 4px;
}

/* Mobile Responsiveness for Micro-Inputs */
@media (max-width: 768px) {
    .workout-completion-enhanced {
        padding: 12px;
    }
    
    .micro-inputs-section {
        padding: 10px;
    }
    
    .micro-label {
        font-size: 13px;
    }
    
    .micro-dropdown {
        padding: 6px 10px;
        font-size: 12px;
    }
}

