/* ============================================================
   TECSA – App Paciente | home.css
   Design tokens from Figma: HANDOFFs / node 2901-16503
   ============================================================ */

/* ---------- Design Tokens ---------- */
:root {
  --color-principal:   #2C3D82;
  --color-principal-dk:#0B0F22;
  --color-secundaria:  #FFE500;
  --color-text:        #333333;
  --color-bg-grey:     #F0F0F0;
  --color-bg-light:    #F1F0F0;
  --color-text-light:  #999999;
  --color-white:       #FFFFFF;
  --color-border:      #E6E6E6;
  --color-border-meal: #E1DFDF;

  --color-good:        #53AE77;
  --color-good-bg:     #E0FFEE;
  --color-warning:     #E2B616;
  --color-alert:       #E45050;

  --color-macro-protein: #FF2D37;
  --color-macro-carbs:   #16E066;
  --color-macro-fiber:   #B1ED96;
  --color-macro-fat:     #F4B436;

  --font-main: 'Segoe UI', 'Inter', system-ui, -apple-system, sans-serif;
  --radius-card: 8px;
  --radius-pill: 100px;
  --radius-nav:  28px;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-main);
  background: #D0D0D0;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  padding: 24px 0 40px;
}
img { display: block; max-width: 100%; }
button, a { cursor: pointer; border: none; background: none; font-family: inherit; text-decoration: none; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--color-secundaria); outline-offset: 2px; }

/* ============================================================
   APP FRAME
   ============================================================ */
.app-frame {
  position: relative;
  width: 402px;
  height: 90vh;
  max-height: 860px;
  min-height: 600px;
  background: var(--color-bg-grey);
  border-radius: 48px;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0,0,0,0.35);
  display: flex;
  flex-direction: column;
}

/* ---------- Scrollable main area ---------- */
.app-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding-bottom: 120px;
}
.app-scroll::-webkit-scrollbar { display: none; }

/* ============================================================
   STATUS BAR
   ============================================================ */
.status-bar {
  background: var(--color-principal);
  display: flex;
  align-items: center;
  height: 60px;
  padding: 12px 0;
  flex-shrink: 0;
}

.status-left {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 140px;
  justify-content: center;
  padding: 0 12px;
}
.status-time {
  font-size: 17px;
  font-weight: 600;
  color: var(--color-white);
  letter-spacing: -0.5px;
  white-space: nowrap;
}
.status-location { width: 12px; height: 14px; object-fit: contain; }

.dynamic-island {
  width: 122px;
  height: 36px;
  background: #000;
  border-radius: 32px;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
.dynamic-island-lens {
  position: absolute;
  right: 12px;
  top: 12px;
  width: 12px;
  height: 12px;
  object-fit: contain;
}

.status-right {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 28px;
}
.status-network { width: 18px; height: 14px; object-fit: contain; }
.status-wifi    { width: 17px; height: 14px; object-fit: contain; }
.status-battery-wrap { position: relative; width: 27px; height: 14px; }
.status-battery-img  { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.status-battery-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 37%; object-fit: contain; }
.status-battery-pct  {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 11px;
  font-weight: 700;
  color: #000;
  white-space: nowrap;
  pointer-events: none;
}

/* ============================================================
   APP HEADER
   ============================================================ */
.app-header {
  background: var(--color-principal);
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 24px;
  flex-shrink: 0;
}
.header-left {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.avatar-btn { flex-shrink: 0; }
.avatar-img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}
.header-greeting {
  font-size: 18px;
  font-weight: 600;
  color: var(--color-white);
  line-height: 33px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bell-btn {
  position: relative;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}
.bell-icon-img {
  position: absolute;
  top: 2.25px;
  left: 3px;
  width: 18px;
  height: 19.5px;
  object-fit: contain;
}
.notif-badge {
  position: absolute;
  top: -2px;
  right: 0;
  min-width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.notif-badge span {
  font-size: 8px;
  font-weight: 600;
  color: var(--color-text);
  line-height: 1;
}

.menu-btn { flex-shrink: 0; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; }
.menu-icon-img { width: 16px; height: 16px; object-fit: contain; }

/* ============================================================
   DATE NAVIGATION
   ============================================================ */
.date-nav {
  background: var(--color-principal);
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  flex-shrink: 0;
}
.date-arrow {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.date-arrow img { width: 100%; height: 100%; object-fit: contain; }
.date-today-btn {
  flex: 1;
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  color: var(--color-white);
  white-space: nowrap;
  padding: 0 16px;
}

/* ============================================================
   DASHBOARD TOP (blue → dark gradient)
   ============================================================ */
.dashboard-top {
  background: linear-gradient(to bottom, var(--color-principal), var(--color-principal-dk));
  padding: 16px;
  flex-shrink: 0;
}
.macro-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 26px;
}

/* Donut chart */
.donut-wrap {
  position: relative;
  width: 186px;
  flex-shrink: 0;
}
.donut-chart-img {
  display: block;
  width: 186px;
  height: 186px;
  object-fit: contain;
}
.donut-svg-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 186px;
  height: 186px;
  pointer-events: none;
}
.donut-center-text {
  position: absolute;
  top: 12px;
  left: 12.84px;
  width: 162px;
  height: 163px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.donut-pct-value {
  font-size: 60px;
  font-weight: 300;
  color: var(--color-white);
  line-height: 1;
}
.donut-pct-symbol {
  font-size: 35px;
  font-weight: 300;
  color: var(--color-white);
}
.donut-label-row {
  display: flex;
  align-items: center;
  gap: 4px;
}
.donut-label-text {
  font-size: 14px;
  color: var(--color-white);
  white-space: nowrap;
}
.donut-info-icon { width: 12px; height: 13px; object-fit: contain; }

.donut-kcal-row {
  margin-top: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex-wrap: wrap;
  padding-bottom: 8px;
}
.donut-kcal-value {
  font-size: 0;
  text-align: center;
  color: var(--color-white);
}
.donut-kcal-value .num  { font-size: 16px; font-weight: 600; letter-spacing: 0.24px; }
.donut-kcal-value .unit { font-size: 12px; font-weight: 400; letter-spacing: 0.24px; }
.donut-kcal-label {
  font-size: 12px;
  color: var(--color-white);
  letter-spacing: 0.24px;
}

/* Macro bars */
.macro-bars {
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex-shrink: 0;
}
.macro-item {
  display: flex;
  align-items: center;
  gap: 8px;
}
.macro-icon-img { width: 30px; height: 30px; object-fit: contain; }
.macro-detail {
  display: flex;
  flex-direction: column;
  gap: 11px;
  width: 110px;
}
.macro-labels {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--color-white);
  letter-spacing: 0.24px;
  white-space: nowrap;
}
.macro-bar-track {
  width: 100%;
  height: 8px;
  background: rgba(255,255,255,0.2);
  border-radius: 8px;
  overflow: hidden;
}
.macro-bar-fill {
  height: 100%;
  border-radius: 8px;
  transition: width 0.6s ease;
}
.macro-bar-fill.proteinas   { background: var(--color-macro-protein); }
.macro-bar-fill.carboidratos{ background: var(--color-macro-carbs); }
.macro-bar-fill.fibras      { background: var(--color-macro-fiber); }
.macro-bar-fill.gorduras    { background: var(--color-macro-fat); }

/* ============================================================
   MAIN WRAPPER (dark-to-grey gradient, hard transition)
   ============================================================ */
.main-wrapper {
  background: linear-gradient(to bottom,
    var(--color-principal-dk) 0%,
    var(--color-principal-dk) 2%,
    var(--color-bg-grey) 2%,
    var(--color-bg-grey) 100%
  );
  padding: 16px;
  display: flex;
  justify-content: center;
}
.main-content {
  width: 370px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--color-white);
  border-radius: var(--radius-card);
  padding: 16px;
  width: 100%;
  flex-shrink: 0;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 4px;
  padding-bottom: 8px;
}
.card-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--color-text);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
}
.card-title-count {
  font-size: 14px;
  font-weight: 400;
  color: var(--color-text);
  white-space: nowrap;
}
.card-btn-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.card-btn-icon img  { width: 100%; height: 100%; object-fit: contain; }
.card-btn-sm {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.card-btn-sm img { width: 100%; height: 100%; object-fit: contain; }
.see-all-link {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
  margin-left: auto;
}

/* ============================================================
   REGISTROS DO DIA
   ============================================================ */
.meal-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  width: 100%;
  text-align: left;
  font-family: var(--font-main);
  background: none;
}
.meal-row.border-bottom { border-bottom: 1px solid var(--color-border-meal); }
.meal-row.first         { padding-top: 16px; }

.meal-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.meal-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text);
}
.meal-status {
  display: flex;
  align-items: center;
  gap: 4px;
}
.status-dot { width: 8px; height: 8px; object-fit: contain; flex-shrink: 0; }
.status-text { font-size: 14px; line-height: 10px; }
.status-text.good    { color: var(--color-good); }
.status-text.warning { color: var(--color-warning); }
.status-text.alert   { color: var(--color-alert); }

.meal-kcal {
  font-size: 14px;
  color: var(--color-text);
  white-space: nowrap;
  flex-shrink: 0;
}
.meal-chevron-btn {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.meal-chevron-btn img { width: 100%; height: 100%; object-fit: contain; }

/* ============================================================
   DIÁRIO ALIMENTAR
   ============================================================ */
.food-photos {
  display: flex;
  gap: 8px;
  height: 62px;
  overflow: hidden;
}
.food-photo-item {
  flex: 1;
  min-width: 0;
  border-radius: var(--radius-card);
  overflow: hidden;
  position: relative;
}
.food-photo-item img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ============================================================
   PLANO ALIMENTAR
   ============================================================ */
.plan-tabs-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  padding: 8px 0;
  margin: 0 -4px;
}
.plan-tabs-scroll::-webkit-scrollbar { display: none; }
.plan-tabs {
  display: flex;
  gap: 8px;
  width: max-content;
}
.plan-tab {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  border-radius: var(--radius-pill);
  width: 220px;
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.2s, color 0.2s;
  flex-shrink: 0;
}
.plan-tab.active {
  background: var(--color-text);
  color: var(--color-white);
  border: none;
}
.plan-tab:not(.active) {
  background: transparent;
  color: var(--color-text);
  border: 1px solid var(--color-text);
}
.plan-tab:not(.active):hover {
  background: var(--color-bg-light);
}

.meal-times {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}
.meal-time-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--color-bg-light);
  border-radius: var(--radius-card);
  padding: 16px 8px;
  width: 100%;
  text-align: left;
  font-family: var(--font-main);
}
.meal-time-icon { width: 24px; height: 24px; object-fit: contain; flex-shrink: 0; }
.meal-time-hour {
  font-size: 16px;
  color: var(--color-text-light);
  letter-spacing: 0.16px;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 40px;
}
.meal-time-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text);
  letter-spacing: 0.16px;
  white-space: nowrap;
}

/* ============================================================
   PROGRESSO SEMANAL
   ============================================================ */
.weekly-progress {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  position: relative;
}
.weekly-score {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px 4px;
  width: 129px;
  flex-shrink: 0;
  min-height: 69px;
}
.score-num {
  font-size: 0;
  text-align: center;
  color: var(--color-text);
}
.score-num .big  { font-size: 20px; font-weight: 600; }
.score-num .sep  { font-size: 10px; font-weight: 400; }
.score-badge {
  background: var(--color-good-bg);
  color: var(--color-good);
  font-size: 12px;
  padding: 2px 16px;
  border-radius: var(--radius-card);
  white-space: nowrap;
}

.weekly-chart-wrap {
  flex: 1;
  min-width: 0;
  position: relative;
  padding-top: 28px;
}
.today-indicator-bubble {
  position: absolute;
  top: 0;
  background: var(--color-secundaria);
  border-radius: 2px;
  height: 18px;
  width: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  font-weight: 600;
  color: var(--color-text);
  left: calc(4 * 28px - 1px); /* 4th day (0-indexed) */
}
.today-indicator-bubble::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--color-secundaria);
}
.days-bars {
  display: flex;
  gap: 0;
}
.day-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  width: 28px;
}
.day-bar-img { width: 20px; height: 50px; object-fit: contain; }
.day-label {
  font-size: 14px;
  color: var(--color-principal);
  text-align: center;
  width: 15px;
  height: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ============================================================
   METAS DE HOJE
   ============================================================ */
.goals-list { display: flex; flex-direction: column; gap: 0; margin-top: 4px; }
.goal-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 0;
}
.goal-row.border-bottom { border-bottom: 1px solid var(--color-border); }
.goal-text { flex: 1; font-size: 16px; color: var(--color-text); }
.goal-check { width: 20px; height: 20px; object-fit: contain; flex-shrink: 0; }

/* ============================================================
   ANEXOS
   ============================================================ */
.anexos-scroll {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  padding: 2px 0;
}
.anexos-scroll::-webkit-scrollbar { display: none; }
.anexo-item {
  background: var(--color-bg-light);
  border-radius: var(--radius-card);
  padding: 16px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
  min-width: 100px;
  max-width: 170px;
  cursor: pointer;
  transition: opacity 0.2s;
}
.anexo-item:hover { opacity: 0.8; }
.anexo-icon { width: 12px; height: 20px; object-fit: contain; }
.anexo-title {
  font-size: 14px;
  color: var(--color-text);
  text-align: center;
  line-height: 16px;
  word-break: break-word;
}

/* ============================================================
   BOTTOM NAVIGATION
   ============================================================ */
.bottom-nav-wrapper {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 117px;
  pointer-events: none;
  background: linear-gradient(to top, var(--color-bg-grey) 35%, rgba(240,240,240,0));
  display: flex;
  align-items: flex-end;
  padding: 0 16px 30px;
}
.bottom-nav-pill {
  pointer-events: auto;
  width: 100%;
  height: 74px;
  background: var(--color-white);
  border: 5px solid rgba(241,240,240,0.7);
  border-radius: var(--radius-nav);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}
.nav-item {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 4px 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.nav-icon { width: 22px; height: 22px; object-fit: contain; }
.nav-label {
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  line-height: 1;
}
.nav-item.active .nav-label { color: var(--color-principal); }
.nav-item:not(.active) .nav-label { color: var(--color-text-light); }

.nav-register-btn {
  width: 74px;
  height: 74px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  padding: 16px 17px;
}
.nav-register-btn img { width: 40px; height: 40px; object-fit: contain; }

/* ============================================================
   RESPONSIVE: on narrow screens, fit the frame to viewport
   ============================================================ */
@media (max-width: 450px) {
  body { padding: 0; }
  .app-frame {
    width: 100vw;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
  }
}
