/* Final UI Fixes - Header Overlap and Workout Builder Modal */

/* ============================================
   1. FIX HEADER OVERLAP ON ALL PAGES
   ============================================ */

/* Base body padding adjustment */
body {
  padding-top: 80px !important; /* Increased from 70px to prevent overlap */
  margin: 0;
  overflow-x: hidden;
}

/* Specific page adjustments */
.dashboard-page,
.workout-builder-page,
.generate-page,
.history-page,
.profile-page {
  padding-top: 0 !important; /* Reset individual page padding */
}

/* Main content padding */
.dashboard-main,
.workout-builder-main,
.main-content,
main {
  padding-top: 20px; /* Add extra padding to main content */
}

/* Fixed header height consistency */
.site-header {
  height: 70px;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
}

/* ============================================
   2. WORKOUT BUILDER MODAL - DESKTOP FIXES
   ============================================ */

/* Modal container - full viewport without scroll */
@media (min-width: 992px) {
  .modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
  }
  
  .modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 1200px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  
  .modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
  }
  
  .modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
  }
  
  /* Sets container for desktop - single page view */
  .sets-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }
  
  .sets-header {
    display: grid;
    grid-template-columns: 60px 120px 120px 120px 120px 60px;
    gap: 12px;
    padding: 8px 0;
    font-weight: 600;
    font-size: 0.9rem;
    color: #64748b;
    border-bottom: 2px solid #e2e8f0;
  }
  
  .set-row {
    display: grid;
    grid-template-columns: 60px 120px 120px 120px 120px 60px;
    gap: 12px;
    align-items: center;
    padding: 8px 0;
  }
  
  .set-number {
    text-align: center;
    font-weight: 600;
    color: #475569;
  }
  
  .set-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.95rem;
    transition: all 0.2s ease;
  }
  
  .set-input:focus {
    outline: none;
    border-color: #5D5FEF;
    box-shadow: 0 0 0 3px rgba(93, 95, 239, 0.1);
  }
  
  .remove-set-btn {
    background: #fee2e2;
    color: #dc2626;
    border: none;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
  }
  
  .remove-set-btn:hover {
    background: #fecaca;
  }
  
  /* Compact layout for more sets visible */
  .selected-exercise-item {
    padding: 16px;
    background: #f8fafc;
    border-radius: 8px;
    margin-bottom: 16px;
  }
  
  .exercise-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
  }
  
  .exercise-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1e293b;
  }
}

/* ============================================
   3. WORKOUT BUILDER MODAL - MOBILE FIXES
   ============================================ */

@media (max-width: 991px) {
  .modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: flex-end;
    z-index: 10000;
    padding: 0;
  }
  
  .modal-content {
    background: white;
    border-radius: 24px 24px 0 0;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  
  .modal-header {
    padding: 20px;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
    position: relative;
  }
  
  .modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: #f1f5f9;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
  }
  
  .modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    -webkit-overflow-scrolling: touch;
  }
  
  /* Mobile sets container - NO HORIZONTAL SCROLL */
  .sets-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 16px;
  }
  
  /* Mobile set headers */
  .sets-header {
    display: none; /* Hide on mobile, use placeholders instead */
  }
  
  /* Mobile set row - vertical layout */
  .set-row {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: relative;
  }
  
  .set-number {
    position: absolute;
    top: 16px;
    left: 16px;
    background: #5D5FEF;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
  }
  
  /* Input group for mobile */
  .set-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding-left: 40px; /* Space for set number */
  }
  
  .input-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
  }
  
  .input-label {
    font-size: 0.75rem;
    color: #64748b;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }
  
  .set-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    background: white;
  }
  
  .set-input:focus {
    outline: none;
    border-color: #5D5FEF;
    box-shadow: 0 0 0 3px rgba(93, 95, 239, 0.1);
  }
  
  /* Remove button for mobile */
  .remove-set-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    background: #fee2e2;
    color: #dc2626;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
  }
  
  .remove-set-btn i {
    font-size: 0.9rem;
  }
  
  /* Exercise item mobile */
  .selected-exercise-item {
    margin-bottom: 20px;
  }
  
  .exercise-header {
    margin-bottom: 16px;
  }
  
  .exercise-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 4px;
  }
  
  /* Add set button mobile */
  .add-set-btn {
    width: 100%;
    padding: 12px;
    background: #5D5FEF;
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 12px;
  }
}

/* Small mobile adjustments */
@media (max-width: 380px) {
  .set-inputs {
    grid-template-columns: 1fr;
    padding-left: 0;
    padding-top: 40px; /* Move inputs below set number */
  }
  
  .modal-body {
    padding: 16px;
  }
}

/* ============================================
   4. ADDITIONAL RESPONSIVE FIXES
   ============================================ */

/* Ensure workout builder main section doesn't overlap */
.workout-builder-main {
  min-height: calc(100vh - 80px);
}

/* Fix z-index stacking */
.modal,
.modal-backdrop {
  z-index: 10000;
}

.site-header {
  z-index: 1000;
}

.dropdown-menu {
  z-index: 1001;
}

/* Smooth scrolling for modal */
.modal-body {
  scroll-behavior: smooth;
}

/* Ensure inputs are touch-friendly on mobile */
@media (max-width: 991px) {
  input[type="text"],
  input[type="number"],
  select,
  textarea {
    font-size: 16px; /* Prevents zoom on iOS */
  }
}