/* ==========================================================================
   FlexibleEats Mobile-First Theme
   Professional Design System with Green/Gray/White Color Palette
   ========================================================================== */

/* ==========================================================================
   MOBILE-FIRST: Base styles are for mobile, then scale up for desktop
   ========================================================================== */

/* Mobile: Remove container padding and maximize screen real estate */
@media (max-width: 767.98px) {
    /* Full-width containers on mobile */
    .container,
    .container-fluid {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
        max-width: 100% !important;
    }

    /* Main content area - minimal padding on mobile */
    main.flex-grow-1 > .container {
        padding: 0.5rem 0.75rem !important;
    }

    /* Cards take full width on mobile with reduced padding */
    .card {
        border-radius: 0 !important;
        margin-left: -0.75rem !important;
        margin-right: -0.75rem !important;
        width: calc(100% + 1.5rem) !important;
        border-left: none !important;
        border-right: none !important;
    }

    /* Card body reduced padding on mobile */
    .card-body {
        padding: 1rem !important;
    }

    /* Card header full width */
    .card-header {
        border-radius: 0 !important;
        margin: 0 !important;
        padding: 0.875rem 1rem !important;
    }

    /* Form controls larger touch targets on mobile */
    .form-control,
    .form-select {
        padding: 0.75rem 1rem !important;
        font-size: 16px !important; /* Prevents iOS zoom */
        min-height: 48px !important; /* Touch-friendly */
    }

    /* Buttons larger on mobile for touch */
    .btn {
        padding: 0.75rem 1.25rem !important;
        font-size: 16px !important;
        min-height: 48px !important;
    }

    .btn-sm {
        padding: 0.5rem 1rem !important;
        min-height: 40px !important;
    }

    /* Stack button groups vertically on mobile */
    .btn-group-mobile-stack {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }

    .btn-group-mobile-stack .btn {
        width: 100%;
    }

    /* Tables scroll horizontally on mobile */
    .table-responsive-mobile {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* List groups full width */
    .list-group {
        border-radius: 0 !important;
        margin-left: -0.75rem !important;
        margin-right: -0.75rem !important;
    }

    .list-group-item:first-child,
    .list-group-item:last-child {
        border-radius: 0 !important;
    }

    /* Page titles smaller on mobile */
    h1 {
        font-size: 1.5rem !important;
        margin-bottom: 1rem !important;
    }

    h1::after {
        width: 40px !important;
        height: 3px !important;
    }

    h2 {
        font-size: 1.25rem !important;
    }

    /* Reduce spacing on mobile */
    .mb-4 {
        margin-bottom: 1rem !important;
    }

    .mb-3 {
        margin-bottom: 0.75rem !important;
    }

    .py-4 {
        padding-top: 0.5rem !important;
        padding-bottom: 0.5rem !important;
    }
}

/* ==========================================================================
   MODAL / POPUP - Mobile Optimized
   ========================================================================== */

/* Mobile: Full-screen modals */
@media (max-width: 767.98px) {
    .modal-dialog {
        margin: 0 !important;
        max-width: 100% !important;
        min-height: 100vh !important;
        display: flex;
        align-items: stretch;
    }

    .modal-dialog.modal-lg,
    .modal-dialog.modal-xl {
        max-width: 100% !important;
    }

    .modal-content {
        border-radius: 0 !important;
        border: none !important;
        min-height: 100vh !important;
        display: flex;
        flex-direction: column;
    }

    .modal-header {
        border-radius: 0 !important;
        padding: 1rem !important;
        position: sticky;
        top: 0;
        z-index: 10;
    }

    .modal-body {
        flex: 1;
        padding: 1rem !important;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .modal-footer {
        border-radius: 0 !important;
        padding: 1rem !important;
        position: sticky;
        bottom: 0;
        z-index: 10;
        background: var(--white);
        border-top: 1px solid var(--border-color);
    }

    /* Modal footer buttons stack on mobile */
    .modal-footer .btn {
        flex: 1;
    }

    .modal-footer > * {
        margin: 0 !important;
    }

    .modal-footer {
        gap: 0.5rem;
        flex-wrap: wrap;
    }

    /* Close button larger touch target */
    .modal-header .btn-close {
        padding: 1rem !important;
        margin: -1rem -1rem -1rem auto !important;
    }
}

/* Desktop: Restore normal modal behavior */
@media (min-width: 768px) {
    .modal-dialog {
        margin: 1.75rem auto;
    }

    .modal-content {
        border-radius: var(--radius-lg);
        min-height: auto;
    }
}

/* ==========================================================================
   BUTTONS - Professional Design with Icons
   ========================================================================== */

/* Base button styles */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    transition: all var(--transition-speed);
    cursor: pointer;
    border: 2px solid transparent;
    font-size: 16px;
    line-height: 1.5;
    text-decoration: none;
    white-space: nowrap;
}

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

/* Button icon styling */
.btn i,
.btn .fa,
.btn .fas,
.btn .far,
.btn .fab {
    font-size: 0.875em;
    line-height: 1;
}

/* PRIMARY BUTTON - Green (Submit/Save actions) */
.btn-primary {
    background-color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    color: var(--white) !important;
}

.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--primary-hover) !important;
    border-color: var(--primary-hover) !important;
    color: var(--white) !important;
    box-shadow: 0 4px 12px var(--primary-glow) !important;
}

.btn-primary:active {
    background-color: var(--primary-hover) !important;
    border-color: var(--primary-hover) !important;
}

/* PRIMARY OUTLINE */
.btn-outline-primary {
    background-color: transparent !important;
    border-color: var(--primary-color) !important;
    color: var(--primary-color) !important;
}

.btn-outline-primary:hover,
.btn-outline-primary:focus {
    background-color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    color: var(--white) !important;
}

/* SECONDARY BUTTON - Gray (Cancel/Back actions) */
.btn-secondary {
    background-color: var(--gray-600) !important;
    border-color: var(--gray-600) !important;
    color: var(--white) !important;
}

.btn-secondary:hover,
.btn-secondary:focus {
    background-color: var(--gray-700) !important;
    border-color: var(--gray-700) !important;
    color: var(--white) !important;
}

/* SECONDARY OUTLINE */
.btn-outline-secondary {
    background-color: transparent !important;
    border-color: var(--gray-400) !important;
    color: var(--gray-600) !important;
}

.btn-outline-secondary:hover,
.btn-outline-secondary:focus {
    background-color: var(--gray-600) !important;
    border-color: var(--gray-600) !important;
    color: var(--white) !important;
}

/* LIGHT BUTTON - Subtle gray background */
.btn-light {
    background-color: var(--gray-100) !important;
    border-color: var(--gray-200) !important;
    color: var(--gray-700) !important;
}

.btn-light:hover,
.btn-light:focus {
    background-color: var(--gray-200) !important;
    border-color: var(--gray-300) !important;
    color: var(--gray-800) !important;
}

/* DARK BUTTON */
.btn-dark {
    background-color: var(--gray-900) !important;
    border-color: var(--gray-900) !important;
    color: var(--white) !important;
}

.btn-dark:hover,
.btn-dark:focus {
    background-color: var(--black) !important;
    border-color: var(--black) !important;
    color: var(--white) !important;
}

/* SUCCESS BUTTON - Uses primary green */
.btn-success {
    background-color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    color: var(--white) !important;
}

.btn-success:hover,
.btn-success:focus {
    background-color: var(--primary-hover) !important;
    border-color: var(--primary-hover) !important;
    color: var(--white) !important;
}

/* DANGER BUTTON - Red for destructive actions */
.btn-danger {
    background-color: var(--danger-color) !important;
    border-color: var(--danger-color) !important;
    color: var(--white) !important;
}

.btn-danger:hover,
.btn-danger:focus {
    background-color: #b91c1c !important;
    border-color: #b91c1c !important;
    color: var(--white) !important;
}

.btn-outline-danger {
    background-color: transparent !important;
    border-color: var(--danger-color) !important;
    color: var(--danger-color) !important;
}

.btn-outline-danger:hover,
.btn-outline-danger:focus {
    background-color: var(--danger-color) !important;
    border-color: var(--danger-color) !important;
    color: var(--white) !important;
}

/* WARNING BUTTON */
.btn-warning {
    background-color: var(--warning-color) !important;
    border-color: var(--warning-color) !important;
    color: var(--white) !important;
}

.btn-warning:hover,
.btn-warning:focus {
    background-color: #d97706 !important;
    border-color: #d97706 !important;
    color: var(--white) !important;
}

/* INFO BUTTON - Uses green tint */
.btn-info {
    background-color: var(--primary-light) !important;
    border-color: var(--primary-light) !important;
    color: var(--white) !important;
}

.btn-info:hover,
.btn-info:focus {
    background-color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    color: var(--white) !important;
}

/* LINK BUTTON */
.btn-link {
    background-color: transparent !important;
    border-color: transparent !important;
    color: var(--primary-color) !important;
    text-decoration: none !important;
}

.btn-link:hover,
.btn-link:focus {
    color: var(--primary-hover) !important;
    text-decoration: underline !important;
}

/* Button sizes - btn-lg removed as per user preference */
.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

/* ==========================================================================
   BADGES - Green-based color scheme
   ========================================================================== */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.35em 0.65em;
    font-size: 0.75em;
    font-weight: 600;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: var(--radius-sm);
}

/* Primary badge - Dark green */
.badge-primary,
.bg-primary {
    background-color: var(--primary-color) !important;
    color: var(--white) !important;
}

/* Success badge - Green */
.badge-success,
.bg-success {
    background-color: var(--primary-color) !important;
    color: var(--white) !important;
}

/* Info badge - Light green */
.badge-info,
.bg-info {
    background-color: var(--primary-light) !important;
    color: var(--white) !important;
}

/* Secondary badge - Gray */
.badge-secondary,
.bg-secondary {
    background-color: var(--gray-500) !important;
    color: var(--white) !important;
}

/* Warning badge */
.badge-warning,
.bg-warning {
    background-color: var(--warning-color) !important;
    color: var(--white) !important;
}

/* Danger badge */
.badge-danger,
.bg-danger {
    background-color: var(--danger-color) !important;
    color: var(--white) !important;
}

/* Light badge */
.badge-light,
.bg-light {
    background-color: var(--gray-200) !important;
    color: var(--gray-700) !important;
    border: 1px solid var(--gray-300) !important;
}

/* Dark badge */
.badge-dark,
.bg-dark {
    background-color: var(--gray-900) !important;
    color: var(--white) !important;
}

/* Soft/Subtle badge variants */
.badge-soft-primary {
    background-color: rgba(79, 121, 66, 0.15) !important;
    color: var(--primary-color) !important;
}

.badge-soft-success {
    background-color: rgba(79, 121, 66, 0.15) !important;
    color: var(--primary-color) !important;
}

.badge-soft-info {
    background-color: rgba(107, 158, 90, 0.15) !important;
    color: var(--primary-light) !important;
}

.badge-soft-secondary {
    background-color: rgba(115, 115, 115, 0.15) !important;
    color: var(--gray-600) !important;
}

.badge-soft-warning {
    background-color: rgba(245, 158, 11, 0.15) !important;
    color: #b45309 !important;
}

.badge-soft-danger {
    background-color: rgba(220, 38, 38, 0.15) !important;
    color: #b91c1c !important;
}

/* Pill badges */
.badge-pill,
.rounded-pill {
    border-radius: var(--radius-full) !important;
}

/* ==========================================================================
   CARDS - Professional styling
   ========================================================================== */

.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.card-header {
    background: var(--gray-900);
    color: var(--white);
    font-weight: 600;
    padding: 1rem 1.25rem;
    border-bottom: none;
}

.card-header h1,
.card-header h2,
.card-header h3,
.card-header h4,
.card-header h5,
.card-header h6,
.card-header .card-title {
    color: var(--white);
    margin: 0;
}

.card-body {
    padding: 1.25rem;
}

.card-footer {
    background: var(--gray-50);
    border-top: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
}

/* Card with light header variant */
.card-header-light {
    background: var(--gray-100) !important;
    color: var(--gray-900) !important;
    border-bottom: 1px solid var(--border-color) !important;
}

.card-header-light h1,
.card-header-light h2,
.card-header-light h3,
.card-header-light h4,
.card-header-light h5,
.card-header-light h6 {
    color: var(--gray-900) !important;
}

/* ==========================================================================
   FORMS - Clean and accessible
   ========================================================================== */

.form-label {
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 0.5rem;
}

.form-control,
.form-select {
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.625rem 1rem;
    font-size: 16px;
    transition: border-color var(--transition-speed), box-shadow var(--transition-speed);
    background-color: var(--white);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-glow);
    outline: none;
}

.form-control::placeholder {
    color: var(--gray-400);
}

.form-control:disabled,
.form-control[readonly] {
    background-color: var(--gray-100);
    cursor: not-allowed;
}

/* Input groups */
.input-group-text {
    background-color: var(--gray-100);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--gray-600);
}

/* Checkboxes and radios */
.form-check-input:checked {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.form-check-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

/* Form validation */
.is-invalid {
    border-color: var(--danger-color) !important;
}

.is-invalid:focus {
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15) !important;
}

.invalid-feedback {
    color: var(--danger-color);
    font-size: 0.875rem;
}

.is-valid {
    border-color: var(--primary-color) !important;
}

.is-valid:focus {
    box-shadow: 0 0 0 3px var(--primary-glow) !important;
}

/* ==========================================================================
   TABLES - Clean and readable
   ========================================================================== */

.table {
    background: var(--white);
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border-color);
    margin-bottom: 0;
}

.table > :not(caption) > * > * {
    padding: 0.875rem 1rem;
    border-bottom-color: var(--border-color);
}

.table thead th {
    background: var(--gray-900);
    color: var(--white);
    font-weight: 600;
    border: none;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.table tbody tr:hover {
    background-color: var(--primary-extra-light);
}

.table-striped tbody tr:nth-of-type(odd) {
    background-color: var(--gray-50);
}

.table-striped tbody tr:nth-of-type(odd):hover {
    background-color: var(--primary-extra-light);
}

/* ==========================================================================
   ALERTS - Professional styling
   ========================================================================== */

.alert {
    border-radius: var(--radius-md);
    border: none;
    padding: 1rem 1.25rem;
    font-weight: 500;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.alert i {
    margin-top: 0.125rem;
}

.alert-success {
    background-color: rgba(79, 121, 66, 0.1) !important;
    color: var(--primary-hover) !important;
    border-left: 4px solid var(--primary-color) !important;
}

.alert-info {
    background-color: rgba(79, 121, 66, 0.1) !important;
    color: var(--primary-hover) !important;
    border-left: 4px solid var(--primary-light) !important;
}

.alert-warning {
    background-color: rgba(245, 158, 11, 0.1) !important;
    color: #92400e !important;
    border-left: 4px solid var(--warning-color) !important;
}

.alert-danger {
    background-color: rgba(220, 38, 38, 0.1) !important;
    color: #991b1b !important;
    border-left: 4px solid var(--danger-color) !important;
}

/* ==========================================================================
   LIST GROUPS
   ========================================================================== */

.list-group {
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.list-group-item {
    border: none;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
    background: var(--white);
    transition: background-color var(--transition-speed);
}

.list-group-item:last-child {
    border-bottom: none;
}

.list-group-item:hover,
.list-group-item-action:hover {
    background-color: var(--primary-extra-light);
}

.list-group-item.active {
    background-color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    color: var(--white) !important;
}

/* ==========================================================================
   UTILITY CLASSES
   ========================================================================== */

/* Text colors */
.text-primary { color: var(--primary-color) !important; }
.text-success { color: var(--primary-color) !important; }
.text-info { color: var(--primary-light) !important; }
.text-secondary { color: var(--gray-600) !important; }
.text-muted { color: var(--gray-500) !important; }
.text-dark { color: var(--gray-900) !important; }
.text-light { color: var(--gray-400) !important; }

/* Background colors */
.bg-primary { background-color: var(--primary-color) !important; }
.bg-success { background-color: var(--primary-color) !important; }
.bg-info { background-color: var(--primary-light) !important; }
.bg-secondary { background-color: var(--gray-600) !important; }

/* Border colors */
.border-primary { border-color: var(--primary-color) !important; }
.border-success { border-color: var(--primary-color) !important; }

/* Hover effects */
.hover-lift {
    transition: transform var(--transition-speed), box-shadow var(--transition-speed);
}

.hover-lift:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* ==========================================================================
   DESKTOP ENHANCEMENTS (768px and up)
   ========================================================================== */

@media (min-width: 768px) {
    /* Restore container padding on desktop */
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    main.flex-grow-1 > .container {
        padding: 2rem 1rem;
    }

    /* Cards with proper border radius on desktop */
    .card {
        border-radius: var(--radius-lg);
        margin-left: 0;
        margin-right: 0;
        width: 100%;
        border: 1px solid var(--border-color);
    }

    .card-header {
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }

    /* List groups with proper border radius */
    .list-group {
        border-radius: var(--radius-lg);
        margin-left: 0;
        margin-right: 0;
    }

    .list-group-item:first-child {
        border-top-left-radius: var(--radius-lg);
        border-top-right-radius: var(--radius-lg);
    }

    .list-group-item:last-child {
        border-bottom-left-radius: var(--radius-lg);
        border-bottom-right-radius: var(--radius-lg);
    }
}

/* ==========================================================================
   WORKOUT EDITOR - Mobile-First Full-Screen Experience
   ========================================================================== */

/* Mobile: Full-screen workout editing */
@media (max-width: 767.98px) {
    /* Workout editor page - remove all container constraints */
    #workout-editor,
    #template-editor {
        margin: 0 -0.75rem;
        width: calc(100% + 1.5rem);
    }

    /* Exercise accordion - full width, minimal borders */
    #workout-editor .accordion,
    #template-editor .accordion {
        border-radius: 0;
    }

    #workout-editor .accordion-item,
    #template-editor .accordion-item {
        border-radius: 0 !important;
        border-left: none !important;
        border-right: none !important;
        margin-bottom: 0;
        border-bottom: 1px solid var(--border-color);
    }

    #workout-editor .accordion-item:first-child,
    #template-editor .accordion-item:first-child {
        border-top: 1px solid var(--border-color);
    }

    /* Exercise header - larger touch target */
    #workout-editor .accordion-button,
    #template-editor .accordion-button {
        padding: 1rem;
        font-size: 1rem;
        font-weight: 600;
        background: var(--white);
    }

    #workout-editor .accordion-button:not(.collapsed),
    #template-editor .accordion-button:not(.collapsed) {
        background: var(--primary-extra-light);
        color: var(--primary-color);
    }

    /* Accordion body - full width */
    #workout-editor .accordion-body,
    #template-editor .accordion-body {
        padding: 0 !important;
        background: var(--gray-50);
    }

    /* Sets container - no border radius on mobile */
    .sets-table-container {
        border-radius: 0 !important;
        border-left: none !important;
        border-right: none !important;
        margin: 0 !important;
    }

    /* Sets header - sticky on mobile for reference while scrolling */
    .sets-header {
        position: sticky;
        top: 0;
        z-index: 5;
        background: var(--gray-100) !important;
        border-bottom: 2px solid var(--border-color) !important;
        padding: 0.75rem 1rem !important;
    }

    .set-header {
        font-size: 0.75rem !important;
        font-weight: 700 !important;
        text-transform: uppercase;
        letter-spacing: 0.025em;
        color: var(--gray-600) !important;
    }

    /* Set rows - card-like appearance for each set */
    .set-row {
        background: var(--white) !important;
        padding: 0.875rem 1rem !important;
        border-bottom: 1px solid var(--border-light) !important;
        min-height: 60px !important;
        align-items: center !important;
    }

    .set-row:last-child {
        border-bottom: none !important;
    }

    /* Set number - more prominent */
    .set-number {
        font-size: 0.875rem !important;
        font-weight: 700 !important;
        color: var(--primary-color) !important;
        background: var(--primary-extra-light) !important;
        border-radius: var(--radius-sm) !important;
        width: 36px !important;
        height: 36px !important;
    }

    /* Input fields - larger touch targets */
    .set-input {
        height: 44px !important;
        font-size: 16px !important;
        font-weight: 600 !important;
        text-align: center !important;
        border: 2px solid var(--border-color) !important;
        border-radius: var(--radius-md) !important;
        background: var(--white) !important;
        transition: all var(--transition-speed) !important;
    }

    .set-input:focus {
        border-color: var(--primary-color) !important;
        box-shadow: 0 0 0 3px var(--primary-glow) !important;
        background: var(--white) !important;
    }

    .set-input::placeholder {
        color: var(--gray-400) !important;
        font-weight: 400 !important;
    }

    /* Delete button - larger touch target */
    .set-actions .btn-icon,
    .set-actions .btn {
        width: 40px !important;
        height: 40px !important;
        padding: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    /* Exercise action buttons - full width on mobile */
    #workout-editor .d-flex.flex-wrap.gap-2.pt-3.mt-3.border-top,
    #template-editor .d-flex.flex-wrap.gap-2.pt-3.mt-3.border-top {
        padding: 1rem !important;
        margin: 0 !important;
        background: var(--white);
        border-top: 1px solid var(--border-color) !important;
        gap: 0.5rem !important;
        flex-wrap: wrap !important;
    }

    #workout-editor .d-flex.flex-wrap.gap-2.pt-3.mt-3.border-top .btn,
    #template-editor .d-flex.flex-wrap.gap-2.pt-3.mt-3.border-top .btn {
        flex: 1 1 auto;
        min-width: calc(50% - 0.25rem);
    }

    /* Exercise notes - full width */
    #workout-editor .mt-4,
    #template-editor .mt-4 {
        padding: 1rem !important;
        margin: 0 !important;
        background: var(--white);
        border-top: 1px solid var(--border-color);
    }

    /* Reorder controls */
    .exercise-reorder-controls {
        margin-left: 0 !important;
        width: 100%;
        justify-content: flex-end;
        margin-top: 0.5rem;
    }

    /* Main action buttons at bottom */
    #workout-editor + hr + .mb-4,
    #template-editor + hr + .mb-4,
    .card-body > form > .d-flex.flex-wrap.gap-2:last-of-type {
        position: sticky;
        bottom: 0;
        background: var(--white);
        padding: 1rem !important;
        margin: 0 -0.75rem !important;
        border-top: 1px solid var(--border-color);
        box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1);
        z-index: 100;
    }
}

/* ==========================================================================
   WORKOUT SETS - Grid Layout with RIR/RPE Support (Mobile)
   ========================================================================== */

@media (max-width: 767.98px) {
    /* Base 4-column grid: Set# | Weight | Reps | Actions */
    .sets-header,
    .set-row {
        display: grid !important;
        grid-template-columns: 40px 1fr 1fr 44px !important;
        gap: 0.5rem !important;
    }

    /* With RIR: Set# | Weight | Reps | RIR | Actions */
    .sets-header.with-rir,
    .set-row.with-rir {
        grid-template-columns: 36px 1fr 1fr 60px 40px !important;
    }

    /* With RPE: Set# | Weight | Reps | RPE | Actions */
    .sets-header.with-rpe,
    .set-row.with-rpe {
        grid-template-columns: 36px 1fr 1fr 60px 40px !important;
    }

    /* With both RIR and RPE: Set# | Weight | Reps | RIR | RPE | Actions */
    .sets-header.with-rir.with-rpe,
    .set-row.with-rir.with-rpe {
        grid-template-columns: 32px 1fr 1fr 50px 50px 36px !important;
    }

    /* RIR/RPE input groups - respect the toggle state */
    .rir-input-group,
    .rpe-input-group {
        display: none !important;
    }
    
    /* Show RIR only when parent has with-rir class */
    .sets-header.with-rir .rir-header,
    .set-row.with-rir .rir-input-group {
        display: flex !important;
    }
    
    /* Show RPE only when parent has with-rpe class */
    .sets-header.with-rpe .rpe-header,
    .set-row.with-rpe .rpe-input-group {
        display: flex !important;
    }

    .rir-input-group .set-input,
    .rpe-input-group .set-input {
        font-size: 16px !important;
        height: 44px !important;
    }

    /* Hide column headers on very small screens, show labels in inputs */
    @media (max-width: 400px) {
        .sets-header {
            display: none !important;
        }

        .set-row {
            grid-template-columns: 32px 1fr 1fr 36px !important;
            padding: 0.75rem !important;
        }

        .set-row.with-rir {
            grid-template-columns: 28px 1fr 1fr 50px 32px !important;
        }

        .set-row.with-rpe {
            grid-template-columns: 28px 1fr 1fr 50px 32px !important;
        }

        .set-row.with-rir.with-rpe {
            grid-template-columns: 24px 1fr 1fr 44px 44px 28px !important;
        }

        .set-input {
            height: 40px !important;
        }
        
        /* Style placeholders on mobile */
        .set-input::placeholder {
            font-size: 11px !important;
            color: #999 !important;
            text-transform: uppercase !important;
            letter-spacing: 0.5px !important;
        }

        .set-number {
            width: 28px !important;
            height: 28px !important;
            font-size: 0.75rem !important;
        }

        .set-actions .btn-icon,
        .set-actions .btn {
            width: 32px !important;
            height: 32px !important;
        }
    }
}

/* ==========================================================================
   WORKOUT PAGE HEADER - Mobile Optimized
   ========================================================================== */

@media (max-width: 767.98px) {
    /* Card header on workout edit page */
    .card > .card-header {
        position: sticky;
        top: 0;
        z-index: 50;
    }

    /* Toggle buttons (RIR/RPE) - more compact on mobile */
    .btn-group.btn-group-sm .btn {
        padding: 0.4rem 0.6rem !important;
        font-size: 0.75rem !important;
        min-width: auto !important;
        flex: 1 !important;
    }
    
    /* Make button group stack better on mobile */
    .btn-group {
        display: flex !important;
        width: 100% !important;
        max-width: 200px !important;
    }
    
    .btn-group .btn {
        flex: 1 !important;
    }

    /* Add Exercise button - prominent */
    #workout-editor .d-flex.justify-content-between.align-items-center.mb-3,
    #template-editor .d-flex.justify-content-between.align-items-center.mb-3 {
        flex-wrap: wrap;
        gap: 0.75rem;
        padding: 0 0.75rem;
        margin-bottom: 0.75rem !important;
    }

    #workout-editor .d-flex.justify-content-between.align-items-center.mb-3 h6,
    #template-editor .d-flex.justify-content-between.align-items-center.mb-3 h6 {
        width: 100%;
        margin-bottom: 0.5rem !important;
    }

    #workout-editor .d-flex.justify-content-between.align-items-center.mb-3 .d-flex.gap-2,
    #template-editor .d-flex.justify-content-between.align-items-center.mb-3 .d-flex.gap-2 {
        width: 100%;
        justify-content: space-between;
    }
}

/* ==========================================================================
   PRINT STYLES
   ========================================================================== */

@media print {
    .btn,
    .navbar,
    .modal-backdrop {
        display: none !important;
    }

    .card {
        border: 1px solid #000 !important;
        box-shadow: none !important;
    }
}
