/* ═══════════════════════════════════════════════════
   HM Profile — Professional Health Routine Theme
   ═══════════════════════════════════════════════════ */

:root {
  --primary: #0d9488;
  --primary-dark: #0f766e;
  --primary-light: #ccfbf1;
  --primary-bg: #f0fdfa;
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-hover: #f1f5f9;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --text: #0f172a;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --success: #059669;
  --success-bg: #ecfdf5;
  --success-border: #a7f3d0;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --warning-border: #fde68a;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,.07), 0 1px 3px rgba(0,0,0,.04);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.08), 0 2px 8px rgba(0,0,0,.04);
  --radius: 0.75rem;
  --radius-lg: 1rem;
  --radius-xl: 1.25rem;
}

/* ── Base ─────────────────────────────────────────── */

html {
  font-size: 15px;
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

::selection { background: var(--primary-light); }

/* ── Header ───────────────────────────────────────── */

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  background: rgba(255,255,255,.92);
}

.navbar { padding: .75rem 0; }

.brand-mark {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text) !important;
  display: flex;
  align-items: center;
  gap: .5rem;
  letter-spacing: -.01em;
}

.brand-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: .5rem;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  font-size: .95rem;
}

.nav-link {
  color: var(--text-secondary) !important;
  font-weight: 600;
  font-size: .9rem;
  padding: .5rem .85rem !important;
  border-radius: var(--radius);
  transition: all .15s;
}

.nav-link:hover,
.nav-link:focus {
  color: var(--primary-dark) !important;
  background: var(--primary-bg);
}

/* ── Main Content ─────────────────────────────────── */

.main-content {
  padding-top: 1.5rem;
  padding-bottom: 3rem;
  min-height: calc(100vh - 9rem);
}

/* ── Footer ───────────────────────────────────────── */

.site-footer {
  border-top: 1px solid var(--border);
  padding: 1rem 0;
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .84rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ── Cards ────────────────────────────────────────── */

.card-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}

.card-panel-flush { padding: 0; }
.card-panel-flush .card-panel-body { padding: 1.5rem; }

/* ── Hero / Page Header ───────────────────────────── */

.page-hero {
  background: linear-gradient(135deg, var(--primary) 0%, #115e59 100%);
  border-radius: var(--radius-xl);
  padding: 2rem;
  color: #fff;
  position: relative;
  overflow: hidden;
}

.page-hero::before {
  content: '';
  position: absolute;
  top: -40%;
  right: -10%;
  width: 20rem;
  height: 20rem;
  border-radius: 50%;
  background: rgba(255,255,255,.06);
}

.page-hero::after {
  content: '';
  position: absolute;
  bottom: -30%;
  left: 10%;
  width: 14rem;
  height: 14rem;
  border-radius: 50%;
  background: rgba(255,255,255,.04);
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255,255,255,.7);
  margin-bottom: .5rem;
}

.hero-title {
  font-size: clamp(1.6rem, 3.5vw, 2.2rem);
  font-weight: 900;
  line-height: 1.15;
  margin: 0;
  letter-spacing: -.02em;
}

/* ── Summary Stats ────────────────────────────────── */

.stats-grid {
  display: grid;
  gap: .75rem;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.15rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .15s, border-color .15s;
}

.stat-card:hover {
  box-shadow: var(--shadow);
  border-color: #cbd5e1;
}

.stat-card .stat-icon {
  width: 2rem;
  height: 2rem;
  border-radius: .5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: .95rem;
  margin-bottom: .5rem;
}

.stat-icon-teal   { background: var(--primary-bg); color: var(--primary); }
.stat-icon-green  { background: var(--success-bg); color: var(--success); }
.stat-icon-amber  { background: var(--warning-bg); color: var(--warning); }
.stat-icon-red    { background: var(--danger-bg);  color: var(--danger); }

.stat-card .stat-label {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
}

.stat-card .stat-value {
  font-size: 1.65rem;
  font-weight: 800;
  line-height: 1.2;
  margin-top: .15rem;
  color: var(--text);
  letter-spacing: -.02em;
}

.stat-value-sm {
  font-size: 1rem !important;
  line-height: 1.35 !important;
}

/* ── Section Title ────────────────────────────────── */

.section-header {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: 1rem;
}

.section-header .section-icon {
  width: 2rem;
  height: 2rem;
  border-radius: .5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: .95rem;
  flex-shrink: 0;
}

.section-header h2 {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0;
  color: var(--text);
}

/* ── Routine Timeline ─────────────────────────────── */

.routine-timeline { position: relative; }

.routine-timeline::before {
  content: '';
  position: absolute;
  top: 1.8rem;
  bottom: 1.8rem;
  left: 1.65rem;
  width: 2px;
  background: var(--border);
}

.routine-block {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  padding: 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
  background: var(--surface);
  transition: all .15s;
  position: relative;
}

.routine-block:hover { border-color: var(--border); box-shadow: var(--shadow-sm); }

.routine-block + .routine-block { margin-top: .5rem; }

.routine-block.is-done {
  border-color: var(--success-border);
  background: var(--success-bg);
}

.routine-block.is-active {
  border-color: #99f6e4;
  background: var(--primary-bg);
}

.routine-block.is-active .timeline-marker .dot {
  border-color: var(--primary);
  background: var(--primary);
  box-shadow: 0 0 0 3px rgba(13,148,136,.18);
}

.btn-start {
  background: var(--primary-bg) !important;
  color: var(--primary) !important;
  border: 1px solid #99f6e4 !important;
  font-weight: 700;
}

.btn-start:hover {
  background: var(--primary-light) !important;
  border-color: var(--primary) !important;
}

.timeline-marker {
  flex-shrink: 0;
  width: 2.3rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: .15rem;
  position: relative;
  z-index: 1;
}

.timeline-marker .dot {
  width: .75rem;
  height: .75rem;
  border-radius: 50%;
  border: 2.5px solid var(--border);
  background: var(--surface);
}

.routine-block.is-done .timeline-marker .dot {
  border-color: var(--success);
  background: var(--success);
}

.routine-body { flex: 1; min-width: 0; }

.routine-time {
  font-size: .8rem;
  font-weight: 700;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: .35rem;
}

.routine-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-top: .15rem;
}

.routine-tags { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .4rem; }

.routine-actions {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: .5rem;
  padding-top: .15rem;
}

/* ── Tags / Pills ─────────────────────────────────── */

.tag {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  font-size: .72rem;
  font-weight: 600;
  padding: .25rem .6rem;
  border-radius: 999px;
  white-space: nowrap;
}

.tag-neutral  { background: var(--surface-hover); color: var(--text-secondary); }
.tag-success  { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
.tag-warning  { background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning-border); }
.tag-danger   { background: var(--danger-bg);  color: var(--danger);  border: 1px solid var(--danger-border); }
.tag-primary  { background: var(--primary-bg); color: var(--primary); }

/* ── Buttons ──────────────────────────────────────── */

.btn { font-weight: 600; font-size: .88rem; border-radius: var(--radius); }

.btn-primary {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  color: #fff !important;
}

.btn-primary:hover,
.btn-primary:focus {
  background: var(--primary-dark) !important;
  border-color: var(--primary-dark) !important;
}

.btn-outline-secondary {
  color: var(--text-secondary);
  border-color: var(--border);
}

.btn-outline-secondary:hover,
.btn-outline-secondary:focus {
  color: var(--text);
  background: var(--surface-hover);
  border-color: #cbd5e1;
}

.btn-sm { font-size: .8rem; padding: .35rem .75rem; }

.btn-icon {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
}

/* ── Suggestion / Adjustment Cards ────────────────── */

.adj-card {
  padding: 1rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border-light);
  transition: border-color .15s;
}

.adj-card:hover { border-color: var(--border); }
.adj-card + .adj-card { margin-top: .5rem; }

/* ── Reminder Panel ───────────────────────────────── */

.reminder-panel {
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  text-align: center;
  background: var(--surface);
}

.reminder-panel .reminder-icon {
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  background: var(--warning-bg);
  color: var(--warning);
  margin-bottom: .75rem;
}

/* ── Toast ────────────────────────────────────────── */

.toast-card {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  color: var(--text);
  box-shadow: var(--shadow-md);
  animation: slideIn .25s ease-out;
}

.toast-card + .toast-card { margin-top: .5rem; }

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-.5rem); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Form Styles ──────────────────────────────────── */

.form-label {
  font-size: .78rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: .3rem;
}

.form-control,
.form-select {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: .9rem;
  padding: .55rem .75rem;
  transition: border-color .15s, box-shadow .15s;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(13,148,136,.12);
}

/* ── Empty State ──────────────────────────────────── */

.empty-state {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--text-muted);
  border-radius: var(--radius);
  background: var(--surface-hover);
  border: 1px dashed var(--border);
  font-size: .9rem;
}

/* ── Modal ────────────────────────────────────────── */

.modal-content {
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

/* ── Date Nav ─────────────────────────────────────── */

.date-nav {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.date-nav .btn {
  min-width: 2.5rem;
  height: 2.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

/* ── Template Card (Manage) ───────────────────────── */

.template-card {
  padding: 1.25rem;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border-light);
  transition: border-color .15s, box-shadow .15s;
}

.template-card:hover {
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}

.template-card + .template-card { margin-top: .75rem; }

.template-card .template-header {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .75rem;
  padding-bottom: .75rem;
  border-bottom: 1px solid var(--border-light);
}

.template-card .template-number {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: .4rem;
  background: var(--primary-bg);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  font-weight: 800;
  flex-shrink: 0;
}

/* ── Responsive ───────────────────────────────────── */

@media (max-width: 767.98px) {
  .page-hero { padding: 1.25rem; }
  .hero-title { font-size: 1.4rem; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); }

  .routine-block {
    flex-wrap: wrap;
  }

  .routine-actions {
    width: 100%;
    padding-top: .5rem;
  }

  .routine-actions .btn { width: 100%; }

  .routine-timeline::before { left: 1.15rem; }

  .card-panel { padding: 1rem; }

  .footer-inner { flex-direction: column; gap: .25rem; }

  .date-nav-label { font-size: .95rem; }
}

@media (max-width: 575.98px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: .5rem; }
  .stat-card { padding: .75rem; }
  .stat-card .stat-value { font-size: 1.35rem; }
}

/* ── Finish Countdown Toast ───────────────────────── */

.finish-countdown-toast {
  position: absolute;
  inset: 0;
  z-index: 10;
  border-radius: var(--radius);
  background: rgba(13, 148, 136, .97);
  display: flex;
  flex-direction: column;
  justify-content: center;
  animation: fctFadeIn .2s ease-out;
}

@keyframes fctFadeIn {
  from { opacity: 0; transform: scale(.97); }
  to   { opacity: 1; transform: scale(1); }
}

.fct-inner {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .75rem 1rem;
  color: #fff;
}

.fct-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
  opacity: .85;
}

.fct-text {
  flex: 1;
  font-size: .88rem;
  font-weight: 600;
}

.fct-cancel {
  background: rgba(255,255,255,.18) !important;
  color: #fff !important;
  border: 1px solid rgba(255,255,255,.3) !important;
  font-weight: 700;
  font-size: .8rem;
  padding: .3rem .75rem;
  border-radius: var(--radius);
  transition: background .15s;
  white-space: nowrap;
}

.fct-cancel:hover {
  background: rgba(255,255,255,.3) !important;
}

.fct-bar {
  height: 3px;
  background: rgba(255,255,255,.2);
  border-radius: 0 0 var(--radius) var(--radius);
  overflow: hidden;
}

.fct-bar-fill {
  width: 100%;
  height: 100%;
  background: #fff;
  border-radius: 0 0 var(--radius) var(--radius);
}

.start-countdown-toast {
  background: rgba(15, 118, 110, .95);
}
