* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #6c5ce7;
    --secondary: #00b894;
    --danger: #d63031;
    --warning: #fdcb6e;
    --dark: #2d3436;
    --light: #dfe6e9;
    --bg: #f5f6fa;
    --white: #ffffff;
    --border: #e1e8ed;
    --shadow: rgba(0,0,0,0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg);
    color: var(--dark);
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.header {
    background: var(--white);
    border-bottom: 1px solid var(--border);
    padding: 1rem 0;
    box-shadow: 0 2px 4px var(--shadow);
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.nav {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-info {
    color: var(--dark);
}

/* Buttons */
.btn {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary);
    color: white;
}
.btn-block {
    width: 100%;
    display: block;
}

.btn-primary:hover {
    background: #5f4dd4;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px var(--shadow);
}

.btn-secondary {
    background: var(--secondary);
    color: white;
}

.btn-secondary:hover {
    background: #00a383;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #c02928;
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}

.btn-outline:hover {
    background: var(--primary);
    color: white;
}

.btn-block {
    width: 100%;
}

.btn-icon {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem 1rem;
    color: var(--dark);
    transition: color 0.2s;
}

.btn-icon:hover {
    color: var(--primary);
}
.templates-separator:hover #separator-icon {
    color: #2d3436 !important;
    transform: scale(1.1);
}

.templates-separator #separator-header:hover {
    background: rgba(0, 0, 0, 0.02);
    border-radius: 8px;
}

/* ✅ Content Sections - FIX FINALE */
.content-section {
    display: none !important;
}

.content-section.active {
    display: block !important;
}

/* Main Content */
.main-content {
    padding: 2rem 0;
}

.main-content .container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* ✅ Section Calendar - Grid SOLO quando active */
#section-calendar.active {
    display: grid !important;
    grid-template-columns: 300px 1fr;
    gap: 2rem;
    align-items: start;
}

/* ✅ Section Stats - Block SOLO quando active */
#section-stats.active {
    display: block !important;
    width: 100%;
    padding-top: 0;
}

/* Stats Container */
.stats-container {
    padding: 0;
    max-width: 1400px;
    margin: 0 auto;
}

#section-stats h2 {
    margin-top: 0 !important;
    margin-bottom: 2rem;
    color: #2d3436;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: transform 0.3s, box-shadow 0.3s;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
}

.stat-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: #667eea;
    margin-bottom: 0.5rem;
}

.stat-label {
    font-size: 0.9rem;
    color: #636e72;
    font-weight: 500;
}

/* Charts Section */
.charts-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
}

.chart-card {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.chart-card h3 {
    margin-bottom: 1.5rem;
    color: #2d3436;
}

.exercise-progress-section {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.exercise-progress-section h3 {
    margin-bottom: 1.5rem;
    color: #2d3436;
}

/* Tab Navigation */
.tab-nav {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
    font-size: 0.95rem;
}

.tab-nav:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.tab-nav.active {
    background: white;
    color: #667eea;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* Sidebar */
.sidebar {
    background: var(--white);
    border-radius: 10px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px var(--shadow);
    height: fit-content;
    position: sticky;
    top: 20px;
}

.sidebar h2 {
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
    color: var(--dark);
}

.help-text {
    font-size: 0.85rem;
    color: #636e72;
    margin-bottom: 1rem;
}

.workout-templates {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    margin-bottom: 1rem;
}

.workout-template {
    position: relative;
    background: white;
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    cursor: grab;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.workout-template:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.workout-template:active {
    cursor: grabbing;
    opacity: 0.7;
}

.template-color {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    flex-shrink: 0;
}

.template-info h3 {
    font-size: 1rem;
    margin-bottom: 0.2rem;
}

.template-info p {
    font-size: 0.8rem;
    color: #636e72;
}

/* Calendar */
.calendar-section {
    background: var(--white);
    border-radius: 10px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px var(--shadow);
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.calendar-header h2 {
    font-size: 1.5rem;
    color: var(--dark);
}

.calendar {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 10px;
}

.calendar-day-header {
    text-align: center;
    font-weight: 600;
    color: var(--dark);
    padding: 0.5rem;
    font-size: 0.9rem;
}

.calendar-day {
    min-height: 100px;
    background: var(--bg);
    border-radius: 8px;
    padding: 0.8rem;
    border: 2px dashed var(--border);
    transition: all 0.2s;
    cursor: pointer;
}

.calendar-day:hover {
    border-color: var(--primary);
    background: #f8f9ff;
}

.calendar-day.has-workout {
    border-style: solid;
    border-width: 2px;
}

.calendar-day.drag-over {
    background: #e3f2fd;
    border-color: var(--primary);
    transform: scale(1.02);
}

.calendar-day.other-month {
    opacity: 0.3;
}

.day-number {
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.day-workout {
    color: white;
    padding: 0.5rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    border: 2px solid transparent;
}
.day-workout-name {
    font-weight: 600;
    margin-bottom: 0.2rem;
}

.day-workout-exercises {
    font-size: 0.75rem;
    opacity: 0.9;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: var(--white);
    border-radius: 12px;
    padding: 2rem;
    max-width: 800px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: slideUp 0.3s;
}

@keyframes slideUp {
    from { 
        opacity: 0;
        transform: translateY(30px);
    }
    to { 
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-sm {
    max-width: 450px;
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    font-size: 2rem;
    font-weight: 300;
    color: #636e72;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}

.modal-close:hover {
    color: var(--danger);
}
#modal-exercise {
    z-index: 1100 !important;
}

/* Forms */
.form-group {
    margin-bottom: 1.2rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 500;
    color: var(--dark);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.7rem;
    border: 2px solid var(--border);
    border-radius: 6px;
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.form-group small {
    display: block;
    margin-top: 0.3rem;
    font-size: 0.8rem;
    color: #636e72;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border);
}

.tab-btn {
    padding: 0.7rem 1.5rem;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-weight: 500;
    color: #636e72;
    transition: all 0.2s;
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* Messages */
.message {
    padding: 1rem;
    border-radius: 6px;
    margin-top: 1rem;
    font-size: 0.9rem;
}

.message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Exercise List */
.exercise-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1rem;
}

.exercise-item {
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    position: relative;
}

.exercise-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.8rem;
}

.exercise-name {
    font-weight: 600;
    font-size: 1rem;
    color: var(--primary);
    cursor: pointer;
    text-decoration: underline;
}

.exercise-name:hover {
    color: #5f4dd4;
}

.exercise-remove {
    background: var(--danger);
    color: white;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
}

.exercise-params {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.8rem;
    margin-bottom: 0.8rem;   
}
.exercise-item .form-group {
    margin-top: 0.5rem;
    margin-bottom: 0;
}

.exercise-item .form-group input[type="text"] {
    width: 100%;
}

.param-group {
    display: flex;
    flex-direction: column;
}

.param-group label {
    font-size: 0.75rem;
    color: #636e72;
    margin-bottom: 0.3rem;
    font-weight: 500;
    white-space: nowrap;  
    overflow: hidden;     
    text-overflow: ellipsis;   
}

.param-group input {
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.9rem;
    width: 100%;
}

/* Video Container */
.video-container {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    margin-bottom: 1.5rem;
    border-radius: 8px;
}

.video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Exercise Info */
.exercise-meta {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.badge {
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    background: var(--primary);
    color: white;
}

.exercise-info h3 {
    margin: 1rem 0 0.5rem 0;
    color: var(--dark);
}

.muscle-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.muscle-tag {
    padding: 0.4rem 0.8rem;
    background: var(--bg);
    border-radius: 6px;
    font-size: 0.85rem;
    color: var(--dark);
}

.tips-list {
    list-style: none;
    padding: 0;
}

.tips-list li {
    padding: 0.5rem 0;
    padding-left: 1.5rem;
    position: relative;
}

.tips-list li:before {
    content: "✓";
    position: absolute;
    left: 0;
    color: var(--secondary);
    font-weight: bold;
}

/* Exercise Results */
.exercise-results {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    max-height: 400px;
    overflow-y: auto;
    padding: 1rem 0;
}

.exercise-card {
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.exercise-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px var(--shadow);
}

.exercise-card h4 {
    margin-bottom: 0.5rem;
    color: var(--dark);
}

.exercise-card p {
    font-size: 0.85rem;
    color: #636e72;
}

/* Search Bar */
.search-bar {
    margin-bottom: 1rem;
}

.search-bar input {
    width: 100%;
    padding: 0.8rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
}

.filters {
    margin-bottom: 1rem;
}

.filters select {
    padding: 0.6rem;
    border: 2px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
}

/* Exercise View Mode (per palestra) */
.exercise-view-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 1rem 0;
}

.exercise-view-item {
    background: var(--bg);
    border-left: 4px solid var(--primary);
    border-radius: 8px;
    padding: 1.2rem;
    box-shadow: 0 2px 4px var(--shadow);
}

.exercise-view-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.exercise-number {
    background: var(--primary);
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.exercise-view-name {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--primary);
    cursor: pointer;
    margin: 0;
    text-decoration: underline;
}

.exercise-view-name:hover {
    color: #5f4dd4;
}

.exercise-view-details {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.8rem;
    margin-bottom: 0.8rem;
}

.detail-badge {
    background: white;
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 0.8rem;
    text-align: center;
}

.detail-label {
    display: block;
    font-size: 0.75rem;
    color: #636e72;
    font-weight: 500;
    text-transform: uppercase;
    margin-bottom: 0.3rem;
}

.detail-value {
    display: block;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--dark);
}

.exercise-view-notes {
    background: #fff3cd;
    border-left: 3px solid #ffc107;
    padding: 0.8rem;
    border-radius: 4px;
    font-size: 0.9rem;
    color: #856404;
}

/* Modal Actions */
.modal-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

/* ✅ RESPONSIVE - FIX PER MOBILE */
@media (max-width: 1024px) {
    #section-calendar.active {
        grid-template-columns: 1fr !important;
    }

    .sidebar {
        position: static;
    }

    .calendar {
        grid-template-columns: repeat(7, 1fr);
        gap: 5px;
    }

    .calendar-day {
        min-height: 80px;
        padding: 0.5rem;
    }
}

@media (max-width: 768px) {
    /* ✅ Header Mobile */
    .header .container {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }

    .logo {
        font-size: 1.5rem;
        text-align: center;
    }

    .nav {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.5rem;
        width: 100%;
    }

    .user-info {
        font-size: 0.9rem;
        text-align: center;
        word-break: break-word;
        max-width: 100%;
    }

    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }

    .tab-nav {
        padding: 0.5rem 0.8rem;
        font-size: 0.85rem;
    }

    /* ✅ Stats Grid Mobile */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .stat-card {
        padding: 1.5rem 1rem;
    }

    .stat-icon {
        font-size: 2rem;
    }

    .stat-value {
        font-size: 1.8rem;
    }

    .stat-label {
        font-size: 0.8rem;
    }

    /* ✅ Charts Mobile */
    .charts-section {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .chart-card {
        padding: 1.5rem;
    }

    .stats-container {
        padding: 0;
    }

    #section-stats h2 {
        font-size: 1.3rem;
        margin-bottom: 1.5rem;
    }

    .main-content .container {
        padding: 1rem;
    }

    /* Calendar Mobile */
    .calendar {
        gap: 3px;
    }

    .calendar-day {
        min-height: 60px;
        padding: 0.3rem;
        font-size: 0.8rem;
    }

    .day-workout {
        padding: 0.3rem;
        font-size: 0.75rem;
    }

    .modal-content {
        width: 95%;
        padding: 1.5rem;
    }

    .exercise-params {
        grid-template-columns: repeat(2, 1fr);
    }

    .exercise-view-details {
        grid-template-columns: repeat(2, 1fr);
    }

    .exercise-view-name {
        font-size: 1.1rem;
    }

    .detail-value {
        font-size: 1.1rem;
    }
}

@media (max-width: 480px) {
    .logo {
        font-size: 1.3rem;
    }

    .user-info {
        font-size: 0.85rem;
    }

    .header .container {
        padding: 0.75rem;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }
}