:root {
    /* Cores de Fundo e Estrutura */
    --as-bg-main: #f8fafc;
    --as-bg-card: #ffffff;
    --as-bg-sidebar: #ffffff;

    /* Cores de Marca (White-Label injetável) */
    --as-primary: #2563eb;
    --as-primary-hover: #1d4ed8;
    --as-primary-light: #eff6ff;
    --as-primary-soft: rgba(37,99,235,.06);

    /* Feedback */
    --as-success: #10b981;
    --as-success-light: #ecfdf5;
    --as-danger: #ef4444;
    --as-danger-light: #fef2f2;
    --as-warning: #f59e0b;
    --as-warning-light: #fffbeb;

    /* Tipografia e Bordas */
    --as-text-main: #0f172a;
    --as-text-secondary: #334155;
    --as-text-muted: #64748b;
    --as-border: #e2e8f0;
    --as-radius: 12px;
    --as-radius-sm: 8px;
    --as-shadow-sm: 0 1px 3px rgba(0,0,0,.04);
    --as-shadow-md: 0 4px 12px rgba(0,0,0,.06);

    /* Compat com JS que usa --accent */
    --accent: var(--as-primary);
    --accent-soft: var(--as-primary-soft);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--as-bg-main);
    color: var(--as-text-main);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    font-size: 15px;
    line-height: 1.6;
    letter-spacing: -0.01em;
}

/* ─── TOAST ─────────────────────────────────────────────────────────────────── */
.toast-container { position: fixed; top: 1rem; left: 50%; transform: translateX(-50%); z-index: 9999; display: flex; flex-direction: column; gap: .5rem; width: 90%; max-width: 400px; }
.toast {
    padding: 14px 18px;
    border-radius: var(--as-radius-sm);
    font-size: .9rem;
    font-weight: 500;
    animation: slideDown .3s cubic-bezier(.4,0,.2,1);
    box-shadow: var(--as-shadow-md);
    display: flex;
    align-items: center;
    gap: .6rem;
}
.toast.success { background: var(--as-success-light); color: #065f46; border-left: 4px solid var(--as-success); }
.toast.error { background: var(--as-danger-light); color: #991b1b; border-left: 4px solid var(--as-danger); }
.toast.info { background: var(--as-primary-light); color: #1e3a5f; border-left: 4px solid var(--as-primary); }
@keyframes slideDown { from { transform: translateY(-100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes slideOut { from { opacity: 1; } to { transform: translateY(-100%); opacity: 0; } }

/* ─── LOGIN ─────────────────────────────────────────────────────────────────── */
.login-container {
    display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 1.5rem;
    background: linear-gradient(160deg, #1e40af 0%, #3b82f6 50%, #1e3a8a 100%);
}
.login-box {
    background: var(--as-bg-card);
    border-radius: 20px;
    padding: 2.5rem 2rem;
    width: 100%; max-width: 400px;
    box-shadow: 0 25px 50px rgba(0,0,0,.15);
}
.login-box h1 { color: var(--as-primary); text-align: center; margin-bottom: .2rem; font-size: 1.5rem; font-weight: 800; }
.login-box .subtitle { text-align: center; color: var(--as-text-muted); margin-bottom: 2rem; font-size: .9rem; }
.auth-form { display: none; }
.auth-form.active { display: block; }
.auth-form h3 { color: var(--as-text-main); margin-bottom: 1.2rem; font-size: 1.05rem; font-weight: 700; }
.switch-link { text-align: center; color: var(--as-text-muted); font-size: .85rem; margin-top: 1.5rem; }
.switch-link a { color: var(--as-primary); text-decoration: none; font-weight: 600; }
.error-msg { color: var(--as-danger); text-align: center; margin-top: 1rem; font-size: .85rem; }

/* ─── APP LAYOUT ────────────────────────────────────────────────────────────── */
.app-container { display: flex; min-height: 100vh; }

.sidebar {
    width: 250px;
    background: var(--as-bg-sidebar);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    border-right: 1px solid var(--as-border);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    overflow-y: auto;
    z-index: 100;
    transition: transform .3s ease;
}
.sidebar h2 { color: var(--as-primary); font-size: 1.2rem; margin-bottom: 1.2rem; text-align: center; font-weight: 800; letter-spacing: -.5px; }
.user-badge {
    text-align: center;
    margin-bottom: 1.2rem;
    padding: 12px;
    background: var(--as-primary-light);
    border-radius: var(--as-radius-sm);
    border: 1px solid rgba(30,64,175,.08);
}
.user-role { display: block; font-size: .6rem; text-transform: uppercase; color: var(--as-primary); letter-spacing: 1.5px; font-weight: 700; }
.user-name { font-size: .9rem; color: var(--as-text-secondary); font-weight: 600; }

.nav-btn {
    background: transparent;
    border: none;
    color: var(--as-text-muted);
    padding: 10px 14px;
    border-radius: var(--as-radius-sm);
    cursor: pointer;
    text-align: left;
    font-size: .88rem;
    transition: all .15s ease;
    font-weight: 500;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
}
.nav-btn:hover { background: #f1f5f9; color: var(--as-text-main); }
.nav-btn.active { background: var(--as-primary-light); color: var(--as-primary); font-weight: 600; }
.logout-btn { margin-top: auto; color: var(--as-danger); opacity: .7; }
.logout-btn:hover { background: var(--as-danger-light); opacity: 1; }

.main-content {
    flex: 1;
    padding: 28px;
    margin-left: 250px;
    overflow-y: auto;
    min-height: 100vh;
    max-width: 900px;
}
.page { display: none; }
.page.active { display: block; animation: fadeIn .2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* ─── CARDS ─────────────────────────────────────────────────────────────────── */
.card {
    background: var(--as-bg-card);
    border: 1px solid var(--as-border);
    border-radius: var(--as-radius);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--as-shadow-sm);
}
.card h3 { color: var(--as-text-main); margin-bottom: 16px; font-size: 1rem; font-weight: 700; }
.card h4 { margin-top: 0; }

/* ─── STATS ─────────────────────────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.stat-card {
    background: var(--as-bg-card);
    border: 1px solid var(--as-border);
    border-radius: var(--as-radius-sm);
    padding: 16px 12px;
    text-align: center;
    transition: all .2s;
}
.stat-card:hover { box-shadow: var(--as-shadow-md); transform: translateY(-1px); }
.stat-card.accent { background: var(--as-primary-light); border-color: rgba(30,64,175,.12); }
.stat-card.danger { background: var(--as-danger-light); border-color: rgba(239,68,68,.12); }
.stat-value { display: block; font-size: 1.7rem; font-weight: 800; color: var(--as-text-main); letter-spacing: -1px; }
.stat-card.accent .stat-value { color: var(--as-primary); }
.stat-card.danger .stat-value { color: var(--as-danger); }
.stat-label { display: block; font-size: .68rem; color: var(--as-text-muted); margin-top: 4px; text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }

/* ─── CONSISTENCY GRID ──────────────────────────────────────────────────────── */
.consistency-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.consistency-day {
    aspect-ratio: 1;
    border-radius: 6px;
    background: #f1f5f9;
    display: flex; align-items: center; justify-content: center;
    font-size: .7rem;
    color: var(--as-text-muted);
    font-weight: 500;
}
.consistency-day.trained { background: var(--as-success); color: #fff; font-weight: 700; }
.consistency-day.today { box-shadow: inset 0 0 0 2px var(--as-primary); color: var(--as-primary); font-weight: 700; }

/* ─── FORMS ─────────────────────────────────────────────────────────────────── */
input, select, textarea {
    background: #f8fafc;
    border: 1.5px solid var(--as-border);
    color: var(--as-text-main);
    padding: 10px 14px;
    border-radius: var(--as-radius-sm);
    width: 100%;
    margin-bottom: 8px;
    font-size: .9rem;
    transition: all .2s;
    font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--as-primary); box-shadow: 0 0 0 3px var(--as-primary-soft); }
input::placeholder, textarea::placeholder { color: #94a3b8; }
label { display: block; margin-bottom: 4px; color: var(--as-text-secondary); font-size: .8rem; font-weight: 600; }

.btn {
    background: var(--as-primary);
    color: #fff;
    border: none;
    padding: 11px 22px;
    border-radius: var(--as-radius-sm);
    cursor: pointer;
    font-weight: 600;
    font-size: .9rem;
    transition: all .15s;
    box-shadow: 0 1px 2px rgba(0,0,0,.05);
    font-family: inherit;
    touch-action: manipulation;
}
.btn:hover { background: var(--as-primary-hover); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(30,64,175,.15); }
.btn:active { transform: translateY(0); }
.btn-danger { background: var(--as-danger); }
.btn-danger:hover { background: #dc2626; }
.btn-sm { padding: 7px 14px; font-size: .82rem; }
.btn-outline { background: transparent; border: 1.5px solid var(--as-primary); color: var(--as-primary); box-shadow: none; }
.btn-outline:hover { background: var(--as-primary-light); }

/* ─── COMBO TIP ─────────────────────────────────────────────────────────────── */
.combo-tip {
    display: flex; align-items: center; gap: .6rem;
    padding: 12px 16px;
    background: var(--as-primary-light);
    border: 1px solid rgba(30,64,175,.1);
    border-radius: var(--as-radius-sm);
    margin-bottom: 12px;
    font-size: .85rem;
    color: var(--as-text-secondary);
    flex-wrap: wrap;
}
.combo-icon { font-size: 1.1rem; }
.combo-tags { display: flex; gap: 4px; flex-wrap: wrap; margin-left: auto; }
.combo-tag { background: var(--as-primary-soft); color: var(--as-primary); padding: 3px 8px; border-radius: 4px; font-size: .7rem; font-weight: 600; }

/* ─── EXERCISE GRID ─────────────────────────────────────────────────────────── */
.muscle-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.muscle-tab {
    background: #f1f5f9;
    border: 1.5px solid transparent;
    color: var(--as-text-muted);
    padding: 6px 14px;
    border-radius: 20px;
    cursor: pointer;
    font-size: .8rem;
    font-weight: 600;
    transition: all .15s;
}
.muscle-tab:hover { border-color: var(--as-primary); color: var(--as-primary); }
.muscle-tab.active { background: var(--as-primary); color: #fff; border-color: var(--as-primary); }

.exercise-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(145px, 1fr)); gap: 10px; }
.exercise-card {
    background: var(--as-bg-card);
    border-radius: var(--as-radius-sm);
    padding: 8px;
    text-align: center;
    cursor: pointer;
    transition: all .2s;
    border: 1.5px solid var(--as-border);
}
.exercise-card:hover { transform: translateY(-2px); border-color: var(--as-primary); box-shadow: var(--as-shadow-md); }
.exercise-card img { width: 100%; height: 100px; object-fit: cover; border-radius: 6px; background: #f1f5f9; }
.exercise-card p { margin-top: 6px; font-size: .76rem; font-weight: 600; color: var(--as-text-secondary); line-height: 1.3; }

/* ─── MODAL ─────────────────────────────────────────────────────────────────── */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); backdrop-filter: blur(3px); z-index: 1000; align-items: center; justify-content: center; padding: 1rem; overflow-y: auto; }
.modal-overlay.show { display: flex; }
.modal-box {
    background: var(--as-bg-card);
    border-radius: 16px;
    padding: 24px 20px;
    width: 100%; max-width: 600px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,.15);
    animation: scaleIn .2s ease;
}
@media (max-width: 768px) {
    .modal-box { max-width: 100%; max-height: 90vh; border-radius: 12px; padding: 20px 16px; }
}
@keyframes scaleIn { from { transform: scale(.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-box h3 { margin-bottom: 16px; font-weight: 700; }

/* ─── TIMER ─────────────────────────────────────────────────────────────────── */
.timer-container { text-align: center; padding: 12px 0; }
.timer-circle {
    width: 130px; height: 130px;
    border-radius: 50%;
    border: 5px solid #f1f5f9;
    display: flex; align-items: center; justify-content: center;
    margin: 10px auto;
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--as-text-main);
    background: var(--as-bg-card);
    box-shadow: var(--as-shadow-sm);
}
.timer-circle.running { border-color: var(--as-success); animation: pulse 1.5s infinite; }
@keyframes pulse { 0%,100%{box-shadow:0 0 0 4px rgba(16,185,129,.08)} 50%{box-shadow:0 0 0 10px rgba(16,185,129,0)} }
.progress-bar { width: 100%; height: 4px; background: #f1f5f9; border-radius: 2px; margin-top: 10px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: linear-gradient(90deg, var(--as-success), #34d399); transition: width .25s linear; }

/* ─── LISTS ─────────────────────────────────────────────────────────────────── */
.workout-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--as-border);
    flex-wrap: wrap; gap: 6px;
    font-size: .9rem;
    transition: background .1s;
}
.workout-item:last-child { border-bottom: none; }
.workout-item:hover { background: #fafafa; }
.history-item { padding: 12px 16px; border-bottom: 1px solid var(--as-border); font-size: .9rem; }
.history-item:last-child { border-bottom: none; }
.badge { font-size: .65rem; padding: 3px 8px; border-radius: 4px; background: #f1f5f9; color: var(--as-text-muted); font-weight: 600; }
.badge.active { background: var(--as-success-light); color: var(--as-success); }

/* ─── STREAK & BADGES ───────────────────────────────────────────────────────── */
.streak-badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 14px;
    background: var(--as-warning-light);
    border: 1px solid rgba(245,158,11,.2);
    border-radius: var(--as-radius-sm);
    font-size: .88rem; font-weight: 700; color: #92400e;
    margin-bottom: 12px;
}
.badges-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.badge-item { padding: 4px 10px; background: var(--as-primary-light); border-radius: 4px; font-size: .75rem; font-weight: 600; color: var(--as-primary); }

/* ─── TEMPO BADGE ───────────────────────────────────────────────────────────── */
.tempo-badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 12px;
    background: var(--as-success-light);
    border: 1px solid rgba(16,185,129,.12);
    border-radius: 6px;
    font-size: .82rem; font-weight: 600; color: #065f46;
    margin-bottom: 10px;
}

/* ─── NEXT WORKOUT ──────────────────────────────────────────────────────────── */
.next-workout { text-align: center; padding: 20px; background: var(--as-primary-light); border-radius: var(--as-radius-sm); }
.next-workout p { font-size: 1rem; margin-bottom: 12px; color: var(--as-text-secondary); }

/* ─── EVOLUÇÃO ──────────────────────────────────────────────────────────────── */
.evolucao-item { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.evolucao-item span:first-child { min-width: 110px; font-size: .82rem; color: var(--as-text-muted); font-weight: 500; }
.evolucao-bar { flex: 1; height: 6px; background: #f1f5f9; border-radius: 3px; overflow: hidden; }
.evolucao-fill { height: 100%; background: linear-gradient(90deg, var(--as-primary), #3b82f6); border-radius: 3px; }
.evolucao-item span:last-child { font-weight: 700; color: var(--as-primary); min-width: 45px; text-align: right; font-size: .88rem; }

/* ─── MOBILE ────────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
        box-shadow: var(--as-shadow-md);
    }
    .sidebar.open { transform: translateX(0); }

    .main-content {
        margin-left: 0;
        padding: 16px;
        padding-top: 60px;
        max-width: 100%;
    }

    .mobile-header {
        display: flex;
        position: fixed;
        top: 0; left: 0; right: 0;
        height: 56px;
        background: var(--as-bg-card);
        border-bottom: 1px solid var(--as-border);
        align-items: center;
        padding: 0 16px;
        z-index: 99;
        box-shadow: var(--as-shadow-sm);
    }
    .mobile-header h2 { font-size: 1rem; color: var(--as-primary); font-weight: 800; margin-left: 12px; }

    .hamburger {
        background: none; border: none; font-size: 1.4rem; cursor: pointer; padding: 8px;
        color: var(--as-text-main); touch-action: manipulation;
    }

    .overlay-bg { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 99; }
    .overlay-bg.show { display: block; }

    .card { padding: 18px; margin-bottom: 14px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .exercise-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .exercise-card img { height: 85px; }
    .modal-box { padding: 20px 16px; }
    .timer-circle { width: 110px; height: 110px; font-size: 1.8rem; }
    .btn { padding: 12px 18px; width: 100%; }
    .muscle-tabs { gap: 4px; }
    .muscle-tab { padding: 5px 10px; font-size: .75rem; }
}

@media (min-width: 769px) {
    .mobile-header { display: none; }
    .overlay-bg { display: none !important; }
}
