/* PawTrack CRM — Stylesheet */

*  { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: Georgia, serif; background: #FDF8F3; color: #2C1810; }
input, select, textarea, button { font-family: Georgia, serif; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: #D4B896; border-radius: 3px; }

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed; top: 0; left: 0; height: 100vh; width: 240px;
  background: #2C1810; z-index: 200;
  transform: translateX(-100%); transition: transform .25s ease;
  overflow-y: auto; display: flex; flex-direction: column;
}
.sidebar.open { transform: translateX(0); }

.sidebar-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 150;
}

.nav-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 20px; color: #A0856C; cursor: pointer;
  font-size: 14px; border: none; background: none;
  width: 100%; text-align: left; transition: background .15s;
}
.nav-btn:hover  { background: #3D2010; color: #F5E6D3; }
.nav-btn.active { background: #C8832A; color: #fff; }

/* ── Modals (small, centred) ──────────────────────────────────────────────── */
.modal-bg {
  position: fixed; inset: 0; background: rgba(44,24,16,.55);
  display: flex; align-items: center; justify-content: center; z-index: 400;
}
.modal {
  background: #fff; border-radius: 14px; padding: 28px;
  width: 500px; max-width: 95vw; max-height: 90vh;
  overflow-y: auto; position: relative;
}

/* ── Dog profile popup ────────────────────────────────────────────────────── */
/*
 * Full-screen overlay with a transparent edge so the admin can see
 * which part of the app they came from. The opaque centre panel holds
 * all content. z-index 500 sits above modals (400) and the sidebar (200).
 */
.dog-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(44, 24, 16, 0.72);
  display: flex; align-items: center; justify-content: center;
  padding: 32px;
  animation: dog-overlay-in .18s ease;
}
@keyframes dog-overlay-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.dog-panel {
  background: #fff; border-radius: 16px;
  width: 100%; max-width: 860px;
  max-height: calc(100vh - 64px);
  display: flex; flex-direction: column;
  box-shadow: 0 24px 64px rgba(44,24,16,.45);
  animation: dog-panel-in .2s ease;
  overflow: hidden;
}
@keyframes dog-panel-in {
  from { transform: translateY(18px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.dog-panel-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 28px 0; flex-shrink: 0;
}
.dog-panel-hdr h2 { font-size: 20px; color: #2C1810; }
.dog-panel-hdr .dog-role-badge {
  font-size: 11px; font-weight: bold; letter-spacing: .6px;
  padding: 3px 10px; border-radius: 20px; margin-left: 10px;
  background: #F5E6D3; color: #8B6355;
}
.dog-panel-close {
  background: none; border: none; cursor: pointer;
  font-size: 22px; color: #8B6355; line-height: 1;
  padding: 4px 8px; border-radius: 6px; transition: background .15s;
  flex-shrink: 0;
}
.dog-panel-close:hover { background: #FFF0F0; color: #C0392B; }

.dog-tabs {
  display: flex; gap: 2px; padding: 16px 28px 0;
  border-bottom: 2px solid #E8D5C0;
  flex-shrink: 0; flex-wrap: wrap;
}
.dog-tab {
  background: none; border: none; cursor: pointer;
  padding: 8px 16px; font-size: 13px; color: #8B6355;
  border-bottom: 3px solid transparent; margin-bottom: -2px;
  transition: color .15s; white-space: nowrap;
  font-family: Georgia, serif;
}
.dog-tab:hover  { color: #2C1810; }
.dog-tab.active { color: #C8832A; border-bottom-color: #C8832A; font-weight: bold; }

.dog-panel-body {
  flex: 1; overflow-y: auto; padding: 24px 28px 28px;
}

/* Sub-record list (DNA tests, vaccinations, weights, etc.) */
.sub-record-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.sub-record {
  background: #FDF8F3; border: 1px solid #E8D5C0;
  border-radius: 8px; padding: 12px 14px;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
}
.sub-record-fields { flex: 1; display: flex; flex-wrap: wrap; gap: 10px 20px; }
.sub-record-field  { display: flex; flex-direction: column; gap: 2px; }
.sub-record-field .lbl { font-size: 10px; }
.sub-record-field span { font-size: 13px; }
.sub-record-delete {
  background: none; border: none; cursor: pointer;
  color: #C0392B; font-size: 16px; padding: 2px 6px;
  border-radius: 4px; flex-shrink: 0; transition: background .15s;
}
.sub-record-delete:hover { background: #FFF0F0; }

.add-sub-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: 1px dashed #D4B896; border-radius: 7px;
  padding: 7px 14px; font-size: 12px; color: #8B6355;
  cursor: pointer; margin-top: 8px; transition: border-color .15s, color .15s;
  font-family: Georgia, serif;
}
.add-sub-btn:hover { border-color: #C8832A; color: #C8832A; }

/* Star rating (sires) */
.star-rating { display: flex; gap: 4px; align-items: center; }
.star {
  font-size: 22px; cursor: pointer; color: #D4B896;
  transition: color .1s; line-height: 1;
  background: none; border: none; padding: 0;
}
.star.filled { color: #C8832A; }
.star:hover  { color: #E0A040; }

/* Read-only field note (points to where data is editable) */
.field-note { font-size: 11px; color: #A0856C; font-style: italic; margin-top: 3px; }

/* Progesterone test phase tag */
.phase-tag {
  display: inline-block; font-size: 10px; font-weight: bold;
  padding: 2px 8px; border-radius: 10px; letter-spacing: .4px;
}
.phase-tag.heat     { background: #FFF0E0; color: #C8832A; }
.phase-tag.prewhelp { background: #F0F0FF; color: #6060C0; }

/* Nested heat block inside the Breeding tab */
.heat-block {
  border: 1px solid #E8D5C0; border-radius: 10px;
  padding: 14px 16px; margin-bottom: 14px; background: #FDFAF7;
}
.heat-block-hdr {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.heat-block-hdr h4 { font-size: 14px; color: #2C1810; }

/* ── Dog name button (inline, opens dog popup) ────────────────────────────── */
.dog-btn {
  display: inline-flex; align-items: center; gap: 4px;
  background: none; border: 1px solid #D4B896; border-radius: 5px;
  padding: 2px 8px; font-size: 12px; color: #8B6355; cursor: pointer;
  vertical-align: middle; margin-left: 6px;
  transition: border-color .15s, color .15s, background .15s;
  font-family: Georgia, serif;
}
.dog-btn:hover { border-color: #C8832A; color: #C8832A; background: #FDF8F3; }

/* ── Admin panel popup ────────────────────────────────────────────────────── */
.admin-panel {
  background: #fff; border-radius: 16px;
  width: 100%; max-width: 560px;
  max-height: calc(100vh - 64px);
  display: flex; flex-direction: column;
  box-shadow: 0 24px 64px rgba(44,24,16,.45);
  animation: dog-panel-in .2s ease;
  overflow: hidden;
}

.login-table {
  width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 10px;
}
.login-table th {
  text-align: left; padding: 6px 10px;
  font-size: 10px; color: #8B6355; font-weight: bold; letter-spacing: .5px;
  border-bottom: 1px solid #E8D5C0;
}
.login-table td {
  padding: 8px 10px; border-bottom: 1px solid #F0E8DE; color: #2C1810;
  word-break: break-all;
}
.login-table tr:last-child td { border-bottom: none; }

/* ── Setup screen (first-time only) ──────────────────────────────────────── */
.setup-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: #FDF8F3;
}
.setup-card {
  background: #fff; border: 1px solid #E8D5C0; border-radius: 16px;
  padding: 40px; width: 420px; max-width: 95vw;
}
.setup-card h1 { font-size: 22px; margin-bottom: 6px; }
.setup-card .setup-sub { font-size: 13px; color: #8B6355; margin-bottom: 28px; }
.setup-key-note {
  background: #FFF8F0; border: 1px solid #E8D5C0; border-radius: 8px;
  padding: 12px 14px; font-size: 12px; color: #8B6355; margin-bottom: 20px;
  line-height: 1.6;
}

/* ── Cards & Rows ─────────────────────────────────────────────────────────── */
.card {
  background: #fff; border: 1px solid #E8D5C0;
  border-radius: 10px; padding: 16px 20px;
}
.row {
  background: #fff; border: 1px solid #E8D5C0; border-radius: 10px;
  padding: 14px 18px; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px; transition: box-shadow .15s;
}
.row:hover { box-shadow: 0 4px 14px rgba(200,131,42,.18); }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn   { border: none; border-radius: 7px; padding: 8px 18px; cursor: pointer; font-size: 13px; font-family: Georgia, serif; }
.btn-p { background: #C8832A; color: #fff; }
.btn-p:hover { background: #B07020; }
.btn-s { background: #F5E6D3; color: #2C1810; border: 1px solid #D4B896; }
.btn-d { background: #FFF0F0; color: #C0392B; border: 1px solid #FFCDD2; }

/* ── Badges & dots ────────────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 20px; padding: 3px 12px; font-size: 12px; font-weight: bold; }
.dot   { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex-shrink: 0; }

/* ── Stats ────────────────────────────────────────────────────────────────── */
.stat-card { background: #fff; border: 1px solid #E8D5C0; border-radius: 12px; padding: 20px; text-align: center; }
.stat-val  { font-size: 32px; font-weight: bold; color: #C8832A; margin-bottom: 4px; }
.stat-lbl  { font-size: 12px; color: #8B6355; }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.fld { margin-bottom: 14px; }
.fld label { display: block; font-size: 11px; color: #8B6355; margin-bottom: 4px; font-weight: bold; letter-spacing: .5px; }
.fld input, .fld select, .fld textarea {
  width: 100%; padding: 9px 12px; border-radius: 7px;
  border: 1px solid #D4B896; font-size: 14px;
  font-family: Georgia, serif; background: #fff;
}
.fld textarea { resize: vertical; }
.fld input:focus, .fld select:focus, .fld textarea:focus {
  outline: none; border-color: #C8832A;
  box-shadow: 0 0 0 2px rgba(200,131,42,.15);
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* ── Layout helpers ───────────────────────────────────────────────────────── */
.sec-hdr { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.sec-hdr h2 { font-size: 20px; }

.back-btn { background: none; border: none; color: #C8832A; cursor: pointer; font-size: 14px; margin-bottom: 16px; padding: 0; font-family: Georgia, serif; }
.back-btn:hover { text-decoration: underline; }

.info-box { background: #FDF8F3; border-radius: 8px; padding: 12px 14px; }
.lbl { font-size: 11px; color: #8B6355; margin-bottom: 3px; font-weight: bold; letter-spacing: .5px; }
.pill { border-radius: 20px; padding: 5px 14px; cursor: pointer; font-size: 12px; border: 1px solid #D4B896; font-family: Georgia, serif; }

/* Section divider within popup tabs */
.tab-section { margin-bottom: 28px; }
.tab-section-title {
  font-size: 11px; font-weight: bold; color: #8B6355; letter-spacing: .6px;
  text-transform: uppercase; margin-bottom: 12px;
  padding-bottom: 6px; border-bottom: 1px solid #E8D5C0;
}

/* ── Loading & error states ───────────────────────────────────────────────── */
.loading-screen {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; min-height: 60vh;
  color: #8B6355; font-size: 14px; gap: 14px;
}
.spinner {
  width: 36px; height: 36px;
  border: 3px solid #E8D5C0; border-top-color: #C8832A;
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-banner {
  background: #FFF0F0; color: #C0392B; border-bottom: 1px solid #FFCDD2;
  padding: 10px 24px; font-size: 13px;
  display: flex; justify-content: space-between; align-items: center;
}
.readonly-banner {
  background: #FFF8F0; border-bottom: 1px solid #E8D5C0;
  padding: 7px 24px; text-align: center; font-size: 13px; color: #8B6355;
}
