/*
 * BodyMetrics - Estilo Principal (Layout SPA & PWA)
 */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-base);
  background-color: var(--bg-app);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-title);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

/* -------------------------------------------------------------
 * SPA LAYOUT SHELL
 * ------------------------------------------------------------- */
#app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Navbar Principal */
.main-header {
  height: 70px;
  background-color: var(--bg-surface);
  backdrop-filter: var(--blur-glass);
  -webkit-backdrop-filter: var(--blur-glass);
  border-bottom: 1px solid var(--border-glass);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  font-size: 1.8rem;
  background: var(--grad-premium);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-family: var(--font-title);
  font-weight: 800;
}

.brand-version {
  font-size: 0.65rem;
  background: var(--bg-card);
  color: var(--text-secondary);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-glass);
}

.user-profile-menu {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-badge {
  display: flex;
  flex-direction: column;
  text-align: right;
}

.user-name {
  font-size: 0.9rem;
  font-weight: 600;
}

.user-role {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.05em;
}

/* Layout de Conteúdo Central */
.app-wrapper {
  display: flex;
  flex: 1;
  position: relative;
}

/* Barra Lateral de Navegação (Desktop) */
.sidebar-nav {
  width: 260px;
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border-glass);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  gap: 8px;
  position: sticky;
  top: 70px;
  height: calc(100vh - 70px);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  cursor: pointer;
}

.nav-link:hover {
  background-color: var(--bg-card);
  color: var(--text-primary);
}

.nav-link.active {
  background: var(--grad-primary);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: 0 4px 15px -3px var(--secondary-glow);
}

/* Área Principal de Renderização da SPA */
main#viewport {
  flex: 1;
  padding: 32px 24px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

/* Barra de Navegação Inferior (Mobile PWA) */
.bottom-nav {
  display: none;
  height: 64px;
  background-color: var(--bg-surface);
  backdrop-filter: var(--blur-glass);
  -webkit-backdrop-filter: var(--blur-glass);
  border-top: 1px solid var(--border-glass);
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  justify-content: space-around;
  align-items: center;
}

.bottom-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.75rem;
  font-weight: 500;
  flex: 1;
  height: 100%;
  transition: color var(--transition-fast);
}

.bottom-link.active {
  color: var(--secondary);
  font-weight: 600;
}

.bottom-link-icon {
  font-size: 1.25rem;
}

/* -------------------------------------------------------------
 * ELEMENTOS VISUAIS E COMPONENTES (GLASSMORPHISM)
 * ------------------------------------------------------------- */

/* Glass Cards */
.glass-card {
  background: var(--grad-surface);
  backdrop-filter: var(--blur-glass);
  -webkit-backdrop-filter: var(--blur-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-md);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

/* Widgets de Métricas Rápidas */
.metric-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.metric-info h4 {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.metric-value {
  font-family: var(--font-title);
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.1;
}

.metric-delta {
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
}

.metric-delta.up { color: var(--success); }
.metric-delta.down { color: var(--error); }
.metric-delta.neutral { color: var(--text-muted); }

.metric-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

/* Formulários Premium */
.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.form-control {
  width: 100%;
  background-color: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-family: var(--font-base);
  font-size: 0.95rem;
  color: var(--text-primary);
  transition: all var(--transition-fast);
}

.form-control:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--secondary-glow);
  background-color: var(--bg-card-hover);
}

/* Botões */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-base);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
}

.btn-primary {
  background: var(--grad-primary);
  color: var(--text-primary);
  box-shadow: 0 4px 15px -3px var(--primary-glow);
}

.btn-secondary {
  background-color: var(--bg-card);
  border: 1px solid var(--border-glass);
  color: var(--text-secondary);
}

.btn-secondary:hover {
  background-color: var(--bg-card-hover);
  color: var(--text-primary);
}

.btn-danger {
  background-color: var(--error);
  color: #fff;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.btn-full {
  width: 100%;
}

/* Tabelas */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-glass);
}

table.table-custom {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

table.table-custom th {
  background-color: var(--bg-surface-opaque);
  color: var(--text-secondary);
  font-weight: 600;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-glass);
}

table.table-custom td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-glass);
  color: var(--text-primary);
  background-color: hsla(223, 47%, 12%, 0.2);
}

table.table-custom tr:last-child td {
  border-bottom: none;
}

/* Badges / Rótulos */
.badge {
  display: inline-block;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: var(--radius-pill);
  text-transform: uppercase;
}

.badge-pending { background-color: hsla(45, 93%, 47%, 0.15); color: var(--warning); border: 1px solid hsla(45, 93%, 47%, 0.3); }
.badge-success { background-color: hsla(142, 70%, 45%, 0.15); color: var(--primary); border: 1px solid hsla(142, 70%, 45%, 0.3); }
.badge-danger { background-color: hsla(350, 89%, 60%, 0.15); color: var(--error); border: 1px solid hsla(350, 89%, 60%, 0.3); }

/* -------------------------------------------------------------
 * COMPONENTES DE VIEWS ESPECÍFICAS
 * ------------------------------------------------------------- */

/* Widget de Água no Dashboard */
.water-widget {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.water-visual {
  position: relative;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  border: 4px solid var(--border-glass);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.water-wave {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  background-color: var(--accent);
  opacity: 0.7;
  transition: height 0.5s ease-out;
}

.water-text {
  position: relative;
  z-index: 2;
  font-weight: 700;
  font-size: 1.1rem;
}

.water-actions {
  display: flex;
  gap: 8px;
}

/* Grid de Fotos de Evolução */
.photos-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 16px;
}

.photo-box {
  aspect-ratio: 3/4;
  border-radius: var(--radius-md);
  border: 1px dashed var(--border-glass);
  background-color: var(--bg-card);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.photo-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  background-color: rgba(0,0,0,0.6);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  position: absolute;
  bottom: 8px;
  z-index: 2;
}

/* Modais */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-content {
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
}

/* Comparador de Avaliações */
.comparison-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.comparison-column {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.comparison-delta-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-glass);
}

.comparison-delta-row span:first-child {
  color: var(--text-secondary);
}

.comparison-delta-value {
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Toasts Container */
#toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  color: #fff;
  min-width: 280px;
  border: 1px solid rgba(255,255,255,0.1);
}

.toast-success { background: linear-gradient(135deg, hsl(142, 70%, 25%) 0%, hsl(142, 70%, 15%) 100%); }
.toast-error { background: linear-gradient(135deg, hsl(350, 70%, 25%) 0%, hsl(350, 70%, 15%) 100%); }
.toast-warning { background: linear-gradient(135deg, hsl(45, 70%, 25%) 0%, hsl(45, 70%, 15%) 100%); }
.toast-info { background: linear-gradient(135deg, hsl(200, 70%, 25%) 0%, hsl(200, 70%, 15%) 100%); }

.toast-message { flex: 1; font-size: 0.85rem; font-weight: 500; }
.toast-close { background: none; border: none; color: rgba(255,255,255,0.5); font-size: 1.2rem; cursor: pointer; }

/* -------------------------------------------------------------
 * RESPONSIVIDADE E ADAPTAÇÕES MOBILE
 * ------------------------------------------------------------- */
@media (max-width: 768px) {
  .sidebar-nav {
    display: none; /* Oculta a barra lateral no mobile */
  }

  main#viewport {
    padding: 16px 12px 90px 12px; /* Margem extra embaixo para a bottom-nav */
  }

  .bottom-nav {
    display: flex; /* Exibe barra de navegação estilo app no mobile */
  }

  .main-header {
    padding: 0 16px;
  }

  .user-badge {
    display: none; /* Simplifica o cabeçalho no celular */
  }

  .photos-grid {
    grid-template-columns: 1fr; /* Coluna única no celular */
  }

  .comparison-container {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }

  .button-group-responsive {
    width: 100%;
    flex-wrap: wrap;
    gap: 8px !important;
  }

  .button-group-responsive .btn {
    flex: 1 1 auto;
    font-size: 0.85rem;
    padding: 10px 14px;
  }

  /* Tabelas Adaptáveis para Cartões no Mobile */
  .table-responsive {
    border: none !important;
    overflow-x: visible !important;
  }
  
  table.table-custom {
    display: block !important;
    width: 100% !important;
  }
  
  table.table-custom thead {
    display: none !important;
  }
  
  table.table-custom tbody {
    display: flex !important;
    flex-direction: column !important;
    gap: 16px !important;
    width: 100% !important;
  }
  
  table.table-custom tr {
    display: block !important;
    padding: 16px !important;
    background-color: var(--bg-surface-opaque) !important;
    border: 1px solid var(--border-glass) !important;
    border-radius: var(--radius-md) !important;
    box-shadow: var(--shadow-sm) !important;
  }
  
  table.table-custom td {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 8px 0 !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
    background: none !important;
    text-align: left !important;
    width: 100% !important;
    font-size: 0.85rem !important;
  }

  table.table-custom td:last-child {
    border-bottom: none !important;
    justify-content: flex-end !important;
    padding-top: 12px !important;
    gap: 8px !important;
  }
  
  table.table-custom td::before {
    content: attr(data-label) !important;
    font-weight: 600 !important;
    color: var(--text-secondary) !important;
    font-size: 0.8rem !important;
    margin-right: 16px !important;
  }
  
  table.table-custom td:not([data-label])::before {
    content: none !important;
  }
}

/* Helper para agrupamento responsivo de botões (geral) */
.button-group-responsive {
  display: flex;
  gap: 12px;
  align-items: center;
}

/* -------------------------------------------------------------
 * ESTILOS DO MÓDULO DE TREINOS
 * ------------------------------------------------------------- */
.serie-log-row {
  background-color: transparent;
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
}

.serie-log-row:hover {
  background-color: hsla(223, 47%, 20%, 0.15);
  border-color: var(--border-glass);
}

.serie-log-row input.form-control {
  border-radius: var(--radius-sm);
  text-align: center;
  background-color: hsla(223, 47%, 8%, 0.4);
}

.btn-divisao-tab, .btn-exec-tab {
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.select-ex-library {
  font-weight: 600;
}

/* -------------------------------------------------------------
 * CONFIGURAÇÃO DE IMPRESSÃO (RELATÓRIO PDF)
 * ------------------------------------------------------------- */
@media print {
  body {
    background: #fff !important;
    color: #000 !important;
    font-size: 11pt !important;
  }

  .main-header, .sidebar-nav, .bottom-nav, .btn, .no-print {
    display: none !important;
  }

  main#viewport {
    padding: 0 !important;
    max-width: 100% !important;
  }

  .glass-card {
    background: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: 1px solid #ddd !important;
    box-shadow: none !important;
    color: #000 !important;
    page-break-inside: avoid;
    margin-bottom: 20px;
  }

  .metric-value {
    color: #000 !important;
  }

  .metric-icon {
    display: none !important;
  }

  table.table-custom td, table.table-custom th {
    background: #fff !important;
    color: #000 !important;
    border-bottom: 1px solid #ddd !important;
  }

  .photos-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    page-break-inside: avoid;
  }

  .photo-box {
    border: 1px solid #ccc !important;
    aspect-ratio: 3/4 !important;
  }
  
  .photo-label {
    background-color: rgba(255, 255, 255, 0.9) !important;
    color: #000 !important;
    border: 1px solid #ccc !important;
  }
}

/* Customização dos inputs numéricos da tabela de montagem de treinos */
#tabela-exercicios-ficha input[type=number]::-webkit-outer-spin-button,
#tabela-exercicios-ficha input[type=number]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
#tabela-exercicios-ficha input[type=number] {
  -moz-appearance: textfield;
  text-align: center;
  font-weight: bold;
}

/* Custom Dropdown para Seleção de Múltiplas Técnicas */
.multiselect-dropdown-content::-webkit-scrollbar {
  width: 6px;
}
.multiselect-dropdown-content::-webkit-scrollbar-thumb {
  background-color: var(--border-glass);
  border-radius: 3px;
}
.multiselect-dropdown-content label {
  transition: background-color 0.2s ease;
}
.multiselect-dropdown-content label:hover {
  background-color: rgba(255, 255, 255, 0.08) !important;
}

