:root {
    --primary-bg: #0f172a;
    --secondary-bg: #1e293b;
    --accent-color: #38bdf8;
    --accent-gradient: linear-gradient(135deg, #38bdf8 0%, #818cf8 100%);
    --success-color: #4ade80;
    --success-gradient: linear-gradient(135deg, #4ade80 0%, #2dd4bf 100%);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --glass-bg: rgba(30, 41, 59, 0.6);
    --glass-border: rgba(255, 255, 255, 0.08);
    --radius-lg: 20px;
    --radius-md: 14px;
    --radius-sm: 10px;
    --error-color: #ef4444;
    --error-gradient: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.2), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --shadow-accent: 0 0 20px rgba(56, 189, 248, 0.2);
}

/* Performance Optimization */
.tab-content, .exercise-item, .glass-card, .btn, .set-circle {
    will-change: transform, opacity;
}

.tab-content:not(.active) {
    content-visibility: hidden;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Rubik', 'Outfit', sans-serif;
}

html {
    height: 100%;
    -webkit-text-size-adjust: 100%;
}

body {
    background-color: var(--primary-bg);
    color: var(--text-primary);
    min-height: 100%;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    overscroll-behavior-y: contain;
    position: relative;
    touch-action: pan-y pinch-zoom;
    -webkit-font-smoothing: antialiased;
    -webkit-overflow-scrolling: touch;
}

.bg-fixed-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

/* Background Glows */
.bg-glow {
    position: absolute;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    filter: blur(100px);
    z-index: -1;
    opacity: 0.4;
}

.glow-1 {
    top: -100px;
    right: -100px;
    background: var(--accent-color);
}

.glow-2 {
    bottom: -100px;
    left: -100px;
    background: #818cf8;
}

/* App Container */
.app-container {
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    padding: calc(20px + env(safe-area-inset-top, 0px)) 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 30px; /* Increased from 25px */
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

/* Navbar */
.navbar {
    position: relative;
    display: flex;
    align-items: center;
    padding: 15px 25px;
    z-index: 10;
    flex: 1;
    gap: 15px;
}



.nav-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-end;
}

.nav-actions .btn {
    display: none; /* Controlled by JS */
    padding: 8px 15px;
    width: auto;
    font-size: 14px;
}

#logout-btn {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    border: 1px solid var(--glass-border);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.05);
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    margin-bottom: 5px;
    transition: var(--transition);
    max-width: 180px;
}

#user-email-display {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    direction: ltr;
}

.user-info i {
    color: var(--accent-color);
    font-size: 14px;
}

.user-info:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
}

.logo {
    font-size: 28px;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 12px;
    letter-spacing: -0.5px;
    color: #ffffff;
    white-space: nowrap;
    flex: 1;
    justify-content: center;
    text-shadow: 0 0 20px rgba(56, 189, 248, 0.3);
}

.logo i {
    color: var(--accent-color);
    filter: drop-shadow(0 0 8px rgba(56, 189, 248, 0.5));
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.nav-links {
    display: flex;
    gap: 12px;
    background: rgba(255, 255, 255, 0.03);
    padding: 6px;
    border-radius: var(--radius-md);
    border: 1px solid var(--glass-border);
}

.nav-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
}

.nav-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.nav-btn.active {
    color: var(--text-primary);
    background: var(--accent-gradient);
    box-shadow: 0 4px 15px rgba(56, 189, 248, 0.4);
}

/* Mobile Bottom Nav */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--glass-border);
    padding: 10px 15px calc(10px + env(safe-area-inset-bottom));
    z-index: 1000;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -10px 25px rgba(0, 0, 0, 0.3);
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 11px;
    font-weight: 600;
    transition: var(--transition);
    background: none;
    border: none;
    padding: 8px;
    border-radius: var(--radius-sm);
    flex: 1;
}

.mobile-nav-item i {
    font-size: 20px;
}

.mobile-nav-item.active {
    color: var(--accent-color);
}

.mobile-nav-item.active i {
    transform: translateY(-2px);
    text-shadow: 0 0 10px rgba(56, 189, 248, 0.5);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 30px; /* Separation between top-level sections */
}

.tab-content {
    display: none;
    flex-direction: column;
    gap: 25px; /* Increased from 20px */
    animation: fadeIn 0.4s ease-out;
}

.tab-content.active {
    display: flex;
    padding-bottom: 20px; /* Base padding for all tabs */
}

@media (max-width: 1024px) {
    .tab-content.active {
        padding-bottom: 40px; /* Extra padding on mobile to ensure gap before fixed nav */
    }
}

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

/* Skeleton Loader */
.skeleton {
    background: linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.03) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: var(--radius-sm);
    color: transparent !important;
    pointer-events: none;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Auth Branding */
.auth-branding {
    text-align: center;
    margin-bottom: 30px;
    animation: fadeIn 0.8s ease-out;
}

.auth-logo {
    width: 80px;
    height: 80px;
    background: var(--accent-gradient);
    border-radius: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 15px;
    font-size: 40px;
    color: white;
    box-shadow: 0 10px 25px rgba(56, 189, 248, 0.4);
    transform: rotate(-10deg);
}

.auth-branding h1 {
    font-size: 36px;
    font-weight: 800;
    margin-bottom: 5px;
    color: #ffffff;
}

.auth-branding h1 span {
    color: #ffffff;
}

.auth-branding p {
    color: var(--text-secondary);
    font-size: 16px;
}

/* Glass Card */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.12); /* Slightly more visible */
    padding: 30px;
    border-radius: var(--radius-lg);
    box-shadow: 0 15px 35px 0 rgba(0, 0, 0, 0.4);
    transition: var(--transition);
}

.glass-card:hover {
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 20px 50px 0 rgba(0, 0, 0, 0.5);
    transform: translateY(-2px);
}

.section-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 25px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.section-title i {
    color: var(--accent-color);
    background: rgba(56, 189, 248, 0.1);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    font-size: 18px;
    flex-shrink: 0;
}

/* Collapsible Card */
.collapsible-card {
    position: relative;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.collapsible-card.collapsed {
    order: 1;
    width: 62px;
    height: 62px;
    padding: 10px;
    cursor: pointer;
    border-radius: 18px;
    margin-bottom: 0 !important;
    flex-shrink: 0;
}

.collapsible-card:not(.collapsed) {
    order: 2;
    width: 100%;
}

.collapsible-card.collapsed:hover {
    background: rgba(56, 189, 248, 0.15);
    border-color: var(--accent-color);
    transform: scale(1.05);
}

.collapsible-card.collapsed .section-title {
    margin: 0;
    width: 40px;
    height: 40px;
    justify-content: center;
}

.collapsible-card.collapsed .section-title i {
    margin: 0;
    background: transparent;
}

.collapsible-card.collapsed .section-title span,
.collapsible-card.collapsed .collapse-toggle,
.collapsible-card.collapsed .card-content {
    display: none !important;
}

.collapse-toggle {
    margin-right: auto; /* Push to the left in RTL */
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition);
}

.collapse-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.collapsible-card:not(.collapsed) .collapse-toggle i {
    transform: rotate(180deg);
}

.collapsible-group {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 25px;
    align-items: flex-start;
}

/* Form Elements */
.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-secondary);
}

input {
    width: 100%;
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--glass-border);
    padding: 14px 18px;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 16px;
    transition: var(--transition);
}

input:focus {
    outline: none;
    border-color: var(--accent-color);
    background: rgba(15, 23, 42, 0.6);
    box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.1), var(--shadow-accent);
}

/* Password Visibility Toggle */
.password-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.password-wrapper input {
    padding-left: 45px; /* Space for the icon on the left in RTL */
}

.password-toggle {
    position: absolute;
    left: 15px; /* Positioned on the left in RTL */
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    padding: 5px;
    z-index: 5;
    font-size: 18px;
}

.password-toggle:hover {
    color: var(--accent-color);
}

/* Custom Checkbox Styling */
.checkbox-container input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 22px;
    height: 22px;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    transition: var(--transition);
    flex-shrink: 0;
}

.checkbox-container input[type="checkbox"]:checked {
    background: var(--accent-gradient);
    border-color: transparent;
}

.checkbox-container input[type="checkbox"]:checked::after {
    content: '\f00c';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 12px;
    color: #0f172a;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.checkbox-container:hover input[type="checkbox"] {
    border-color: var(--accent-color);
}

/* Reps Grid */
.reps-grid {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 25px;
}

.rep-input-group {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 15px;
    width: 100%;
}

.rep-input-group > div {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.rep-input-group label {
    font-size: 14px;
}

.rep-input-group input {
    text-align: center;
}

/* Buttons */
.btn {
    width: 100%;
    padding: 14px 24px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    transition: var(--transition);
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
    box-shadow: 0 4px 15px rgba(56, 189, 248, 0.3), inset 0 1px 1px rgba(255,255,255,0.2);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(56, 189, 248, 0.5), inset 0 1px 1px rgba(255,255,255,0.3);
}

.btn-success {
    background: var(--success-gradient);
    color: #0f172a;
    box-shadow: 0 4px 15px rgba(74, 222, 128, 0.3), inset 0 1px 1px rgba(255,255,255,0.3);
}

.btn-success:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(74, 222, 128, 0.5), inset 0 1px 1px rgba(255,255,255,0.4);
}

.btn-danger {
    background: var(--error-gradient);
    color: white;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3), inset 0 1px 1px rgba(255,255,255,0.2);
}

.btn-danger:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(239, 68, 68, 0.5), inset 0 1px 1px rgba(255,255,255,0.3);
}

.btn-outline {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    box-shadow: var(--shadow-sm);
}

.btn-outline:hover {
    background: rgba(56, 189, 248, 0.1);
    color: var(--accent-color);
    border-color: var(--accent-color);
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 5px 15px rgba(56, 189, 248, 0.2);
}

.btn-outline:active {
    transform: translateY(0);
}

/* Exercise List */
.exercise-list {
    margin: 20px 0;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.exercise-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    padding: 15px 20px;
    border-radius: var(--radius-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: slideIn 0.3s ease-out;
    cursor: move;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}

.exercise-info h3 {
    font-size: 18px;
    margin-bottom: 5px;
}

.exercise-info p {
    font-size: 14px;
    color: var(--text-secondary);
}

.remove-btn {
    background: transparent;
    border: none;
    color: #ef4444;
    cursor: pointer;
    font-size: 18px;
    padding: 5px;
    transition: var(--transition);
}

.remove-btn:hover {
    color: #f87171;
    transform: scale(1.1);
}

.edit-btn {
    background: transparent;
    border: none;
    color: var(--accent-color);
    cursor: pointer;
    font-size: 18px;
    padding: 5px;
    transition: var(--transition);
}

.edit-btn:hover {
    color: var(--text-primary);
    transform: scale(1.1);
}

.item-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.workouts-list .exercise-item {
    cursor: pointer;
    transition: var(--transition);
}

.workouts-list .exercise-item:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateX(-5px);
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    background: rgba(255,255,255,0.02);
    border-radius: var(--radius-lg);
    border: 1px dashed var(--glass-border);
}

.empty-state i {
    font-size: 56px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    opacity: 0.6;
    margin-bottom: 10px;
}

.empty-state p {
    max-width: 250px;
    line-height: 1.6;
    font-size: 16px;
}

.plan-actions {
    margin-top: 20px;
}

/* Active Workout (Activity Tab) */
.workout-exercise-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 20px;
}

.workout-exercise-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 10px;
}

.workout-exercise-header h3 {
    font-size: 20px;
    color: var(--accent-color);
}

.sets-container {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    padding: 10px 0;
}

/* Set Circle */
.set-circle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 3px solid var(--accent-color);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    background: transparent;
    user-select: none;
    position: relative;
    overflow: hidden;
}

.set-circle::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--success-gradient);
    opacity: 0;
    transition: var(--transition);
    z-index: -1;
}

.set-circle:hover {
    transform: scale(1.1);
    box-shadow: 0 0 15px rgba(56, 189, 248, 0.4);
}

.set-circle.done {
    border-color: var(--success-color);
    color: #0f172a;
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(74, 222, 128, 0.4);
}

.set-circle.done::after {
    opacity: 1;
}

/* Smaller circles for history */
.set-circle.sm {
    width: 42px;
    height: 42px;
    border-width: 2px;
    cursor: default;
}

.set-circle.sm:hover {
    transform: none;
    box-shadow: none;
}

.set-circle.sm.done {
    transform: none;
    box-shadow: 0 0 10px rgba(74, 222, 128, 0.2);
}

.sets-container.sm {
    gap: 8px;
    padding: 5px 0;
}

.edit-weight-btn, .edit-reps-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    font-size: 14px;
}

.edit-weight-btn:hover, .edit-reps-btn:hover {
    background: rgba(56, 189, 248, 0.1);
    color: var(--accent-color);
    border-color: var(--accent-color);
    transform: translateY(-2px);
}

.edit-weight-btn:active, .edit-reps-btn:active {
    transform: translateY(0);
}

/* Footer */
footer {
    text-align: center;
    padding: 20px 0;
    color: var(--text-secondary);
    font-size: 14px;
    border-top: 1px solid var(--glass-border);
}

footer a {
    color: var(--accent-color);
    text-decoration: none;
    transition: var(--transition);
    font-weight: 600;
}

footer a:hover {
    color: var(--text-primary);
    text-shadow: 0 0 8px rgba(56, 189, 248, 0.4);
}

/* Timer Widget */
.timer-widget {
    position: fixed;
    top: 20%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    width: 90%;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.9) 0%, rgba(15, 23, 42, 0.9) 100%);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(56, 189, 248, 0.4);
    box-shadow: 0 15px 50px 0 rgba(0, 0, 0, 0.5), 0 0 15px rgba(56, 189, 248, 0.2);
    padding: 20px;
    transition: box-shadow 0.3s ease;
}

.timer-widget.dragging {
    box-shadow: 0 25px 70px 0 rgba(0, 0, 0, 0.6), 0 0 25px rgba(56, 189, 248, 0.4);
    transition: none;
}

.timer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    font-size: 16px;
    font-weight: 600;
    color: var(--accent-color);
    cursor: move;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    user-select: none;
}

.close-timer {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    transition: var(--transition);
    line-height: 1;
}

.close-timer:hover {
    color: #ef4444;
}

.timer-display {
    font-size: 48px;
    font-weight: 800;
    letter-spacing: 2px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-family: 'Outfit', sans-serif;
}

/* Workout Duration Bar */
.workout-duration-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 12px 20px;
    background: rgba(56, 189, 248, 0.1);
    border: 1px solid rgba(56, 189, 248, 0.2);
    border-radius: var(--radius-md);
    color: var(--accent-color);
    font-weight: 700;
    font-size: 18px;
    letter-spacing: 0.5px;
}

.workout-duration-bar i {
    font-size: 20px;
    animation: pulse 2s infinite;
}

/* Mini Timer Bar - Fixed & Floating */
.mini-timer-bar {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    width: 95%;
    max-width: 480px;
    z-index: 2000;
    background: var(--accent-gradient);
    color: #0f172a;
    padding: 12px 24px;
    border-radius: var(--radius-lg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4), 0 0 20px rgba(56, 189, 248, 0.3);
    animation: slideInUpTimer 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.timer-complete-flash {
    animation: pulseRed 0.8s infinite alternate !important;
}

@keyframes pulseRed {
    from { color: #0f172a; }
    to { color: #ef4444; }
}

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

@keyframes slideInDown {
    from { transform: translateY(-10px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.mini-timer-info {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

.timer-label {
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.8;
    min-width: 50px;
}

.mini-timer-info i {
    font-size: 20px;
    filter: drop-shadow(0 0 5px rgba(15, 23, 42, 0.3));
}

.timer-display-container {
    background: rgba(15, 23, 42, 0.15);
    padding: 6px 12px;
    border-radius: 12px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 100px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative; /* Added for adjustment animation */
    overflow: visible;
}

.timer-adjustment-float {
    position: absolute;
    top: -5px;
    left: 50%;
    transform: translateX(-50%);
    font-weight: 800;
    font-size: 18px;
    color: #0f172a; /* Same as timer text */
    pointer-events: none;
    animation: floatUpFadeOut 0.8s cubic-bezier(0.165, 0.84, 0.44, 1) forwards;
    z-index: 10;
    text-shadow: 0 0 4px rgba(255, 255, 255, 0.4);
}

.timer-adjustment-float.negative {
    color: #ef4444; /* Red for negative adjustment */
}

@keyframes floatUpFadeOut {
    0% {
        opacity: 0;
        transform: translate(-50%, 0);
    }
    20% {
        opacity: 1;
        transform: translate(-50%, -10px);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -40px);
    }
}

#mini-timer-display {
    font-size: 26px;
    font-family: 'Outfit', sans-serif;
    font-variant-numeric: tabular-nums;
    letter-spacing: 1px;
    font-weight: 800;
    color: #0f172a;
    transition: all 0.3s ease;
    line-height: 1;
}

.over-target {
    color: #ef4444 !important;
    text-shadow: 0 0 10px rgba(239, 68, 68, 0.3);
}

.over-target-bg {
    background: rgba(239, 68, 68, 0.2) !important;
    border-color: rgba(239, 68, 68, 0.3) !important;
    animation: softPulse 1.5s infinite alternate;
}

@keyframes softPulse {
    from { transform: scale(1); box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1), 0 0 5px rgba(239, 68, 68, 0.2); }
    to { transform: scale(1.05); box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1), 0 0 15px rgba(239, 68, 68, 0.4); }
}

.mini-timer-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.mini-btn {
    background: rgba(15, 23, 42, 0.15);
    border: 1px solid rgba(15, 23, 42, 0.1);
    color: #0f172a;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: 700;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 16px;
    flex-shrink: 0;
}

.mini-btn:hover {
    background: rgba(15, 23, 42, 0.3);
    transform: scale(1.15) rotate(5deg);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.mini-btn:active {
    transform: scale(0.9);
}
/* Performance Tab Styles */
.performance-chart-container {
    background: rgba(15, 23, 42, 0.4);
    border-radius: 16px;
    padding: 15px;
    border: 1px solid var(--glass-border);
    margin-bottom: 20px;
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.2);
}

.performance-stats .glass-card {
    transition: transform 0.3s ease;
}

.performance-stats .glass-card:hover {
    transform: translateY(-5px);
}

.timer-separator {
    width: 1px;
    height: 24px;
    background: rgba(15, 23, 42, 0.1);
    margin: 0 5px;
}

.close-mini {
    background: rgba(239, 68, 68, 0.2) !important;
    color: #ef4444 !important;
    border-color: rgba(239, 68, 68, 0.1) !important;
}

.close-mini:hover {
    background: #ef4444 !important;
    color: white !important;
}

.timer-controls {
    display: flex;
    gap: 10px;
    width: 100%;
}

.timer-btn {
    flex: 1;
    padding: 10px;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
}

.timer-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-color);
}

.timer-btn-main {
    background: var(--accent-color);
    color: #0f172a;
    border: none;
}

.timer-btn-main:hover {
    background: #0ea5e9;
}

@keyframes pulse {
    from { opacity: 1; }
    to { opacity: 0.4; }
}

/* Custom Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 3000;
    animation: fadeIn 0.3s ease-out;
}

.modal-card {
    width: 90%;
    max-width: 400px;
    text-align: center;
    border: 1px solid rgba(56, 189, 248, 0.3);
    box-shadow: 0 8px 32px 0 rgba(56, 189, 248, 0.2);
}

.modal-card.modal-large {
    max-width: 800px;
    width: 95%;
    padding: 15px;
}

.modal-card.modal-large .modal-content {
    margin-bottom: 15px;
}

.modal-content {
    font-size: 18px;
    font-weight: 500;
    margin-bottom: 25px;
    color: var(--text-primary);
}

.modal-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.modal-btn {
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    font-size: 16px;
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-btn-confirm {
    background: var(--accent-gradient);
    color: var(--text-primary);
    box-shadow: 0 4px 15px rgba(56, 189, 248, 0.3);
}

.modal-btn-confirm:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(56, 189, 248, 0.5);
}

/* Auth Card Styles */
#auth-tab {
    display: none;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
    padding: 20px 0;
}

#auth-tab.active {
    display: flex;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    animation: fadeInScale 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes fadeInScale {
    from { 
        opacity: 0; 
        transform: scale(0.95) translateY(10px); 
    }
    to { 
        opacity: 1; 
        transform: scale(1) translateY(0); 
    }
}

.auth-card input {
    margin-bottom: 5px;
}

#auth-toggle-text:hover span {
    text-decoration: underline;
}

#logout-btn:hover {
    background: rgba(239, 68, 68, 0.1) !important;
    color: #ef4444 !important;
    border-color: rgba(239, 68, 68, 0.2) !important;
}

.modal-btn-cancel {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
}

.modal-btn-cancel:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

/* Custom Datetime Picker for Modal */
.modal-datetime-input {
    width: 100%;
    background: rgba(15, 23, 42, 0.9) !important;
    border: 2px solid var(--accent-color) !important;
    color: var(--text-primary) !important;
    padding: 15px !important;
    border-radius: var(--radius-md) !important;
    font-size: 18px !important;
    margin-bottom: 20px !important;
    text-align: center;
    appearance: none;
    -webkit-appearance: none;
    font-family: 'Outfit', sans-serif;
    box-shadow: 0 4px 20px rgba(56, 189, 248, 0.2);
    display: block;
    cursor: pointer;
}

.modal-datetime-input:focus {
    outline: none !important;
    box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.4) !important;
    background: var(--secondary-bg) !important;
}

/* Specific fix for iOS to make it look like a button */
.modal-datetime-input::-webkit-date-and-time-value {
    text-align: center;
    min-height: 1.5em;
}


/* Fix for iOS datetime-local icon/styling */
::-webkit-calendar-picker-indicator {
    filter: invert(1);
    cursor: pointer;
}


/* iOS Install Guide */
.ios-install-guide {
    text-align: right;
    padding: 10px 5px;
}

.guide-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    color: var(--accent-color);
}

.guide-header i {
    font-size: 28px;
}

.guide-header h3 {
    font-size: 20px;
    margin: 0;
}

.ios-install-guide p {
    margin-bottom: 20px;
    font-size: 16px;
    color: var(--text-primary);
}

.guide-steps {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.step {
    display: flex;
    align-items: center;
    gap: 15px;
    background: rgba(255, 255, 255, 0.05);
    padding: 12px 15px;
    border-radius: var(--radius-md);
    border: 1px solid var(--glass-border);
}

.step-num {
    background: var(--accent-gradient);
    color: #0f172a;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 14px;
    flex-shrink: 0;
}

.step p {
    margin: 0;
    font-size: 14px;
    line-height: 1.4;
}

.step i {
    font-size: 18px;
    vertical-align: middle;
}

/* Responsive - Mobile Perfection */
@media (max-width: 1024px) {
    .app-container {
        padding: calc(10px + env(safe-area-inset-top, 0px)) 10px calc(140px + env(safe-area-inset-bottom, 20px)); /* Significantly more space for bottom nav + gap */
    }

    .app-header {
        display: block;
    }

    .navbar {
        display: flex;
        align-items: center;
        padding: 12px 15px;
        border-radius: var(--radius-md);
        margin-bottom: 20px;
        gap: 10px;
        background: var(--glass-bg);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        border: 1px solid var(--glass-border);
    }

    .nav-actions {
        display: flex;
        flex-direction: column;
        gap: 6px;
        align-items: flex-end;
    }
    
    .nav-actions .btn {
        margin: 0 !important;
        font-size: 12px !important;
        padding: 6px 12px !important;
        width: auto !important;
    }
    
    #nav-links {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        background: rgba(15, 23, 42, 0.9);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-top: 1px solid var(--glass-border);
        display: flex;
        justify-content: space-around;
        padding: 10px 5px;
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 15px));
        margin: 0;
        z-index: 1000;
        border-radius: 0;
        gap: 5px;
        box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.5);
    }
    
    .nav-btn {
        flex-direction: column;
        gap: 6px;
        font-size: 10px;
        padding: 8px 5px;
        background: transparent !important;
        box-shadow: none !important;
        flex: 1;
        color: var(--text-secondary);
        border-radius: 12px;
        transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .nav-btn.active {
        color: var(--accent-color);
        background: rgba(56, 189, 248, 0.1) !important;
    }
    
    .nav-btn.active i {
        color: var(--accent-color);
        transform: translateY(-3px);
        text-shadow: 0 0 15px rgba(56, 189, 248, 0.6);
    }
    
    .nav-btn i {
        font-size: 20px;
        transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    }
    
    .glass-card {
        padding: 20px;
        border-radius: var(--radius-md);
    }
    
    .modal-card {
        padding: 30px 20px;
    }
    
    .modal-card.modal-large {
        padding: 15px;
    }

    .section-title {
        font-size: 20px;
    }
    
    .workout-exercise-header h3 {
        font-size: 16px;
    }
    
    .set-circle {
        width: 50px;
        height: 50px;
    }
    
    .set-circle span:first-child {
        font-size: 16px !important;
    }
    
    .set-circle span:last-child {
        font-size: 10px !important;
    }
    
    .timer-display {
        font-size: 36px;
    }
    
    footer {
        display: none;
    }

    .mini-timer-bar {
        bottom: calc(100px + env(safe-area-inset-bottom, 20px)); /* Stay well above the bottom navigation */
        width: calc(100% - 16px);
        padding: 8px 12px;
        gap: 10px;
        border-radius: 16px;
    }

    .mini-timer-info {
        gap: 8px;
    }

    .timer-label {
        display: none; /* Hide 'מנוחה' text on small screens */
    }

    .timer-display-container {
        min-width: 85px;
        padding: 4px 8px;
    }

    #mini-timer-display {
        font-size: 22px;
    }

    .mini-btn {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }

    .mini-timer-actions {
        gap: 8px;
    }

    .timer-separator {
        margin: 0 2px;
        height: 20px;
    }

    /* Extra padding when timer is active to clear buttons */
    body.timer-active .app-container {
        padding-bottom: calc(220px + env(safe-area-inset-bottom, 20px));
    }
}

/* Drag and Drop Styles */
.exercise-item.dragging {
    opacity: 0.6;
    border: 2px solid var(--accent-color);
    background: var(--secondary-bg);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    z-index: 1000;
}

.exercise-item.over {
    border-top: 3px solid var(--accent-color);
    padding-top: 12px;
}

.drag-handle {
    cursor: grab;
    margin-inline-end: 15px;
    padding: 12px 8px;
    color: var(--text-secondary);
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.drag-handle:hover {
    color: var(--accent-color);
}

.drag-handle:active {
    cursor: grabbing;
}

.exercise-item[draggable="true"] {
    user-select: none;
    -webkit-user-drag: element;
}

/* Admin & Coach Tabs */
#admin-role-select, #admin-coach-select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 12px center;
    background-size: 16px;
    padding-left: 40px;
}

#admin-user-result {
    animation: slideInDown 0.3s ease-out;
}

#trainee-management-container {
    animation: fadeIn 0.4s ease-out;
}

.trainee-sub-tab-active {
    background: var(--accent-gradient) !important;
    color: white !important;
}

#trainee-plans-view h3, #trainee-history-view h3 {
    margin: 20px 0 15px 0;
    font-size: 18px;
    color: var(--text-secondary);
}

/* Video Upload Styles */
.video-upload-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    font-size: 14px;
}

.video-upload-btn:hover {
    background: rgba(56, 189, 248, 0.1);
    color: var(--accent-color);
    border-color: var(--accent-color);
    transform: translateY(-2px);
}

.video-upload-btn.has-video {
    background: rgba(74, 222, 128, 0.1);
    color: var(--success-color);
    border-color: var(--success-color);
}

.video-preview-mini {
    padding: 0 0 10px 0;
    margin-top: -5px;
}

.upload-toast {
    position: fixed;
    bottom: 20px;
    left: 20px;
    right: 20px;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    color: white;
    padding: 12px 20px;
    border-radius: 12px;
    z-index: 9999;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.4s ease-out;
    transition: opacity 0.5s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes slideUp {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
