/* Profile page */

html, body {
  height: auto;
  overflow: auto;
}

body {
  background: #EAF1F6;
}

/* ---- Top nav ---- */

.profile-nav {
  display: flex;
  align-items: center;
  height: 52px;
  padding: 0 16px;
  border-bottom: 1px solid #C4D9E4;
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
}

.back-link {
  color: #2D3E50;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  margin-right: auto;
}

.back-link:hover { color: #1a2b38; }

.profile-nav-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #2D3E50;
  margin: 0;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

/* ---- Page layout ---- */

.profile-layout {
  max-width: 520px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}

/* ---- Header card ---- */

.profile-header {
  background: #fff;
  border: 1px solid #C4D9E4;
  border-radius: 12px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 16px;
}

.avatar-wrap {
  position: relative;
  width: 88px;
  height: 88px;
  flex-shrink: 0;
  cursor: pointer;
}

.avatar-img {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #C4D9E4;
  background: #E6EFF4;
  display: block;
}

.avatar-initials {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: #2D3E50;
  color: #fff;
  font-size: 2rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #C4D9E4;
  user-select: none;
}

.avatar-overlay {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(0,0,0,0.35);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
}

.avatar-wrap:hover .avatar-overlay { opacity: 1; }

.profile-header-info h2 {
  font-size: 1.2rem;
  font-weight: 700;
  color: #2D3E50;
  margin-bottom: 4px;
}

.profile-header-info .ph-email {
  font-size: 0.82rem;
  color: #7A99AA;
}

/* ---- Crop modal ---- */

.crop-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.crop-box {
  background: #fff;
  border-radius: 16px;
  padding: 24px 20px 20px;
  width: 290px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.crop-box h3 {
  margin: 0;
  font-size: 1rem;
  color: #2D3E50;
  font-weight: 700;
}

.crop-circle {
  width: 240px;
  height: 240px;
  border-radius: 50%;
  overflow: hidden;
  cursor: grab;
  position: relative;
  background: #EAF1F6;
  border: 2px solid #C4D9E4;
  touch-action: none;
  flex-shrink: 0;
}

.crop-circle:active { cursor: grabbing; }

.crop-circle img {
  position: absolute;
  user-select: none;
  pointer-events: none;
}

.crop-zoom-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  color: #7A99AA;
}

.crop-zoom-row input[type=range] {
  flex: 1;
  accent-color: #2D3E50;
}

.crop-actions {
  display: flex;
  gap: 10px;
  width: 100%;
}

.crop-cancel-btn {
  flex: 1;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid #C4D9E4;
  background: #fff;
  color: #2D3E50;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.crop-confirm-btn {
  flex: 1;
  padding: 10px;
  border-radius: 8px;
  border: none;
  background: #2D3E50;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.crop-confirm-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

/* ---- Admin banner ---- */

.admin-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #2D3E50;
  color: #fff;
  border-radius: 10px;
  padding: 10px 16px;
  margin-bottom: 12px;
  font-size: 0.85rem;
  font-weight: 600;
}

.admin-banner-link {
  color: #C4D9E4;
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 600;
}

.admin-banner-link:hover { color: #fff; }

/* ---- Height row ---- */

.height-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.height-row input {
  flex: 1;
  min-width: 0;
}

.unit-label {
  font-size: 0.85em;
  color: #666;
  white-space: nowrap;
}

/* ---- Phone row ---- */

.phone-row {
  display: flex;
  gap: 8px;
}

.phone-row select {
  width: 72px;
  min-width: 0;
  flex-shrink: 0;
}

.phone-row input {
  flex: 1;
}

/* ---- Two-column body ---- */

.profile-body {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 16px;
  align-items: start;
}

/* ---- Sidebar tabs ---- */

.profile-sidenav {
  display: flex;
  flex-direction: column;
}

.profile-tab {
  padding: 12px 8px;
  text-align: center;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #7A99AA;
  cursor: pointer;
  font-family: inherit;
  transition: color 0.2s, border-color 0.2s;
}

.profile-tab.active {
  color: #2D3E50;
  border-bottom-color: #2D3E50;
}

/* ---- Content area ---- */

.profile-content {
  min-width: 0;
}

.profile-tab-panel {
  display: none;
}

.profile-tab-panel.active {
  display: block;
}

/* ---- Mobile: tabs en fila encima del contenido ---- */

@media (max-width: 480px) {
  .profile-body {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .profile-sidenav {
    flex-direction: row;
    background: #fff;
    border: 1px solid #C4D9E4;
    border-radius: 10px;
    overflow: hidden;
  }

  .profile-tab {
    flex: 1;
    font-size: 0.65rem;
    padding: 10px 4px;
    border-bottom: none;
    border-bottom: 2px solid transparent;
  }
}

/* ---- Cards ---- */

.profile-card {
  background: #fff;
  border: 1px solid #C4D9E4;
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 16px;
}

.profile-card h3 {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #7A99AA;
  margin-bottom: 14px;
}

/* ---- Form groups ---- */

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

.form-group label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  color: #7A99AA;
  margin-bottom: 5px;
  padding-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #C4D9E4;
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  color: #2D3E50;
  background: #fff;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.2s;
}

.form-group .phone-row select { width: auto; }

.form-group input:focus,
.form-group textarea:focus { border-color: #2D3E50; }

.form-group input:disabled { background: #F4F8F9; color: #7A99AA; }

.form-group textarea { resize: vertical; min-height: 72px; }

/* ---- Bio fields ---- */

.bio-fields {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

@media (max-width: 400px) {
  .bio-fields { grid-template-columns: 1fr 1fr; }
}

/* ---- Biometrics table ---- */

#bio-history-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.bio-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.bio-table th {
  text-align: left;
  padding: 6px 8px;
  color: #7A99AA;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid #EEF3F6;
}

.bio-table td {
  padding: 8px 8px;
  border-bottom: 1px solid #F4F8F9;
  color: #2D3E50;
}

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

/* ---- Buttons ---- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: opacity 0.2s, background 0.15s;
}

.btn-primary {
  background: #2D3E50;
  color: #fff;
}

.btn-primary:hover:not(:disabled) { opacity: 0.85; }

.btn-secondary {
  background: transparent;
  border: 1px solid #C4D9E4;
  color: #2D3E50;
}

.btn-secondary:hover:not(:disabled) { background: #EAF1F6; }

.btn:disabled { opacity: 0.5; cursor: default; }

/* ---- Habits ---- */

.habit-target-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.habit-item {
  padding: 12px 0;
  border-bottom: 1px solid #F4F8F9;
}

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

.habit-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: #2D3E50;
  margin-bottom: 6px;
}

.habit-meta {
  font-size: 0.78rem;
  color: #7A99AA;
  margin-bottom: 8px;
}

.habit-progress-bar {
  height: 6px;
  background: #E6EFF4;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 8px;
}

.habit-progress-fill {
  height: 100%;
  background: #2D3E50;
  border-radius: 999px;
  transition: width 0.3s;
}

.habit-log-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.habit-log-row input[type="number"] {
  width: 90px;
  padding: 6px 10px;
  border: 1px solid #C4D9E4;
  border-radius: 7px;
  font-size: 0.85rem;
  font-family: inherit;
  color: #2D3E50;
  outline: none;
}

.habit-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.habit-edit-btn {
  background: none;
  border: none;
  color: #7A99AA;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  transition: color 0.15s;
}

.habit-edit-btn:hover { color: #2D3E50; }

.habit-delete-btn {
  background: none;
  border: none;
  color: #C44;
  font-size: 0.78rem;
  cursor: pointer;
  padding: 0;
}

.habit-done-badge {
  font-size: 0.75rem;
  font-weight: 700;
  color: #27ae60;
  background: #eafaf1;
  border-radius: 6px;
  padding: 2px 8px;
}

/* ---- Progress ---- */

.progress-date {
  font-size: 0.78rem;
  font-weight: 700;
  color: #7A99AA;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
  margin-top: 14px;
}

.progress-date:first-child { margin-top: 0; }

.progress-block {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid #F4F8F9;
  font-size: 0.88rem;
  color: #2D3E50;
}

.progress-block:last-child { border-bottom: none; }

.progress-score {
  font-weight: 600;
  color: #2D3E50;
  font-size: 0.82rem;
}

.empty-state {
  text-align: center;
  color: #7A99AA;
  font-size: 0.88rem;
  padding: 24px 0;
}

/* ---- Weekly Progress ---- */

.weekly-progress {
  background: #fff;
  border: 1px solid #C4D9E4;
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 16px;
}

.wp-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.wp-title {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #7A99AA;
  margin: 0;
  flex-shrink: 0;
}

.wp-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.wp-range {
  font-size: 0.82rem;
  color: #4A6478;
  margin-right: 4px;
}

.wp-nav-btn {
  width: 28px;
  height: 28px;
  border: 1px solid #C4D9E4;
  border-radius: 6px;
  background: #fff;
  color: #2D3E50;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background .15s, border-color .15s;
}
.wp-nav-btn:hover { background: #EAF1F6; border-color: #7A99AA; }

.wp-today-btn { font-weight: 700; font-size: 0.78rem; letter-spacing: .04em; }

/* ---- Bio period selector ---- */

.bio-period-wrap {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.bio-period-btn {
  padding: 3px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid #C4D9E4;
  border-radius: 12px;
  background: #fff;
  color: #4A6375;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}

.bio-period-btn:hover { background: #EAF1F6; border-color: #7A99AA; }

.bio-period-btn.active {
  background: #2D3E50;
  border-color: #2D3E50;
  color: #fff;
}

.wp-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 4px;
}

.wp-row-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #7A99AA;
}

.wp-circles {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.wp-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.wp-dot--rest,
.wp-dot--upcoming { background: #fff; border: 2px solid #D0E0EA; }
.wp-dot--complete { background: #4CAF50; }
.wp-dot--partial  { background: #FFC107; }
.wp-dot--missed   { background: #EF5350; }

.wp-dot-x {
  color: #fff;
  font-size: 1.1rem;
  line-height: 1;
  font-weight: 700;
  margin-top: -1px;
}

.wp-chart-wrap { margin-top: 12px; }

.wp-chart-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #7A99AA;
  text-align: left;
  margin: 0 0 4px;
}

.wp-chart {
  width: 100%;
  height: auto;
  display: block;
}

/* ---- Bio charts ---- */

.bio-chart-card { display: flex; flex-direction: column; gap: 16px; }

.bio-chart-section { display: flex; flex-direction: column; }

.bio-chart-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #7A99AA;
  margin: 0 0 4px;
}

/* Toast (reutiliza el global .toast de style.css) */
