/* ============================================================
   FitTrainer - TEMA PRETO com acentos em VERMELHO
   ============================================================ */

/* ===== LAYOUT BASE — MOBILE FIRST ===== */
*, *::before, *::after {
    box-sizing: border-box;
    -webkit-box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

body {
    width: 100%;
    max-width: 100vw;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
    background: var(--bg);
    color: var(--text);
    font-family: 'Figtree', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    overscroll-behavior: none;
    touch-action: manipulation;
    position: relative;
}

/* Inputs permitem seleção de texto */
input, textarea, select {
    -webkit-user-select: text;
    user-select: text;
    font-family: inherit;
}

/* Container principal — centralizado e com safe-area */
.app {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 1rem;
    padding-top: calc(1rem + env(safe-area-inset-top));
    padding-left: calc(1rem + env(safe-area-inset-left));
    padding-right: calc(1rem + env(safe-area-inset-right));
    padding-bottom: calc(5rem + env(safe-area-inset-bottom));
    position: relative;
    animation: pwaFadeIn 0.25s ease-out;
}

/* Navegação inferior fixa */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: var(--card);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 0.75rem;
    padding-bottom: calc(0.5rem + env(safe-area-inset-bottom));
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

/* Header sem padding extra de safe-area (já vem do .app) */
.header {
    padding-top: 0;
}

/* Previne overflow horizontal em QUALQUER elemento */
* {
    max-width: 100%;
}

p, h1, h2, h3, h4, h5, h6, span, div, a, button, label, li {
    word-break: break-word;
    overflow-wrap: break-word;
}

img, video, iframe, table {
    max-width: 100%;
}

/* Flex items não estouram */
.flex-item, .info, .actions, .brand, .brand > div {
    min-width: 0;
}

/* Animação de entrada */
@keyframes pwaFadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Remove sombra azul em toques no iOS */
a, button, .btn, .nav-btn, .list-item {
    -webkit-tap-highlight-color: transparent;
}

:root {
    --bg: #0a0a0a;
    --card: #141414;
    --card-2: #1a1a1a;
    --text: #ffffff;
    --muted: #888888;
    --accent: #ef4444;
    --accent-soft: rgba(239, 68, 68, 0.14);
    --accent2: #f97316;
    --accent2-soft: rgba(249, 115, 22, 0.14);
    --border: #262626;
    --danger: #dc2626;
    --danger-soft: rgba(220, 38, 38, 0.10);
    --success: #22c55e;
    --success-soft: rgba(34, 197, 94, 0.12);
}

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

html, body {
    font-family: 'Figtree', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
}

.app {
    max-width: 900px;
    margin: 0 auto;
    /* Padding definido na regra PWA no início do arquivo (com safe-area) */
}

/* ===== HEADER ===== */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 0 1.5rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.5rem;
}
.brand { display: flex; align-items: center; gap: 0.75rem; }
.brand-icon {
    width: 44px; height: 44px;
    background: var(--accent-soft);
    border: 1px solid var(--accent);
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    color: var(--accent); font-size: 1.5rem;
}
.brand h1 { font-size: 1.25rem; font-weight: 700; color: var(--text); }
.brand p { font-size: 0.8rem; color: var(--muted); }

.role-badge {
    display: inline-flex; align-items: center; gap: 0.35rem;
    padding: 0.35rem 0.75rem;
    background: var(--accent-soft);
    border: 1px solid var(--accent);
    border-radius: 999px;
    font-size: 0.8rem; font-weight: 600; color: var(--accent);
}
.role-badge.student {
    background: var(--accent2-soft);
    border-color: var(--accent2);
    color: var(--accent2);
}
.role-badge.admin {
    background: rgba(168, 85, 247, 0.14);
    border-color: #a855f7;
    color: #a855f7;
}

/* ===== FLASH MESSAGES ===== */
.flash-container { margin-bottom: 1rem; }
.flash {
    padding: 0.8rem 1rem; border-radius: 10px; margin-bottom: 0.5rem;
    font-size: 0.9rem; font-weight: 500;
    border: 1px solid transparent;
}
.flash-success {
    background: var(--success-soft); color: var(--success);
    border-color: var(--success);
}
.flash-error {
    background: var(--danger-soft); color: #fca5a5;
    border-color: var(--danger);
}

/* ===== LOGIN ===== */
.login-wrap { max-width: 420px; margin: 3rem auto 0; }
.login-card {
    background: var(--card); border: 1px solid var(--border);
    border-radius: 18px; padding: 2rem;
    box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}
.login-card .logo { text-align: center; margin-bottom: 1.5rem; }
.login-card .logo-icon {
    width: 72px; height: 72px;
    background: var(--accent-soft); border: 1px solid var(--accent);
    border-radius: 20px;
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--accent); font-size: 2rem; margin-bottom: 0.75rem;
}
.login-card h2 { font-size: 1.35rem; font-weight: 700; margin-bottom: 0.25rem; }
.login-card .subtitle { color: var(--muted); font-size: 0.9rem; margin-bottom: 1.5rem; }

/* ===== FORM ===== */
.form-group { margin-bottom: 1rem; }
.form-group label {
    display: block; font-size: 0.85rem; font-weight: 600;
    color: var(--muted); margin-bottom: 0.4rem;
}
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 0.75rem 0.85rem;
    border: 1px solid var(--border); border-radius: 10px;
    font-family: inherit; font-size: 0.95rem;
    background: var(--card-2); color: var(--text);
    transition: border-color 0.15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none; border-color: var(--accent);
}
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
    padding: 0.7rem 1.1rem; border-radius: 10px;
    font-family: inherit; font-size: 0.9rem; font-weight: 600;
    cursor: pointer; border: 1px solid transparent;
    transition: all 0.15s; white-space: nowrap; text-decoration: none;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.15); }
.btn-secondary {
    background: var(--card); border-color: var(--border); color: var(--text);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger {
    background: var(--danger-soft); border-color: var(--danger); color: var(--danger);
}
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-warn {
    background: var(--accent2-soft); border-color: var(--accent2); color: var(--accent2);
}
.btn-warn:hover { background: var(--accent2); color: #fff; }
.btn-ghost {
    background: transparent; color: var(--muted); padding: 0.4rem 0.7rem;
}
.btn-ghost:hover { color: var(--text); }
.btn-lg { padding: 0.9rem 1.5rem; font-size: 1rem; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ===== CARD ===== */
.card {
    background: var(--card); border: 1px solid var(--border);
    border-radius: 14px; padding: 1.25rem; margin-bottom: 1rem;
}
.card-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 1rem;
}
.card-title {
    font-size: 1.05rem; font-weight: 700;
    display: flex; align-items: center; gap: 0.5rem;
}
.card-title i { color: var(--accent); }

/* ===== TABS ===== */
.tabs {
    display: flex; gap: 0.5rem; margin-bottom: 1.5rem;
    overflow-x: auto; padding-bottom: 0.25rem;
}
.tab-btn {
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.6rem 1rem;
    background: var(--card); border: 1px solid var(--border);
    border-radius: 999px;
    font-family: inherit; font-size: 0.85rem; font-weight: 600;
    color: var(--muted); cursor: pointer; text-decoration: none;
    white-space: nowrap; transition: all 0.2s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active {
    background: var(--accent-soft); border-color: var(--accent);
    color: var(--accent);
}

/* ===== FILTER ===== */
.filter-wrap {
    background: var(--card); border: 1px solid var(--border);
    border-radius: 12px; padding: 1rem; margin-bottom: 1.5rem;
}
.filter-wrap label {
    display: block; font-size: 0.85rem; font-weight: 600;
    color: var(--muted); margin-bottom: 0.5rem;
}

/* ===== LIST ITEM ===== */
.list-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1rem; background: var(--card-2);
    border-radius: 10px; margin-bottom: 0.5rem; gap: 0.75rem;
}
.list-item .info { flex: 1; min-width: 0; }
.list-item .name { font-weight: 600; font-size: 0.95rem; margin-bottom: 0.15rem; }
.list-item .meta { font-size: 0.8rem; color: var(--muted); }
.list-item .actions { display: flex; gap: 0.25rem; }

/* ===== WORKOUT CARD ===== */
.workout-card {
    background: var(--card); border: 1px solid var(--border);
    border-radius: 14px; padding: 1.25rem; margin-bottom: 1rem;
    border-left: 4px solid var(--accent);
}
.workout-card.today {
    border-left-color: var(--accent2);
    background: linear-gradient(135deg, var(--card) 0%, rgba(249,115,22,0.04) 100%);
}
.workout-card .w-header {
    display: flex; align-items: flex-start; justify-content: space-between;
    margin-bottom: 0.75rem; gap: 0.75rem;
}
.workout-card .w-title {
    font-weight: 700; font-size: 1.05rem; margin-bottom: 0.2rem;
}
.workout-card .w-date { font-size: 0.8rem; color: var(--muted); }
.workout-card .w-status {
    display: inline-flex; align-items: center; gap: 0.3rem;
    padding: 0.25rem 0.6rem; border-radius: 999px;
    font-size: 0.75rem; font-weight: 600;
}
.status-pending { background: var(--accent2-soft); color: var(--accent2); }
.status-done { background: var(--success-soft); color: var(--success); }

/* ===== EXERCISE TABLE ===== */
.exercise-table {
    width: 100%; border-collapse: collapse;
    margin-top: 0.75rem; font-size: 0.85rem;
}
.exercise-table th, .exercise-table td {
    padding: 0.5rem 0.4rem; text-align: left;
    border-bottom: 1px solid var(--border);
}
.exercise-table th {
    color: var(--muted); font-weight: 600; font-size: 0.75rem;
    text-transform: uppercase; letter-spacing: 0.03em;
}

/* ===== EXERCISE FORM ROW ===== */
.exercise-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr 1fr auto;
    gap: 0.5rem; align-items: end;
    padding: 0.75rem; background: var(--card-2);
    border-radius: 10px; margin-bottom: 0.5rem;
}
@media (max-width: 600px) {
    .exercise-row { grid-template-columns: 1fr 1fr; }
}
.exercise-row input {
    padding: 0.5rem 0.6rem; font-size: 0.85rem;
    background: var(--bg); border: 1px solid var(--border);
    border-radius: 6px; color: var(--text); font-family: inherit;
}
.exercise-row label {
    display: block; font-size: 0.7rem; color: var(--muted);
    margin-bottom: 0.2rem; font-weight: 600;
}
.exercise-row .field { display: flex; flex-direction: column; }

/* ===== TIMER ===== */
.timer-wrap {
    text-align: center; padding: 2rem 1rem;
    background: var(--card); border: 2px solid var(--accent);
    border-radius: 20px; margin-bottom: 1.5rem;
}
.timer-label {
    font-size: 0.85rem; color: var(--muted);
    text-transform: uppercase; letter-spacing: 0.08em;
    font-weight: 600; margin-bottom: 0.5rem;
}
.timer-display {
    font-size: 3.5rem; font-weight: 700; color: var(--accent);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em; line-height: 1; margin-bottom: 1rem;
}
.timer-display.running { animation: pulse 2s ease-in-out infinite; }
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* ===== COACH ONLY INFO ===== */
.coach-only {
    margin-top: 0.75rem; padding: 0.75rem;
    background: var(--accent2-soft);
    border: 1px dashed var(--accent2);
    border-radius: 10px; font-size: 0.85rem;
}
.coach-only .label {
    font-weight: 700; color: var(--accent2); font-size: 0.75rem;
    text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.4rem;
}
.coach-only .time-row {
    display: flex; justify-content: space-between;
    padding: 0.15rem 0;
}
.coach-only .time-row span:first-child { color: var(--muted); }

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center; padding: 3rem 1rem; color: var(--muted);
}
.empty-state i { font-size: 3rem; margin-bottom: 0.75rem; opacity: 0.5; }
.empty-state p { font-size: 0.9rem; margin-bottom: 1rem; }

/* ===== STATS ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem; margin-bottom: 1.5rem;
}
.stat-card {
    background: var(--card); border: 1px solid var(--border);
    border-radius: 12px; padding: 1rem;
}
.stat-card .stat-value {
    font-size: 1.5rem; font-weight: 700; color: var(--accent);
    font-variant-numeric: tabular-nums;
}
.stat-card .stat-label {
    font-size: 0.75rem; color: var(--muted);
    text-transform: uppercase; letter-spacing: 0.04em;
    font-weight: 600; margin-top: 0.15rem;
}

/* ===== SECTION HEADER ===== */
.section-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 1rem;
}
.section-header h2 { font-size: 1.1rem; font-weight: 700; }

/* ===== BOTTOM NAV ===== */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--card); border-top: 1px solid var(--border);
    display: flex; justify-content: center; gap: 0.5rem;
    padding: 0.5rem 1rem; z-index: 50;
}
.nav-btn {
    display: inline-flex; flex-direction: column; align-items: center;
    gap: 0.15rem; padding: 0.4rem 0.9rem;
    background: transparent; border: none; border-radius: 10px;
    font-family: inherit; font-size: 0.7rem; font-weight: 600;
    color: var(--muted); cursor: pointer; transition: all 0.15s;
    text-decoration: none;
}
.nav-btn i { font-size: 1.2rem; }
.nav-btn:hover { color: var(--text); }
.nav-btn.active { color: var(--accent); background: var(--accent-soft); }

/* ===== UTILITIES ===== */
.hidden { display: none !important; }
.text-right { text-align: right; }
.mt-1 { margin-top: 1rem; }
.mb-1 { margin-bottom: 1rem; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ============================================================
   REGRAS ANTI-QUEBRA — GARANTEM QUE NADA ESTOURE A TELA
   ============================================================ */
/* Remove white-space: nowrap de botões — texto pode quebrar */
.btn { white-space: normal; word-break: break-word; }

/* Textos longos quebram palavras em vez de estourar */
.w-title, .card-title, .list-item .name, .brand h1,
.section-header h2, .login-card h2, h1, h2, h3, h4 {
    word-break: break-word;
    overflow-wrap: break-word;
}

/* Badge de perfil — encolhe se precisar */
.role-badge {
    white-space: normal;
    word-break: break-word;
    max-width: 100%;
}

/* Meta informações — quebram linha */
.w-date, .list-item .meta {
    word-break: break-word;
}

/* ============================================================
   CARD DE EXECUÇÃO DO TREINO (aluno) — DESIGN PROFISSIONAL
   Estrutura:
   ┌─────────────────────────────────────────────────────┐
   │ 🏋️ Nome do Exercício          │  BADGE  4 × 10 reps │ ← header
   ├─────────────────────────────────────────────────────┤
   │ ⚖️ CARGA (kg)          │  ⏱️ DESCANSO (seg)        │ ← body
   │ [ input ]              │  [ input ]               │
   └─────────────────────────────────────────────────────┘
   ============================================================ */
.execute-card {
    background: var(--card-2);
    border: 1px solid var(--border);
    border-radius: 14px;
    margin-bottom: 1rem;
    overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.execute-card:hover {
    border-color: rgba(239, 68, 68, 0.3);
    box-shadow: 0 4px 20px rgba(0,0,0,0.25);
}
/* Cabeçalho do card */
.execute-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1rem 1.1rem;
    background: linear-gradient(135deg, rgba(239,68,68,0.06) 0%, transparent 100%);
    border-bottom: 1px solid var(--border);
}
.execute-card-name {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text);
    word-break: break-word;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
}
.execute-card-name i {
    color: var(--accent);
    font-size: 1.1rem;
    flex-shrink: 0;
}
.execute-card-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.35rem 0.75rem;
    background: var(--accent2-soft);
    border: 1px solid var(--accent2);
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--accent2);
    white-space: nowrap;
    flex-shrink: 0;
}
.execute-card-badge i { font-size: 0.9rem; }
/* Corpo do card — campos de input */
.execute-card-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    padding: 1.1rem;
}
.execute-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 0;
}
.execute-field-label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.execute-field-label.load { color: var(--accent); }
.execute-field-label.rest { color: var(--accent2); }
.execute-field input {
    width: 100%;
    padding: 0.75rem 0.9rem;
    font-size: 1rem;
    font-weight: 600;
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.execute-field input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}
.execute-field input::placeholder {
    color: #555;
    font-weight: 400;
}
/* Responsividade do card de execução */
@media (max-width: 480px) {
    .execute-card-header {
        flex-wrap: wrap;
        padding: 0.85rem 1rem;
    }
    .execute-card-badge {
        width: 100%;
        justify-content: center;
    }
    .execute-card-body {
        grid-template-columns: 1fr;
        gap: 0.85rem;
        padding: 1rem;
    }
    .execute-card-name { font-size: 0.95rem; }
}

/* ===== QUICK ACCESS ===== */
.quick-access {
    background: var(--card-2); border: 1px solid var(--border);
    border-radius: 12px; padding: 1rem; margin-top: 1.5rem;
    font-size: 0.85rem; color: var(--muted);
}
.quick-access strong { color: var(--accent); }
.quick-access code {
    background: var(--bg); padding: 0.1rem 0.4rem;
    border-radius: 4px; font-size: 0.8rem; color: var(--text);
}

/* ============================================================
   RESPONSIVIDADE — CELULAR / TABLET
   Nada quebra a tela. Tudo que não cabe vai para a linha de baixo.
   ============================================================ */

/* Evita rolagem horizontal em qualquer situação */
html, body {
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
}

/* --- Ajustes gerais para telas até 600px --- */
@media (max-width: 600px) {
    .app {
        padding-left: calc(0.75rem + env(safe-area-inset-left));
        padding-right: calc(0.75rem + env(safe-area-inset-right));
        padding-top: calc(0.75rem + env(safe-area-inset-top));
        padding-bottom: calc(5.5rem + env(safe-area-inset-bottom));
    }

    /* Header — quebra em 2 linhas se não couber */
    .header {
        flex-wrap: wrap;
        gap: 0.75rem;
        justify-content: space-between;
    }
    .brand h1 { font-size: 1.1rem; }
    .brand p { font-size: 0.75rem; }
    .brand-icon { width: 38px; height: 38px; font-size: 1.25rem; }

    /* Section header — quebra linha */
    .section-header {
        flex-wrap: wrap;
        gap: 0.75rem;
    }
    .section-header h2 { font-size: 1rem; }

    /* Lista de itens — quebra linha */
    .list-item {
        flex-wrap: wrap;
    }
    .list-item .actions {
        width: 100%;
        justify-content: flex-end;
    }

    /* Cabeçalho do card de treino — quebra linha */
    .workout-card .w-header {
        flex-wrap: wrap;
    }
    .workout-card .w-title { font-size: 1rem; }
    .workout-card .w-date { font-size: 0.75rem; }

    /* Tabelas de exercícios — rolagem horizontal se não couber */
    .exercise-table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -0.25rem;
        padding: 0 0.25rem;
    }
    .exercise-table {
        min-width: 420px;
        width: 100%;
    }

    /* Filtro — quebra linha */
    .filter-wrap > div {
        flex-wrap: wrap;
    }

    /* Cronômetro — reduz tamanho */
    .timer-display {
        font-size: 2.5rem;
    }
    .timer-wrap {
        padding: 1.5rem 0.75rem;
    }

    /* Linha de exercícios do formulário — 2 colunas */
    .exercise-row {
        grid-template-columns: 1fr 1fr !important;
        gap: 0.5rem;
    }
    .exercise-row .field:nth-child(1) {
        grid-column: span 2;
    }

    /* Navegação inferior — rola horizontalmente se não couber */
    .bottom-nav {
        justify-content: flex-start;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding: 0.5rem 0.75rem;
        gap: 0.25rem;
    }
    .nav-btn {
        padding: 0.4rem 0.65rem;
        font-size: 0.65rem;
        flex-shrink: 0;
    }
    .nav-btn i { font-size: 1.1rem; }

    /* Botões — permitem quebrar linha de texto */
    .btn {
        white-space: normal;
        word-break: break-word;
    }
    .btn-lg { padding: 0.75rem 1.1rem; font-size: 0.95rem; }

    /* Cartão de login */
    .login-wrap { margin-top: 1.5rem; }
    .login-card { padding: 1.5rem; }

    /* Stats — 2 por linha */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Coach only info */
    .coach-only .time-row {
        flex-wrap: wrap;
        gap: 0.25rem;
    }
}

/* --- Ajustes extras para telas MUITO pequenas (até 380px) --- */
@media (max-width: 380px) {
    .timer-display { font-size: 2rem; }
    .stats-grid { grid-template-columns: 1fr; }
    .brand h1 { font-size: 1rem; }
    .exercise-row { grid-template-columns: 1fr !important; }
    .exercise-row .field:nth-child(1) { grid-column: span 1; }
    .btn { padding: 0.6rem 0.9rem; font-size: 0.85rem; }
    .nav-btn { padding: 0.35rem 0.5rem; font-size: 0.6rem; }
}

/* --- Ajustes para orientação paisagem em celular --- */
@media (max-height: 500px) and (orientation: landscape) {
    .timer-display { font-size: 2rem; }
    .timer-wrap { padding: 1rem; }
    .app { padding-bottom: calc(4rem + env(safe-area-inset-bottom)); }
}

/* ============================================================
   REGRAS DE GARANTIA — NADA QUEBRA O LAYOUT
   ============================================================ */
/* Textos longos quebram palavra em vez de estourar */
p, h1, h2, h3, h4, h5, h6, span, div, a, button, label {
    word-break: break-word;
    overflow-wrap: break-word;
}

/* Flex items não encolhem além do necessário */
.flex-item, .info, .actions {
    min-width: 0;
}

/* Previne overflow horizontal em qualquer elemento */
* {
    max-width: 100%;
}

/* Cards e list items não estouram */
.card, .list-item, .login-card, .workout-card, .execute-card {
    width: 100%;
    max-width: 100%;
}

/* Inputs e selects não ultrapassam a tela */
input, select, textarea, button {
    max-width: 100%;
    box-sizing: border-box;
}

/* Ajusta header para mobile — não deixa brand e perfil na mesma linha se não couber */
.header .brand {
    min-width: 0;
    flex-shrink: 1;
}

/* Navegação inferior: itens tem tamanho mínimo e não quebram */
.bottom-nav .nav-btn {
    flex-shrink: 0;
    min-width: 0;
}

/* Stats grid: em telas pequenas, 2 colunas */
@media (max-width: 500px) {
    .stats-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 0.6rem;
    }
}

/* Garante que o conteúdo não fique atrás da bottom nav */
body {
    padding-bottom: 0;
}

/* Form rows: em telas pequenas, 1 coluna */
@media (max-width: 500px) {
    .form-row {
        grid-template-columns: 1fr !important;
        gap: 0;
    }
}


/* ============================================================
   CORREÇÕES DE EMERGÊNCIA — GARANTE LAYOUT MOBILE
   Estas regras sobrescrevem qualquer outra que esteja quebrando
   ============================================================ */

/* Força container principal a nunca estourar */
html, body {
    width: 100% !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
    position: relative !important;
}

/* Garante que o app ocupe a tela toda corretamente */
.app {
    width: 100% !important;
    max-width: 900px !important;
    margin: 0 auto !important;
    padding: 1rem !important;
    padding-top: calc(1rem + env(safe-area-inset-top)) !important;
    padding-left: calc(0.75rem + env(safe-area-inset-left)) !important;
    padding-right: calc(0.75rem + env(safe-area-inset-right)) !important;
    padding-bottom: calc(5rem + env(safe-area-inset-bottom)) !important;
    box-sizing: border-box !important;
    display: block !important;
}

/* Header flex nunca quebra o layout */
.header {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 0.5rem !important;
    margin-bottom: 1rem !important;
    padding: 0 !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

.header > div:first-child,
.header > a:first-child {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    max-width: 100% !important;
}

.header > div:last-child,
.header > div[style] {
    flex: 0 0 auto !important;
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 0.25rem !important;
    justify-content: flex-end !important;
    max-width: 100% !important;
}

/* Brand não estoura */
.brand {
    display: flex !important;
    align-items: center !important;
    gap: 0.6rem !important;
    min-width: 0 !important;
    max-width: 100% !important;
}

.brand > div {
    min-width: 0 !important;
    max-width: 100% !important;
    overflow: hidden !important;
}

.brand h1 {
    font-size: 1.15rem !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    margin: 0 !important;
}

.brand p {
    font-size: 0.75rem !important;
    margin: 0 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

/* Section header sempre quebra linha */
.section-header {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 0.5rem !important;
    margin-bottom: 1rem !important;
    width: 100% !important;
}

.section-header h2 {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    font-size: 1.05rem !important;
    margin: 0 !important;
}

.section-header .btn,
.section-header a {
    flex: 0 0 auto !important;
}

/* Lista de itens: sempre quebra linha */
.list-item {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 0.5rem !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

.list-item .info {
    flex: 1 1 200px !important;
    min-width: 0 !important;
    max-width: 100% !important;
}

.list-item .actions {
    flex: 0 0 auto !important;
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 0.25rem !important;
    justify-content: flex-end !important;
    max-width: 100% !important;
}

/* Navegação inferior: nunca quebra, rola se necessário */
.bottom-nav {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 999 !important;
    display: flex !important;
    flex-wrap: nowrap !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 0.25rem !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    padding: 0.5rem 0.5rem !important;
    padding-bottom: calc(0.5rem + env(safe-area-inset-bottom)) !important;
    background: var(--card) !important;
    border-top: 1px solid var(--border) !important;
}

.bottom-nav .nav-btn {
    flex: 0 0 auto !important;
    min-width: 0 !important;
    padding: 0.35rem 0.55rem !important;
    font-size: 0.65rem !important;
    display: inline-flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 0.1rem !important;
    white-space: nowrap !important;
}

.bottom-nav .nav-btn i {
    font-size: 1.1rem !important;
}

/* Cards nunca estouram */
.card, .login-card, .workout-card, .execute-card, .flash {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

/* Formulários: 1 coluna em mobile */
.form-row {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 0 !important;
}

@media (min-width: 601px) {
    .form-row {
        grid-template-columns: 1fr 1fr !important;
        gap: 0.75rem !important;
    }
}

/* Inputs e botões cabem na tela */
input, select, textarea, button, .btn {
    max-width: 100% !important;
    box-sizing: border-box !important;
}

/* Tabelas tem scroll horizontal */
table {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
}

/* Stats grid: 2 colunas em mobile */
.stats-grid {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 0.6rem !important;
}

@media (min-width: 601px) {
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)) !important;
    }
}

/* Timer: tamanho adequado */
.timer-display {
    font-size: clamp(2rem, 10vw, 3.5rem) !important;
}

/* Ajustes para telas MUITO pequenas */
@media (max-width: 360px) {
    .app {
        padding-left: calc(0.5rem + env(safe-area-inset-left)) !important;
        padding-right: calc(0.5rem + env(safe-area-inset-right)) !important;
    }
    .brand h1 { font-size: 1rem !important; }
    .bottom-nav .nav-btn { padding: 0.3rem 0.4rem !important; font-size: 0.6rem !important; }
    .bottom-nav .nav-btn i { font-size: 1rem !important; }
}

/* Garante que nada fique atrás da navegação inferior */
body::after {
    content: '';
    display: block;
    height: 0;
}
