/* ================================================================
   Morning Pulse App — Design System
   Clean, minimal, calm. Inspired by Notion.
   ================================================================ */

/* --- Reset & Base --- */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: ui-sans-serif, -apple-system, system-ui, Inter, sans-serif;
  color: #37352f;
  background: #ffffff;
  line-height: 1.6;
  min-height: 100vh;
}

/* --- Typography --- */

h1, h2, h3, h4 {
  font-weight: 600;
  color: #37352f;
  letter-spacing: -0.01em;
}

h1 {
  font-size: 1.75rem;
  line-height: 1.2;
  margin-bottom: 0.25rem;
}

h2 {
  font-size: 1.15rem;
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
  color: #37352f;
}

p, li, td, th, dd, dt, label {
  color: #55534e;
}

a {
  color: #37352f;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s;
}

a:hover {
  border-bottom-color: #d3d1cb;
}

code {
  font-family: 'SFMono-Regular', 'Consolas', 'Liberation Mono', 'Menlo', monospace;
  font-size: 0.85em;
  background: #f7f6f3;
  padding: 0.15em 0.4em;
  border-radius: 4px;
  color: #eb5757;
}

small, .text-secondary {
  font-size: 0.85rem;
  color: #9b9a97;
}

.text-muted {
  color: #b4b4b0;
}

em {
  color: #9b9a97;
  font-style: normal;
}

strong {
  font-weight: 600;
  color: #37352f;
}

/* --- Layout Shell --- */

.layout {
  display: flex;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  min-width: 0;
  padding: 3rem 4rem 4rem 4rem;
}

/* --- Left Side Nav (Desktop) --- */

.side-nav {
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  width: 200px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: 1.5rem 0.75rem;
  border-right: 1px solid #f7f6f3;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.3rem 0.65rem 0.75rem;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid #f7f6f3;
  text-decoration: none;
}

.nav-logo img {
  border-radius: 6px;
}

.nav-logo-text {
  font-size: 0.82rem;
  font-weight: 600;
  color: #37352f;
  letter-spacing: -0.01em;
}

.nav-logo:hover {
  background: none;
  border-bottom: 1px solid #f7f6f3;
}

.side-nav a,
.side-nav button.nav-user-trigger {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.65rem;
  border-radius: 6px;
  font-size: 0.85rem;
  color: #9b9a97;
  border: none;
  border-bottom: none;
  background: none;
  white-space: nowrap;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  width: 100%;
  transition: background 0.15s, color 0.15s;
}

.side-nav a:hover,
.side-nav button.nav-user-trigger:hover {
  background: #f7f6f3;
  color: #37352f;
  border-bottom: none;
}

.side-nav a.active {
  background: #f7f6f3;
  color: #37352f;
  font-weight: 500;
}

.nav-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Mask-based SVG icons — inherits color from parent */
.icon {
  display: inline-block;
  width: 16px;
  height: 16px;
  background: currentColor;
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
}

.icon-dashboard { -webkit-mask-image: url('/static/icons/dashboard.svg'); mask-image: url('/static/icons/dashboard.svg'); }
.icon-apps { -webkit-mask-image: url('/static/icons/apps.svg'); mask-image: url('/static/icons/apps.svg'); }
.icon-user { -webkit-mask-image: url('/static/icons/user.svg'); mask-image: url('/static/icons/user.svg'); }
.icon-help { -webkit-mask-image: url('/static/icons/help.svg'); mask-image: url('/static/icons/help.svg'); }
.icon-settings { -webkit-mask-image: url('/static/icons/settings.svg'); mask-image: url('/static/icons/settings.svg'); }
.icon-logout { -webkit-mask-image: url('/static/icons/logout.svg'); mask-image: url('/static/icons/logout.svg'); }
.icon-burger { -webkit-mask-image: url('/static/icons/burger.svg'); mask-image: url('/static/icons/burger.svg'); }
.icon-edit { -webkit-mask-image: url('/static/icons/edit.svg'); mask-image: url('/static/icons/edit.svg'); }
.icon-billing { -webkit-mask-image: url('/static/icons/billing.svg'); mask-image: url('/static/icons/billing.svg'); }
.icon-feedback { -webkit-mask-image: url('/static/icons/message-square.svg'); mask-image: url('/static/icons/message-square.svg'); }

.side-nav .nav-spacer {
  flex: 1;
}

/* --- User Menu & Popover --- */

.nav-user-menu {
  position: relative;
}

.nav-user-trigger {
  overflow: hidden;
}

.nav-user-email {
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.user-popover {
  display: none;
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  width: 190px;
  background: #ffffff;
  border: 1px solid #ebebea;
  border-radius: 16px;
  padding: 0.35rem;
  z-index: 300;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.user-popover.open {
  display: block;
}

.user-popover a {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.45rem 0.6rem;
  border-radius: 5px;
  font-size: 0.85rem;
  color: #55534e;
  border-bottom: none;
  transition: background 0.12s;
}

.user-popover a:hover {
  background: #f7f6f3;
  color: #37352f;
  border-bottom: none;
}

.user-popover .nav-icon {
  color: #9b9a97;
}

.popover-divider {
  height: 1px;
  background: #f7f6f3;
  margin: 0.3rem 0;
}

/* --- Mobile Burger --- */

.burger-toggle {
  display: none;
  position: fixed;
  top: 1.25rem;
  left: 1.25rem;
  z-index: 200;
  background: #ffffff;
  border: 1px solid #ebebea;
  border-radius: 16px;
  width: 40px;
  height: 40px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.burger-toggle .icon {
  width: 18px;
  height: 18px;
  color: #55534e;
}

.mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.08);
  z-index: 150;
}

.mobile-nav {
  display: none;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 260px;
  background: #ffffff;
  z-index: 160;
  padding: 4.5rem 1rem 2rem;
  flex-direction: column;
  gap: 0.15rem;
  box-shadow: 4px 0 20px rgba(0,0,0,0.04);
}

.mobile-nav a,
.mobile-nav span {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.75rem;
  border-radius: 6px;
  font-size: 0.9rem;
  color: #55534e;
  border-bottom: none;
  transition: background 0.15s;
}

.mobile-nav a:hover {
  background: #f7f6f3;
  border-bottom: none;
}

.mobile-nav a.active {
  background: #f7f6f3;
  color: #37352f;
  font-weight: 500;
}

.mobile-nav .nav-divider {
  height: 1px;
  background: #ebebea;
  margin: 0.5rem 0;
}

.mobile-nav .nav-user {
  font-size: 0.8rem;
  color: #b4b4b0;
  padding: 0.5rem 0.75rem;
}

body.menu-open .mobile-overlay,
body.menu-open .mobile-nav {
  display: flex;
}

/* --- Page Header --- */

.page-header {
  margin-bottom: 2rem;
}

.page-header h1 {
  margin-bottom: 0.15rem;
}

.page-subtitle {
  font-size: 0.9rem;
  color: #9b9a97;
}

.breadcrumb {
  font-size: 0.8rem;
  color: #b4b4b0;
  margin-bottom: 1.25rem;
}

.breadcrumb a {
  color: #9b9a97;
}

.breadcrumb a:hover {
  color: #55534e;
}

.breadcrumb .sep {
  margin: 0 0.4rem;
  color: #d3d1cb;
}

/* --- Cards --- */

.card {
  background: #ffffff;
  border: 1px solid #ebebea;
  border-radius: 16px;
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.card-section {
  background: #ffffff;
  border: 1px solid #ebebea;
  border-radius: 12px;
  padding: 1.5rem 1.75rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.card-section > h2:first-child {
  margin-top: 0;
}

.card-section > .page-header {
  margin-bottom: 0.5rem;
}

.card-section > .detail-grid {
  margin-bottom: 0;
}

.card-section > .actions-bar:last-child {
  margin-bottom: 0;
}

.card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 0;
  border-bottom: 1px solid #f7f6f3;
}

.card-row:last-child {
  border-bottom: none;
}

.card-row .label {
  font-size: 0.8rem;
  color: #9b9a97;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 500;
}

.card-row .value {
  color: #37352f;
  font-weight: 500;
}

/* --- Tables --- */

.table-wrap {
  overflow-x: auto;
  margin: 0.5rem 0 1.5rem;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

thead th {
  text-align: left;
  font-weight: 500;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #9b9a97;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid #ebebea;
  white-space: nowrap;
}

tbody td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #f7f6f3;
  color: #55534e;
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover td {
  background: #fafaf9;
}

/* --- Forms --- */

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: #9b9a97;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.4rem;
}

.form-group input,
.form-group select,
.form-group textarea {
  display: block;
  width: 100%;
  padding: 0.55rem 0.75rem;
  font-size: 0.9rem;
  font-family: inherit;
  color: #37352f;
  background: #ffffff;
  border: 1px solid #f2f2f1;
  border-radius: 6px;
  outline: none;
  transition: border-color 0.15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: #a5a5a0;
}

.form-group input::placeholder {
  color: #c8c7c1;
}

.form-group input[readonly] {
  background: #f7f6f3;
  color: #9b9a97;
}

.form-hint {
  font-size: 0.78rem;
  color: #b4b4b0;
  margin-top: 0.3rem;
}

/* --- Buttons --- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  font-family: inherit;
  font-weight: 500;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  text-decoration: none;
  border-bottom: none;
  line-height: 1.4;
}

.btn:hover {
  border-bottom: none;
}

.btn-primary {
  background: #37352f;
  color: #ffffff;
}

.btn-primary:hover {
  background: #2f2e29;
  color: #ffffff;
}

.btn-secondary {
  background: #f7f6f3;
  color: #55534e;
}

.btn-secondary:hover {
  background: #ebebea;
}

.btn-ghost {
  background: transparent;
  color: #9b9a97;
  padding: 0.4rem 0.6rem;
}

.btn-ghost:hover {
  background: #f7f6f3;
  color: #55534e;
}

.btn-danger {
  background: transparent;
  color: #c4554d;
  font-size: 0.8rem;
  padding: 0.3rem 0.6rem;
}

.btn-danger:hover {
  background: #fdf2f2;
}

.btn-google {
  background: #ffffff;
  color: #55534e;
  border: 1px solid #e0dfdb;
  gap: 0.5rem;
}

.btn-google:hover {
  background: #f7f6f3;
}

/* --- Inline Actions --- */

.actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.actions form {
  display: inline;
}

.actions-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 2rem;
}

/* --- Status Indicators --- */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 4px;
  letter-spacing: 0.02em;
}

.badge-ok {
  background: #edf8ee;
  color: #2e7d32;
}

.badge-danger {
  background: #fdecea;
  color: #c62828;
}

.badge-warn {
  background: #fdf6ec;
  color: #b8860b;
}

.badge-off {
  background: #f7f6f3;
  color: #9b9a97;
}

.badge-info {
  background: #e8f0fe;
  color: #1a73e8;
}

.badge-default {
  background: #f0f0ef;
  color: #6b6b68;
}

/* --- Platform Pills --- */

.platform {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.78rem;
  font-weight: 500;
  color: #9b9a97;
  letter-spacing: 0.04em;
}

/* --- Empty States --- */

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: #b4b4b0;
}

.empty-state p {
  color: #b4b4b0;
  margin-bottom: 1rem;
}

/* --- Definition List (Detail pages) --- */

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  margin: 1rem 0 2rem;
}

.detail-item {
  padding: 0.85rem 0;
  border-bottom: 1px solid #f7f6f3;
}

.detail-item .label {
  font-size: 0.75rem;
  font-weight: 500;
  color: #9b9a97;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.2rem;
}

.detail-item .value {
  color: #37352f;
}

/* --- Divider --- */

.divider {
  height: 1px;
  background: #ebebea;
  margin: 1.5rem 0;
  border: none;
}

/* --- Auth Pages (centered layout) --- */

.auth-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
}

.auth-card {
  width: 100%;
  max-width: 360px;
}

.auth-card h1 {
  font-size: 1.5rem;
  margin-bottom: 0.35rem;
}

.auth-card .auth-subtitle {
  color: #9b9a97;
  font-size: 0.9rem;
  margin-bottom: 2rem;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.5rem 0;
  font-size: 0.8rem;
  color: #c8c7c1;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #ebebea;
}

.auth-footer {
  text-align: center;
  margin-top: 2rem;
  font-size: 0.85rem;
  color: #9b9a97;
}

.auth-footer a {
  color: #37352f;
  font-weight: 500;
}

/* --- Inline Edit Mode --- */

.inline-edit-input {
  font-family: inherit;
  font-size: inherit;
  color: #37352f;
  background: #ffffff;
  border: 1px solid #f2f2f1;
  border-radius: 5px;
  padding: 0.3rem 0.5rem;
  outline: none;
  width: 100%;
  max-width: 20rem;
  transition: border-color 0.15s;
}

.inline-edit-input:focus {
  border-color: #a5a5a0;
}

h1 .inline-edit-input {
  font-size: 1.75rem;
  font-weight: 600;
  padding: 0.1rem 0.4rem;
  letter-spacing: -0.01em;
}

.inline-edit-select {
  font-family: inherit;
  font-size: inherit;
  color: #37352f;
  background: #ffffff;
  border: 1px solid #e0dfdb;
  border-radius: 5px;
  padding: 0.3rem 0.5rem;
  outline: none;
  cursor: pointer;
}

.inline-edit-select:focus {
  border-color: #a5a5a0;
}

/* View / edit state visibility */
[data-view] { display: block; }
[data-edit] { display: none; }
.editing [data-view] { display: none; }
.editing [data-edit] { display: block; }
.editing a[data-edit],
.editing button[data-edit] { display: inline-block; }

.page-header-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.page-header-row h1 {
  flex: 1;
  min-width: 0;
}

/* --- Footer --- */

.app-footer {
  margin-top: 4rem;
  padding: 1.5rem 0;
  border-top: 1px solid #f7f6f3;
  font-size: 0.78rem;
  color: #c8c7c1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

/* --- Responsive --- */

@media (max-width: 768px) {
  .main-content {
    padding: 4.5rem 1.5rem 3rem;
  }

  .side-nav {
    display: none;
  }

  .burger-toggle {
    display: flex;
  }

  h1 {
    font-size: 1.5rem;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .actions-bar {
    flex-direction: column;
    align-items: flex-start;
  }

  .auth-wrapper {
    padding: 1.5rem;
  }
}

@media (max-width: 480px) {
  .main-content {
    padding: 4.5rem 1rem 2.5rem;
  }

  table {
    font-size: 0.82rem;
  }

  thead th,
  tbody td {
    padding: 0.6rem 0.65rem;
  }
}

/* --- Info popover (small ? button + bubble) --- */

.info-popover-wrap {
  position: relative;
}

.info-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.15rem;
  height: 1.15rem;
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1;
  color: #9b9a97;
  background: #f1f1ef;
  border: 0px solid #e3e2de;
  border-radius: 50%;
  cursor: pointer;
  vertical-align: middle;
  margin-left: 0.2rem;
  transition: background 0.15s, color 0.15s;
}

.info-toggle:hover {
  background: #e3e2de;
  color: #6b6b68;
}

.info-popover {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 22rem;
  max-width: calc(100vw - 2rem);
  padding: 1rem 1.2rem;
  font-size: 0.82rem;
  line-height: 1.55;
  color: #6b6b68;
  background: #ffffff;
  border: 1px solid #ebebea;
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.10);
  z-index: 1000;
}

.info-popover.open {
  display: block;
}

/* Sparkline chips on dashboard */
.spark-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.5rem 0.2rem 0.35rem;
  border: 1px solid var(--color-border, #ebebea);
  border-radius: 6px;
  text-decoration: none;
  color: inherit;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.spark-chip:hover {
  border-color: #c8c8c5;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.spark-svg {
  width: 64px;
  min-width: 64px;
  height: 20px;
  flex-shrink: 0;
}

.spark-svg.spark-svg-wide {
  width: 120px;
  min-width: 120px;
}

.spark-label {
  font-size: 0.72rem;
  color: #6b6b68;
  white-space: nowrap;
  max-width: 7rem;
  overflow: hidden;
  text-overflow: ellipsis;
}
