/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    overflow-x: hidden;
    -webkit-tap-highlight-color: rgba(0,0,0,0);
}

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

/* Header Styles */
.header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 1rem;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.header h1 {
    color: #2563eb;
    font-size: 1.5rem;
    font-weight: 700;
}

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

/* Button Styles */
.btn {
    border: none;
    border-radius: 12px;
    padding: 0.6rem 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    font-size: 0.9rem;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
}

.btn-secondary {
    background: #6b7280;
    color: white;
}

.btn-secondary:hover {
    background: #4b5563;
    transform: translateY(-2px);
}

.btn-warm {
    background: linear-gradient(45deg, #f59e0b, #d97706);
    color: white;
}

.btn-warm:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(245, 158, 11, 0.4);
}

.btn-cool {
    background: linear-gradient(45deg, #06b6d4, #0891b2);
    color: white;
    width: 100%;
    justify-content: center;
    padding: 1rem;
    font-size: 1rem;
}

.btn-cool:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(6, 182, 212, 0.4);
}

.btn-back {
    background: #6b7280;
    color: white;
}

.btn-back:hover {
    background: #4b5563;
}

.btn-close {
    background: #ef4444;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    justify-content: center;
    padding: 0;
}

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

/* Screen Management */
.screen {
    display: none;
}

.screen.active {
    display: block;
}

/* Day Grid */
.day-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.day-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 1.5rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.day-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

.day-card.completed {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
}

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

.day-header h3 {
    font-size: 1.4rem;
    font-weight: 700;
    color: #2563eb;
}

.day-card.completed .day-header h3 {
    color: white;
}

.completed-icon {
    font-size: 1.2rem;
    color: #10b981;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.day-card.completed .completed-icon {
    opacity: 1;
    color: white;
}

.day-focus {
    font-size: 1.1rem;
    font-weight: 500;
    color: #6b7280;
    margin-bottom: 1rem;
}

.day-card.completed .day-focus {
    color: rgba(255, 255, 255, 0.9);
}

.day-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
}

.exercise-count {
    color: #2563eb;
    font-weight: 600;
}

.day-card.completed .exercise-count {
    color: white;
}

.progress-text {
    color: #6b7280;
    font-weight: 500;
}

.day-card.completed .progress-text {
    color: rgba(255, 255, 255, 0.9);
}

/* Post Workout Section */
.post-workout-section {
    margin-top: 2rem;
}

/* Workout Screen */
.workout-header {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

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

.workout-info h2 {
    color: #2563eb;
    margin-bottom: 1rem;
    font-size: 1.3rem;
}

.progress-bar {
    background: #e5e7eb;
    border-radius: 10px;
    height: 8px;
    margin-bottom: 0.5rem;
    overflow: hidden;
}

.progress-fill {
    background: linear-gradient(45deg, #10b981, #059669);
    height: 100%;
    transition: width 0.3s ease;
    width: 0%;
}

/* Exercise Container */
.exercise-container {
    display: grid;
    gap: 1rem;
}

/* Exercise Card Enhancements */
.exercise-image-container {
    margin: 1rem 0;
    text-align: center;
    border-radius: 12px;
    overflow: hidden;
    background: #f8f9fa;
}

.exercise-image {
    width: 100%;
    max-width: 300px;
    height: 200px;
    object-fit: contain;
    object-position: center;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
    background: #f8f9fa;
}

.exercise-image:hover {
    transform: scale(1.02);
}

.exercise-placeholder {
    padding: 2rem;
    color: #6b7280;
    background: #f3f4f6;
    border-radius: 12px;
    border: 2px dashed #d1d5db;
}

.exercise-placeholder i {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    display: block;
}

.exercise-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: #6b7280;
    margin-top: 0.5rem;
}

.target-muscles {
    background: linear-gradient(45deg, #10b981, #059669);
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
}

.exercise-card.completed .target-muscles {
    background: rgba(255, 255, 255, 0.3);
    color: white;
}

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

.btn-benefits {
    background: #10b981;
    color: white;
    padding: 0.5rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    justify-content: center;
    font-size: 0.9rem;
}

.btn-benefits:hover {
    background: #059669;
    transform: translateY(-2px);
}

.btn-instructions {
    background: #3b82f6;
    color: white;
    padding: 0.5rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    justify-content: center;
    font-size: 0.9rem;
}

.btn-instructions:hover {
    background: #2563eb;
    transform: translateY(-2px);
}

/* Info Modal Content */
.info-content {
    text-align: left;
}

.info-content h4 {
    color: #2563eb;
    margin-bottom: 1rem;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.info-content h5 {
    color: #10b981;
    margin: 1rem 0 0.5rem 0;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.target-muscles-info {
    background: #f0fdf4;
    padding: 1rem;
    border-radius: 12px;
    border-left: 4px solid #10b981;
    margin-bottom: 1rem;
}

.target-muscles-info p {
    color: #166534;
    font-weight: 600;
    margin: 0;
}

.content-text {
    line-height: 1.6;
}

.content-text p {
    margin-bottom: 0.5rem;
    color: #374151;
}

.content-text p:empty {
    display: none;
}

.exercise-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    position: relative;
}

.exercise-card.completed {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
}

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

.exercise-info h3 {
    font-size: 1.2rem;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 0.5rem;
}

.exercise-card.completed .exercise-info h3 {
    color: white;
}

.exercise-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.9rem;
    color: #6b7280;
}

.exercise-card.completed .exercise-meta {
    color: rgba(255, 255, 255, 0.9);
}

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

.btn-video {
    background: #ef4444;
    color: white;
    padding: 0.5rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    justify-content: center;
    font-size: 0.9rem;
}

.btn-complete {
    background: #10b981;
    color: white;
    padding: 0.5rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    justify-content: center;
    font-size: 0.9rem;
}

.btn-complete.completed {
    background: #059669;
}

.exercise-progress {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e5e7eb;
}

.exercise-card.completed .exercise-progress {
    border-top-color: rgba(255, 255, 255, 0.3);
}

.sets-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
}

.set-tracker {
    background: #f3f4f6;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    padding: 0.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.8rem;
    font-weight: 600;
}

.exercise-card.completed .set-tracker {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
    color: white;
}

.set-tracker.completed {
    background: #10b981;
    border-color: #059669;
    color: white;
}

.set-tracker:hover {
    transform: scale(1.05);
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-content {
    background: white;
    border-radius: 20px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid #e5e7eb;
}

.modal-header h3 {
    color: #1f2937;
    font-size: 1.3rem;
    font-weight: 600;
}

.modal-body {
    padding: 1.5rem;
}

.video-container {
    margin-bottom: 1.5rem;
}

.video-container iframe {
    width: 100%;
    height: 250px;
    border-radius: 12px;
    border: none;
}

.exercise-details {
    text-align: center;
}

.sets-reps {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 1rem;
}

.sets, .reps {
    background: linear-gradient(45deg, #2563eb, #1d4ed8);
    color: white;
    padding: 0.8rem 1.5rem;
    border-radius: 12px;
    font-weight: 600;
    font-size: 1rem;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .header-actions {
        width: 100%;
        justify-content: center;
    }

    .day-grid {
        grid-template-columns: 1fr;
    }

    .exercise-header {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .exercise-actions {
        flex-direction: row;
        justify-content: space-between;
        flex-wrap: wrap;
    }

    .exercise-image {
        height: 150px;
        object-fit: contain;
        object-position: center;
        background: #f8f9fa;
    }

    .sets-reps {
        flex-direction: column;
        gap: 1rem;
    }

    .video-container iframe {
        height: 200px;
    }

    .modal-content {
        margin: 1rem;
        max-height: calc(100vh - 2rem);
    }
}

@media (max-width: 480px) {
    .main {
        padding: 1rem 0.5rem;
    }

    .day-card, .exercise-card {
        padding: 1rem;
    }

    .workout-header {
        padding: 1rem;
    }
}

/* Mobile Bottom Navigation */
.mobile-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: space-around;
    padding: 0.4rem env(safe-area-inset-bottom) 0.6rem env(safe-area-inset-left);
    border-top: 1px solid #e5e7eb;
    z-index: 2000;
}

.mobile-nav .nav-btn {
    background: none;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    font-size: 0.7rem;
    color: #4b5563;
    padding: 0.4rem 0.6rem;
    min-width: 60px;
    border-radius: 10px;
    font-weight: 600;
}

.mobile-nav .nav-btn i {
    font-size: 1.2rem;
}

.mobile-nav .nav-btn.active, .mobile-nav .nav-btn:active {
    background: #2563eb;
    color: #fff;
}

/* Add bottom padding so content not hidden behind nav */
@media (max-width: 768px) {
    body, .app {
        padding-bottom: 70px; /* space for nav */
    }
}

/* iOS Install Tip */
.ios-install-tip {
    position: fixed;
    bottom: 70px;
    left: 50%;
    transform: translateX(-50%);
    background: #2563eb;
    color: #fff;
    padding: 0.75rem 1rem;
    border-radius: 16px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    max-width: 320px;
    z-index: 2100;
    animation: slideUp 0.4s ease;
}

.ios-install-tip .tip-close {
    background: rgba(255,255,255,0.2);
    border: none;
    color: #fff;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes slideUp {
    from { opacity: 0; transform: translate(-50%, 20px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

/* Gesture hint (optional future) */
.gesture-hint {
    position: fixed;
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
    background: rgba(0,0,0,0.4);
    color: #fff;
    padding: 0.3rem 0.6rem;
    border-radius: 8px;
    font-size: 0.65rem;
    letter-spacing: 0.5px;
    z-index: 1500;
}

/* PWA Styles */
@media (display-mode: standalone) {
    .header {
        padding-top: env(safe-area-inset-top);
    }
}

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

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

.bounce-in {
    animation: bounceIn 0.6s ease;
}

@keyframes bounceIn {
    0% { transform: scale(0.3); opacity: 0; }
    50% { transform: scale(1.05); opacity: 0.8; }
    70% { transform: scale(0.9); opacity: 0.9; }
    100% { transform: scale(1); opacity: 1; }
}

/* Calendar Styles */
.calendar-header {
    background: rgba(255,255,255,0.95);
    padding: 1rem 1.2rem;
    border-radius: 16px;
    margin-bottom: 1rem;
    box-shadow: 0 6px 18px rgba(0,0,0,0.08);
}
.calendar-header h2 { color:#2563eb; font-size:1.2rem; margin-bottom:0.2rem; }
.calendar-header p { font-size:0.8rem; color:#6b7280; }

.calendar-container {
    display: grid;
    grid-template-columns: repeat(auto-fit,minmax(42px,1fr));
    gap: 0.4rem;
    background: rgba(255,255,255,0.8);
    padding: 0.6rem;
    border-radius: 18px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
}

.calendar-day {
    position: relative;
    background: #f3f4f6;
    border-radius: 10px;
    min-height: 42px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    padding: 2px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
    -webkit-user-select: none; user-select: none;
}
.calendar-day:hover { transform: translateY(-2px); box-shadow:0 4px 10px rgba(0,0,0,0.12); }
.calendar-day.today { border-color:#2563eb; }
.calendar-day.past { opacity:0.85; }
.calendar-day.missed { background: #fee2e2; }
.calendar-day.completed { background: #10b981; color:#fff; }
.calendar-day.has-note::after {
    content: '\f249'; /* sticky-note icon */
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    top: 2px; right: 4px;
    font-size: 0.55rem;
    color: #f59e0b;
}
.calendar-day .d-num { font-weight:600; }
.calendar-day .m-num { font-size:0.55rem; opacity:0.7; }
.calendar-day.strike .d-num, .calendar-day.strike .m-num { text-decoration: line-through; }
.calendar-legend { margin:1rem 0; display:flex; flex-wrap:wrap; gap:0.6rem; font-size:0.65rem; }
.calendar-legend span { display:flex; align-items:center; gap:0.3rem; }
.legend-box { width:14px; height:14px; border-radius:4px; background:#f3f4f6; border:1px solid #d1d5db; }
.legend-box.completed { background:#10b981; }
.legend-box.today { background:#2563eb; }
.legend-box.missed { background:#fee2e2; }
.legend-box.note { background:#f59e0b; }

/* Note Modal */
.note-modal-content { max-width:480px; }
.note-textarea {
    width:100%;
    border:2px solid #e5e7eb;
    border-radius:12px;
    padding:0.75rem;
    font-family:inherit;
    resize:vertical;
    background:#f9fafb;
    outline:none;
}
.note-textarea:focus { border-color:#2563eb; box-shadow:0 0 0 2px rgba(37,99,235,0.2); }
.note-actions { margin-top:1rem; display:flex; gap:0.6rem; }
.note-date { font-size:0.8rem; color:#6b7280; margin-bottom:0.5rem; }

@media (max-width:600px) {
    .calendar-container { grid-template-columns: repeat(auto-fit, minmax(36px,1fr)); }
    .calendar-day { min-height:38px; }
}
