/* ============================================================
   GoatTrack — main.css
   Design tokens → Layout → Components → Responsive
   ============================================================ */

/* ── TOKENS ─────────────────────────────────────────────── */
:root {
  --earth:    #2c1a0e;
  --bark:     #4a2e1a;
  --clay:     #8b4513;
  --sand:     #c9a97a;
  --straw:    #e8d5a3;
  --cream:    #faf6ee;
  --moss:     #4a6741;
  --sky:      #6b9db8;
  --gold:     #d4a017;
  --ember:    #c0392b;
  --purple:   #9b59b6;
  --pink:     #d4789e;

  --card-bg:  rgba(255, 255, 255, 0.88);
  --border:   rgba(139, 69, 19, 0.15);
  --shadow:   0 4px 24px rgba(44, 26, 14, 0.10);
}

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

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--cream);
  color: var(--earth);
  min-height: 100vh;
  background-image:
    radial-gradient(ellipse at 0% 0%,   rgba(201,169,122,.25) 0%, transparent 50%),
    radial-gradient(ellipse at 100% 100%, rgba(74,103,65,.15)  0%, transparent 50%);
}

/* ── LOADING OVERLAY ─────────────────────────────────────── */
.loading-overlay {
  position: fixed; inset: 0;
  background: rgba(44,26,14,.45);
  z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(3px);
}
.spinner {
  width: 44px; height: 44px;
  border: 4px solid rgba(232,213,163,.3);
  border-top-color: var(--sand);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── TOAST NOTIFICATION ──────────────────────────────────── */
.toast {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  padding: .75rem 1.2rem;
  border-radius: 9px;
  font-size: .85rem; font-weight: 500;
  box-shadow: 0 6px 24px rgba(44,26,14,.2);
  z-index: 9000;
  animation: slideIn .25s ease;
  max-width: 320px;
}
.toast.success { background: var(--moss);    color: white; }
.toast.error   { background: var(--ember);   color: white; }
.toast.info    { background: var(--sky);     color: white; }
@keyframes slideIn { from { opacity:0; transform: translateY(12px); } to { opacity:1; transform: translateY(0); } }

/* ── LOGIN ───────────────────────────────────────────────── */
#loginScreen {
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
}
.login-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2.6rem 2.4rem;
  width: 100%; max-width: 400px;
  box-shadow: 0 20px 60px rgba(44,26,14,.15);
  text-align: center;
  backdrop-filter: blur(6px);
}
.login-logo  { font-size: 3rem;   margin-bottom: .4rem; }
.login-title { font-family: 'Playfair Display', serif; font-size: 1.8rem; color: var(--earth); margin-bottom: .3rem; }
.login-sub   { font-size: .85rem; color: var(--clay);  margin-bottom: 2rem; }

.lf { text-align: left; margin-bottom: 1rem; }
.lf label {
  display: block; font-size: .72rem; font-weight: 600; color: var(--clay);
  text-transform: uppercase; letter-spacing: .7px; margin-bottom: 5px;
}
.lf input {
  width: 100%; padding: 11px 14px;
  border: 1.5px solid var(--border); border-radius: 9px;
  font-family: 'DM Sans', sans-serif; font-size: .9rem; color: var(--earth);
  outline: none; background: white; transition: border-color .2s;
}
.lf input:focus { border-color: var(--clay); }

.btn-login {
  width: 100%; padding: 12px;
  background: var(--earth); color: var(--straw);
  border: none; border-radius: 9px;
  font-family: 'DM Sans', sans-serif; font-size: .95rem; font-weight: 600;
  cursor: pointer; transition: background .2s; margin-top: .5rem;
}
.btn-login:hover { background: var(--bark); }

.login-error {
  color: var(--ember); font-size: .82rem; margin-top: .8rem;
  display: none; text-align: left; line-height: 1.5;
}
.login-error pre { font-family: 'DM Mono', monospace; }

.demo-accounts { margin-top: 1.5rem; padding-top: 1.2rem; border-top: 1px solid var(--border); }
.demo-accounts p { font-size: .75rem; color: #999; margin-bottom: .6rem; text-transform: uppercase; letter-spacing: .5px; }
.demo-row { display: flex; gap: .5rem; justify-content: center; flex-wrap: wrap; }
.demo-btn {
  background: var(--straw); border: 1px solid var(--sand); border-radius: 6px;
  padding: 5px 12px; font-size: .78rem; color: var(--bark);
  cursor: pointer; font-family: 'DM Sans', sans-serif; transition: background .2s;
}
.demo-btn:hover { background: var(--sand); }

/* ── HEADER ──────────────────────────────────────────────── */
#appShell { display: none; }

header {
  background: var(--earth);
  padding: 0 1.5rem;
  display: flex; align-items: center; justify-content: space-between;
  height: 60px;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 20px rgba(44,26,14,.4);
}
.logo { display: flex; align-items: center; gap: 10px; }
.logo-icon {
  width: 34px; height: 34px;
  background: var(--sand); border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.logo-text { font-family: 'Playfair Display', serif; font-size: 1.3rem; color: var(--straw); }
.logo-text span { color: var(--sand); }

.header-nav { display: flex; gap: 4px; }
.nav-btn {
  background: transparent; border: none;
  color: rgba(232,213,163,.7);
  padding: 8px 14px; border-radius: 6px;
  font-family: 'DM Sans', sans-serif; font-size: .85rem;
  cursor: pointer; transition: all .2s;
  display: flex; align-items: center; gap: 6px;
}
.nav-btn:hover, .nav-btn.active {
  background: rgba(255,255,255,.12); color: var(--straw);
}

.header-right { display: flex; align-items: center; gap: .7rem; }
.user-pill {
  display: flex; align-items: center; gap: 7px;
  background: rgba(255,255,255,.1); border-radius: 20px; padding: 5px 12px 5px 8px;
}
.user-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
}
.av-admin { background: var(--gold); color: var(--earth); }
.av-user  { background: var(--sky);  color: white; }
.user-name  { font-size: .8rem; color: var(--straw); font-weight: 500; }
.role-badge { font-size: .64rem; padding: 1px 7px; border-radius: 10px; font-weight: 700; text-transform: uppercase; }
.rb-admin   { background: rgba(212,160,23,.25); color: var(--gold); }
.rb-user    { background: rgba(107,157,184,.25); color: #b8d4e3; }

.btn-add {
  background: var(--moss); color: white;
  border: none; padding: 7px 15px; border-radius: 6px;
  font-family: 'DM Sans', sans-serif; font-size: .82rem; font-weight: 600;
  cursor: pointer; transition: background .2s;
  display: flex; align-items: center; gap: 5px;
}
.btn-add:hover { background: #3a5431; }

.btn-logout {
  background: rgba(192,57,43,.2); border: 1px solid rgba(192,57,43,.3); color: #e88;
  padding: 6px 13px; border-radius: 6px;
  font-size: .78rem; cursor: pointer;
  font-family: 'DM Sans', sans-serif; transition: all .2s;
}
.btn-logout:hover { background: rgba(192,57,43,.4); }

/* ── MAIN LAYOUT ─────────────────────────────────────────── */
main { max-width: 1440px; margin: 0 auto; padding: 1.6rem 1.5rem 4rem; }

/* ── STATS CARDS ─────────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: .85rem; margin-bottom: 1.4rem;
}
.stat-card {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px;
  padding: 1.1rem 1.3rem; box-shadow: var(--shadow);
  position: relative; overflow: hidden; transition: transform .2s;
}
.stat-card:hover { transform: translateY(-2px); }
.stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0;
  height: 3px; border-radius: 12px 12px 0 0;
}
.sc-total::before  { background: var(--clay); }
.sc-male::before   { background: var(--sky); }
.sc-female::before { background: var(--pink); }
.sc-kids::before   { background: var(--gold); }
.sc-active::before { background: var(--moss); }
.sc-med::before    { background: var(--purple); }

.si-icon { font-size: 1.4rem; margin-bottom: .25rem; }
.sv { font-family: 'Playfair Display', serif; font-size: 1.8rem; font-weight: 700; line-height: 1; }
.sl { font-size: .7rem; color: var(--clay); font-weight: 500; text-transform: uppercase; letter-spacing: .7px; margin-top: 3px; }

/* ── FILTER PANEL ────────────────────────────────────────── */
.filter-panel {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: 13px;
  padding: 1.2rem 1.4rem; margin-bottom: 1.2rem; box-shadow: var(--shadow);
}
.filter-grid     { display: grid; grid-template-columns: 2fr repeat(5,1fr) auto; gap: .6rem; align-items: end; }
.med-filter-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr auto;   gap: .6rem; align-items: end; }

.fg label {
  display: block; font-size: .7rem; font-weight: 600; color: var(--clay);
  text-transform: uppercase; letter-spacing: .6px; margin-bottom: 4px;
}
.fg input, .fg select {
  width: 100%; padding: 8px 11px;
  border: 1.5px solid var(--border); border-radius: 7px;
  background: white; font-family: 'DM Sans', sans-serif; font-size: .85rem;
  color: var(--earth); outline: none; transition: border-color .2s; appearance: none;
}
.fg input:focus, .fg select:focus { border-color: var(--clay); }

.btn-reset {
  padding: 8px 14px; background: transparent;
  border: 1.5px solid var(--border); border-radius: 7px;
  font-family: 'DM Sans', sans-serif; font-size: .82rem;
  color: var(--clay); cursor: pointer; transition: all .2s; white-space: nowrap;
}
.btn-reset:hover { background: var(--straw); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: .65rem; }
.chip {
  background: var(--straw); border: 1px solid var(--sand); border-radius: 20px;
  padding: 3px 10px 3px 9px; font-size: .75rem; color: var(--bark);
  display: flex; align-items: center; gap: 5px; font-weight: 500;
}
.chip button { background: none; border: none; cursor: pointer; color: var(--clay); font-size: .85rem; }

/* ── TABLE WRAPPER ───────────────────────────────────────── */
.tbl-wrap {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: 13px; box-shadow: var(--shadow); overflow: hidden;
}
.tbl-toolbar {
  padding: .9rem 1.3rem;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.tbl-count { font-size: .83rem; color: var(--clay); }
.tbl-count strong { color: var(--earth); }

.view-toggle { display: flex; gap: 3px; }
.vbtn {
  padding: 5px 9px; border: 1.5px solid var(--border);
  background: white; border-radius: 5px; cursor: pointer; font-size: .88rem; transition: all .2s;
}
.vbtn.active { background: var(--earth); color: var(--straw); border-color: var(--earth); }

/* ── TABLE ───────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; }
thead tr { background: var(--earth); color: var(--straw); }
thead th {
  padding: 10px 13px; text-align: left;
  font-size: .69rem; font-weight: 600; text-transform: uppercase; letter-spacing: .8px;
  cursor: pointer; white-space: nowrap; user-select: none;
}
thead th:hover { background: var(--bark); }
thead th.sorted .si { opacity: 1; color: var(--sand); }
.si { margin-left: 3px; opacity: .4; font-size: .68rem; }

tbody tr { border-bottom: 1px solid rgba(139,69,19,.07); transition: background .15s; }
tbody tr:hover { background: rgba(201,169,122,.1); }
tbody td { padding: 10px 13px; font-size: .855rem; vertical-align: middle; }

/* ── TABLE CELL BADGES ───────────────────────────────────── */
.tag-b {
  font-family: 'DM Mono', monospace; font-size: .75rem;
  background: var(--straw); color: var(--bark);
  padding: 2px 7px; border-radius: 4px;
}
.nm { font-weight: 600; }
.breed-b {
  background: rgba(74,103,65,.12); color: var(--moss);
  padding: 2px 8px; border-radius: 11px; font-size: .75rem; font-weight: 500;
}
.gd { display: inline-flex; align-items: center; gap: 5px; font-weight: 500; }
.gd::before { content: ''; width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.gd.male   { color: var(--sky); } .gd.male::before   { background: var(--sky); }
.gd.female { color: #c06080;   } .gd.female::before { background: #c06080; }
.age-c { font-family: 'DM Mono', monospace; font-size: .8rem; }
.kid-b { background: rgba(212,160,23,.15); color: #8a6200; padding: 2px 7px; border-radius: 11px; font-size: .72rem; font-weight: 600; }
.sp { padding: 2px 9px; border-radius: 20px; font-size: .72rem; font-weight: 600; text-transform: capitalize; }
.sp.on-farm  { background: rgba(74,103,65,.15);   color: var(--moss); }
.sp.sold     { background: rgba(107,157,184,.15);  color: #3a7a9e; }
.sp.deceased { background: rgba(192,57,43,.12);    color: var(--ember); }
.csw { display: inline-flex; align-items: center; gap: 5px; }
.sw  { width: 11px; height: 11px; border-radius: 3px; border: 1px solid rgba(0,0,0,.1); }

.abtn {
  background: none; border: 1.5px solid var(--border); border-radius: 5px;
  padding: 3px 7px; cursor: pointer; font-size: .8rem;
  color: var(--clay); transition: all .15s; margin-right: 3px;
}
.abtn:hover { background: var(--straw); }

/* ── CARD GRID ───────────────────────────────────────────── */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(225px,1fr)); gap: .85rem; padding: 1rem; }
.gc {
  background: white; border: 1px solid var(--border); border-radius: 11px;
  padding: 1rem; transition: transform .2s, box-shadow .2s;
}
.gc:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(44,26,14,.14); }
.gc-hdr { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: .65rem; }
.gav { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.25rem; }
.gc-nm  { font-weight: 700; font-size: .93rem; color: var(--earth); }
.gc-tag { font-family: 'DM Mono', monospace; font-size: .69rem; color: var(--clay); }
.gc-row { display: flex; justify-content: space-between; font-size: .77rem; color: var(--bark); margin-bottom: 4px; }
.gc-row .k { color: #999; font-size: .69rem; text-transform: uppercase; letter-spacing: .4px; }

/* ── PAGINATION ──────────────────────────────────────────── */
.pag { display: flex; align-items: center; justify-content: center; gap: 5px; padding: 1rem; border-top: 1px solid var(--border); }
.pb {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--border); background: white; border-radius: 7px;
  cursor: pointer; font-size: .83rem; font-family: 'DM Sans', sans-serif; transition: all .15s;
}
.pb:hover  { background: var(--straw); }
.pb.active { background: var(--earth); color: var(--straw); border-color: var(--earth); }
.pb:disabled { opacity: .3; cursor: not-allowed; }

/* ── EMPTY STATE ─────────────────────────────────────────── */
.empty { text-align: center; padding: 3.5rem 2rem; color: var(--sand); }
.empty .ei { font-size: 2.6rem; margin-bottom: .7rem; }
.empty h3  { font-family: 'Playfair Display', serif; color: var(--clay); margin-bottom: .4rem; }

/* ── MEDICAL STATS ───────────────────────────────────────── */
.med-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: .85rem; margin-bottom: 1.4rem; }
.med-stat {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: 11px; padding: 1rem 1.2rem;
  box-shadow: var(--shadow); border-top: 3px solid var(--purple);
}

/* ── USERS TABLE ─────────────────────────────────────────── */
.users-wrap {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: 13px; box-shadow: var(--shadow); overflow: hidden;
}
.sec-hdr {
  padding: 1rem 1.4rem; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.sec-title { font-family: 'Playfair Display', serif; font-size: 1.05rem; color: var(--earth); }
.active-b { padding: 2px 8px; border-radius: 10px; font-size: .71rem; font-weight: 600; }
.active-b.yes { background: rgba(74,103,65,.15);  color: var(--moss); }
.active-b.no  { background: rgba(192,57,43,.10);  color: var(--ember); }
.rp { padding: 2px 9px; border-radius: 10px; font-size: .71rem; font-weight: 700; text-transform: uppercase; }
.rp.admin { background: rgba(212,160,23,.2); color: #8a6200; }
.rp.user  { background: rgba(107,157,184,.2); color: #2a6a8a; }

/* ── MODALS ──────────────────────────────────────────────── */
.mo {
  display: none; position: fixed; inset: 0;
  background: rgba(44,26,14,.5); z-index: 200;
  align-items: center; justify-content: center;
  backdrop-filter: blur(3px);
}
.mo.open { display: flex; }
.modal {
  background: var(--cream); border-radius: 15px;
  width: 90%; max-width: 560px; max-height: 90vh;
  overflow-y: auto; box-shadow: 0 20px 60px rgba(44,26,14,.3);
}
.modal.wide { max-width: 700px; }
.mh { padding: 1.3rem 1.5rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.mt { font-family: 'Playfair Display', serif; font-size: 1.15rem; color: var(--earth); }
.mc { background: none; border: none; cursor: pointer; font-size: 1.3rem; color: var(--clay); }
.mb { padding: 1.3rem 1.5rem; }
.mg { display: grid; grid-template-columns: 1fr 1fr; gap: .85rem; }

.fg2 label {
  display: block; font-size: .7rem; font-weight: 600; color: var(--clay);
  text-transform: uppercase; letter-spacing: .6px; margin-bottom: 4px;
}
.fg2 input, .fg2 select, .fg2 textarea {
  width: 100%; padding: 9px 11px;
  border: 1.5px solid var(--border); border-radius: 7px;
  font-family: 'DM Sans', sans-serif; font-size: .875rem; color: var(--earth);
  outline: none; background: white; transition: border-color .2s;
}
.fg2 input:focus, .fg2 select:focus, .fg2 textarea:focus { border-color: var(--clay); }
.fg2.full { grid-column: 1 / -1; }

.mf { padding: .9rem 1.5rem; border-top: 1px solid var(--border); display: flex; gap: .6rem; justify-content: flex-end; }
.bcn { padding: 8px 18px; background: transparent; border: 1.5px solid var(--border); border-radius: 7px; font-family: 'DM Sans', sans-serif; cursor: pointer; color: var(--clay); }
.bsv { padding: 8px 18px; background: var(--moss); border: none; border-radius: 7px; font-family: 'DM Sans', sans-serif; font-weight: 600; color: white; cursor: pointer; transition: background .2s; }
.bsv:hover { background: #3a5431; }

/* ── DETAIL VIEW (inside modal) ──────────────────────────── */
.ds { margin-bottom: 1.1rem; }
.ds h4 {
  font-size: .7rem; font-weight: 600; color: var(--clay);
  text-transform: uppercase; letter-spacing: .6px;
  margin-bottom: .5rem; padding-bottom: 3px; border-bottom: 1px solid var(--border);
}
.dg { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem .9rem; }
.dk { font-size: .7rem; color: #999; text-transform: uppercase; letter-spacing: .4px; }
.dv { font-size: .87rem; font-weight: 500; color: var(--earth); }

.mhi { background: white; border: 1px solid var(--border); border-radius: 8px; padding: .75rem 1rem; margin-bottom: .55rem; }
.mhi:last-child { margin-bottom: 0; }
.mhd    { font-family: 'DM Mono', monospace; font-size: .73rem; color: var(--clay); margin-bottom: 2px; }
.mhtype { font-weight: 600; font-size: .87rem; color: var(--earth); }
.mhcost { font-size: .77rem; color: var(--moss); font-weight: 600; margin-top: 2px; }

.ro-hint {
  background: rgba(107,157,184,.1); border: 1px solid rgba(107,157,184,.3);
  border-radius: 8px; padding: .6rem 1rem;
  font-size: .8rem; color: #2a6a8a; margin-bottom: 1rem;
  display: flex; align-items: center; gap: 8px;
}

/* ── RESPONSIVE ──────────────────────────────────────────── */
@media (max-width: 960px) {
  .filter-grid, .med-filter-grid { grid-template-columns: 1fr 1fr; }
  .filter-grid > *:last-child,
  .med-filter-grid > *:last-child { grid-column: 1 / -1; }
  .header-nav .nav-btn span { display: none; }
}

@media (max-width: 600px) {
  main { padding: 1rem; }
  .mg  { grid-template-columns: 1fr; }
  table th:nth-child(n+6),
  table td:nth-child(n+6) { display: none; }
}
