/* /app/assets/css/style.css */

/* --- VARIÁVEIS E GERAL --- */
:root {
    --primary-color: #3367D6;
    --danger-color: #dc3545;
    --success-color: #28a745;
    --bg-color: #f4f4f4;
    --text-color: #333;
    --card-bg: #fff;
}

* { box-sizing: border-box; }

/* ADICIONE ISTO: Garante que a base ocupe 100% */
html {
    height: 100%; 
}

/* ATUALIZE O BODY: Adicione height, width e overscroll */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    
    /* Correções de Scroll */
    height: 100%;
    width: 100%;
    overflow-x: hidden; /* Previne rolagem lateral */
    overscroll-behavior-y: none; /* Previne o efeito "elástico" ao puxar a página */
}

/* ATUALIZE A PAGE: Troque 100vh por 100dvh */
.page {
    display: none;
    width: 100%;
    min-height: 100%;
    min-height: 100dvh;
    
    /* AUMENTAMOS O ESPAÇO AQUI: */
    /* De 80px para 100px para garantir que o conteúdo não fique escondido atrás do botão */
    padding-bottom: 100px; 
    
    box-sizing: border-box; 
}

/* --- CABEÇALHO E RODAPÉ --- */
.app-header {
    background-color: var(--primary-color);
    color: white;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.app-header h2 { margin: 0; font-size: 1.2rem; }

.app-footer {
    position: fixed;
    bottom: 0;
    left: 0; /* Garante alinhamento */
    width: 100%;
    background: white;
    
    /* ALTERAÇÃO PRINCIPAL AQUI: */
    /* Aumentamos o padding e usamos env() para respeitar a área segura do celular */
    padding: 15px 15px calc(15px + env(safe-area-inset-bottom)) 15px;
    
    box-shadow: 0 -2px 5px rgba(0,0,0,0.1);
    display: flex;
    justify-content: center;
    z-index: 1000; /* Garante que fique por cima de tudo */
}

.main-content { padding: 15px; }

/* --- FORMULÁRIOS (LOGIN/REGISTRO/EDITOR) --- */
.form-grupo { margin-bottom: 15px; }

input, select {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 16px; /* Evita zoom no iPhone */
    margin-bottom: 10px;
}

/* --- BOTÕES --- */
button {
    cursor: pointer;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    padding: 10px 15px;
    transition: opacity 0.2s;
}

button:active { opacity: 0.8; }

.btn-principal {
    background-color: var(--primary-color);
    color: white;
    width: 100%;
    padding: 15px;
    font-weight: bold;
}

.btn-secundario {
    background-color: #eee;
    color: #333;
    width: 100%;
    margin-top: 10px;
}

.btn-perigo {
    background-color: transparent;
    border: 1px solid white;
    color: white;
    padding: 5px 10px;
    font-size: 0.9rem;
}

/* --- DASHBOARD (LISTA DE TREINOS) --- */
#lista-treinos {
    list-style: none;
    padding: 0;
    margin: 0;
}

.treino-item {
    background: var(--card-bg);
    margin-bottom: 10px;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.treino-info {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    cursor: pointer; /* Indica clique */
}

.treino-info strong { font-size: 1.1rem; display: block; margin-bottom: 4px;}
.treino-info span { font-size: 0.85rem; color: #666; }

.btn-editar-treino {
    background: transparent;
    border: 1px solid #ddd;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 10px;
}

/* --- EDITOR DE TREINO --- */
.exercicio-editor-item {
    background: white;
    border: 1px solid #ddd;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 10px;
}

.linha-input-topo {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.editor-ex-nome { flex: 2; margin-bottom: 0; }
.editor-ex-tipo { flex: 1; margin-bottom: 0; }

.btn-remover-ex {
    background: #ffebee;
    color: var(--danger-color);
    width: 40px;
    font-weight: bold;
    padding: 0;
}

.linha-input-detalhes {
    display: flex;
    gap: 8px;
}

.editor-ex-series, .editor-ex-reps {
    flex: 1;
    margin-bottom: 0;
}

/* Ajuste para os campos com sufixo dentro do Editor */
.linha-input-detalhes .input-with-suffix {
    flex: 1; /* Ocupa o espaço disponível igualmente */
    width: auto; /* Remove a largura fixa de 110px */
    background-color: #fff;
}

/* Classe auxiliar para o texto do sufixo (para podermos mudar via JS) */
.suffix-text {
    font-size: 0.8rem;
    color: #888;
    pointer-events: none;
}

/* --- TELA DE EXECUÇÃO (WORKOUT) --- */
.exercicio-card {
    background: white;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.exercicio-card h4 {
    margin-top: 0;
    color: var(--primary-color);
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.serie-log {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    padding: 5px 0;
}

.serie-log span { width: 60px; font-weight: bold; font-size: 0.9rem; }

.input-kg, .input-reps {
    width: 70px;
    margin-bottom: 0;
    text-align: center;
}

/* --- CAMPOS COM SUFIXO (kg/reps) --- */
.input-with-suffix {
    display: flex;
    align-items: center;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 0 8px;
    width: 110px; /* Largura fixa para alinhar bonitinho */
    margin: 0 5px; /* Espaço entre os campos */
}

/* O input em si fica sem borda para parecer integrado */
.input-with-suffix input {
    border: none;
    background: transparent;
    padding: 8px 2px;
    width: 100%;
    margin-bottom: 0;
    text-align: right; /* Número alinhado à direita, perto do sufixo */
    font-size: 1rem;
    outline: none; /* Remove a borda azul de foco padrão */
}

/* O texto (kg/reps) */
.input-with-suffix span {
    font-size: 0.8rem;
    color: #888;
    padding-left: 4px;
    font-weight: normal;
    pointer-events: none; /* Permite clicar através do texto */
    white-space: nowrap; /* Garante que não quebre linha */
}

/* Ajuste visual quando o campo recebe foco */
.input-with-suffix:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(51, 103, 214, 0.2);
}

.btn-marcar-serie {
    background: #e9ecef;
    color: #333;
    width: auto; /* Mudamos de fixo para auto para caber texto se precisar */
    min-width: 40px;
    height: 40px;
    padding: 0 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 20px; /* Mais arredondado */
    font-weight: bold;
    border: 1px solid #ccc;
    transition: all 0.2s;
}

/* Estado Concluído (Permite clicar para desfazer) */
.btn-marcar-serie.concluido {
    background: var(--success-color);
    color: white;
    border-color: var(--success-color);
}

/* Opcional: Estilo de hover para indicar que pode desfazer */
.btn-marcar-serie.concluido:hover {
    background-color: #218838; /* Um verde um pouco mais escuro */
    content: "Desfazer";
}

.btn-marcar-serie:disabled {
    background: var(--success-color);
    color: white;
}

.btn-add-serie {
    background: transparent;
    color: var(--primary-color);
    width: auto;
    font-size: 0.9rem;
    padding: 5px 0;
}

/* --- CRONÔMETRO MODERNO --- */
.timer-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 15px;
    width: 100%;
    margin: 5px 0;
}

.timer-display {
    font-family: 'Courier New', Courier, monospace; /* Fonte monoespaçada para números */
    font-size: 2.5rem;
    font-weight: bold;
    color: #333;
    margin-bottom: 15px;
    letter-spacing: 2px;
}

.timer-controls {
    display: flex;
    gap: 15px;
}

.btn-timer {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.1s, background-color 0.2s;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.btn-timer:active { transform: scale(0.95); }

.btn-timer.play { background-color: var(--success-color); color: white; }
.btn-timer.pause { background-color: #ffc107; color: #333; }
.btn-timer.reset { background-color: #6c757d; color: white; font-size: 1rem; }

/* Estado "Rodando" */
.timer-container.running {
    border-color: var(--success-color);
    background-color: #e8f5e9;
}
.timer-container.running .timer-display {
    color: var(--success-color);
}

/* --- TIMER DE DESCANSO (FIXO) --- */
#timer-descanso {
    background: #222;
    color: white;
    position: sticky;
    top: 60px; /* Logo abaixo do header */
    padding: 10px;
    text-align: center;
    z-index: 99;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 0 0 8px 8px;
    margin: 0 10px 10px 10px;
}

#timer-descanso h3 { margin: 0; font-size: 1rem; }
#btn-pular-descanso {
    background: #444;
    color: white;
    padding: 5px 10px;
    font-size: 0.8rem;
}

/* --- LOADING E ERROS --- */
#page-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    color: var(--primary-color);
}

/* --- NOTIFICAÇÃO DE UPDATE --- */
.update-toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    left: 20px; /* No mobile, ocupa a largura */
    background-color: #333;
    color: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    z-index: 1000;
    display: flex;
    justify-content: center;
    
    /* Animação de entrada */
    transition: transform 0.3s ease-in-out, opacity 0.3s;
    transform: translateY(0);
    opacity: 1;
}

.update-toast.hide {
    transform: translateY(100px); /* Joga para baixo */
    opacity: 0;
    pointer-events: none; /* Impede clique quando invisível */
}

.update-toast .content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 400px;
}

#btn-update-app {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 5px;
    font-weight: bold;
    font-size: 0.8rem;
    cursor: pointer;
    margin-left: 10px;
}

/* --- BOTÃO DE INSTALAÇÃO --- */
.install-container {
    position: fixed;
    bottom: 20px; /* Pode ajustar se tiver menu inferior */
    left: 20px;
    right: 20px;
    z-index: 999;
    background-color: white;
    padding: 10px 15px;
    border-radius: 50px; /* Formato de pílula */
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    display: flex;
    justify-content: center;
    border: 1px solid #eee;
    
    transition: transform 0.4s ease;
}

.install-container.hide {
    display: none;
}

.install-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 400px;
}

.install-content span {
    font-weight: bold;
    color: #333;
}

#btn-install-app {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 20px;
    padding: 8px 20px;
    font-size: 0.85rem;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/* --- MODAL IOS --- */
.ios-modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    z-index: 2000;
    display: flex;
    align-items: flex-end; /* Aparece em baixo */
    justify-content: center;
}

.ios-modal.hide {
    display: none;
}

.ios-content {
    background: white;
    width: 100%;
    max-width: 500px;
    border-radius: 20px 20px 0 0;
    padding: 25px;
    box-shadow: 0 -5px 20px rgba(0,0,0,0.2);
    animation: slideUp 0.3s ease-out;
}

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

.ios-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.ios-header h3 { margin: 0; color: #333; }

#btn-close-ios {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #999;
    padding: 0;
    width: auto;
}

.ios-content ol {
    padding-left: 20px;
    line-height: 1.6;
    color: #555;
}

.ios-content svg {
    vertical-align: middle;
    margin: 0 5px;
}

/* BOTÃO DE SINCRONIZAÇÃO MANUAL */
.btn-sync-container {
    margin-top: 15px;
    text-align: center;
}

.btn-sync {
    background-color: #fff;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-sync:disabled {
    border-color: #ccc;
    color: #999;
    background-color: #f9f9f9;
    cursor: not-allowed;
}