/* ── NaturalMed Clinic Manager — App Styles ── */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600&family=DM+Mono:wght@400;500&display=swap');

:root {
  --sage:       #4a7c59;
  --sage-light: #c8ddd0;
  --sage-pale:  #eaf2ed;
  --rust:       #b85c38;
  --rust-light: #f2d9cf;
  --gold:       #c9a84c;
  --ink:        #1a1a18;
  --muted:      #6b6b62;
  --rule:       #e5e2d8;
  --paper:      #f9f8f5;
  --white:      #ffffff;
  --radius:     8px;
  --shadow:     0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md:  0 4px 12px rgba(0,0,0,.10);
}

* { box-sizing: border-box; }

body {
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
}

/* ── LAYOUT ── */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--ink);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
}

.sidebar-logo {
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
  font-size: .95rem;
  font-weight: 600;
  color: #fff;
  letter-spacing: -.01em;
}

.sidebar-logo span { color: var(--sage-light); }

.sidebar-nav { flex: 1; padding: .75rem .625rem; overflow-y: auto; }

.nav-item {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .5rem .75rem;
  border-radius: 6px;
  font-size: .845rem;
  font-weight: 500;
  color: rgba(255,255,255,.55);
  text-decoration: none;
  transition: background .15s, color .15s;
  margin-bottom: 2px;
}
.nav-item:hover { background: rgba(255,255,255,.07); color: rgba(255,255,255,.9); }
.nav-item.active { background: rgba(255,255,255,.12); color: #fff; }
.nav-item svg { flex-shrink: 0; opacity: .8; }

.nav-section {
  font-size: .65rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: rgba(255,255,255,.25);
  padding: .9rem .75rem .3rem;
}

.sidebar-footer {
  padding: .875rem 1rem;
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: .75rem;
  color: rgba(255,255,255,.35);
}

.main-content {
  margin-left: 240px;
  flex: 1;
  min-width: 0;
  padding: 2rem 2.5rem;
  max-width: 1200px;
}

/* ── PAGE HEADER ── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.75rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.page-title {
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -.02em;
  line-height: 1.2;
}
.page-title-pt { color: var(--muted); font-weight: 400; }
.page-sub { font-size: .825rem; color: var(--muted); margin-top: .2rem; }
.breadcrumb { font-size: .775rem; color: var(--muted); margin-bottom: .3rem; }
.breadcrumb a { color: var(--sage); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1rem;
  border-radius: var(--radius);
  font-size: .825rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: opacity .15s, box-shadow .15s;
  white-space: nowrap;
}
.btn:hover { opacity: .88; }
.btn-primary   { background: var(--sage); color: #fff; }
.btn-secondary { background: var(--white); color: var(--ink); border: 1px solid var(--rule); }
.btn-danger    { background: var(--rust-light); color: var(--rust); border: 1px solid #e8c4b4; }
.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 6px;
  color: var(--muted); text-decoration: none;
  transition: background .15s, color .15s;
}
.btn-icon:hover { background: var(--sage-pale); color: var(--sage); }

/* ── SEARCH ── */
.search-bar {
  position: relative;
  margin-bottom: 1.25rem;
  max-width: 480px;
}
.search-icon {
  position: absolute;
  left: .875rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}
.search-input {
  width: 100%;
  padding: .55rem .875rem .55rem 2.5rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--white);
  font-size: .85rem;
  color: var(--ink);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.search-input:focus {
  border-color: var(--sage);
  box-shadow: 0 0 0 3px rgba(74,124,89,.12);
}

/* ── TABLE ── */
.table-wrap {
  background: var(--white);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.data-table { width: 100%; border-collapse: collapse; }
.data-table thead { background: #f4f3ef; }
.data-table th {
  padding: .625rem 1rem;
  text-align: left;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--rule);
}
.data-table td {
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--rule);
  font-size: .845rem;
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr.table-row:hover { background: var(--sage-pale); }
.patient-name { font-weight: 500; color: var(--ink); }
.patient-meta { font-size: .72rem; color: var(--muted); margin-top: 1px; }

/* ── PAGINATION ── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  margin-top: 1.25rem;
}
.page-btn {
  padding: .4rem .9rem;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--white);
  font-size: .8rem;
  color: var(--ink);
  text-decoration: none;
  transition: background .15s;
}
.page-btn:hover { background: var(--sage-pale); }
.page-info { font-size: .8rem; color: var(--muted); }

/* ── EMPTY STATE ── */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  background: var(--white);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}
.empty-icon { font-size: 2.5rem; margin-bottom: .75rem; }
.empty-state h3 { font-size: 1rem; font-weight: 600; margin-bottom: .35rem; }
.empty-state p { font-size: .85rem; color: var(--muted); margin-bottom: 1.25rem; }

/* ── BADGES ── */
.badge-constitution {
  display: inline-block;
  padding: .2rem .55rem;
  border-radius: 99px;
  font-size: .7rem;
  font-weight: 600;
}
.badge-wood  { background: #dcf0dc; color: #2d6a2d; }
.badge-fire  { background: #fde8e8; color: #9b2c2c; }
.badge-earth { background: #fef3c7; color: #92400e; }
.badge-metal { background: #e8eaf6; color: #3949ab; }
.badge-water { background: #dbeafe; color: #1e40af; }
.badge-mixed { background: #f3e8ff; color: #6b21a8; }

.status-badge {
  display: inline-block;
  padding: .2rem .55rem;
  border-radius: 99px;
  font-size: .7rem;
  font-weight: 600;
}
.status-scheduled  { background: #dbeafe; color: #1e40af; }
.status-confirmed  { background: #dcfce7; color: #166534; }
.status-attended   { background: var(--sage-light); color: var(--sage); }
.status-cancelled  { background: #fde8e8; color: #9b2c2c; }
.status-no_show    { background: #fef3c7; color: #92400e; }

/* ── DETAIL PAGE ── */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}
@media (max-width: 900px) { .detail-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) { .detail-grid { grid-template-columns: 1fr; } }

.detail-card {
  background: var(--white);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow);
}
.detail-card-title {
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: .875rem;
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--rule);
}
.detail-list { display: grid; grid-template-columns: auto 1fr; gap: .3rem .75rem; }
.detail-list dt { font-size: .77rem; color: var(--muted); font-weight: 500; white-space: nowrap; }
.detail-list dd { font-size: .845rem; color: var(--ink); }
.detail-list-wide { grid-template-columns: 160px 1fr; }

/* ── FORM ── */
.patient-form { max-width: 900px; }
.form-section {
  background: var(--white);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.form-section-title {
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 1rem;
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--rule);
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .875rem 1.25rem;
}
.form-group-full { grid-column: 1 / -1; }
.form-group label {
  display: block;
  font-size: .775rem;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: .3rem;
}
.form-control, select.form-control {
  width: 100%;
  padding: .5rem .75rem;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--white);
  font-size: .845rem;
  color: var(--ink);
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.form-control:focus {
  border-color: var(--sage);
  box-shadow: 0 0 0 3px rgba(74,124,89,.12);
}
.form-control.required { border-left: 3px solid var(--sage); }
textarea.form-control { resize: vertical; min-height: 60px; }
.form-errors {
  background: var(--rust-light);
  border: 1px solid #e8c4b4;
  border-radius: var(--radius);
  padding: .875rem 1rem;
  margin-bottom: 1rem;
  font-size: .83rem;
  color: var(--rust);
}
.form-actions {
  display: flex;
  gap: .75rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
}

/* ── MESSAGES ── */
.messages-container { margin-bottom: 1.25rem; }
.message {
  padding: .7rem 1rem;
  border-radius: var(--radius);
  font-size: .845rem;
  margin-bottom: .5rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.message-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.message-error   { background: var(--rust-light); color: var(--rust); border: 1px solid #e8c4b4; }
.message-info    { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

/* ── HTMX loading indicator ── */
.htmx-indicator { opacity: 0; transition: opacity 200ms ease-in; }
.htmx-request .htmx-indicator { opacity: 1; }
