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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #f5f7fa;
    min-height: 100vh;
    margin: 0;
    padding: 0;
}

.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Styles */
.sidebar {
    width: 260px;
    background: linear-gradient(180deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    position: fixed;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-header {
    padding: 30px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    margin: 0;
    color: white;
}

.sidebar-nav {
    flex: 1;
    padding: 20px 0;
}

.nav-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-menu li {
    margin: 0;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 15px 25px;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: all 0.3s;
    border-left: 3px solid transparent;
    cursor: pointer;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.nav-item.active {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border-left-color: white;
    font-weight: 600;
}

.nav-icon {
    font-size: 1.3rem;
    margin-right: 12px;
    width: 24px;
    text-align: center;
}

.nav-text {
    font-size: 1rem;
}

/* Main Content Area */
.main-content {
    flex: 1;
    margin-left: 260px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.content-header {
    background: white;
    padding: 25px 40px;
    border-bottom: 1px solid #e0e0e0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.content-header h2 {
    margin: 0;
    font-size: 1.8rem;
    color: #333;
    font-weight: 600;
}

.content-body {
    flex: 1;
    padding: 30px 40px;
    background: #f5f7fa;
    overflow-y: auto;
}

/* Login Page Styles */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 400px;
}

.login-logo-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
}

.login-logo {
    max-width: 200px;
    width: 100%;
    height: auto;
    display: block;
    object-fit: contain;
}

.login-logo[src=""] {
    display: none;
}

.login-box h1 {
    text-align: center;
    color: #667eea;
    margin-bottom: 10px;
    font-size: 2.5rem;
}

.login-subtitle {
    text-align: center;
    color: #666;
    margin-bottom: 30px;
    font-size: 1rem;
}

.login-box .form-group {
    margin-bottom: 20px;
}

.login-box label {
    display: block;
    margin-bottom: 8px;
    color: #555;
    font-weight: 500;
}

.login-box input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

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

.btn-login {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.login-error {
    margin-top: 15px;
    padding: 12px;
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-radius: 6px;
    font-size: 0.9rem;
}

.user-info {
    display: flex;
    align-items: center;
    position: absolute;
    right: 40px;
    top: 25px;
}

.user-info span {
    margin-right: 15px;
    color: #666;
}

.btn-logout {
    padding: 8px 16px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
}

.btn-logout:hover {
    background: #c82333;
}

.view {
    display: none;
}

.view.active {
    display: block;
}

/* Mobile Menu Toggle Button */
.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 44px;
    height: 44px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    z-index: 1001;
    margin-right: 15px;
}

.mobile-menu-toggle span {
    width: 100%;
    height: 3px;
    background-color: #333;
    border-radius: 3px;
    transition: all 0.3s ease;
}

.mobile-menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(8px, 8px);
}

.mobile-menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -7px);
}

/* Sidebar Backdrop */
.sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-backdrop.active {
    display: block;
    opacity: 1;
}

/* Content Header - Add flex for mobile menu */
.content-header {
    display: flex;
    align-items: center;
}

/* Responsive Design - Mobile First Approach */
@media (max-width: 768px) {
    /* Mobile Menu Toggle */
    .mobile-menu-toggle {
        display: flex;
    }
    
    /* Sidebar - Hidden by default on mobile, slides in when active */
    .sidebar {
        position: fixed;
        left: -260px;
        width: 260px;
        transition: left 0.3s ease;
        z-index: 1000;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
    }
    
    .sidebar.active {
        left: 0;
    }
    
    /* Show nav text on mobile when sidebar is open */
    .nav-text {
        display: inline;
    }
    
    .nav-icon {
        margin-right: 12px;
        font-size: 1.3rem;
    }
    
    .sidebar-header h1 {
        font-size: 1.5rem;
        text-align: left;
    }
    
    /* Main content - full width on mobile */
    .main-content {
        margin-left: 0;
        width: 100%;
    }
    
    /* Content padding */
    .content-header {
        padding: 15px 20px;
    }
    
    .content-header h2 {
        font-size: 1.5rem;
    }
    
    .content-body {
        padding: 15px 20px;
    }
    
    /* Forms - Stack inputs vertically */
    .form-section {
        padding: 15px;
    }
    
    .form-section > div {
        flex-direction: column;
    }
    
    .form-section > div > div {
        width: 100%;
        min-width: 100%;
        margin-bottom: 15px;
    }
    
    /* Buttons - Ensure minimum touch target (44x44px) */
    button, .btn-primary, .btn-secondary, .btn-success {
        min-height: 44px;
        padding: 12px 20px;
        font-size: 1rem;
    }
    
    .btn-small {
        min-height: 44px;
        padding: 10px 16px;
    }
    
    /* Button groups - Stack vertically on mobile */
    .exercise-actions, .workout-actions {
        flex-direction: column;
        gap: 10px;
    }
    
    .exercise-actions button,
    .workout-actions button {
        width: 100%;
    }
    
    /* Tables - Convert to cards or horizontal scroll */
    table {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    thead {
        display: none;
    }
    
    tbody {
        display: block;
    }
    
    tr {
        display: block;
        margin-bottom: 15px;
        border: 1px solid #ddd;
        border-radius: 8px;
        padding: 15px;
        background: white;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }
    
    td {
        display: flex;
        justify-content: space-between;
        padding: 8px 0;
        border: none;
        text-align: right;
    }
    
    td:before {
        content: attr(data-label);
        font-weight: 600;
        text-align: left;
        margin-right: 15px;
        color: #667eea;
    }
    
    /* Exercise items - Full width cards */
    .exercise-item {
        flex-direction: column;
        padding: 15px;
    }
    
    .exercise-info {
        width: 100%;
        margin-bottom: 15px;
    }
    
    .exercise-actions {
        width: 100%;
    }
    
    /* Workout items - Full width cards */
    .workout-item {
        flex-direction: column;
        padding: 15px;
    }
    
    .workout-info {
        width: 100%;
        margin-bottom: 15px;
    }
    
    .workout-actions {
        width: 100%;
    }
    
    /* Exercise sets - Full width */
    .exercise-sets {
        margin-top: 15px;
        padding-top: 15px;
    }
    
    /* Metric inputs - Stack vertically */
    .machine-metrics {
        flex-direction: column;
    }
    
    .metric-input-group {
        width: 100%;
        margin-bottom: 15px;
    }
    
    /* Custom metric buttons - Stack on mobile */
    .custom-metric {
        flex-direction: column;
        align-items: stretch;
    }
    
    .custom-metric input {
        width: 100%;
        margin-bottom: 10px;
    }
    
    .btn-remove-metric {
        width: 100%;
        min-height: 44px;
        align-self: stretch;
    }
    
    /* Add Custom Metric button - Full width on mobile */
    #add-custom-metric-btn {
        width: 100%;
        margin-top: 10px;
    }
    
    /* Modals - Full screen on mobile */
    #add-set-modal > div {
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        padding: 20px;
    }
    
    /* User info in header - Adjust for mobile */
    .user-info {
        position: static;
        margin-top: 10px;
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
        flex-wrap: wrap;
    }
    
    .user-info span {
        font-size: 0.9rem;
        margin-right: 10px;
        margin-bottom: 5px;
    }
    
    .btn-logout {
        min-height: 44px;
    }
    
    /* Empty table message - Full width on mobile */
    td[colspan] {
        display: block;
        text-align: center;
        padding: 20px;
    }
    
    /* Export PDF and Complete Workout buttons - Stack vertically */
    #export-pdf-btn,
    #complete-workout-btn {
        width: 100%;
        margin-bottom: 10px;
    }
    
    /* Search inputs - Full width */
    input[type="text"],
    input[type="email"],
    input[type="number"],
    select,
    textarea {
        width: 100%;
        min-height: 44px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    /* Select dropdowns - Full width */
    #member-select {
        width: 100%;
        min-width: 100%;
    }
    
    /* Progress table container - Horizontal scroll */
    #progress-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Toast notifications - Adjust for mobile */
    #toast-container {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: calc(100% - 20px);
    }
    
    .toast {
        min-width: auto;
        max-width: 100%;
    }
}

/* Tablet Styles */
@media (min-width: 769px) and (max-width: 1024px) {
    .sidebar {
        width: 220px;
    }
    
    .main-content {
        margin-left: 220px;
    }
    
    .content-header,
    .content-body {
        padding: 20px 30px;
    }
    
    /* Tables - Still allow horizontal scroll if needed */
    table {
        font-size: 0.9rem;
    }
    
    /* Forms - Can use 2 columns where appropriate */
    .form-section > div {
        flex-wrap: wrap;
    }
    
    .form-section > div > div {
        flex: 1 1 calc(50% - 10px);
        min-width: 200px;
    }
}

h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 1.8rem;
}

h3 {
    color: #555;
    margin: 20px 0 15px 0;
    font-size: 1.4rem;
}

h4 {
    color: #666;
    margin: 15px 0 10px 0;
    font-size: 1.1rem;
}

.form-section {
    margin-bottom: 25px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
}

label {
    display: block;
    margin-bottom: 8px;
    color: #555;
    font-weight: 500;
}

input[type="text"],
input[type="email"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 1rem;
    margin-bottom: 15px;
    transition: border-color 0.3s;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #667eea;
}

.field-error {
    border-color: #dc3545 !important;
    background-color: #fff5f5 !important;
    animation: shake 0.3s;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.field-error-message {
    color: #dc3545;
    font-size: 0.85rem;
    margin-top: -10px;
    margin-bottom: 10px;
    padding-left: 5px;
    font-weight: 500;
}

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

.exercise-inputs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 15px;
}

.metrics-section {
    margin: 20px 0;
    padding: 15px;
    background: #f0f0f0;
    border-radius: 6px;
}

.machine-specific-metrics {
    margin-bottom: 15px;
    padding: 12px;
    background: #e8f0fe;
    border-radius: 6px;
    border-left: 3px solid #667eea;
}

.machine-specific-metrics h6 {
    margin: 0 0 10px 0;
    font-weight: 600;
}

.machine-specific-metrics .metrics-inputs {
    grid-template-columns: repeat(3, 1fr);
}

#chest-press-metrics .metrics-inputs {
    grid-template-columns: repeat(5, 1fr);
}

.metrics-section h5 {
    margin: 0 0 12px 0;
    color: #555;
    font-size: 1rem;
}

.metrics-inputs {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 10px;
}

.metric-input-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.metric-input-group label {
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.metric-input-group input {
    margin-bottom: 0;
}

.custom-metric {
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    gap: 10px;
    margin-bottom: 10px;
}

.custom-metric input {
    margin-bottom: 0;
}

.btn-small {
    padding: 8px 16px;
    font-size: 0.9rem;
}

.btn-remove-metric {
    padding: 8px 12px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.2rem;
    font-weight: bold;
    line-height: 1;
    transition: background 0.3s;
}

.btn-remove-metric:hover {
    background: #c82333;
}

#custom-metrics-container {
    margin-top: 10px;
}

.exercise-metrics {
    color: #555;
    font-size: 0.9rem;
}

.workout-item {
    background: white;
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 6px;
    border-left: 4px solid #667eea;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: box-shadow 0.3s;
}

.workout-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.workout-info {
    flex: 1;
}

.workout-info h5 {
    color: #333;
    margin-bottom: 8px;
    font-size: 1.1rem;
}

.workout-details {
    display: flex;
    gap: 15px;
    color: #666;
    font-size: 0.9rem;
    align-items: center;
}

.workout-actions {
    display: flex;
    gap: 8px;
}

.btn-edit,
.btn-delete,
.btn-select,
.btn-clone {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-clone {
    background: #17a2b8;
    color: white;
}

.btn-clone:hover {
    background: #138496;
}

.btn-edit {
    background: #ffc107;
    color: #333;
}

.btn-edit:hover {
    background: #e0a800;
}

.btn-delete {
    background: #dc3545;
    color: white;
}

.btn-delete:hover {
    background: #c82333;
}

.btn-select {
    background: #28a745;
    color: white;
}

.btn-select:hover {
    background: #218838;
}

#workouts-list-section {
    margin-bottom: 25px;
}

#workouts-list-section h3 {
    margin-bottom: 15px;
}

.btn-primary,
.btn-secondary,
.btn-success {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #6c757d;
    color: white;
    margin-left: 10px;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover {
    background: #218838;
}

#member-select {
    display: inline-block;
    width: auto;
    min-width: 250px;
    margin-right: 10px;
}

#exercises-list {
    margin: 20px 0;
}

.exercise-item {
    background: white;
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 6px;
    border-left: 4px solid #667eea;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.exercise-actions {
    display: flex;
    gap: 8px;
    margin-left: 15px;
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.exercise-info h5 {
    color: #333;
    margin-bottom: 5px;
}

.exercise-details {
    color: #666;
    font-size: 0.9rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

thead {
    background: #667eea;
    color: white;
}

th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
}

td {
    padding: 12px 15px;
    border-bottom: 1px solid #e0e0e0;
}

tbody tr:hover {
    background: #f8f9fa;
}

.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
}

.status-created {
    background: #ffc107;
    color: #333;
}

.status-completed {
    background: #28a745;
    color: white;
}

#progress-table-container {
    overflow-x: auto;
}

#progress-table th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 20px;
    transition: background-color 0.2s ease;
}

#progress-table th.sortable:hover {
    background-color: #667eea;
    color: white;
}

#progress-table th.sortable .sort-indicator {
    position: absolute;
    right: 8px;
    color: #667eea;
    font-size: 0.8em;
    transition: color 0.2s ease;
}

#progress-table th.sortable:hover .sort-indicator {
    color: white;
}

#progress-table th.sortable .sort-indicator.active {
    font-weight: bold;
}

/* Add Set Modal */
#add-set-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

#add-set-modal > div {
    background: white;
    padding: 30px;
    border-radius: 10px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.btn-add-set {
    background: #28a745;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background-color 0.2s;
}

.btn-add-set:hover {
    background: #218838;
}

.message {
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 15px;
    display: none;
}

.message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.message.show {
    display: block;
}

/* Toast Notification Styles */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    min-width: 300px;
    max-width: 500px;
    padding: 16px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-size: 14px;
    font-weight: 500;
    color: white;
    background: #28a745;
    opacity: 0;
    transform: translateX(400px);
    transition: all 0.3s ease-in-out;
    pointer-events: auto;
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast-success {
    background: #28a745;
    color: white;
}

.toast-error {
    background: #dc3545;
    color: white;
}

.toast-info {
    background: #17a2b8;
    color: white;
}

.toast-warning {
    background: #ffc107;
    color: #212529;
}

