/* ===================================================================
   Pigeon Loft — shared stylesheet for the public site and admin panel
   =================================================================== */

:root {
  --ink: #24291f;
  --ink-soft: #5b6152;
  --paper: #faf8f2;
  --paper-alt: #f1ede1;
  --line: #dcd6c4;
  --brand: #3e5c3a;
  --brand-dark: #2b4128;
  --brand-light: #eef2e6;
  --accent: #a9622f;
  --accent-light: #f6e8dc;
  --danger: #a6383a;
  --danger-light: #fbe9e9;
  --ok: #3e5c3a;
  --ok-light: #e7efe3;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(36, 41, 31, 0.06), 0 4px 16px rgba(36, 41, 31, 0.06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; font-weight: 700; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
.muted { color: var(--ink-soft); }
.prose { white-space: normal; }

/* ---------- buttons ---------- */
.btn {
  display: inline-block;
  padding: .55em 1.1em;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: .92rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { border-color: var(--brand); text-decoration: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-ghost { background: transparent; }
.btn-ghost-light { background: transparent; border-color: rgba(255,255,255,.6); color: #fff; }
.btn-ghost-light:hover { background: rgba(255,255,255,.15); }
.btn-danger { background: var(--danger-light); border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-small { padding: .35em .8em; font-size: .82rem; }
.btn-large { padding: .8em 1.6em; font-size: 1rem; }
.btn-row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }

/* ---------- flash / alerts ---------- */
.flash { padding: .8em 1em; border-radius: var(--radius); margin: 0 0 1.2em; font-size: .92rem; }
.flash-success { background: var(--ok-light); color: var(--ok); border: 1px solid #cfe0c8; }
.flash-error { background: var(--danger-light); color: var(--danger); border: 1px solid #edc9ca; }

/* ---------- badges ---------- */
.badge { display: inline-block; padding: .2em .7em; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--paper-alt); color: var(--ink-soft); }
.badge-for_sale { background: var(--accent-light); color: var(--accent); }
.badge-active, .badge-breeder { background: var(--ok-light); color: var(--ok); }
.badge-sold, .badge-completed { background: var(--paper-alt); color: var(--ink-soft); }
.badge-retired, .badge-deceased { background: #eee; color: #888; }
.badge-order-new { background: var(--accent-light); color: var(--accent); }
.badge-order-contacted, .badge-order-confirmed { background: var(--brand-light); color: var(--brand-dark); }
.badge-order-paid, .badge-order-shipped, .badge-order-completed { background: var(--ok-light); color: var(--ok); }
.badge-order-cancelled { background: var(--danger-light); color: var(--danger); }

/* ===================================================================
   Public site
   =================================================================== */
.site-header { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.site-header-inner {
  max-width: 1080px; margin: 0 auto; padding: .9rem 1.25rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
}
.site-brand { display: flex; align-items: center; gap: .5rem; font-weight: 800; font-size: 1.15rem; color: var(--ink); }
.site-logo { height: 36px; width: 36px; object-fit: cover; border-radius: 8px; }
.site-logo-emoji { font-size: 1.5rem; }
.site-nav { display: flex; gap: 1.4rem; font-weight: 600; font-size: .95rem; }
.site-nav a { color: var(--ink-soft); }
.site-nav a:hover { color: var(--brand-dark); }

.site-container { max-width: 1080px; margin: 0 auto; padding: 0 1.25rem; }
.section { padding: 2.4rem 0; }
.section-narrow { max-width: 560px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 1rem; }

.hero {
  background: linear-gradient(180deg, rgba(20,24,20,.55), rgba(20,24,20,.75)), var(--brand-dark);
  background-size: cover; background-position: center;
  color: #fff; text-align: center; padding: 5rem 1.25rem;
}
.hero-inner { max-width: 640px; margin: 0 auto; }
.hero h1 { font-size: 2.4rem; margin-bottom: .3em; }
.hero-tagline { font-size: 1.1rem; opacity: .92; margin-bottom: 1.6em; }
.hero-actions { display: flex; gap: .8rem; justify-content: center; flex-wrap: wrap; }

.pigeon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1.1rem; }
.pigeon-card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; color: var(--ink); box-shadow: var(--shadow); transition: transform .12s ease;
}
.pigeon-card:hover { transform: translateY(-2px); text-decoration: none; }
.pigeon-card-photo { aspect-ratio: 4/3; background: var(--paper-alt); position: relative; overflow: hidden; }
.pigeon-card-photo img { width: 100%; height: 100%; object-fit: cover; }
.thumb-placeholder-lg { display: flex; align-items: center; justify-content: center; height: 100%; font-size: 2.6rem; }
.pigeon-card-flag { position: absolute; top: .5rem; right: .5rem; background: rgba(36,41,31,.75); color: #fff; font-size: .72rem; font-weight: 700; padding: .2em .6em; border-radius: 999px; }
.pigeon-card-body { padding: .8rem .9rem; }
.pigeon-card-title { font-weight: 700; }
.pigeon-card-name { color: var(--ink-soft); font-size: .9rem; }
.pigeon-card-meta { font-size: .82rem; color: var(--ink-soft); margin-top: .3em; }
.pigeon-card-price { margin-top: .4em; font-weight: 700; color: var(--accent); }

.bloodline-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
.bloodline-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; color: var(--ink); box-shadow: var(--shadow); }
.bloodline-card-name { font-weight: 700; margin-bottom: .3em; }

.pigeon-detail { display: grid; grid-template-columns: minmax(0,340px) 1fr; gap: 2rem; margin-bottom: 2rem; }
.pigeon-detail-photo { border-radius: var(--radius); overflow: hidden; background: var(--paper-alt); aspect-ratio: 4/3; }
.pigeon-detail-photo img { width: 100%; height: 100%; object-fit: cover; }
.pigeon-detail-name { color: var(--ink-soft); font-size: 1.05rem; margin-top: -.6em; }
@media (max-width: 720px) { .pigeon-detail { grid-template-columns: 1fr; } }

.contact-direct { margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid var(--line); }
.hp-field { position: absolute; left: -9999px; }

.site-footer { border-top: 1px solid var(--line); margin-top: 2rem; background: var(--paper-alt); }
.site-footer-inner { max-width: 1080px; margin: 0 auto; padding: 1.6rem 1.25rem; display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.site-footer-contact { text-align: right; font-size: .9rem; }
.site-footer-bottom { text-align: center; font-size: .78rem; color: var(--ink-soft); padding: .8rem 1.25rem 1.4rem; }

/* ===================================================================
   Shared: tables, forms, pedigree chart
   =================================================================== */
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { text-align: left; padding: .55em .6em; border-bottom: 1px solid var(--line); }
.table th { color: var(--ink-soft); font-weight: 600; font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; }
.thumb-cell { width: 44px; }
.thumb { width: 40px; height: 40px; border-radius: 6px; object-fit: cover; }
.thumb-placeholder { display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; background: var(--paper-alt); border-radius: 6px; }
.row-actions a { margin-right: .8em; font-weight: 600; font-size: .85rem; }

.kv-table { width: 100%; border-collapse: collapse; margin-bottom: 1rem; }
.kv-table th { text-align: left; width: 40%; padding: .4em 0; color: var(--ink-soft); font-weight: 600; vertical-align: top; }
.kv-table td { padding: .4em 0; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem 1.4rem; max-width: 760px; }
.form-grid label { display: flex; flex-direction: column; gap: .35em; font-weight: 600; font-size: .88rem; color: var(--ink-soft); }
.form-grid .full { grid-column: 1 / -1; }
.form-grid input[type=text], .form-grid input[type=email], .form-grid input[type=number],
.form-grid input[type=date], .form-grid input[type=password], .form-grid input[type=file],
.form-grid select, .form-grid textarea {
  font: inherit; padding: .55em .7em; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink);
}
.form-grid textarea { resize: vertical; }
.checkbox-row { flex-direction: row !important; align-items: center; gap: .5em !important; }
.form-actions { display: flex; gap: .8rem; align-items: center; margin-top: .4rem; }
.inline-form-spaced { margin-top: .8rem; display: flex; gap: .6rem; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

.filter-bar { display: flex; gap: .6rem; align-items: center; margin: 1rem 0; flex-wrap: wrap; }
.filter-bar input, .filter-bar select { font: inherit; padding: .5em .7em; border: 1px solid var(--line); border-radius: 8px; }

.current-photo img { max-width: 160px; border-radius: 8px; margin-bottom: .4em; }
.detail-photo { width: 100%; max-width: 320px; border-radius: var(--radius); margin-bottom: 1rem; }
.plain-list { list-style: none; padding: 0; margin: 0; }
.plain-list li { padding: .25em 0; }
.tag-list { list-style: none; padding: 0; margin: 0 0 1rem; display: flex; flex-wrap: wrap; gap: .5em; }
.tag-list li { background: var(--paper-alt); padding: .3em .5em .3em .8em; border-radius: 999px; font-size: .85rem; display: flex; align-items: center; gap: .3em; }
.tag-delete-form { display: inline-flex; margin: 0; }
.tag-delete-btn { border: none; background: none; color: var(--ink-soft); cursor: pointer; font-size: 1.1em; line-height: 1; padding: 0 .2em; border-radius: 4px; }
.tag-delete-btn:hover { color: #fff; background: var(--danger); }

.pedigree-scroll { overflow-x: auto; }
.pedigree-table { border-collapse: collapse; width: 100%; min-width: 640px; }
.pedigree-table th { font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-soft); padding: .4em; text-align: center; }
.pedigree-cell {
  border: 1px solid var(--line); padding: .5em .7em; font-size: .85rem; font-weight: 600;
  background: #fff; text-align: center; vertical-align: middle;
}
.pedigree-cell a { color: var(--ink); }
.pedigree-name { font-weight: 400; color: var(--ink-soft); font-size: .8em; }
.pedigree-empty { color: var(--line); font-weight: 400; background: var(--paper-alt); }
.pedigree-cock { border-left: 3px solid #5b7bb0; }
.pedigree-hen { border-left: 3px solid #c47a9a; }

/* ===================================================================
   Admin panel
   =================================================================== */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--paper-alt); }
.auth-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 2rem; width: 100%; max-width: 380px; }
.auth-card h1 { text-align: center; font-size: 1.3rem; }
.auth-card form { display: flex; flex-direction: column; gap: .9rem; margin-top: 1rem; }
.auth-card label { display: flex; flex-direction: column; gap: .35em; font-weight: 600; font-size: .88rem; color: var(--ink-soft); }
.auth-card input { font: inherit; padding: .6em .7em; border: 1px solid var(--line); border-radius: 8px; }
.auth-card .btn { margin-top: .3rem; }

.admin-body { background: var(--paper-alt); }
.admin-shell { display: flex; min-height: 100vh; }
.admin-sidebar { width: 220px; background: var(--brand-dark); color: #fff; display: flex; flex-direction: column; padding: 1.2rem 0; flex-shrink: 0; }
.admin-brand { font-weight: 800; padding: 0 1.2rem 1.2rem; border-bottom: 1px solid rgba(255,255,255,.15); margin-bottom: 1rem; }
.admin-nav { display: flex; flex-direction: column; gap: .1rem; flex: 1; }
.admin-nav a { color: rgba(255,255,255,.8); padding: .6em 1.2rem; font-weight: 600; font-size: .92rem; }
.admin-nav a:hover, .admin-nav a.active { background: rgba(255,255,255,.1); color: #fff; text-decoration: none; }
.admin-nav-footer { border-top: 1px solid rgba(255,255,255,.15); padding-top: .8rem; display: flex; flex-direction: column; }
.admin-nav-footer a { color: rgba(255,255,255,.7); padding: .5em 1.2rem; font-size: .85rem; }
.admin-nav-footer a:hover { color: #fff; }
.admin-main { flex: 1; padding: 2rem; max-width: 1100px; }

.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1.4rem; margin-bottom: 1.4rem; box-shadow: var(--shadow); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1.4rem; align-items: start; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } .admin-shell { flex-direction: column; } .admin-sidebar { width: 100%; flex-direction: row; flex-wrap: wrap; align-items: center; } .admin-nav { flex-direction: row; flex-wrap: wrap; } .admin-nav-footer { flex-direction: row; } }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1rem; margin: 1.2rem 0 1.6rem; }
.stat-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.2rem; box-shadow: var(--shadow); }
.stat-card-alert { border-color: var(--accent); background: var(--accent-light); }
.stat-num { font-size: 1.8rem; font-weight: 800; }
.stat-label { color: var(--ink-soft); font-size: .82rem; }
