/* SYSTEM DESIGN & VARIABLES */
:root, [data-theme="dark"] {
    --bg-dark: #080808;
    --bg-surface: rgba(26, 26, 26, 0.6);
    --bg-surface-solid: #1a1a1a;
    --border-color: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.16);
    
    /* Brand Colors (Musculosamente Pro Orange Identity) */
    --accent-primary: #FF6B00; /* Orange Premium */
    --accent-primary-rgb: 255, 107, 0;
    --accent-secondary: #FF8800; /* Deep Orange */
    --accent-glow: linear-gradient(135deg, #FF6B00 0%, #FF8800 50%, #FF9E44 100%);
    
    /* Semantic Colors */
    --accent-red: #ff4d4d;
    --accent-red-rgb: 255, 77, 77;
    --accent-green: #00ff88;
    --accent-green-rgb: 0, 255, 136;
    --accent-amber: #ffcc00;
    
    /* Text Colors */
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --text-muted: #666666;
    
    /* Layout Constants */
    --max-width: 500px;
    --nav-height: 72px;
    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    
    /* Shadows */
    --glow-shadow: 0 8px 32px 0 rgba(255, 107, 0, 0.25);
    --card-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
}

/* CLEAN LIGHT THEME (ESTILO APPLE) */
[data-theme="light"] {
    --bg-dark: #F5F7FB;
    --bg-surface: rgba(255, 255, 255, 0.85);
    --bg-surface-solid: #FFFFFF;
    --border-color: rgba(15, 23, 42, 0.12);
    --border-hover: rgba(15, 23, 42, 0.25);
    
    --accent-primary: #FF6B00;
    --accent-primary-rgb: 255, 107, 0;
    --accent-secondary: #FF8800;
    --accent-glow: linear-gradient(135deg, #FF6B00 0%, #FF8800 50%, #FF9E44 100%);
    
    --accent-red: #DC3545;
    --accent-red-rgb: 220, 53, 69;
    --accent-green: #28A745;
    --accent-green-rgb: 40, 167, 69;
    --accent-amber: #D97706;
    
    --text-primary: #1F2937;
    --text-secondary: #4B5563;
    --text-muted: #6B7280;
    
    --glow-shadow: 0 8px 24px 0 rgba(255, 107, 0, 0.18);
    --card-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
}

/* FASHION BARBIE THEME (DELICATE PINK) */
[data-theme="barbie"] {
    --bg-dark: #FFF4F8;
    --bg-surface: rgba(255, 255, 255, 0.9);
    --bg-surface-solid: #FFF9FC;
    --border-color: rgba(180, 60, 120, 0.18);
    --border-hover: rgba(180, 60, 120, 0.35);
    
    --accent-primary: #FF69B4;
    --accent-primary-rgb: 255, 105, 180;
    --accent-secondary: #FF9DCF;
    --accent-glow: linear-gradient(135deg, #FF69B4 0%, #FF9DCF 100%);
    
    --accent-red: #FF708C;
    --accent-red-rgb: 255, 112, 140;
    --accent-green: #20C997;
    --accent-green-rgb: 32, 201, 151;
    --accent-amber: #F59E0B;
    
    --text-primary: #6A214F;
    --text-secondary: #8E3E6D;
    --text-muted: #AD6F92;
    
    --glow-shadow: 0 8px 32px 0 rgba(255, 105, 180, 0.25);
    --card-shadow: 0 10px 28px rgba(190, 94, 145, 0.12);
}

/* SELETOR DE TEMAS */
.theme-selector {
    display: flex;
    background: var(--bg-surface-solid);
    padding: 4px;
    border-radius: 14px;
    gap: 4px;
    border: 1px solid var(--border-color);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.08);
    width: 100%;
}

.theme-btn {
    flex: 1;
    padding: 10px 8px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 700;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    appearance: none;
    -webkit-appearance: none;
}

.theme-btn:hover {
    color: var(--text-primary);
    background: rgba(125, 125, 125, 0.1);
}

.theme-btn.active {
    background: var(--accent-glow);
    color: #ffffff !important;
    box-shadow: 0 4px 14px var(--glow-shadow);
}

/* RESET & BASE STYLES */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-main);
    overflow-x: hidden;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    line-height: 1.5;
}

/* APP CONTAINER */
.app-container {
    width: 100%;
    max-width: var(--max-width);
    min-height: 100vh;
    background-color: var(--bg-dark);
    position: relative;
    padding-bottom: calc(var(--nav-height) + 24px); /* Espaço para barra de navegação */
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.8);
}

/* SCROLLBAR */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-dark);
}
::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* VIEWS (PAGES) CONTROL */
.view {
    display: none;
    padding: 24px 20px;
    animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    flex-direction: column;
    gap: 20px;
}

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

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

/* GLASSMORPHISM UTILITY */
.glass {
    background: var(--bg-surface);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 18px;
    box-shadow: var(--card-shadow);
    transition: border-color 0.3s ease, transform 0.3s ease;
}

.glass:hover {
    border-color: var(--border-hover);
}

/* TYPOGRAPHY SHAPING */
h1, h2, h3, h4 {
    font-weight: 700;
    letter-spacing: -0.02em;
}

h1 span, h2 span, h3 span {
    background: var(--accent-glow);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* BUTTONS */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    font-family: var(--font-main);
    font-size: 1rem;
    font-weight: 600;
    border-radius: 14px;
    border: none;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    color: #fff;
    text-decoration: none;
}

.btn-primary {
    background: var(--accent-glow);
    color: #050507;
    font-weight: 700;
}

.btn-primary:active {
    transform: scale(0.97);
    filter: brightness(0.9);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

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

.btn-secondary:active {
    transform: scale(0.97);
}

.btn-danger {
    background: rgba(var(--accent-red-rgb), 0.15);
    border: 1px solid rgba(var(--accent-red-rgb), 0.3);
    color: var(--accent-red);
}

.btn-danger:hover {
    background: rgba(var(--accent-red-rgb), 0.25);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.875rem;
    border-radius: 10px;
}

.btn-full {
    width: 100%;
}

.btn-glow:hover {
    box-shadow: var(--glow-shadow);
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border-radius: 50%;
    transition: background-color 0.2s ease, color 0.2s ease;
}

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

/* ==================== TELA: ONBOARDING ==================== */
#view-onboarding {
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

.onboarding-card {
    padding: 40px 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    text-align: center;
}

.logo-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 72px;
    height: 72px;
    background: rgba(var(--accent-primary-rgb), 0.1);
    border: 2px solid var(--accent-primary);
    border-radius: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-primary);
    box-shadow: var(--glow-shadow);
    margin-bottom: 8px;
}

.onboarding-card h1 {
    font-size: 2.2rem;
    font-weight: 800;
}

.tagline {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.onboarding-form {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: left;
}

.input-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    padding-left: 4px;
}

.input-group input, .input-group select {
    background: var(--bg-surface-solid);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 14px 16px;
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 1rem;
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
    width: 100%;
    outline: none;
}

.input-group input:focus, .input-group select:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(0, 242, 254, 0.1);
}

.privacy-note {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* ==================== TELA: DASHBOARD ==================== */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.welcome-text {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.user-name {
    font-size: 1.5rem;
    font-weight: 700;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.stat-card {
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 14px;
}

.stat-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.red-glow {
    background: rgba(255, 59, 48, 0.1);
    color: var(--accent-red);
}

.green-glow {
    background: rgba(52, 199, 89, 0.1);
    color: var(--accent-green);
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 700;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Banner de Início Rápido */
.start-workout-banner {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.glow-card {
    border-color: rgba(0, 242, 254, 0.2);
    box-shadow: 0 10px 40px rgba(0, 242, 254, 0.05);
}

.start-workout-banner h3 {
    font-size: 1.25rem;
}

.start-workout-banner p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Seção Recentes */
.recent-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.section-title-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.section-title-bar h3 {
    font-size: 1.1rem;
}

.workout-summary-card {
    padding: 18px;
}

.empty-state {
    color: var(--text-secondary);
    font-size: 0.875rem;
    text-align: center;
    padding: 24px 10px;
}

.recent-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

.recent-date {
    font-size: 0.75rem;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.05);
    padding: 4px 8px;
    border-radius: 6px;
}

.recent-exercises-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.recent-exercise-item {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
}

.recent-ex-name {
    font-weight: 500;
}

.recent-ex-sets {
    color: var(--text-secondary);
}

/* ==================== TELA: EXERCÍCIOS ==================== */
.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.view-header h2 {
    font-size: 1.5rem;
}

/* Filtros de Categorias */
.category-filters-container {
    margin: 0 -20px;
    padding: 0 20px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.category-filters-container::-webkit-scrollbar {
    display: none;
}

.category-filters {
    display: flex;
    gap: 8px;
    padding-bottom: 4px;
    width: max-content;
}

.filter-chip {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: 20px;
    font-family: var(--font-main);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-chip.active {
    background: var(--accent-glow);
    color: #050507;
    border-color: transparent;
    font-weight: 600;
}

/* Grid de Exercícios */
.exercise-list-wrapper {
    flex: 1;
    min-height: 0;
}

.exercise-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.exercise-card {
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.exercise-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.exercise-title {
    font-size: 1rem;
    font-weight: 600;
}

.exercise-tag {
    font-size: 0.75rem;
    color: var(--accent-primary);
    background: rgba(var(--accent-primary-rgb), 0.08);
    padding: 2px 8px;
    border-radius: 6px;
    width: fit-content;
}

.exercise-actions {
    display: flex;
    gap: 4px;
}

/* ==================== TELA: TREINO ATIVO ==================== */
.sticky-header {
    position: sticky;
    top: 0;
    background: var(--bg-dark);
    z-index: 10;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.workout-timer-text {
    font-size: 0.875rem;
    color: var(--accent-primary);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* Estado Vazio */
.workout-setup-box {
    padding: 40px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 16px;
    margin-top: 40px;
}

.workout-setup-box h4 {
    font-size: 1.15rem;
}

.workout-setup-box p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    max-width: 280px;
    line-height: 1.4;
}

/* Lista de Exercícios Ativos */
.active-exercises-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.active-ex-card {
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.active-ex-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 10px;
}

.active-ex-header h4 {
    font-size: 1.05rem;
    font-weight: 600;
}

/* Tabela de Séries */
.sets-table {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sets-header-row, .set-row {
    display: grid;
    grid-template-columns: 0.8fr 1.5fr 1.5fr 0.8fr;
    align-items: center;
    gap: 8px;
    text-align: center;
}

.sets-header-row span {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.set-index {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.set-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.set-input-wrap input {
    width: 100%;
    background: var(--bg-surface-solid);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 10px;
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 0.875rem;
    text-align: center;
    outline: none;
    transition: border-color 0.2s;
}

.set-input-wrap input:focus {
    border-color: var(--accent-primary);
}

/* Remover flechas do input number */
.set-input-wrap input::-webkit-outer-spin-button,
.set-input-wrap input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.set-checkbox {
    width: 28px;
    height: 28px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin: 0 auto;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    color: transparent;
}

.set-row.completed .set-checkbox {
    background: var(--accent-green);
    border-color: var(--accent-green);
    color: #000;
    transform: scale(1.05);
}

.set-row.completed input {
    background: rgba(52, 199, 89, 0.05);
    border-color: rgba(52, 199, 89, 0.2);
    color: rgba(255, 255, 255, 0.6);
}

.btn-add-set-link {
    background: none;
    border: none;
    color: var(--accent-primary);
    font-family: var(--font-main);
    font-size: 0.825rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    align-self: flex-start;
    padding: 4px 0;
}

.btn-add-set-link:hover {
    text-decoration: underline;
}

.active-workout-actions {
    margin-top: 10px;
}

/* ==================== TELA: HISTÓRICO ==================== */
.history-timeline {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.history-card {
    padding: 18px;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
    margin-bottom: 12px;
}

.history-info h4 {
    font-size: 1.1rem;
}

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

.history-ex-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

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

.history-ex-title {
    font-size: 0.9rem;
    font-weight: 600;
}

.history-sets-capsules {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.set-capsule {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* ==================== CRONÔMETRO DE DESCANSO FLUTUANTE ==================== */
.rest-timer-widget {
    position: fixed;
    bottom: calc(var(--nav-height) + 16px);
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 40px);
    max-width: calc(var(--max-width) - 40px);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    z-index: 99;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), 0 0 10px rgba(var(--accent-primary-rgb), 0.1);
    border-color: rgba(var(--accent-primary-rgb), 0.3);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.rest-timer-widget.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 20px);
}

.timer-progress-ring {
    position: relative;
    width: 46px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.timer-progress-ring svg {
    position: absolute;
    top: 0;
    left: 0;
    transform: rotate(-90deg);
}

.progress {
    transition: stroke-dashoffset 0.1s linear;
}

.timer-number {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--accent-primary);
    z-index: 2;
}

.timer-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.timer-label {
    font-size: 0.875rem;
    font-weight: 600;
}

.timer-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.timer-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-timer-adjust {
    background: rgba(var(--accent-primary-rgb), 0.08);
    border: 1px solid rgba(var(--accent-primary-rgb), 0.2);
    color: var(--accent-primary);
    padding: 6px 10px;
    border-radius: 8px;
    font-family: var(--font-main);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
}

.btn-timer-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
}

/* ==================== BARRA DE NAVEGAÇÃO INFERIOR ==================== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: var(--max-width);
    height: var(--nav-height);
    display: flex;
    justify-content: space-around;
    align-items: center;
    border-radius: 20px 20px 0 0;
    border-bottom: none;
    border-left: none;
    border-right: none;
    z-index: 100;
}

.nav-item {
    background: none;
    border: none;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-family: var(--font-main);
    font-size: 0.7rem;
    font-weight: 500;
    cursor: pointer;
    flex: 1;
    padding: 8px 0;
    transition: color 0.2s, transform 0.2s;
}

.nav-item svg {
    transition: transform 0.2s;
}

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

.nav-item.active svg {
    transform: translateY(-2px);
}

.nav-item-main {
    position: relative;
    top: -12px;
}

.nav-main-icon {
    width: 48px;
    height: 48px;
    background: var(--accent-glow);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(var(--accent-primary-rgb), 0.4);
    margin-bottom: -2px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.nav-item-main:hover .nav-main-icon {
    transform: scale(1.08) translateY(-2px);
    box-shadow: 0 6px 24px rgba(var(--accent-primary-rgb), 0.6);
}

/* ==================== MODAIS ==================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: flex-end; /* Abre de baixo no mobile */
    z-index: 999;
    opacity: 1;
    transition: opacity 0.3s ease;
}

@media(min-width: 500px) {
    .modal-overlay {
        align-items: center;
    }
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    width: 100%;
    max-width: var(--max-width);
    border-radius: 24px 24px 0 0;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@media(min-width: 500px) {
    .modal-content {
        border-radius: 24px;
        margin: 20px;
        width: calc(100% - 40px);
    }
}

.modal-large {
    height: 85vh;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.25rem;
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
}

.modal-divider {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 8px 0;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 10px;
}

/* Seleção de Exercícios Interno */
.modal-tip {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.modal-search-bar input {
    background: var(--bg-surface-solid);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 10px 14px;
    color: var(--text-primary);
    width: 100%;
    outline: none;
    font-family: var(--font-main);
    font-size: 0.875rem;
}

.modal-search-bar input:focus {
    border-color: var(--accent-primary);
}

.select-exercises-body {
    flex: 1;
}

.select-exercises-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 45vh;
    overflow-y: auto;
    padding-right: 4px;
}

.select-item-card {
    padding: 14px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.select-item-card.selected {
    border-color: var(--accent-primary);
    background: rgba(var(--accent-primary-rgb), 0.05);
}

.select-checkbox-indicator {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: transparent;
    transition: all 0.2s;
}

.select-item-card.selected .select-checkbox-indicator {
    border-color: var(--accent-primary);
    background: var(--accent-primary);
    color: #000;
}

/* Zona de Perigo nas Configurações */
.danger-zone {
    border: 1px solid rgba(var(--accent-red-rgb), 0.25);
    background: rgba(var(--accent-red-rgb), 0.03);
    border-radius: 14px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.danger-zone h4 {
    color: var(--accent-red);
    font-size: 0.95rem;
}

.danger-zone p {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* UTILITY CLASSES */
.hidden {
    display: none !important;
}

/* ANIMATIONS */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
        box-shadow: 0 0 15px rgba(var(--accent-primary-rgb), 0.2);
    }
    50% {
        opacity: .8;
        box-shadow: 0 0 25px rgba(var(--accent-primary-rgb), 0.45);
    }
}

.animate-pulse {
    animation: pulse 2.5s infinite ease-in-out;
}

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

.animate-bounce {
    animation: bounce 2s infinite ease-in-out;
}

/* ==================== ROTINAS E CADASTRADOS INLINE ==================== */
.routines-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 10px;
}

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

.routine-card {
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.routine-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.routine-title {
    font-size: 1rem;
    font-weight: 600;
}

.routine-subtitle {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.routine-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.inline-exercise-box {
    background: rgba(20, 20, 25, 0.95);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 12px;
    animation: slideDown 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.inline-exercise-box h5 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent-primary);
    margin-bottom: 8px;
}

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

/* ==================== HISTÓRICO RETRÁTIL ==================== */
.history-card {
    transition: all 0.3s ease;
    cursor: pointer;
}

.history-card:hover {
    border-color: rgba(255, 255, 255, 0.1);
}

.history-ex-list {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease, margin-top 0.35s ease, padding-top 0.35s ease;
    border-top: 1px solid transparent;
}

.history-card.expanded .history-ex-list {
    max-height: 1800px; /* valor limite alto para suportar muitos exercícios */
    opacity: 1;
    margin-top: 12px;
    padding-top: 12px;
    border-top-color: rgba(255, 255, 255, 0.05);
}

/* ==================== ESTILOS IMPORTADOR TXT ==================== */
.file-dropzone {
    border: 2px dashed var(--border-color);
    border-radius: 14px;
    padding: 24px 16px;
    text-align: center;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.02);
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.file-dropzone:hover, .file-dropzone.dragover {
    border-color: var(--accent-primary);
    background: rgba(var(--accent-primary-rgb), 0.05);
}

.file-dropzone span {
    font-size: 0.825rem;
    color: var(--text-secondary);
}

.import-preview-box {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 14px;
}

.import-routine-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    padding: 10px 12px;
}

.import-routine-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--accent-primary);
    margin-bottom: 6px;
}

.import-ex-chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.import-ex-chip {
    font-size: 0.725rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 2px 8px;
    border-radius: 6px;
    color: var(--text-secondary);
}

.import-ex-chip.is-new {
    border-color: rgba(var(--accent-primary-rgb), 0.3);
    color: #fff;
}

