/* NutriPlan · CSS Global */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #F4F1EC;
  --surface:  #FDFCFA;
  --warm:     #EDE5D8;
  --border:   #E0D8CE;
  --stone:    #B8A898;
  --muted:    #9A8E82;
  --mid:      #5C5248;
  --dark:     #1E1A16;
  --forest:   #1E3A2F;
  --moss:     #3D7A5A;
  --sage:     #7EC8A0;
  --sage-lt:  #C8DDD0;
  --amber:    #C97A2A;
  --red:      #C0392B;
  --white:    #FFFFFF;
  --serif:    'Fraunces', Georgia, serif;
  --sans:     'DM Sans', sans-serif;
  --sh:       0 1px 3px rgba(30,26,22,.06);
  --sh-md:    0 4px 16px rgba(30,26,22,.07);
}

html { font-size: 14px; scroll-behavior: smooth; }
body { font-family: var(--sans); background: var(--bg); color: var(--dark); min-height: 100vh; }
a { color: inherit; }
button { font-family: var(--sans); cursor: pointer; }
input, select, textarea { font-family: var(--sans); }

/* ── LAYOUT ADMIN ── */
.layout-admin { display: flex; }
.sidebar {
  width: 232px; flex-shrink: 0;
  background: var(--forest);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 50; overflow-y: auto;
}
.sb-brand { padding: 22px 20px 18px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sb-logo { font-family: var(--serif); font-size: 19px; font-weight: 500; color: #F4F1EC; }
.sb-logo em { color: var(--sage); font-style: italic; }
.sb-tagline { display: block; font-size: 11px; color: rgba(255,255,255,.25); margin-top: 2px; }
.sb-user { display: flex; align-items: center; gap: 10px; padding: 14px 20px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sb-av { width: 34px; height: 34px; border-radius: 50%; background: var(--moss); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 500; flex-shrink: 0; }
.sb-name { font-size: 12px; font-weight: 500; color: rgba(255,255,255,.82); }
.sb-role { font-size: 11px; color: rgba(255,255,255,.3); margin-top: 1px; }
.sb-nav { flex: 1; padding: 10px; }
.sb-item { display: flex; align-items: center; gap: 9px; padding: 9px 10px; border-radius: 8px; font-size: 13px; color: rgba(255,255,255,.45); text-decoration: none; margin-bottom: 1px; transition: background .15s, color .15s; }
.sb-item:hover { background: rgba(255,255,255,.07); color: rgba(255,255,255,.82); }
.sb-item.active { background: rgba(255,255,255,.13); color: #F4F1EC; font-weight: 500; }
.sb-logout { margin: 0 10px 16px; padding: 9px 10px; border-radius: 8px; font-size: 12px; color: rgba(255,255,255,.3); text-decoration: none; display: block; transition: color .15s; }
.sb-logout:hover { color: rgba(255,255,255,.6); }
.admin-main { margin-left: 232px; flex: 1; display: flex; flex-direction: column; min-height: 100vh; }

/* ── TOPBAR ── */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); padding: 0 28px; height: 54px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 40; }
.topbar-title { font-family: var(--serif); font-size: 17px; font-weight: 500; font-style: italic; }
.topbar-sub { font-size: 11px; color: var(--muted); margin-top: 1px; }

/* ── CONTENT ── */
.content { padding: 24px 28px; flex: 1; }

/* ── CARDS ── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--sh); overflow: hidden; }
.card-hd { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-title { font-size: 13px; font-weight: 500; }
.card-link { font-size: 12px; color: var(--moss); text-decoration: none; font-weight: 500; }
.card-body { padding: 18px; }

/* ── GRIDS ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; }
.grid-main { display: grid; grid-template-columns: 1fr 300px; gap: 16px; }

/* ── KPIs ── */
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; }
.kpi-label { font-size: 11px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; }
.kpi-val { font-family: var(--serif); font-size: 26px; font-weight: 500; line-height: 1; }
.kpi-delta { font-size: 12px; color: var(--moss); margin-top: 3px; }

/* ── BOTONES ── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 18px; border-radius: 100px; font-size: 13px; font-weight: 500; border: none; cursor: pointer; text-decoration: none; transition: all .15s; }
.btn-primary { background: var(--forest); color: #F4F1EC; }
.btn-primary:hover { background: var(--moss); }
.btn-secondary { background: transparent; color: var(--mid); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--warm); }
.btn-danger { background: transparent; color: var(--red); border: 1px solid rgba(192,57,43,.25); }
.btn-danger:hover { background: rgba(192,57,43,.07); }
.btn-sm { padding: 6px 12px; font-size: 12px; }

/* ── FORMULARIOS ── */
.form-group { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.form-label { font-size: 11px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.form-control { padding: 9px 12px; border-radius: 9px; border: 1.5px solid var(--border); background: var(--bg); font-size: 13px; color: var(--dark); outline: none; transition: border-color .15s; width: 100%; }
.form-control:focus { border-color: var(--moss); background: var(--surface); }
.form-control.error { border-color: var(--red); background: #FEF2F2; }
.form-error { font-size: 11px; color: var(--red); margin-top: 2px; }
textarea.form-control { resize: vertical; min-height: 72px; line-height: 1.5; }

/* ── TABLA ── */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th { padding: 11px 14px; text-align: left; font-size: 11px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; background: var(--bg); border-bottom: 1px solid var(--border); }
tbody tr { border-bottom: 1px solid #F0EBE3; transition: background .1s; }
tbody tr:hover { background: var(--warm); }
tbody tr:last-child { border-bottom: none; }
tbody td { padding: 12px 14px; vertical-align: middle; }

/* ── BADGES ── */
.badge { display: inline-flex; align-items: center; font-size: 11px; font-weight: 500; padding: 3px 9px; border-radius: 20px; }
.badge-green { background: #DCFCE7; color: #166534; }
.badge-amber { background: #FEF3C7; color: #92400E; }
.badge-red   { background: #FEE2E2; color: #991B1B; }
.badge-blue  { background: #DBEAFE; color: #1D4ED8; }
.badge-gray  { background: var(--warm); color: var(--mid); }

/* ── ALERTAS ── */
.alert { padding: 12px 16px; border-radius: 10px; font-size: 13px; margin-bottom: 16px; }
.alert-error   { background: #FEE2E2; color: #991B1B; border: 1px solid #FECACA; }
.alert-success { background: #DCFCE7; color: #166534; border: 1px solid #BBF7D0; }
.alert-info    { background: #DBEAFE; color: #1D4ED8; border: 1px solid #BFDBFE; }

/* ── TIMELINE ── */
.timeline { display: flex; flex-direction: column; }
.tl-item { display: flex; gap: 14px; padding-bottom: 20px; }
.tl-dot-wrap { display: flex; flex-direction: column; align-items: center; width: 20px; flex-shrink: 0; }
.tl-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; margin-top: 3px; }
.tl-line { flex: 1; width: 1.5px; background: var(--border); margin-top: 4px; }
.tl-content { flex: 1; }
.tl-titulo { font-size: 13px; font-weight: 500; color: var(--dark); margin-bottom: 4px; }
.tl-desc { font-size: 12px; color: var(--mid); line-height: 1.55; }
.tl-fecha { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* ── AVATAR ── */
.avatar { border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 500; flex-shrink: 0; }
.avatar-sm { width: 32px; height: 32px; font-size: 11px; background: var(--sage-lt); color: var(--forest); }
.avatar-md { width: 40px; height: 40px; font-size: 14px; background: var(--sage-lt); color: var(--forest); }
.avatar-lg { width: 56px; height: 56px; font-size: 20px; font-family: var(--serif); background: var(--sage-lt); color: var(--forest); }

/* ── LOGIN ── */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 40px 36px; width: 100%; max-width: 400px; box-shadow: var(--sh-md); }
.login-logo { font-family: var(--serif); font-size: 24px; font-weight: 500; color: var(--forest); margin-bottom: 4px; }
.login-logo em { color: #D4573A; font-style: italic; }
.login-sub { font-size: 14px; color: var(--muted); margin-bottom: 28px; }

/* ── WIZARD ── */
.wizard-steps { display: flex; align-items: center; padding: 16px 28px; background: var(--surface); border-bottom: 1px solid var(--border); gap: 0; }
.wizard-step { display: flex; align-items: center; gap: 8px; flex: 1; }
.wizard-dot { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--border); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 500; color: var(--muted); background: var(--surface); flex-shrink: 0; transition: all .3s; }
.wizard-dot.active { border-color: var(--forest); color: var(--forest); }
.wizard-dot.done { background: var(--forest); border-color: var(--forest); color: #F4F1EC; }
.wizard-label { font-size: 12px; color: var(--muted); }
.wizard-label.active { color: var(--dark); font-weight: 500; }
.wizard-line { flex: 1; height: 2px; background: var(--border); margin: 0 8px; transition: background .3s; }
.wizard-line.done { background: var(--forest); }

/* ── GRÁFICA ── */
.chart-summary { display: flex; background: var(--bg); border-radius: 10px; overflow: hidden; margin-bottom: 16px; border: 1px solid var(--border); }
.chart-summary-item { flex: 1; padding: 10px 12px; border-right: 1px solid var(--border); text-align: center; }
.chart-summary-item:last-child { border-right: none; }
.chart-summary-label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 3px; }
.chart-summary-val { font-family: var(--serif); font-size: 16px; font-weight: 500; }

/* ── MENSAJES ── */
.chat-layout { display: flex; height: calc(100vh - 54px); overflow: hidden; }
.chat-sidebar { width: 280px; border-right: 1px solid var(--border); display: flex; flex-direction: column; background: var(--surface); overflow-y: auto; flex-shrink: 0; }
.chat-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.conv-item { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid #F0EBE3; cursor: pointer; transition: background .12s; text-decoration: none; color: inherit; }
.conv-item:hover, .conv-item.active { background: #EEF7F1; }
.conv-nombre { font-size: 13px; font-weight: 500; color: var(--dark); }
.conv-preview { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px; margin-top: 1px; }
.unread-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--moss); flex-shrink: 0; }
.messages-list { flex: 1; overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; }
.msg-wrap { display: flex; align-items: flex-end; gap: 7px; margin-bottom: 4px; }
.msg-wrap.mio { flex-direction: row-reverse; }
.bubble { max-width: 68%; padding: 9px 13px; border-radius: 14px; font-size: 13px; line-height: 1.5; word-break: break-word; }
.bubble-otro { background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; color: var(--dark); }
.bubble-mio { background: var(--forest); color: #F4F1EC; border-bottom-right-radius: 4px; }
.bubble-time { font-size: 10px; color: var(--muted); margin-top: 3px; text-align: right; }
.bubble-mio .bubble-time { color: rgba(244,241,236,.5); }
.chat-input-area { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); background: var(--surface); flex-shrink: 0; }
.chat-input { flex: 1; padding: 10px 14px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--bg); font-size: 13px; color: var(--dark); outline: none; resize: none; line-height: 1.5; max-height: 100px; overflow-y: auto; }
.chat-send { width: 40px; height: 40px; border-radius: 10px; background: var(--forest); border: none; color: #F4F1EC; display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; transition: background .15s; }
.chat-send:hover { background: var(--moss); }

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .admin-main { margin-left: 0; }
  .content { padding: 16px; }
  .grid-2, .grid-3, .grid-4, .grid-main { grid-template-columns: 1fr; }
}
