/* 
 * DISSENY PREMIUM PER A LA WEB-APP DE GIMNÀSTICA
 * Creat per Antigravity
 */

:root {
    /* DEFAULT: Material 3 Dark Scheme (MoGa Custom) */
    --primary: #A6C8FF;
    --on-primary: #02315E;
    --primary-container: #234776;
    --on-primary-container: #D5E3FF;

    --secondary: #BDC7DC;
    --tertiary: #DABDE2;

    --error: #FFB4AB;

    --bg-dark: #111318;
    /* surface */
    --bg-card: rgba(67, 71, 78, 0.4);
    /* surface-variant at 40% */
    --bg-card-hover: rgba(67, 71, 78, 0.7);

    --accent-gradient: linear-gradient(135deg, #A6C8FF 0%, #DABDE2 100%);
    --accent-color: #A6C8FF;

    --text-primary: #E1E2E9;
    /* on-surface */
    --text-secondary: #C4C6CF;
    /* on-surface-variant */

    --border-color: rgba(141, 145, 153, 0.2);
    /* outline at 20% */
    --shadow-premium: 0 12px 32px rgba(0, 0, 0, 0.6);
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --selection-color: #A6C8FF;
    --input-bg: #1A1C20;
}

[data-theme="light"] {
    --primary: #3D5F90;
    --on-primary: #FFFFFF;
    --primary-container: #D5E3FF;
    --on-primary-container: #234776;

    --secondary: #555F71;
    --tertiary: #6E5676;

    --error: #BA1A1A;

    --bg-dark: #F9F9FF;
    /* surface */
    --bg-card: rgba(224, 226, 236, 0.6);
    /* surface-variant at 60% for better contrast on light */
    --bg-card-hover: rgba(224, 226, 236, 0.9);

    --accent-gradient: linear-gradient(135deg, #3D5F90 0%, #6E5676 100%);
    --accent-color: #3D5F90;

    --text-primary: #191C20;
    /* on-surface */
    --text-secondary: #43474E;
    /* on-surface-variant */

    --border-color: rgba(116, 119, 127, 0.3);
    /* outline at 30% for visibility */
    --shadow-premium: 0 12px 32px rgba(0, 0, 0, 0.1);
    --selection-color: #3D5F90;
    --input-bg: #FFFFFF;
}


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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at top, rgba(166, 200, 255, 0.08) 0%, transparent 70%);
    pointer-events: none;
    z-index: -1;
}

body.modal-open {
    overflow: hidden;
}

.hidden {
    display: none !important;
}

.mobile-br {
    display: none;
}

h1,
h2,
h3 {
    font-family: 'Outfit', sans-serif;
    letter-spacing: -0.02em;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
}

/* Header */
.main-header {
    padding: 1.5rem 0 0;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(17, 19, 24, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

[data-theme="light"] .main-header {
    background: rgba(249, 249, 255, 0.88);
}

.main-header h1 {
    font-size: clamp(1.2rem, 5vw, 3.5rem);
    font-weight: 800;
    margin-bottom: 0.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.accent {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 30px rgba(171, 199, 255, 0.3);
}

.subtitle {
    font-size: clamp(0.65rem, 2.5vw, 1.1rem);
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-weight: 300;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Navigació Principal */
.main-nav {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 1.5rem;
    margin-bottom: 0;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.nav-tab {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 600;
    padding: 0.5rem 0;
    cursor: pointer;
    position: relative;
    transition: var(--transition-smooth);
}

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

.nav-tab.active::after {
    content: "";
    position: absolute;
    bottom: -0.6rem;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--accent-gradient);
    border-radius: 3px;
}

/* Filtres - Toggle Bar */
.filter-toggle-bar {
    display: flex;
    justify-content: flex-end;
    padding: 0.5rem 0 0;
}

.filter-toggle-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.2rem 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    transition: var(--transition-smooth);
    letter-spacing: 0.03em;
    text-transform: uppercase;
    opacity: 0.7;
}

.filter-toggle-btn:hover {
    color: var(--primary);
    background: transparent;
    border-color: transparent;
    opacity: 1;
}

.filter-chevron {
    transition: transform 0.3s ease;
}

.filter-toggle-btn[aria-expanded="false"] .filter-chevron {
    transform: rotate(-90deg);
}

/* Filtres - Contenidor col·lapsable */
.filter-collapsible {
    overflow: hidden;
    max-height: 200px;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
        opacity 0.3s ease,
        padding 0.3s ease;
    opacity: 1;
}

.filter-collapsible.collapsed {
    max-height: 0;
    opacity: 0;
}

/* Filtres */
.filter-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.filters {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

.mobile-flex-break {
    display: none;
}

.filter-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.7rem 1.2rem;
    border-radius: 50px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    transition: var(--transition-smooth);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.material-trigger .arrow {
    transition: transform 0.3s ease;
}

.material-trigger.active .arrow {
    transform: rotate(180deg);
}

.material-menu {
    max-height: 0;
    overflow: hidden;
    transition: var(--transition-smooth);
    background: rgba(255, 255, 255, 0.02);
    border-radius: 20px;
    margin: 0 auto;
    width: fit-content;
    border: 1px solid transparent;
}

.material-menu.open {
    max-height: 500px;
    margin-bottom: 3rem;
    padding: 1.5rem 2rem;
    border-color: var(--border-color);
    box-shadow: var(--shadow-premium);
}

.material-menu-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.menu-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-secondary);
    font-weight: 700;
}

.toggle-group {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

/* Custom Toggle Control */
.toggle-control {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: var(--transition-smooth);
}

.toggle-control:hover {
    color: var(--text-primary);
}

.toggle-control input {
    display: none;
}

.control-indicator {
    width: 40px;
    height: 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    position: relative;
    transition: var(--transition-smooth);
    border: 1px solid var(--border-color);
}

.control-indicator::after {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    background: var(--text-secondary);
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: var(--transition-smooth);
}

.toggle-control input:checked+.control-indicator {
    background: var(--accent-gradient);
    border-color: transparent;
}

.toggle-control input:checked+.control-indicator::after {
    left: 22px;
    background: var(--bg-dark);
}

.toggle-control input:checked~.toggle-label {
    color: var(--text-primary);
}

.filter-btn:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    transform: translateY(-2px);
}

.filter-btn.active {
    background: var(--accent-gradient);
    color: var(--on-primary);
    border-color: transparent;
    box-shadow: 0 5px 15px rgba(171, 199, 255, 0.3);
}

/* Grid d'Exercicis */
.exercise-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 2rem;
    padding-bottom: 2rem;
}

.exercise-counter {
    text-align: right;
    margin-top: 2rem;
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
    opacity: 0.8;
}

/* Card d'Exercici */
.exercise-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    overflow: hidden;
    transition: var(--transition-smooth);
    backdrop-filter: blur(12px);
    display: flex;
    flex-direction: column;
    cursor: pointer;
}

.exercise-card:hover {
    transform: translateY(-10px);
    border-color: var(--accent-color);
    box-shadow: var(--shadow-premium);
}

.card-img {
    width: 100%;
    height: 200px;
    object-fit: contain;
    background: #FFFFFF;
    /* Fons blanc per als pictogrames */
    border-bottom: 1px solid var(--border-color);
}

.card-content {
    padding: 1.5rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.category-tag {
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--accent-color);
    margin-bottom: 0.5rem;
    letter-spacing: 0.05em;
}

.mobile-category {
    display: none;
}

.exercise-card h3 {
    font-size: 1.4rem;
    margin-bottom: 1rem;
}

.rep-tag {
    display: inline-block;
    background: var(--primary-container);
    color: var(--on-primary-container);
    padding: 0.3rem 0.8rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.instructions {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: var(--transition-smooth);
}

.exercise-card:hover .instructions {
    -webkit-line-clamp: 10;
    line-clamp: 10;
}

.benefit-box {
    margin-top: auto;
    background: rgba(255, 255, 255, 0.02);
    padding: 1rem;
    border-radius: 12px;
    border-left: 2px solid var(--accent-color);
}

.benefit-box strong {
    display: block;
    font-size: 0.75rem;
    color: var(--accent-color);
    text-transform: uppercase;
}

.benefit-box p {
    font-size: 0.85rem;
    font-style: italic;
    color: var(--text-secondary);
}

/* --- COMPLEXITAT (ESTRELLES) --- */
.complexity-container {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    margin-bottom: 0.5rem;
}

.complexity-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-right: 0.2rem;
    opacity: 0.8;
}

.stars {
    display: flex;
    gap: 1px;
}

.star {
    font-size: 0.85rem;
    color: var(--border-color);
}

.star.filled {
    color: #FFD700;
}

[data-theme="light"] .star.filled {
    color: #FBC02D;
}

/* Animació de càrrega */
.loading {
    grid-column: 1 / -1;
    text-align: center;
    padding: 5rem;
    font-size: 1.5rem;
    color: var(--text-secondary);
}

.execution-header-compact {
    display: block;
    /* Stacked per defecte a desktop */
    margin-bottom: 2rem;
}

.modal-img {
    width: 100%;
    max-height: 300px;
    object-fit: contain;
    background: #FFFFFF;
    border-radius: 20px;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-color);
}

@media (max-width: 768px) {
    .mobile-br {
        display: block;
    }

    .desktop-only {
        display: none !important;
    }

    .main-header h1 {
        font-size: 2.5rem;
        line-height: 1.1;
    }

    .main-header h1 .accent {
        font-size: 2.2rem;
    }

    .main-header .subtitle {
        display: none !important;
    }

    .nav-tab {
        font-size: 0.8rem;
    }

    .container {
        padding: 0 1.5rem;
    }

    .instructions {
        display: none;
        /* Amaguem les instruccions a la targeta mateixa per estalviar espai */
    }

    .mobile-flex-break {
        display: block;
        flex-basis: 100%;
        height: 0;
    }

    .exercise-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    /* Targeta Compacta */
    .exercise-card {
        position: relative;
        /* Per al posicionament absolut del botó de play */
        flex-direction: row;
        align-items: flex-start;
        /* Canviem a flex-start per controlar millor el layout horitzontal */
        padding: 0.8rem;
        height: auto;
        min-height: 100px;
        gap: 1rem;
    }

    .card-img {
        width: 80px;
        height: 80px;
        border-radius: 12px;
        border-bottom: none;
        flex-shrink: 0;
    }

    .card-content {
        padding: 0;
        flex-grow: 1;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        padding-right: 2.5rem;
        /* Espai per al botó absolut a la dreta */
    }

    .exercise-card h3 {
        font-size: 1.05rem;
        margin-bottom: 0.2rem;
        line-height: 1.2;
    }

    .rep-tag {
        margin-bottom: 0.8rem;
        /* Augmentem l'espai inferior */
        padding: 0.2rem 0.6rem;
        font-size: 0.75rem;
        width: fit-content;
    }

    .exercise-card .benefit-box,
    .exercise-card .desktop-category,
    .exercise-card .btn-execute {
        display: none;
    }

    .mobile-meta-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        margin-bottom: 0.5rem;
    }

    .mobile-meta-row .complexity-container {
        margin-bottom: 0;
    }

    .mobile-category {
        display: inline-block !important;
        margin-bottom: 0;
    }

    /* Botó de Play Ràpid - Alineat Bottom-Right */
    .btn-quick-play {
        display: flex !important;
        position: absolute;
        bottom: 0.8rem;
        right: 0.8rem;
        background: var(--accent-gradient);
        color: var(--on-primary);
        width: 44px;
        height: 44px;
        border-radius: 50%;
        align-items: center;
        justify-content: center;
        border: none;
        cursor: pointer;
        font-size: 1.2rem;
        box-shadow: 0 4px 12px rgba(171, 199, 255, 0.3);
        transition: var(--transition-smooth);
        z-index: 2;
    }

    .btn-quick-play:hover {
        transform: scale(1.1);
    }

    .modal-content {
        padding: 1.5rem;
    }

    /* Modal Execució Compacte */
    .execution-header-compact {
        display: flex;
        gap: 0.8rem;
        align-items: center;
        margin-bottom: 1.2rem;
        background: rgba(255, 255, 255, 0.03);
        padding: 0.8rem;
        border-radius: 16px;
    }

    .execution-header-compact .modal-img {
        width: 100px;
        height: 100px;
        object-fit: contain;
        margin-bottom: 0;
        border-radius: 12px;
        flex-shrink: 0;
    }

    .execution-header-compact .goal-highlight {
        margin: 0;
        padding: 0;
        background: none;
        border: none;
        text-align: left;
    }

    .execution-header-compact .goal-highlight h4 {
        font-size: 0.75rem;
        margin-bottom: 0.2rem;
        opacity: 0.7;
    }

    .execution-header-compact .goal-val {
        font-size: 1rem;
        line-height: 1.3;
    }

    .execution-header-compact .goal-highlight .complexity-container {
        margin-top: 0.5rem;
        padding: 0;
        background: none;
        border: none;
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
    }

    .execution-header-compact .goal-highlight .complexity-label {
        font-size: 0.65rem;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        opacity: 0.6;
    }

    .execution-header-compact .goal-highlight .stars {
        font-size: 0.8rem;
        gap: 2px;
    }

    .execution-card h2 {
        font-size: 1.4rem;
        margin-bottom: 0.8rem;
    }

    .star {
        font-size: 1rem;
    }

    /* --- FULL SCREEN MODALS ON MOBILE (DETAIL & EXECUTION) --- */
    .modal.open:has(.detail-card),
    .modal.open:has(.execution-card) {
        padding: 0;
        align-items: stretch;
        background-color: var(--bg-dark);
        /* Fons opac en mòbil per a aquests modals */
    }

    .modal-content.detail-card,
    .modal-content.execution-card {
        width: 100vw;
        min-height: 100dvh;
        height: auto;
        max-width: none;
        border-radius: 0;
        margin: 0;
        display: flex;
        flex-direction: column;
        padding: 1.5rem;
        border: none;
        box-shadow: none;
        transform: none;
        animation: none;
    }

    #detailContent,
    #executionContent {
        flex-grow: 1;
        display: flex;
        flex-direction: column;
        height: 100%;
    }

    .modal-footer-actions,
    .execution-footer {
        margin-top: auto;
        padding: 1rem 0;
        background: var(--bg-dark);
        border-top: none;
        width: 100%;
    }
}

.modal-footer-actions {
    margin-top: 2rem;
}

/* --- MODALS & PERFIL --- */
.detail-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 0.5rem;
}

.tab-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 8px;
    transition: var(--transition-smooth);
}

.tab-btn.active {
    background: rgba(171, 199, 255, 0.1);
    color: var(--primary);
}

.tab-pane {
    display: none;
    animation: fadeIn 0.3s ease;
}

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

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

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

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    justify-content: center;
    align-items: flex-start;
    overflow-y: auto;
    padding: 2rem 0;
}

.modal.open {
    display: flex;
}

.profile-card {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: 24px;
    border: 1px solid var(--border-color);
    backdrop-filter: blur(12px);
    transition: var(--transition-smooth);
}

.profile-card:hover {
    border-color: var(--accent-color);
}

.page-card {
    max-width: 600px;
    margin: 2rem auto;
}

.modal-content {
    background: var(--bg-dark);
    padding: 2.5rem;
    border: 1px solid var(--border-color);
    border-radius: 32px;
    width: 90%;
    max-width: 500px;
    position: relative;
    box-shadow: var(--shadow-premium);
    animation: modalFadeIn 0.4s ease-out;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

.close-modal {
    position: absolute;
    right: 1.5rem;
    top: 1rem;
    font-size: 2rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-smooth);
}

.close-modal:hover {
    color: var(--primary);
}

.profile-card h2,
.execution-card h2,
.detail-card h2 {
    margin-bottom: 1.5rem;
    color: var(--primary);
}

.btn-quick-play {
    display: none;
    /* Amagat per defecte a desktop */
}

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

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.form-group input,
.form-group select {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    padding: 0.8rem 1rem;
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
    transition: var(--transition-smooth);
}

.form-group select option {
    background: var(--input-bg);
    color: var(--text-primary);
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.08);
}

.save-btn,
.close-btn-action {
    width: 100%;
    background: var(--accent-gradient);
    color: var(--on-primary);
    border: none;
    padding: 1rem;
    border-radius: 16px;
    font-weight: 700;
    cursor: pointer;
    margin-top: 1rem;
    transition: var(--transition-smooth);
}

.save-btn:hover,
.close-btn-action:hover {
    transform: scale(1.02);
    box-shadow: 0 5px 15px rgba(171, 199, 255, 0.3);
}

.profile-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    width: 45px;
    height: 45px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
    margin-left: 1rem;
}

.profile-btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--primary);
    color: var(--primary);
}

/* Executa Botó Card */
.btn-execute {
    background: var(--accent-gradient);
    color: var(--on-primary);
    border: none;
    padding: 0.8rem;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    margin-top: 1rem;
    transition: var(--transition-smooth);
}

.btn-execute:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(171, 199, 255, 0.3);
}

.goal-highlight {
    background: rgba(171, 199, 255, 0.05);
    padding: 1.5rem;
    border-radius: 20px;
    border-left: 4px solid var(--primary);
    margin: 1.5rem 0;
}

.goal-highlight h4 {
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.goal-val {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-primary);
}

.detail-complexity-box {
    margin: 0.75rem 0;
    padding: 0.6rem;
    background: rgba(171, 199, 255, 0.05);
    border-radius: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--border-color);
}

.detail-complexity-box .complexity-label {
    font-size: 0.9rem;
    color: var(--primary);
    margin-right: 1rem;
}

.detail-complexity-box .star {
    font-size: 1.4rem;
}

.modal-img-small {
    width: 100%;
    height: auto;
    max-height: 250px;
    object-fit: contain;
    background: #FFFFFF;
    /* Fons blanc per als pictogrames */
    border-radius: 20px;
    margin-bottom: 0.5rem;
    border: 1px solid var(--border-color);
}

.modal-desc {
    font-size: 0.76rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 1.5rem;
}

/* --- RUTINES I SELECCIÓ --- */

/* Ocultar botons d'execució en mode selecció */
.exercise-card.selecting .btn-execute,
.exercise-card.selecting .btn-quick-play {
    display: none !important;
}

/* Barra de Selecció */
.selection-bar {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary-container);
    color: var(--on-primary-container);
    backdrop-filter: blur(20px);
    padding: 1rem 2rem;
    border-radius: 100px;
    border: 1px solid var(--primary);
    box-shadow: var(--shadow-premium);
    z-index: 1000;
    width: auto;
    min-width: 300px;
}

.selection-bar.hidden {
    display: none;
}

.bar-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
}

.btn-primary-small {
    background: var(--accent-gradient);
    color: var(--on-primary);
    border: none;
    padding: 0.6rem 1.5rem;
    border-radius: 50px;
    font-weight: 600;
    cursor: pointer;
}

.btn-danger-small {
    background: rgba(255, 180, 171, 0.15);
    /* Basat en --error */
    border: 1px solid var(--error);
    color: var(--error);
    padding: 0.4rem 1.2rem;
    /* Alçada menor (0.4rem vs 0.6rem/0.7rem) */
    border-radius: 50px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.btn-danger-small:hover {
    background: var(--error);
    color: #410002;
    /* on-error dark */
    box-shadow: 0 4px 12px rgba(255, 180, 171, 0.2);
    transform: translateY(-1px);
}

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

/* Rutines Section */
.view-section {
    padding-top: 1rem;
    padding-bottom: 1.5rem;
    transition: opacity 0.3s ease;
}

.view-section.hidden {
    display: none !important;
}

#profileSection {
    padding-bottom: 0px !important;
}

#profileSection h2 {
    margin-bottom: 0px !important;
}

#profileSection .subtitle {
    margin-bottom: 10px !important;
}

#profileSection .form-group {
    margin-bottom: 12px !important;
}

#profileSection input,
#profileSection select {
    padding-top: 7px !important;
    padding-bottom: 7px !important;
}

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

.routines-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.routine-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 1.5rem;
    border-radius: 20px;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.routine-card:hover {
    transform: scale(1.02);
    border-color: var(--primary);
    background: var(--bg-card-hover);
}

.routine-card h3 {
    margin-bottom: 0.5rem;
}

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

/* Mode Selecció en Cards */
.exercise-card.selecting {
    border-color: rgba(171, 199, 255, 0.4);
}

.exercise-card.selected {
    background: rgba(171, 199, 255, 0.1);
    border-color: var(--primary);
}

.exercise-card.selected::before {
    content: "✓";
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: var(--primary);
    color: var(--on-primary);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    z-index: 5;
}

/* Barra de Progrés en Modal */
.progress-wrapper {
    display: flex;
    align-items: center;
    gap: 1rem;
    width: 100%;
    margin-bottom: 1.5rem;
}

.progress-info-count {
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--primary);
    min-width: 1.2rem;
    text-align: center;
    font-family: 'Outfit', sans-serif;
}

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

.progress-bar {
    height: 100%;
    background: var(--accent-gradient);
    width: 0%;
    transition: width 0.4s ease;
}

.nav-btns-step {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    gap: 1rem;
}

.btn-step {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.7rem 1.2rem;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    flex: 1;
}

.btn-step:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.02);
    border-radius: 20px;
    border: 1px dashed var(--border-color);
}

/* FAB - Botó '+' */
.fab-btn {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 64px;
    height: 64px;
    border-radius: 20px;
    background: var(--accent-gradient);
    color: var(--on-primary);
    border: none;
    font-size: 2.2rem;
    font-weight: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 12px 32px rgba(171, 199, 255, 0.4);
    cursor: pointer;
    z-index: 100;
    transition: var(--transition-smooth);
}

.fab-btn:hover {
    transform: scale(1.15) rotate(90deg);
    box-shadow: 0 16px 48px rgba(171, 199, 255, 0.6);
}

/* Icona Eliminar */
/* Targetes de Rutina actualitzades */
.routine-card {
    display: flex;
    flex-direction: column;
    min-height: 200px;
}

.routine-exercises-list {
    font-size: 0.75rem;
    color: var(--text-secondary);
    opacity: 0.8;
    margin-top: 0.5rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex-grow: 1;
    /* Push actions to the bottom */
}

.routine-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.8rem;
    margin-top: 1.5rem;
}

.btn-play {
    background: var(--accent-gradient);
    color: var(--on-primary);
    border: none;
    border-radius: 12px;
    padding: 0.6rem 2.2rem;
    /* Més ample */
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
    font-weight: 700;
}

.btn-play:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 20px rgba(171, 199, 255, 0.4);
}

.btn-icon-delete {
    background: rgba(255, 82, 82, 0.1);
    color: #ff5252;
    border: 1px solid rgba(255, 82, 82, 0.2);
    border-radius: 12px;
    padding: 0.6rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
}

.btn-icon-delete:hover {
    background: rgba(255, 82, 82, 0.2);
    transform: scale(1.1);
    color: #ff5252;
}

.routine-card .count {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
    display: block;
}

/* Footer */
.main-footer {
    padding: 3rem 0;
    text-align: center;
    border-top: 1px solid var(--border-color);
    margin-top: 1rem;
    clear: both;
}

.main-footer p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.main-footer p:hover {
    color: var(--primary);
}

/* --- ESTILS PER A L'EDICIÓ DE RUTINES --- */
.edit-list {
    list-style: none;
    margin: 1.5rem 0;
}

.edit-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: rgba(255, 255, 255, 0.03);
    padding: 0.8rem 1rem;
    border-radius: 12px;
    margin-bottom: 0.8rem;
    border: 1px solid var(--border-color);
}

.edit-item-name {
    flex-grow: 1;
    font-size: 0.95rem;
    font-weight: 500;
}

.edit-item-img {
    width: 60px;
    height: 60px;
    object-fit: contain;
    background: #fff;
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

.edit-controls {
    display: flex;
    gap: 0.4rem;
}

.btn-edit-control {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
}

.btn-edit-control:hover:not(:disabled) {
    background: var(--bg-card-hover);
    color: var(--primary);
    border-color: var(--primary);
}

.btn-edit-control:disabled {
    opacity: 0.2;
    cursor: not-allowed;
}

.btn-edit-control.delete {
    background: rgba(255, 82, 82, 0.1);
    color: #ff5252;
    border: 1px solid rgba(255, 82, 82, 0.2);
}

.btn-edit-control.delete:hover:not(:disabled) {
    background: rgba(255, 82, 82, 0.2);
    color: #ff5252;
    border-color: rgba(255, 82, 82, 0.4);
}

/* Botó d'edició a la card de rutina */
.btn-icon-edit {
    background: rgba(171, 199, 255, 0.1);
    color: var(--primary);
    border: 1px solid rgba(171, 199, 255, 0.2);
    border-radius: 12px;
    padding: 0.6rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
}

.btn-icon-edit:hover {
    background: rgba(171, 199, 255, 0.2);
    transform: scale(1.1);
}

/* --- ESTILS PER AL MODE ALEATORI --- */
.random-toggle-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(171, 199, 255, 0.05);
    padding: 0.8rem 1.2rem;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    width: 100%;
}

.random-toggle-label {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Switch estil Material */
.switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    transition: .4s;
    border-radius: 24px;
    border: 1px solid var(--border-color);
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: var(--text-secondary);
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background: var(--accent-gradient);
    border-color: transparent;
}

input:checked+.slider:before {
    transform: translateX(24px);
    background-color: var(--bg-dark);
}

/* --- ESTILS PER AFEGIR EXERCICIS DES D'EDICIÓ --- */
.add-exercise-selection {
    background: rgba(0, 0, 0, 0.2);
    padding: 1.5rem;
    border-radius: 20px;
    margin: 1.5rem 0;
    border: 1px dashed var(--primary);
    animation: fadeIn 0.3s ease;
}

.add-exercise-list-scroll {
    max-height: 250px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding-right: 0.5rem;
}

.add-exercise-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--bg-card);
    padding: 0.6rem 1rem;
    border-radius: 12px;
    cursor: pointer;
    transition: var(--transition-smooth);
    border: 1px solid transparent;
}

.add-exercise-item:hover {
    background: var(--bg-card-hover);
    border-color: var(--primary);
}

.add-ex-info {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.add-ex-name {
    font-size: 0.9rem;
    font-weight: 600;
}

.add-ex-cat {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

/* --- ESTILS EXECUCIÓ (OPCIONS) --- */
.execution-options {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    background: rgba(255, 255, 255, 0.03);
    padding: 1rem;
    border-radius: 15px;
    margin-bottom: 0.15rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
}



/* Responsivitat d'etiquetes i peus */
.label-mobile {
    display: none;
}

.label-desktop {
    display: inline;
}

.execution-footer {
    display: flex;
    flex-direction: column;
}

.disclaimer-footer {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
    text-align: center;
}

@media (max-width: 600px) {
    .profile-card.page-card {
        background: transparent !important;
        border: none !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        padding: 0 !important;
        margin: 1rem auto !important;
        backdrop-filter: none !important;
    }

    #executionModal.modal {
        padding: 0 !important;
        align-items: stretch !important;
        background: var(--bg-dark) !important;
    }

    #executionModal .modal-content.execution-card {
        width: 100% !important;
        max-width: 100% !important;
        height: 100% !important;
        min-height: 100dvh !important;
        border-radius: 0 !important;
        border: none !important;
        box-shadow: none !important;
        margin: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        padding: 1.5rem !important;
        transform: none !important;
        animation: none !important;
    }

    div#executionModal.modal.open {
        display: flex !important;
    }

    #executionContent {
        display: flex !important;
        flex-direction: column !important;
        flex-grow: 1 !important;
    }

    .label-mobile {
        display: inline;
    }

    .label-desktop {
        display: none;
    }

    .complexity-label {
        display: none;
    }

    .execution-footer {
        display: flex;
        flex-direction: column;
        margin-top: auto !important;
    }

    .progress-wrapper {
        order: 0;
        margin-bottom: 1.5rem !important;
    }

    .progress-container {
        margin-bottom: 0 !important;
    }

    .nav-btns-step {
        order: 1;
        margin-bottom: 1.5rem !important;
    }

    .execution-options {
        order: 2;
        flex-direction: row;
        gap: 0.5rem;
        padding: 0.6rem;
        margin-bottom: 0;
        background: rgba(255, 255, 255, 0.02);
        border-radius: 16px;
    }

    .disclaimer-footer {
        order: 3;
        font-size: 0.75rem;
        margin-top: 0.2rem;
        padding-top: 1rem;
        border-top: 1px solid var(--border-color);
        opacity: 0.8;
        margin-bottom: 0;
    }

    .random-toggle-container {
        flex-direction: row !important;
        gap: 0.4rem;
        flex: 1;
        padding: 0.5rem 0.6rem;
        background: rgba(255, 255, 255, 0.03);
        border-radius: 12px;
        justify-content: space-between !important;
        align-items: center !important;
        min-width: 0;
        /* Permet que s'encongeixi si cal */
    }

    .random-toggle-label {
        font-size: 0.75rem;
        flex-direction: row;
        gap: 0.4rem;
        text-align: left;
        white-space: nowrap;
        overflow: hidden;
    }

    .random-toggle-label svg {
        width: 14px;
        height: 14px;
        opacity: 0.7;
        flex-shrink: 0;
    }

    .random-toggle-label span {
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* Activity Log Styles */
.activity-log-list {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    margin-top: 1.5rem;
}

.activity-card {
    background: var(--surface-variant);
    border-radius: 20px;
    padding: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: var(--transition-smooth);
}

.activity-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

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

.activity-date-info {
    display: flex;
    flex-direction: column;
}

.activity-date {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--on-surface);
}

.activity-time {
    font-size: 0.75rem;
    opacity: 0.6;
}

.activity-status {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 0.3rem 0.6rem;
    border-radius: 8px;
    letter-spacing: 0.5px;
}

.activity-status.completada {
    background: rgba(76, 175, 80, 0.1);
    color: #81c784;
}

.activity-status.parcial {
    background: rgba(255, 152, 0, 0.1);
    color: #ffb74d;
}

.activity-card h3 {
    font-size: 1.2rem;
    margin-bottom: 1.2rem;
    color: var(--primary-color);
}

.activity-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    padding-top: 1.2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    opacity: 0.5;
    letter-spacing: 0.5px;
}

.stat-val {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--on-surface);
}

.stat-val.intensity {
    color: var(--primary);
    background: var(--primary-container);
    padding: 0.2rem 0.6rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 800;
    display: inline-block;
    margin-top: 4px;
}

.activity-header-right {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.activity-card .btn-icon-delete {
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: var(--text-secondary);
    padding: 0.5rem;
    border-radius: 10px;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    justify-content: center;
}

.activity-card .btn-icon-delete:hover {
    background: rgba(186, 26, 26, 0.1);
    color: #ffb4ab;
}

/* Light Theme Adjustments */
[data-theme="light"] .activity-card {
    background: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .activity-status.completada {
    background: #e8f5e9;
    color: #2e7d32;
}

[data-theme="light"] .activity-status.parcial {
    background: #fff3e0;
    color: #ef6c00;
}

[data-theme="light"] .activity-stats {
    border-top-color: rgba(0, 0, 0, 0.05);
}

/* --- KORA360 INTENSITY INDEX STYLES --- */
.kora-index-container {
    animation: fadeIn 0.5s ease-out;
    margin-top: 8px;
}

.kora-index-title {
    color: var(--primary) !important;
    font-size: 1.25rem !important;
    font-weight: 700;
    text-align: center;
    margin-bottom: 0.25rem !important;
    font-family: 'Outfit', sans-serif;
}

.kora-index-subtitle {
    text-align: center;
    font-size: 0.85rem !important;
    color: var(--text-secondary);
    margin-bottom: 1.5rem !important;
}

.kora-index-box {
    display: grid;
    grid-template-columns: 100px 1fr;
    gap: 1.5rem;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    padding: 1.5rem;
    border-radius: 20px;
    transition: var(--transition-smooth);
}

.profile-card:hover .kora-index-box {
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.04);
}

.kora-gauge-wrapper {
    position: relative;
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.kora-gauge-svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.kora-gauge-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.08);
    stroke-width: 8px;
}

.kora-gauge-progress {
    fill: none;
    stroke-width: 8px;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.5s cubic-bezier(0.4, 0, 0.2, 1), stroke 0.5s ease;
}

.kora-gauge-value {
    position: absolute;
    font-size: 1.25rem;
    font-weight: 800;
    font-family: 'Outfit', sans-serif;
    color: var(--text-primary);
}

.kora-index-info {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.kora-index-badge {
    align-self: flex-start;
    padding: 0.35rem 0.8rem;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: var(--transition-smooth);
}

/* Badge colors */
.kora-index-badge.mobility {
    background: rgba(76, 175, 80, 0.1);
    color: #81c784;
    border: 1px solid rgba(76, 175, 80, 0.2);
}

.kora-index-badge.conditioning {
    background: rgba(77, 182, 172, 0.1);
    color: #4db6ac;
    border: 1px solid rgba(77, 182, 172, 0.2);
}

.kora-index-badge.toning {
    background: rgba(79, 172, 254, 0.1);
    color: #4facfe;
    border: 1px solid rgba(79, 172, 254, 0.2);
}

.kora-index-badge.active {
    background: rgba(255, 183, 77, 0.1);
    color: #ffb74d;
    border: 1px solid rgba(255, 183, 77, 0.2);
}

.kora-index-badge.max {
    background: rgba(255, 82, 82, 0.1);
    color: #ff5252;
    border: 1px solid rgba(255, 82, 82, 0.2);
}

.kora-index-desc {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0;
    transition: var(--transition-smooth);
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .kora-index-box {
        grid-template-columns: 1fr;
        justify-items: center;
        text-align: center;
        gap: 1rem;
    }
    
    .kora-index-badge {
        align-self: center;
    }
}