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

:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --secondary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --success-gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --warning-gradient: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    --dark-gradient: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-dark: #1a202c;
    --text-primary: #2d3748;
    --text-secondary: #4a5568;
    --text-light: #718096;
    --border-color: #e2e8f0;
    --shadow-light: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-medium: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-heavy: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --routine-primary: #8b5cf6;
    --routine-secondary: #a78bfa;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header Styles */
.header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-light);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo i {
    font-size: 2rem;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo h1 {
    font-size: 1.75rem;
    font-weight: 700;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-stats {
    display: flex;
    gap: 2rem;
}

.stat-item {
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-light);
    font-weight: 500;
}

/* Main Content */
.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    flex: 1;
}

/* Day Selector */
.day-selector {
    margin-bottom: 3rem;
}

.day-selector h2 {
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.day-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
}

.day-btn {
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    padding: 1.25rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    color: var(--text-secondary);
    box-shadow: var(--shadow-light);
}

.day-btn i {
    font-size: 1.25rem;
    transition: all 0.3s ease;
}

.day-btn:hover {
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

.day-btn.active {
    background: var(--primary-gradient);
    border-color: transparent;
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

.day-btn.active i {
    transform: scale(1.1);
}

/* Workout Section */
.workout-section {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-light);
    border: 1px solid var(--border-color);
}

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

.section-header h2 {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--text-primary);
}

.add-exercise-btn {
    background: var(--success-gradient);
    color: white;
    border: none;
    padding: 0.875rem 1.5rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-light);
}

.add-exercise-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

/* Exercises Grid */
.exercises-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.5rem;
}

.exercise-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.exercise-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--primary-gradient);
}

.exercise-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-medium);
    border-color: #667eea;
}

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

.exercise-name {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

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

.action-btn {
    background: none;
    border: none;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-light);
}

.action-btn:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

.action-btn.delete:hover {
    background: #fed7d7;
    color: #e53e3e;
}

.exercise-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.stat {
    text-align: center;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.stat-number {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-light);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-light);
    grid-column: 1 / -1;
}

.empty-state i {
    font-size: 4rem;
    margin-bottom: 1.5rem;
    opacity: 0.3;
}

.empty-state h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.empty-state p {
    margin-bottom: 2rem;
    font-size: 1rem;
}

.add-first-exercise-btn {
    background: var(--primary-gradient);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-light);
}

.add-first-exercise-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 500px;
    margin: 2rem;
    box-shadow: var(--shadow-heavy);
    transform: translateY(-20px);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal {
    transform: translateY(0);
}

.modal-header {
    padding: 2rem 2rem 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    color: var(--text-light);
    transition: all 0.2s ease;
}

.close-btn:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

.modal-body {
    padding: 2rem;
}

/* Form Styles */
.form-group {
    margin-bottom: 1.5rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

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

.form-group input {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    transition: all 0.2s ease;
    background: var(--bg-primary);
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

.btn-secondary {
    flex: 1;
    padding: 0.875rem;
    border: 2px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background: var(--border-color);
}

.btn-primary {
    flex: 2;
    padding: 0.875rem;
    border: none;
    background: var(--primary-gradient);
    color: white;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-light);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-medium);
}

/* Responsive Design */
@media (max-width: 768px) {
    .header-content {
        padding: 1rem;
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .header-stats {
        gap: 1rem;
    }
    
    .main-content {
        padding: 1rem;
    }
    
    .day-buttons {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .section-header {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    
    .exercises-grid {
        grid-template-columns: 1fr;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .modal {
        margin: 1rem;
    }
    
    .modal-body {
        padding: 1.5rem;
    }
}

@media (max-width: 480px) {
    .day-buttons {
        grid-template-columns: 1fr;
    }
    
    .exercise-stats {
        grid-template-columns: 1fr;
    }
}

/* Animation Classes */
.fade-in {
    animation: fadeIn 0.3s ease forwards;
}

.slide-in {
    animation: slideIn 0.3s ease forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

/* Loading States */
.loading {
    opacity: 0.7;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #667eea;
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Authentication Styles */
.auth-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-gradient);
    padding: 1rem;
}

.auth-container {
    background: var(--bg-secondary);
    padding: 3rem;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-heavy);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.auth-header .logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.auth-header .logo i {
    font-size: 2rem;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.auth-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.auth-subtitle {
    color: var(--text-light);
    margin-bottom: 2rem;
    font-size: 0.95rem;
}

.auth-tabs {
    display: flex;
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    padding: 0.25rem;
    margin-bottom: 2rem;
}

.auth-tab {
    flex: 1;
    padding: 0.75rem;
    border: none;
    background: transparent;
    color: var(--text-light);
    font-weight: 500;
    border-radius: calc(var(--radius-md) - 2px);
    cursor: pointer;
    transition: all 0.2s ease;
}

.auth-tab.active {
    background: var(--bg-secondary);
    color: var(--text-primary);
    box-shadow: var(--shadow-light);
}

.auth-form {
    display: none;
    text-align: left;
}

.auth-form.active {
    display: block;
}

.auth-form .form-group {
    margin-bottom: 1.5rem;
}

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

.auth-form input {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    transition: border-color 0.2s ease;
    background: var(--bg-primary);
}

.auth-form input:focus {
    outline: none;
    border-color: #667eea;
    background: var(--bg-secondary);
}

.auth-form .btn-primary {
    width: 100%;
    padding: 1rem;
    font-size: 1rem;
    font-weight: 600;
    margin-top: 1rem;
    position: relative;
}

.auth-form .btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.btn-loader {
    display: none;
}

.btn-primary:disabled .btn-text {
    opacity: 0;
}

.btn-primary:disabled .btn-loader {
    display: inline-block;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Firebase Setup Notice */
.setup-notice {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 1rem;
}

.setup-content {
    background: var(--bg-secondary);
    padding: 2rem;
    border-radius: var(--radius-lg);
    max-width: 500px;
    width: 100%;
    text-align: left;
}

.setup-content i {
    font-size: 2rem;
    color: #f59e0b;
    margin-bottom: 1rem;
}

.setup-content h3 {
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.setup-content ol {
    margin: 1rem 0;
    padding-left: 1.5rem;
}

.setup-content li {
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.setup-content a {
    color: #667eea;
    text-decoration: none;
}

.setup-content a:hover {
    text-decoration: underline;
}

.setup-content .btn-secondary {
    margin-top: 1.5rem;
    width: 100%;
}

/* Header Updates */
.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.user-name {
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-actions .action-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-light);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
    font-weight: 500;
}

.header-actions .action-btn:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.header-actions .action-btn.active {
    background: var(--primary-gradient);
    color: white;
}

.header-actions .btn-secondary {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    font-weight: 500;
}

/* View Management */
.view {
    display: none;
}

.view.active {
    display: block;
}

/* History View Styles */
.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.history-header h2 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
}

.date-filter {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.date-input {
    padding: 0.5rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.9rem;
}

.date-input:focus {
    outline: none;
    border-color: #667eea;
}

.history-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.history-day {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-light);
}

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

.history-date {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.history-stats {
    display: flex;
    gap: 1.5rem;
    font-size: 0.9rem;
    color: var(--text-light);
}

.history-exercises {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.history-exercise-card {
    background: var(--bg-primary);
    padding: 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.history-exercise-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.history-exercise-stats {
    display: flex;
    justify-content: space-between;
    color: var(--text-light);
    font-size: 0.9rem;
}

/* Responsive Updates */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 1rem;
    }
    
    .header-user {
        flex-direction: column;
        gap: 1rem;
        width: 100%;
    }
    
    .header-actions {
        justify-content: center;
    }
    
    .history-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .date-filter {
        align-self: stretch;
        justify-content: space-between;
    }
    
    .history-day-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .history-stats {
        align-self: stretch;
        justify-content: space-between;
    }
}

/* Routine Styles */
.section-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.add-routine-btn {
    background: linear-gradient(135deg, var(--routine-primary) 0%, var(--routine-secondary) 100%);
    color: white;
    border: none;
    padding: 0.875rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: var(--shadow-light);
}

.add-routine-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

.routine-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    max-height: 400px;
    overflow-y: auto;
    padding: 0.5rem;
}

.routine-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    box-shadow: var(--shadow-light);
    transition: all 0.3s ease;
    cursor: pointer;
}

.routine-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
    border-color: var(--routine-primary);
}

.routine-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.routine-header h4 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.routine-category {
    background: var(--routine-primary);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
}

.routine-description {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    font-size: 0.875rem;
    line-height: 1.5;
}

.routine-stats {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    font-size: 0.875rem;
    color: var(--text-light);
}

.select-routine-btn {
    width: 100%;
    background: var(--routine-primary);
    color: white;
    border: none;
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.select-routine-btn:hover {
    background: var(--routine-secondary);
}

.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--text-light);
}

.loading-state i {
    font-size: 2rem;
    margin-bottom: 1rem;
}

@media (max-width: 768px) {
    .section-actions {
        flex-direction: column;
        gap: 0.75rem;
        width: 100%;
    }
    
    .add-routine-btn,
    .add-exercise-btn {
        width: 100%;
        justify-content: center;
    }
    
    .routine-grid {
        grid-template-columns: 1fr;
        max-height: 300px;
    }
}

/* Exercise enhancements for routines */
.exercise-title {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.superset-badge {
    background: linear-gradient(135deg, #f59e0b 0%, #f97316 100%);
    color: white;
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
    align-self: flex-start;
    text-transform: uppercase;
}

.routine-badge {
    background: var(--routine-primary);
    color: white;
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
    align-self: flex-start;
    opacity: 0.8;
}

.superset-exercise {
    border-left: 4px solid #f59e0b;
    position: relative;
}

.superset-exercise::before {
    content: '';
    position: absolute;
    top: 0;
    left: -4px;
    width: 4px;
    height: 100%;
    background: linear-gradient(135deg, #f59e0b 0%, #f97316 100%);
}

.routine-exercises-preview {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
    color: var(--text-light);
    font-size: 0.8rem;
}

.routine-stats span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* Save Routine Button */
.save-routine-btn {
    background: var(--warning-gradient);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.save-routine-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

.save-routine-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Save Routine Modal Styles */
.routine-preview {
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}

.routine-preview h4 {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.routine-preview h4::before {
    content: '📋';
    font-size: 1rem;
}

.preview-exercises {
    max-height: 200px;
    overflow-y: auto;
}

.preview-exercise-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.85rem;
}

.preview-exercise-item:last-child {
    border-bottom: none;
}

.preview-exercise-name {
    font-weight: 500;
    color: var(--text-primary);
}

.preview-exercise-details {
    display: flex;
    gap: 0.75rem;
    color: var(--text-light);
    font-size: 0.8rem;
}

.preview-exercise-extras {
    display: flex;
    gap: 0.5rem;
}

.preview-extra-badge {
    background: var(--success-gradient);
    color: white;
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 500;
}

.preview-extra-badge.notes {
    background: #f59e0b;
}

.preview-extra-badge.video {
    background: #ef4444;
}

/* Form select styling */
select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--text-primary);
    background: var(--bg-secondary);
    cursor: pointer;
    transition: border-color 0.2s ease;
}

select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Custom Routine Styling */
.custom-routine {
    border-left: 4px solid var(--warning-gradient);
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
}

.routine-badges {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.custom-badge {
    background: var(--warning-gradient);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

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

.routine-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin: 0.75rem 0;
    font-size: 0.8rem;
}

.routine-stats span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    color: var(--text-light);
}

.routine-stats .fas.fa-sticky-note {
    color: #f59e0b;
}

.routine-stats .fab.fa-youtube {
    color: #ef4444;
}

/* Exercise Notes and Video Sections */
.exercise-notes,
.exercise-video {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}

.exercise-notes h4,
.exercise-video h4 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.exercise-notes h4 i {
    color: #f59e0b;
}

.exercise-video h4 i {
    color: #ef4444;
}

.exercise-notes p {
    color: var(--text-primary);
    font-size: 0.9rem;
    line-height: 1.5;
    white-space: pre-line;
}

.video-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: #ef4444;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.video-link:hover {
    color: #dc2626;
    transform: translateX(2px);
}

.video-link i {
    font-size: 1.1em;
}

/* Form styling for textarea */
textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--text-primary);
    background: var(--bg-secondary);
    resize: vertical;
    min-height: 80px;
    transition: border-color 0.2s ease;
}

textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Mobile responsive styles for notes and video sections */
@media (max-width: 768px) {
    .exercise-notes,
    .exercise-video {
        margin-top: 0.75rem;
        padding: 0.75rem;
    }
    
    .exercise-notes h4,
    .exercise-video h4 {
        font-size: 0.85rem;
        gap: 0.375rem;
    }
    
    .exercise-notes p {
        font-size: 0.85rem;
        line-height: 1.4;
    }
    
    .video-link {
        font-size: 0.85rem;
        gap: 0.375rem;
    }
    
    /* Ensure form fields are properly sized on mobile */
    .form-group textarea {
        font-size: 16px; /* Prevents zoom on iOS */
        min-height: 60px;
    }
    
    .form-group input[type="url"] {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    /* Ensure exercise cards are properly spaced on mobile */
    .exercises-grid {
        gap: 1rem;
    }
    
    .exercise-card {
        padding: 1rem;
    }
    
    /* Make sure notes and video sections don't get hidden */
    .exercise-notes,
    .exercise-video {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
}

@media (max-width: 480px) {
    .exercise-notes,
    .exercise-video {
        margin-top: 0.5rem;
        padding: 0.5rem;
    }
    
    .exercise-notes h4,
    .exercise-video h4 {
        font-size: 0.8rem;
        margin-bottom: 0.375rem;
    }
    
    .exercise-notes p {
        font-size: 0.8rem;
    }
    
    .video-link {
        font-size: 0.8rem;
    }
    
    /* Additional modal improvements for very small screens */
    .modal {
        margin: 0.5rem;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .modal-header {
        padding: 1.5rem 1.5rem 1rem;
    }
    
    .modal-header h3 {
        font-size: 1.25rem;
    }
    
    .modal-body {
        padding: 1.5rem;
        max-height: calc(90vh - 120px);
        overflow-y: auto;
    }
    
    .form-group {
        margin-bottom: 1.25rem;
    }
    
    .form-group textarea {
        min-height: 50px;
    }
}

/* Browser Sections Styles */
.browser-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.browser-header h2 {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--text-primary);
}

.browser-stats {
    color: var(--text-secondary);
    font-weight: 500;
}

/* Filters Section */
.filters-section {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    margin-bottom: 2rem;
    box-shadow: var(--shadow-light);
}

.search-bar {
    position: relative;
    margin-bottom: 1.5rem;
}

.search-bar i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
}

.search-bar input {
    width: 100%;
    padding: 0.875rem 1rem 0.875rem 3rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    transition: all 0.3s ease;
    background: var(--bg-primary);
}

.search-bar input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    background: white;
}

.filter-controls {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
    min-width: 180px;
}

.filter-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.filter-group select {
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    background: var(--bg-primary);
    cursor: pointer;
    transition: all 0.3s ease;
}

.filter-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    background: white;
}

/* Exercise Cards in Browser */
.exercise-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
    cursor: pointer;
    height: fit-content;
}

.exercise-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
    border-color: #667eea;
}

.exercise-card.custom-exercise {
    border-left: 4px solid #f39c12;
}

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

.exercise-badges {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
}

.exercise-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    line-height: 1.3;
}

.muscle-badge {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
}

.exercise-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.exercise-meta span {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

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

.video-badge {
    background: #ff6b6b;
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* Exercise/Routine Details Modal */
.modal.large {
    max-width: 800px;
    width: 90%;
}

.exercise-details, .routine-details {
    max-height: 70vh;
    overflow-y: auto;
    padding: 0.5rem;
}

.detail-section {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.detail-section:last-of-type {
    border-bottom: none;
}

.detail-section h4 {
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.detail-item strong {
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
}

.detail-item span {
    color: var(--text-primary);
    font-weight: 500;
}

.video-links {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.video-link {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    text-decoration: none;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

.video-link:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

.detail-actions {
    display: flex;
    justify-content: center;
    padding-top: 1.5rem;
    margin-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

/* Routine Details Specific */
.routine-info {
    margin-bottom: 2rem;
}

.routine-description {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-style: italic;
}

.exercises-breakdown {
    margin-top: 2rem;
}

.exercise-group {
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.exercise-group h5 {
    background: var(--bg-primary);
    padding: 1rem 1.5rem;
    margin: 0;
    color: var(--text-primary);
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
}

.superset-group h5 {
    background: linear-gradient(135deg, #8b5cf6 0%, #a78bfa 100%);
    color: white;
}

.exercise-list {
    padding: 0;
}

.exercise-item {
    display: flex;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    gap: 1rem;
}

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

.superset-item {
    background: rgba(139, 92, 246, 0.05);
}

.superset-order {
    background: var(--routine-primary);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    flex-shrink: 0;
}

.exercise-item .exercise-name {
    flex: 1;
    font-size: 1rem;
    font-weight: 500;
    margin: 0;
}

.exercise-details {
    display: flex;
    gap: 1rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

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

.extra-badge {
    font-size: 1rem;
}

.extra-badge.notes {
    color: #f39c12;
}

.extra-badge.video {
    color: #e74c3c;
}

/* Responsive Design for Browser */
@media (max-width: 768px) {
    .filter-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filter-group {
        min-width: unset;
    }
    
    .browser-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .exercise-meta {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .detail-grid {
        grid-template-columns: 1fr;
    }
    
    .video-links {
        flex-direction: column;
    }
    
    .exercise-details {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .exercise-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    
    .superset-order {
        align-self: flex-start;
    }
}

/* Modal Tabs Styles */
.modal-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
    gap: 0;
}

.modal-tab {
    flex: 1;
    padding: 1rem 1.5rem;
    border: none;
    background: var(--bg-primary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-weight: 500;
    border-bottom: 3px solid transparent;
}

.modal-tab:first-child {
    border-top-left-radius: var(--radius-md);
}

.modal-tab:last-child {
    border-top-right-radius: var(--radius-md);
}

.modal-tab:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.modal-tab.active {
    background: var(--bg-secondary);
    color: #667eea;
    border-bottom-color: #667eea;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Database Selection Styles */
.database-selection {
    max-height: 70vh;
    overflow-y: auto;
}

.modal-filters {
    background: var(--bg-primary);
    padding: 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-color);
}

.modal-filters .search-bar {
    margin-bottom: 1rem;
}

.filter-row {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.filter-row .filter-group {
    flex: 1;
    min-width: 150px;
}

.btn-secondary.small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    height: fit-content;
}

/* Modal Exercise List */
.modal-exercise-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
}

.modal-exercise-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--bg-secondary);
}

.modal-exercise-item:last-child {
    border-bottom: none;
}

.modal-exercise-item:hover {
    background: var(--bg-primary);
    transform: translateX(4px);
}

.modal-exercise-item.selected {
    background: rgba(102, 126, 234, 0.1);
    border-color: #667eea;
    transform: translateX(4px);
}

.modal-exercise-item h4 {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-exercise-item .exercise-meta {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.equipment-badge {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 500;
}

.custom-badge {
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.more-results {
    padding: 1rem;
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
    background: var(--bg-primary);
}

/* Selected Exercise Preview */
.selected-exercise-preview {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin-top: 1.5rem;
}

.selected-exercise-preview h4 {
    color: var(--text-primary);
    margin-bottom: 1rem;
    font-size: 1.1rem;
    font-weight: 600;
}

.preview-details h5 {
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    font-size: 1rem;
    font-weight: 600;
}

.preview-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.preview-meta span {
    display: flex;
    flex-direction: column;
}

.preview-videos {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.video-link.small {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    text-decoration: none;
}

.preview-form {
    border-top: 1px solid var(--border-color);
    padding-top: 1rem;
    margin-top: 1rem;
}

.preview-form .form-row {
    margin-bottom: 1rem;
}

.preview-form .form-group {
    margin-bottom: 0;
}

/* Modal Responsive */
@media (max-width: 768px) {
    .modal-tabs {
        flex-direction: column;
    }
    
    .modal-tab {
        border-radius: 0;
        border-bottom: 1px solid var(--border-color);
    }
    
    .modal-tab:first-child {
        border-top-left-radius: 0;
        border-top-right-radius: 0;
    }
    
    .modal-tab:last-child {
        border-top-right-radius: 0;
        border-bottom: 3px solid transparent;
    }
    
    .modal-tab.active {
        border-bottom-color: #667eea;
        border-right-color: #667eea;
        border-right: 3px solid #667eea;
    }
    
    .filter-row {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filter-row .filter-group {
        min-width: unset;
    }
    
    .modal-exercise-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    
    .preview-meta {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .preview-videos {
        flex-direction: column;
    }
}

/* Loading Spinner */
.loading-spinner {
    margin-top: 1rem;
    font-size: 1.5rem;
    color: #667eea;
}

.loading-spinner i {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}