:root {
    --bg-color: #0d0d0d;
    --card-bg: #1e1e1e;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --primary-color: #00ff88;
    /* Vibrant Green */
    --primary-hover: #00cc6a;
    --accent-color: #7000ff;
    /* Deep Purple */
    --danger-color: #ff4757;
    --border-radius: 16px;
    --font-family: 'Outfit', sans-serif;
    --transition: 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-family);
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
}

.app-container {
    width: 100%;
    max-width: 480px;
    /* Mobile first constrain */
    background-color: var(--bg-color);
    min-height: 100vh;
    position: relative;
    padding-bottom: 80px;
}

/* HEADER */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    position: sticky;
    top: 0;
    background: rgba(13, 13, 13, 0.9);
    backdrop-filter: blur(10px);
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.5rem;
    color: var(--primary-color);
}

.logo h1 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.nav-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    padding: 8px;
    cursor: pointer;
    transition: var(--transition);
}

.nav-btn.active {
    color: var(--primary-color);
}

/* VIEWS */
.view {
    display: none;
    padding: 0 20px;
    animation: fadeIn 0.3s ease;
}

.view.active-view {
    display: block;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* COMPONENTS */
h2 {
    font-weight: 600;
    margin-bottom: 5px;
}

.welcome-banner {
    margin: 20px 0 40px;
}

.welcome-banner span {
    color: var(--primary-color);
}

.welcome-banner p {
    color: var(--text-secondary);
}

.section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.routines-grid {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.routine-card {
    background: var(--card-bg);
    padding: 20px;
    border-radius: var(--border-radius);
    position: relative;
    overflow: hidden;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: var(--transition);
}

.routine-card:active {
    transform: scale(0.98);
}

.routine-card h3 {
    margin-bottom: 5px;
}

.routine-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.routine-card .card-actions {
    position: absolute;
    top: 15px;
    right: 15px;
    z-index: 10;
    display: flex;
    gap: 10px;
}

.btn-icon ion-icon,
.btn-back ion-icon,
.btn-delete-ex ion-icon {
    pointer-events: none;
}

.btn-icon,
.btn-back {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    width: 44px;
    /* Increased from 40px */
    height: 44px;
    /* Increased from 40px */
    border-radius: 50%;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn-primary,
.btn-secondary {
    border: none;
    border-radius: 12px;
    padding: 14px 20px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition);
}

.btn-primary {
    background: var(--primary-color);
    color: #000;
}

.btn-primary:active {
    background: var(--primary-hover);
}

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

.w-100 {
    width: 100%;
}

.spacer {
    height: 20px;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

input {
    width: 100%;
    background: var(--card-bg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 14px;
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
}

input:focus {
    border-color: var(--primary-color);
}

.exercise-input-group {
    background: rgba(255, 255, 255, 0.03);
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 15px;
    position: relative;
}

.btn-delete-ex {
    position: absolute;
    top: 10px;
    right: 10px;
    color: var(--danger-color);
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
}

/* WORKOUT VIEW */
.workout-progress {
    display: flex;
    align-items: center;
    gap: 15px;
    margin: 20px 0;
}

.progress-bar {
    flex: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.fill {
    height: 100%;
    background: var(--primary-color);
    transition: width 0.3s ease;
}

.active-exercise-card {
    text-align: center;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
    padding: 20px;
    border-radius: 20px;
    background: linear-gradient(145deg, #1e1e1e, #181818);
}

.workout-duration-timer {
    font-size: 0.9rem;
    color: var(--primary-color);
    background: rgba(0, 255, 136, 0.1);
    padding: 2px 10px;
    border-radius: 20px;
    font-weight: 600;
    font-family: monospace;
}

.active-exercise-card h2 {
    font-size: 2rem;
    margin-bottom: 5px;
}

.exercise-instructions {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-style: italic;
    margin-bottom: 15px;
    line-height: 1.4;
}

.prev-info {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
    font-weight: 600;
}

.set-info {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 30px;
}

.badge {
    background: rgba(255, 255, 255, 0.1);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.badge.secondary {
    color: var(--primary-color);
    background: rgba(0, 255, 136, 0.1);
}

.input-big-wrapper {
    margin-bottom: 25px;
    text-align: left;
}

.input-big-wrapper input {
    font-size: 2rem;
    text-align: center;
    font-weight: 700;
    color: var(--primary-color);
}

.btn-large {
    font-size: 1.2rem;
    padding: 20px;
}

/* REST OVERLAY */
.rest-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.rest-overlay.hidden {
    display: none;
}

.timer-container {
    text-align: center;
}

.timer-display {
    font-size: 6rem;
    font-weight: 700;
    color: var(--primary-color);
    font-family: monospace;
    margin: 20px 0;
    text-shadow: 0 0 30px rgba(0, 255, 136, 0.3);
}

.timer-controls {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.btn-chk {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    padding: 10px 20px;
    border-radius: 30px;
    cursor: pointer;
    font-size: 1rem;
}

.btn-chk:active {
    background: #fff;
    color: #000;
}

/* HISTORY */
.history-item {
    background: var(--card-bg);
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 10px;
    border-left: 4px solid var(--primary-color);
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
}

.history-date {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

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

.delete-history-btn {
    background: none;
    border: none;
    color: var(--danger-color);
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-radius: 50%;
    transition: background 0.2s;
}

.delete-history-btn:hover {
    background: rgba(255, 71, 87, 0.1);
}

.history-item {
    cursor: pointer;
    transition: transform 0.2s, background-color 0.2s;
}

.history-item:active {
    transform: scale(0.98);
    background-color: rgba(255, 255, 255, 0.05);
}

.history-detail-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.detail-exercise-group {
    background: var(--card-bg);
    padding: 15px;
    border-radius: var(--border-radius);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.detail-exercise-group h4 {
    color: var(--primary-color);
    margin-bottom: 10px;
    font-size: 1.1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 5px;
}

.detail-set-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 0.95rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

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

.detail-set-num {
    color: var(--text-secondary);
    font-weight: 600;
}

.detail-set-data {
    font-weight: 500;
}

.view-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

.header-actions {
    margin-left: auto;
    display: flex;
    gap: 10px;
}

.btn-text {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
}

/* AUTH / LOGIN VIEW */
.login-container {
    max-width: 400px;
    margin: 80px auto;
    padding: 40px 30px;
    background: var(--card-bg);
    border-radius: 24px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.login-header ion-icon {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 15px;
}

.login-header h1 {
    font-size: 2rem;
    margin-bottom: 5px;
}

.login-header p {
    color: var(--text-secondary);
    margin-bottom: 30px;
}

.auth-tabs {
    display: flex;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 5px;
    margin-bottom: 30px;
}

.tab-btn {
    flex: 1;
    padding: 10px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.tab-btn.active {
    background: var(--primary-color);
    color: white;
}

.error-message {
    color: #ff4d4d;
    font-size: 0.9rem;
    margin-top: 15px;
    min-height: 1.2rem;
}

.hidden {
    display: none !important;
}

.logout-btn {
    color: #ff4d4d !important;
}

/* VIEW SWITCHER */
.view-switcher {
    display: flex;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 4px;
    margin-bottom: 20px;
    gap: 4px;
}

.switcher-btn {
    flex: 1;
    padding: 10px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.switcher-btn ion-icon {
    font-size: 1.2rem;
}

.switcher-btn.active {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 4px 12px rgba(0, 255, 136, 0.2);
}

/* CALENDAR VIEW */
.history-calendar-view {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 20px;
    animation: fadeIn 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.calendar-header h4 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.calendar-grid-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.calendar-days-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
}

.calendar-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.03);
}

.calendar-day:hover {
    background: rgba(255, 255, 255, 0.08);
}

.calendar-day.empty {
    background: transparent;
    cursor: default;
}

.calendar-day.today {
    border: 2px solid var(--primary-color);
    font-weight: 700;
}

.calendar-day.has-workout {
    background: rgba(0, 255, 136, 0.15);
    color: var(--primary-color);
    font-weight: 700;
}

.calendar-day.has-workout::after {
    content: '';
    position: absolute;
    bottom: 6px;
    width: 4px;
    height: 4px;
    background: var(--primary-color);
    border-radius: 50%;
}

/* PROGRESS VIEW */
.goal-card {
    background: linear-gradient(145deg, #1e1e1e, #181818);
    padding: 20px;
    border-radius: var(--border-radius);
    border: 1px solid rgba(255, 255, 255, 0.05);
    margin-bottom: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.goal-card .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.goal-card h4 {
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.goal-info {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 10px;
}

#goal-exercise-text {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

#goal-weight-text {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary-color);
}

.goal-progress-container {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 10px;
}

.goal-progress-bar {
    flex: 1;
    height: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 5px;
    overflow: hidden;
}

#goal-percentage {
    font-weight: 700;
    color: var(--primary-color);
    min-width: 40px;
    text-align: right;
}

.goal-status {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-style: italic;
}

.btn-icon-small {
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.btn-icon-small:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--primary-color);
}

.progression-item {
    background: var(--card-bg);
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 12px;
    border-left: 4px solid var(--accent-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: fadeIn 0.3s ease;
}

.progression-main h4 {
    margin-bottom: 4px;
    font-size: 1.05rem;
}

.progression-main p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.progression-stats {
    text-align: right;
}

.progression-weight {
    display: block;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-color);
}

.progression-diff {
    font-size: 0.75rem;
    font-weight: 600;
}

.diff-up {
    color: var(--primary-color);
}

.diff-down {
    color: var(--danger-color);
}

.diff-neutral {
    color: var(--text-secondary);
}

.flex-1 {
    flex: 1;
}

/* AVATAR SELECTOR */
.avatar-selector {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 10px;
    padding: 10px 0;
}

.avatar-option {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    cursor: pointer;
    transition: var(--transition);
    border: 3px solid transparent;
    background: rgba(255, 255, 255, 0.05);
}

.avatar-option:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.1);
}

.avatar-option.selected {
    border-color: var(--primary-color);
    background: rgba(0, 255, 136, 0.1);
    box-shadow: 0 0 15px rgba(0, 255, 136, 0.3);
}

.user-avatar-small {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.2rem;
    background: rgba(255, 255, 255, 0.1);
    overflow: hidden;
}

.user-avatar-large {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4rem;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    border: 2px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.progress-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

/* PROFILE VIEW */
.profile-container {
    padding: 20px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.user-avatar-huge {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 7rem;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    border: 3px solid var(--primary-color);
    box-shadow: 0 10px 25px rgba(0, 255, 136, 0.2);
    margin-bottom: 30px;
}

.profile-card {
    width: 100%;
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 20px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.profile-info-item {
    margin-bottom: 20px;
}

.profile-info-item:last-child {
    margin-bottom: 0;
}

.profile-info-item label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 5px;
}

.profile-info p {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.home-banner-flex {
    display: flex;
    justify-content: flex-start;
    gap: 20px;
    align-items: center;
}

.user-avatar-medium {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3.5rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.logo {
    gap: 12px;
}