/* GYMRAT — Portal alumno móvil (iPhone / Safari / PWA) */

:root {
  --mobile-nav-h: calc(64px + env(safe-area-inset-bottom, 0px));
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* PWA / iOS */
@supports (padding: max(0px)) {
  .login-page {
    padding-top: max(32px, var(--safe-top));
    padding-bottom: max(32px, var(--safe-bottom));
  }
}

/* Instalar en iPhone */
.install-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  margin-bottom: 16px;
  border-radius: var(--radius-sm);
  background: var(--accent-blue-soft);
  border: 1px solid rgba(0, 212, 255, 0.25);
  font-size: 0.88rem;
  line-height: 1.45;
}

.install-banner strong { color: var(--accent-blue); }
.install-banner .btn-dismiss {
  margin-left: auto;
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0 4px;
}

/* Botón principal de entrenamiento */
.btn-workout-start {
  width: 100%;
  margin-top: 16px;
  padding: 16px 20px;
  font-size: 1.05rem;
  font-weight: 700;
  border: none;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-hover) 100%);
  color: #0A0E14;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 52px;
  box-shadow: 0 4px 20px var(--brand-glow);
  -webkit-tap-highlight-color: transparent;
}

.btn-workout-start:active { transform: scale(0.98); }
.btn-workout-start:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.exercise-list-mobile {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
}

.exercise-list-mobile li {
  padding: 12px 14px;
  margin-bottom: 8px;
  border-radius: var(--radius-sm);
  background: var(--surface-elevated);
  border: 1px solid var(--border);
}

.exercise-list-mobile li strong { display: block; margin-bottom: 4px; }
.exercise-list-mobile li span {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* Bottom navigation (móvil) */
.mobile-bottom-nav {
  display: none;
}

@media (max-width: 768px) {
  body.client-mobile-app {
    padding-bottom: var(--mobile-nav-h);
  }

  body.client-mobile-app .layout {
    grid-template-columns: 1fr;
    min-height: 100vh;
  }

  body.client-mobile-app .sidebar {
    display: none;
  }

  body.client-mobile-app .main {
    padding: 16px 16px calc(16px + var(--mobile-nav-h));
    padding-top: max(16px, var(--safe-top));
  }

  body.client-mobile-app .page-header {
    margin-bottom: 12px;
  }

  body.client-mobile-app .page-header h1 {
    font-size: 1.35rem;
  }

  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    height: var(--mobile-nav-h);
    padding-bottom: var(--safe-bottom);
    background: var(--glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--border);
    align-items: stretch;
    justify-content: space-around;
  }

  .mobile-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border: none;
    background: none;
    color: var(--muted);
    font-size: 0.65rem;
    font-weight: 600;
    cursor: pointer;
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
    font-family: inherit;
  }

  .mobile-tab i { font-size: 1.35rem; }
  .mobile-tab.active { color: var(--brand); }
  .mobile-tab.tab-workout { color: var(--brand); }
  .mobile-tab.tab-workout.active {
    background: var(--brand-soft);
    border-radius: 12px 12px 0 0;
  }

  .chat-compose {
    position: sticky;
    bottom: var(--mobile-nav-h);
    background: var(--surface);
    padding: 10px 0;
    margin-top: 12px;
  }

  .chat-compose input {
    min-height: 44px;
    font-size: 16px; /* evita zoom en iOS */
  }

  input[type="number"],
  input[type="email"],
  input[type="password"],
  textarea {
    font-size: 16px;
  }
}

/* Sheet "Más" */
.more-sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.more-sheet {
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 20px 16px calc(20px + var(--safe-bottom));
  animation: slideUp 0.25s ease;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.more-sheet h3 { margin: 0 0 16px; }
.more-sheet-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.more-sheet-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 72px;
  font-family: inherit;
}

.more-sheet-btn i { font-size: 1.5rem; color: var(--brand); }

/* ─── Entrenamiento activo (pantalla completa) ─── */
.workout-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: var(--bg);
  background-image: var(--bg-accent);
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

.workout-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.workout-header-info { flex: 1; min-width: 0; }
.workout-header-info h2 {
  margin: 0;
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.workout-timer {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.workout-progress-bar {
  height: 4px;
  background: var(--surface-elevated);
  flex-shrink: 0;
}

.workout-progress-fill {
  height: 100%;
  background: var(--brand);
  transition: width 0.3s ease;
}

.workout-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
}

.workout-exercise-card {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.workout-exercise-card.current {
  border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand-glow);
}

.workout-exercise-card.done { opacity: 0.65; }

.workout-exercise-card h3 {
  margin: 0 0 4px;
  font-size: 1.1rem;
}

.workout-target {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.set-row {
  display: grid;
  grid-template-columns: 36px 1fr 1fr 44px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.set-row .set-num {
  font-weight: 700;
  color: var(--muted);
  text-align: center;
}

.set-row input {
  width: 100%;
  padding: 10px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-elevated);
  color: var(--text);
  text-align: center;
  min-height: 44px;
}

.set-row input:focus {
  outline: none;
  border-color: var(--brand);
}

.set-check {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  background: transparent;
  color: var(--brand);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  -webkit-tap-highlight-color: transparent;
}

.set-check.done {
  background: var(--brand);
  border-color: var(--brand);
  color: #0A0E14;
}

.rest-bar {
  position: sticky;
  bottom: 0;
  background: var(--accent-blue-soft);
  border-top: 1px solid rgba(0, 212, 255, 0.3);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.rest-bar strong { color: var(--accent-blue); font-size: 1.1rem; }

.workout-footer {
  padding: 12px 16px calc(12px + var(--safe-bottom));
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.workout-footer .btn-finish {
  width: 100%;
  min-height: 52px;
  font-size: 1rem;
  font-weight: 700;
}

/* Historial */
.history-item {
  padding: 14px 16px;
  margin-bottom: 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.history-item:active { background: var(--brand-soft); }

.history-item .history-date {
  font-weight: 700;
  margin-bottom: 4px;
}

.history-item .history-meta {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* Feedback post-entreno */
.feedback-stars {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 16px 0;
}

.feedback-star {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: transparent;
  font-size: 1.4rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.feedback-star.selected {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.toast-mobile {
  position: fixed;
  bottom: calc(var(--mobile-nav-h) + 12px);
  left: 16px;
  right: 16px;
  z-index: 400;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  background: var(--brand);
  color: #0A0E14;
  font-weight: 600;
  text-align: center;
  animation: fadeInUp 0.3s ease;
  box-shadow: var(--shadow-lg);
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.workout-overlay .toast-mobile {
  bottom: calc(12px + var(--safe-bottom));
}
