/* ================================
   1. VARIÁVEIS DE TEMA
================================ */
:root {
  --color-bg: #f5f7fb;
  --color-surface: #ffffff;
  --color-primary: #2563eb;
  --color-primary-soft: #e0ecff;
  --color-accent: #22c55e;
  --color-text: #111827;
  --color-text-muted: #6b7280;
  --color-border: #e5e7eb;

  --radius-lg: 12px;
  --radius-md: 8px;
  --shadow-soft: 0 10px 25px rgba(15, 23, 42, 0.18);

  --header-height: 60px;
  --bottom-nav-height: 72px;
  --transition-fast: 0.2s ease;
}

:root[data-theme="dark"] {
  --color-bg: #020617;
  --color-surface: rgba(10, 16, 30, 0.96);
  --color-primary: #2563eb;
  --color-primary-soft: #1e293b;
  --color-accent: #22c55e;
  --color-text: #f9fafb;
  --color-text-muted: #9ca3af;
  --color-border: #1f2937;
  --shadow-soft: 0 14px 32px rgba(15, 23, 42, 0.9);
}

/* ================================
   2. RESET E BASE
================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background-color: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Gradiente só no dark */
:root[data-theme="dark"] body {
  background: radial-gradient(circle at top, #0f172a 0%, #020617 40%, #000 100%);
}

.hidden {
  display: none !important;
}

/* ================================
   3. HEADER
================================ */
header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  padding: 0 1rem;
  background-color: rgba(15, 23, 42, 0.95);
  color: #f9fafb;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 20;
  backdrop-filter: blur(12px);
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.7);
}

.header-left {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.header-left h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  font-family: "Poppins", system-ui, sans-serif;
}

.header-subtitle {
  display: block;
  font-size: 0.7rem;
  color: #9ca3af;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#btn-open-drawer {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 1.4rem;
  padding: 6px;
  border-radius: 999px;
  color: #e5e7eb;
  transition: background-color 0.2s ease, transform 0.15s ease;
}

#btn-open-drawer:hover {
  background-color: rgba(148, 163, 184, 0.3);
  transform: translateY(-1px);
}

/* ================================
   4. DRAWER LATERAL
================================ */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 30;
}

.side-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 260px;
  max-width: 80%;
  height: 100vh;
  background-color: var(--color-surface);
  box-shadow: -12px 0 32px rgba(0, 0, 0, 0.7);
  padding: 1rem;
  z-index: 40;
  transform: translateX(100%);
  transition: transform 0.25s ease-out;
  display: flex;
  flex-direction: column;
}

.side-drawer.open {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.drawer-header h2 {
  margin: 0;
  font-size: 1rem;
  font-family: "Poppins", system-ui, sans-serif;
}

#btn-close-drawer {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 1.1rem;
  color: #e5e7eb;
  background-color: #111827;
  width: 28px;
  height: 28px;
  border-radius: 999px;
}

.drawer-user-info {
  margin-bottom: 1rem;
}

#drawer-nickname {
  display: block;
  font-weight: 600;
  font-size: 0.95rem;
}

.drawer-email {
  display: block;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.drawer-nav {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.drawer-nav button {
  width: 100%;
}

/* ================================
   5. MAIN / CARDS
================================ */
main {
  flex: 1;
  padding: 1rem;
  padding-top: calc(var(--header-height) + 0.75rem);
  padding-bottom: calc(var(--bottom-nav-height) + 1rem);
  display: flex;
  justify-content: center;
}

#auth-section,
#app-dashboard {
  width: 100%;
  max-width: 720px;
  background-color: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 1.25rem 1.25rem 1.5rem;
  border: 1px solid var(--color-border);
}


#auth-section {
  text-align: center;
}

#auth-section h2 {
  margin-top: 0;
  font-family: "Poppins", system-ui, sans-serif;
}

#auth-section p {
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

/* Card genérico */
.card,
.home-card {
  background-color: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 0.9rem 1rem;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-soft);
  margin-bottom: 0.75rem;
}


.card h3,
.home-card h3 {
  margin: 0 0 0.4rem 0;
  font-size: 0.95rem;
  font-family: "Poppins", system-ui, sans-serif;
}

/* ================================
   6. BOTÕES
================================ */
button {
  background-color: var(--color-primary);
  color: #f9fafb;
  border: 1px solid rgba(15, 23, 42, 0.8);
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
  margin-top: 0.4rem;
  transition: background-color 0.2s, transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.9);
}

button:hover {
  background-color: #1d4ed8;
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(15, 23, 42, 1);
}

button:active {
  transform: translateY(1px);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.8);
}

#btn-login {
  margin-top: 1rem;
}

#drawer-btn-logout,
#btn-logout {
  background-color: #ef4444;
  box-shadow: 0 10px 24px rgba(127, 29, 29, 0.9);
}

#drawer-btn-logout:hover,
#btn-logout:hover {
  background-color: #dc2626;
}

/* Botão neutro */
button.secondary,
#btn-cancel-edit,
#weight-modal-cancel {
  background-color: #6b7280;
  box-shadow: none;
}

button.secondary:hover,
#btn-cancel-edit:hover,
#weight-modal-cancel:hover {
  background-color: #4b5563;
}

/* ================================
   7. MENU INFERIOR
================================ */
#main-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-height);
  background-color: var(--color-surface);
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 15;
  box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.9);
}

#main-nav button {
  background: none;
  box-shadow: none;
  margin: 0;
  padding: 0.15rem 0.3rem;
  border-radius: 999px;
  color: var(--color-text-muted);
  font-size: 1.5rem; /* tamanho dos ícones */
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

#main-nav button span {
  font-size: 0.8rem;
  margin-top: 2px;
}

#main-nav button.active {
  background-color: var(--color-primary-soft);
  color: var(--color-primary);
}

/* ================================
   8. CONTEÚDO / SEÇÕES
================================ */
#content-area {
  margin-top: 0.5rem;
  border-radius: var(--radius-lg);
  background-color: rgba(15, 23, 42, 0.03);
  padding: 1rem;
}

.content-section h2 {
  margin-top: 0;
  margin-bottom: 0.4rem;
  font-family: "Poppins", system-ui, sans-serif;
  font-size: 1.1rem;
}

.content-section p {
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

/* ================================
   9. HOME
================================ */
.home-greeting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

#home-greeting-title {
  margin: 0;
  font-size: 1.1rem;
}

#home-greeting-subtitle {
  margin: 0.1rem 0 0 0;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.home-greeting-icon {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  background: radial-gradient(circle, #22c55e 0%, #0f172a 65%);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 1);
}

.home-card {
  margin-bottom: 0.75rem;
}

/* ================================
   10. FORMULÁRIOS
================================ */
label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 0.15rem;
}

input,
select,
textarea {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  font-size: 0.95rem;
  outline: none;
  background-color: #020617;
  color: var(--color-text);
  transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
}

:root[data-theme="light"] input,
:root[data-theme="light"] select,
:root[data-theme="light"] textarea {
  background-color: #ffffff;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.6);
}

textarea {
  min-height: 70px;
  resize: vertical;
}

/* forms */
#form-profile,
#form-create-template,
#form-create-exercise {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

/* ================================
   11. PERFIL
================================ */
#profile-section {
  margin-top: 0.25rem;
}

#profile-display-view p {
  font-size: 0.95rem;
  line-height: 1.5;
  margin: 0.2rem 0;
}

#profile-display-view p strong {
  color: var(--color-text);
}

#metrics-display {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--color-border);
}

.profile-actions {
  margin-top: 0.8rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* ================================
   12. MODAL ATUALIZAR PESO
================================ */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal-content {
  background-color: var(--color-surface);
  padding: 1rem 1.2rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  width: 90%;
  max-width: 360px;
}

.modal-content h3 {
  margin: 0 0 0.4rem 0;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.4rem;
  margin-top: 0.75rem;
}

/* ================================
   13. MEUS TREINOS
================================ */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.templates-grid {
  margin-top: 0.5rem;
}

#templates-list {
  list-style: none;
  padding-left: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.55rem;
}

#templates-list li {
  background-color: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 0.65rem 0.7rem;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-soft);
  position: relative;
}


#templates-list li button {
  background: none;
  color: var(--color-primary);
  box-shadow: none;
  padding: 0;
  margin-top: 0;
  font-weight: 600;
}

#templates-list li button:hover {
  background: none;
  text-decoration: underline;
}

.template-description {
  display: block;
  margin-top: 2px;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

/* Detalhes do treino */
#template-details {
  margin-top: 0.8rem;
}

#exercises-list {
  list-style: none;
  padding-left: 0;
  margin: 0;
}

#exercises-list li {
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius-md);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  margin-bottom: 0.4rem;
}


/* ================================
   14. INICIAR TREINO
================================ */
#start-workout-templates {
  margin-top: 0.5rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.55rem;
}

.template-card {
  position: relative;
}

.template-card-last {
  border-color: var(--color-primary);
  box-shadow: 0 16px 32px rgba(37, 99, 235, 0.8);
}

.template-last-badge {
  position: absolute;
  top: 6px;
  left: 10px;
  padding: 2px 6px;
  border-radius: 999px;
  background-color: var(--color-primary);
  color: #f9fafb;
  font-size: 0.7rem;
}

/* Sessão ativa */
#active-workout-section {
  margin-top: 0.8rem;
}

#active-exercises-container {
  margin-top: 0.4rem;
}

.active-exercise {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.6rem;
  background-color: var(--color-surface);
  box-shadow: var(--shadow-soft);
}


.active-exercise h4 {
  margin: 0 0 4px 0;
}

.active-exercise p {
  margin: 0 0 6px 0;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.sets-list {
  list-style: none;
  padding-left: 0;
  margin: 0 0 6px 0;
}

.sets-list li {
  font-size: 0.85rem;
}

/* form séries */
.form-add-set {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 0.5rem;
  align-items: flex-end;
}

.form-add-set label {
  font-size: 0.75rem;
}

.form-add-set button {
  margin-top: 0;
}

/* ================================
   15. MEU PROGRESSO
================================ */
.progress-menu {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.6rem;
}

.progress-tab {
  flex: 1;
  margin-top: 0;
}

.progress-tab.active {
  background-color: var(--color-primary);
  color: #f9fafb;
}

.progress-inner-section {
  margin-top: 0.3rem;
}

#progress-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.progress-card {
  background-color: var(--color-surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  padding: 0.6rem 0.75rem;
}

.progress-card h3 {
  margin: 0 0 4px 0;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.progress-card p {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
}

/* listas progresso */
#sessions-list,
#prs-list {
  list-style: none;
  padding-left: 0;
  margin: 0;
}

.session-item,
.pr-item {
  padding: 0.6rem 0.7rem;
  border-radius: var(--radius-md);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  margin-bottom: 0.4rem;
}

.session-header {
  font-weight: 600;
  margin-bottom: 2px;
}

.session-sub {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-bottom: 4px;
}

.session-stats {
  font-size: 0.85rem;
}

.pr-item span {
  font-size: 0.9rem;
}

/* ================================
   16. TOASTS / TIMER / CONFETTI
================================ */
#toast-container {
  position: fixed;
  bottom: var(--bottom-nav-height);
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.toast {
  min-width: 200px;
  max-width: 320px;
  background-color: var(--color-primary);
  color: #fff;
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  font-size: 0.85rem;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.6);
  opacity: 0;
  transform: translateY(15px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  background-color: #dc2626;
}

#rest-timer {
  position: fixed;
  top: calc(var(--header-height) + 8px);
  right: 14px;
  background-color: rgba(15, 23, 42, 0.95);
  color: #e5e7eb;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  border: 1px solid rgba(148, 163, 184, 0.45);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
  z-index: 25;
}

/* Confetti */
.confetti-container {
  pointer-events: none;
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: 60;
}

.confetti-piece {
  position: absolute;
  width: 6px;
  height: 14px;
  background-color: #fde047;
  opacity: 0.9;
  animation: confetti-fall 1.2s ease-out forwards;
}

@keyframes confetti-fall {
  0% {
    transform: translateY(-20px) rotate(0deg);
  }
  100% {
    transform: translateY(110vh) rotate(720deg);
    opacity: 0;
  }
}

/* ================================
   17. RESPONSIVIDADE
================================ */
@media (max-width: 480px) {
  .header-subtitle {
    display: none;
  }

  header {
    height: 56px;
    padding: 0 0.75rem;
  }
}

@media (min-width: 768px) {
  header {
    padding: 0 2rem;
  }

  main {
    padding: 1.5rem;
    padding-top: calc(var(--header-height) + 1.2rem);
    padding-bottom: 1.5rem;
  }

  #app-dashboard,
  #auth-section {
    padding: 1.5rem 1.75rem 1.75rem;
  }

  #main-nav {
    position: static;
    height: auto;
    margin-top: 1rem;
    margin-bottom: 0;
    box-shadow: none;
    border-radius: var(--radius-md);
    padding: 0.35rem;
    gap: 0.4rem;
    justify-content: space-between;
  }

  #main-nav button {
    flex-direction: row;
    font-size: 1.1rem;
    padding: 0.25rem 0.6rem;
  }

  #main-nav button span {
    font-size: 0.85rem;
  }
}
