/* --- SISTEMA DE DISEÑO & VARIABLES CSS (MODO OSCURO PREMIUM) --- */
:root {
  --bg-primary: #0b0f19;
  --bg-secondary: #111827;
  --bg-card: rgba(31, 41, 55, 0.7);
  --bg-card-hover: rgba(45, 55, 72, 0.8);
  --bg-input: #1f2937;
  
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-light: rgba(99, 102, 241, 0.15);
  
  --accent-success: #10b981;
  --accent-warning: #f59e0b;
  --accent-danger: #ef4444;
  --accent-info: #06b6d4;

  --text-main: #f9fafb;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;

  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: #6366f1;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.25);

  --font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --bottom-nav-height: 68px;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
  padding-bottom: calc(var(--bottom-nav-height) + 20px);
}

/* Glassmorphism utility */
.glass {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
}

/* Top App Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  background: rgba(11, 15, 25, 0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
}

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

.brand-icon {
  font-size: 1.4rem;
  background: linear-gradient(135deg, var(--primary), #a855f7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-title {
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

/* Network Status Badge */
.status-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.3s ease;
}

.status-badge.online {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-success);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-badge.online::before {
  content: '';
  width: 6px;
  height: 6px;
  background: var(--accent-success);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--accent-success);
}

.status-badge.offline {
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-warning);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.status-badge.offline::before {
  content: '';
  width: 6px;
  height: 6px;
  background: var(--accent-warning);
  border-radius: 50%;
}

/* Container Principal */
.app-container {
  max-width: 600px;
  margin: 0 auto;
  padding: 16px;
}

/* --- AUTENTICACIÓN --- */
.auth-wrapper {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 80vh;
}

.auth-card {
  padding: 28px 24px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.auth-header {
  text-align: center;
  margin-bottom: 24px;
}

.auth-header h1 {
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 6px;
  background: linear-gradient(135deg, #fff, var(--text-muted));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.auth-header p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.form-group {
  margin-bottom: 18px;
}

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

.form-control {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 0.95rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.select-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239ca3af'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px;
}

/* Botones */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 13px 20px;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: #ffffff;
  box-shadow: var(--shadow-glow);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn-sm {
  padding: 8px 12px;
  font-size: 0.85rem;
  width: auto;
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--accent-danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.auth-toggle {
  text-align: center;
  margin-top: 18px;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.auth-toggle a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

/* --- NAVEGACIÓN INFERIOR (BOTTOM BAR MOBILE) --- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-height);
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 99;
  max-width: 600px;
  margin: 0 auto;
}

.nav-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 500;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.nav-tab .tab-icon {
  font-size: 1.35rem;
  transition: transform 0.2s;
}

.nav-tab.active {
  color: var(--primary);
  font-weight: 700;
}

.nav-tab.active .tab-icon {
  transform: translateY(-2px);
}

/* --- VISTAS / PESTAÑAS --- */
.view-section {
  display: none;
  animation: fadeIn 0.3s ease;
}

.view-section.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Headers de Vista */
.section-header {
  margin-bottom: 20px;
}

.section-header h2 {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-main);
}

.section-header p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* --- RUTINAS (CLIENTE) --- */
.day-selector {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 10px;
  margin-bottom: 16px;
  scrollbar-width: none;
}

.day-selector::-webkit-scrollbar {
  display: none;
}

.day-btn {
  flex: 0 0 auto;
  padding: 8px 14px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.day-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.4);
}

.workout-card {
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
}

.workout-title-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.workout-title-box h3 {
  font-size: 1.15rem;
  color: var(--text-main);
}

.exercise-item {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 12px;
}

.exercise-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.exercise-name {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-main);
}

.exercise-meta {
  display: flex;
  gap: 12px;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.exercise-meta span {
  background: rgba(255, 255, 255, 0.06);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
}

/* Interactive Checkboxes para Series */
.sets-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.set-check {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-input);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  font-size: 0.8rem;
  cursor: pointer;
  user-select: none;
  transition: all 0.2s;
}

.set-check input[type="checkbox"] {
  accent-color: var(--accent-success);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.set-check.completed {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.4);
  color: var(--accent-success);
}

/* --- DIETA (CLIENTE) --- */
.macro-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.macro-box {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
  text-align: center;
}

.macro-val {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--primary);
}

.macro-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.calories-bar-container {
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 20px;
  border: 1px solid var(--border-color);
}

.calories-info {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 0.85rem;
  font-weight: 600;
}

.progress-track {
  width: 100%;
  height: 10px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent-info));
  border-radius: var(--radius-full);
  transition: width 0.5s ease;
}

.meal-accordion {
  margin-bottom: 12px;
  border-radius: var(--radius-md);
  overflow: hidden;
}

.meal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  cursor: pointer;
  font-weight: 600;
}

.meal-header span {
  display: flex;
  align-items: center;
  gap: 8px;
}

.meal-content {
  padding: 14px 16px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-top: none;
  font-size: 0.88rem;
}

.food-item {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.08);
}

.food-item:last-child {
  border-bottom: none;
}

/* --- PROGRESO (CLIENTE) --- */
.progress-form {
  padding: 18px;
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
}

.log-history-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.log-card {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.log-date {
  font-weight: 700;
  font-size: 0.95rem;
}

.log-weight {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--accent-success);
}

.log-badge {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-success);
}

/* --- ADMIN PANEL --- */
.admin-client-select {
  margin-bottom: 20px;
}

.admin-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.admin-tab-btn {
  flex: 1;
  padding: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  border-radius: var(--radius-md);
  font-weight: 600;
  cursor: pointer;

}

.admin-tab-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: var(--radius-lg);
  padding: 24px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
}

/* Toast System */
.toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 90%;
  max-width: 400px;
}

.toast {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(-10px);
  transition: all 0.3s ease;
}

.toast-show {
  opacity: 1;
  transform: translateY(0);
}

.toast-success { border-left: 4px solid var(--accent-success); }
.toast-warning { border-left: 4px solid var(--accent-warning); }
.toast-info { border-left: 4px solid var(--primary); }

.empty-state {
  text-align: center;
  padding: 30px 15px;
  color: var(--text-muted);
}
.empty-state-icon {
  font-size: 2.5rem;
  margin-bottom: 10px;
  opacity: 0.6;
}

.progress-photo-img {
  cursor: pointer;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.progress-photo-img:hover {
  opacity: 0.92;
  transform: scale(1.01);
}
