/* ── Design System ─────────────────────────────────────────────────── */
:root {
    --primary: #2E7D32;
    --primary-light: #4CAF50;
    --surface: #F9FBE7;
    --on-primary: #FFFFFF;
    --text: #212121;
    --text-muted: #555555;
    --text-hint: #888888;
    --border: #C8E6C9;
    --danger: #D32F2F;
    --warning-bg: #FFF3F3;
    --warning-border: #FFCDD2;
    --radius: 10px;
    --shadow: 0 1px 4px rgba(0,0,0,0.08);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--surface);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main.container {
    flex: 1;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Navbar ───────────────────────────────────────────────────────── */
.navbar {
    background: var(--primary);
    color: var(--on-primary);
    padding: 0 16px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.navbar-inner {
    max-width: 540px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
    height: 56px;
    flex-wrap: wrap;
}
.navbar-brand {
    color: var(--on-primary);
    font-weight: 700;
    font-size: 18px;
    white-space: nowrap;
}
.navbar-brand:hover { text-decoration: none; }
.navbar-farm {
    color: rgba(255,255,255,0.85);
    font-size: 14px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.navbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}
.navbar-user { color: var(--on-primary); font-size: 18px; }
.navbar-user:hover { text-decoration: none; }
.navbar-user-name {
    color: rgba(255,255,255,0.9);
    font-size: 13px;
    display: none;
}
@media (min-width: 480px) {
    .navbar-user-name { display: inline; }
}
.navbar-logout {
    color: rgba(255,255,255,0.8);
    font-size: 13px;
}

/* ── Container ────────────────────────────────────────────────────── */
.container {
    max-width: 540px;
    margin: 0 auto;
    padding: 16px;
}

/* ── Buttons ──────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.1s;
    text-decoration: none;
    white-space: nowrap;
}
.btn:hover { opacity: 0.9; text-decoration: none; }
.btn:active { transform: scale(0.97); }

.btn-primary {
    background: var(--primary);
    color: var(--on-primary);
}
.btn-primary-light {
    background: var(--primary-light);
    color: var(--on-primary);
    padding: 6px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
}
.btn-primary-light:hover { opacity: 0.9; text-decoration: none; }
.btn-danger {
    background: var(--danger);
    color: var(--on-primary);
}
.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 1.5px solid var(--border);
}
.btn-outline:hover { border-color: var(--primary); }
.btn-block { width: 100%; }
.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background 0.15s;
}
.btn-icon:hover { background: rgba(0,0,0,0.06); }
.btn-icon-danger:hover { background: var(--warning-bg); color: var(--danger); }

/* ── Cards ────────────────────────────────────────────────────────── */
.card {
    background: #FFFFFF;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    margin-bottom: 16px;
}

/* ── Chips ────────────────────────────────────────────────────────── */
.chip {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    color: #fff;
    white-space: nowrap;
}
.chip-role {
    background: var(--primary-light);
}

/* ── Species filter chips ─────────────────────────────────────────── */
.species-filters {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.species-chip {
    padding: 5px 12px;
    border-radius: 16px;
    border: 1.5px solid var(--border);
    background: #fff;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.15s;
    white-space: nowrap;
}
.species-chip:hover { border-color: var(--primary-light); }
.species-chip.active {
    background: var(--primary);
    color: var(--on-primary);
    border-color: var(--primary);
}

/* ── Search bar ───────────────────────────────────────────────────── */
.search-bar {
    margin-bottom: 12px;
}
.search-bar-row .search-bar { margin-bottom: 0; }
.search-bar input {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    background: #fff;
    color: var(--text);
    outline: none;
    transition: border-color 0.15s;
}
.search-bar input:focus { border-color: var(--primary-light); }
.search-bar input::placeholder { color: var(--text-hint); }

/* ── Animal tiles ─────────────────────────────────────────────────── */
.animal-tile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 8px;
    background: #fff;
    transition: box-shadow 0.15s, border-color 0.15s;
    text-decoration: none;
    color: var(--text);
}
.animal-tile:hover {
    box-shadow: 0 2px 8px rgba(46,125,50,0.12);
    border-color: var(--primary-light);
    text-decoration: none;
}
.animal-tile-icon { font-size: 32px; flex-shrink: 0; }
.animal-tile-info { flex: 1; min-width: 0; }
.animal-tile-name { font-weight: 600; font-size: 15px; }
.animal-tile-id { color: var(--text-muted); font-size: 13px; }
.animal-tile-meta { color: var(--text-hint); font-size: 12px; }
.animal-tile-event {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}

/* ── Bulk select ──────────────────────────────────────────────────── */
.search-bar-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }

.animal-tile.selectable { cursor: pointer; }
.animal-tile.selected {
    border-color: var(--primary);
    background: #E8F5E9;
    box-shadow: 0 0 0 2px var(--primary-light);
}
.tile-check {
    font-size: 20px;
    flex-shrink: 0;
    margin-right: 2px;
    color: var(--primary);
}

.bulk-bar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--primary);
    color: #fff;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 200;
    justify-content: center;
    flex-wrap: wrap;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.15);
}
.bulk-bar span { font-weight: 600; margin-right: 4px; }
.bulk-bar .btn {
    background: rgba(255,255,255,0.18);
    color: #fff;
    border: 1.5px solid rgba(255,255,255,0.5);
}
.bulk-bar .btn:hover { background: rgba(255,255,255,0.30); opacity: 1; }
.bulk-bar .btn-primary {
    background: #fff;
    color: var(--primary);
    border-color: #fff;
}

.bulk-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 300;
}
.bulk-modal-box {
    background: #fff;
    border-radius: var(--radius);
    padding: 24px;
    width: min(480px, 95vw);
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}
.bulk-modal-box h3 { margin: 0 0 4px; }

/* ── Reminders ────────────────────────────────────────────────────── */
.reminders-panel { border-left: 3px solid var(--primary-light); }
.reminder-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px;
    border-radius: 6px;
    margin-bottom: 4px;
    gap: 8px;
    transition: background 0.15s;
}
.reminder-item:hover { background: rgba(0,0,0,0.02); }
.reminder-item.overdue {
    background: var(--warning-bg);
    border-left: 3px solid var(--danger);
}
.reminder-item.done { opacity: 0.5; }
.reminder-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}
.reminder-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.reminder-text {
    font-size: 14px;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.reminder-text.text-done { text-decoration: line-through; }
.reminder-date { font-size: 12px; color: var(--text-muted); white-space: nowrap; }

/* ── Animal profile ───────────────────────────────────────────────── */
.animal-profile { border-top: 3px solid var(--primary); }
.profile-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}
.profile-icon { font-size: 48px; }
.profile-name { font-size: 22px; font-weight: 700; }
.profile-id { color: var(--text-muted); font-size: 14px; }
.profile-details { margin-bottom: 16px; }
.profile-parents { margin-bottom: 16px; }
.profile-parents h4 { margin-bottom: 8px; color: var(--text-muted); font-size: 14px; }
.profile-actions {
    display: flex;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}
.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid rgba(0,0,0,0.04);
    font-size: 14px;
}
.detail-label { color: var(--text-muted); font-weight: 500; }

/* ── Timeline (events) ────────────────────────────────────────────── */
.timeline { padding: 4px 0; }
.timeline-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(0,0,0,0.04);
    font-size: 14px;
}
.timeline-date { color: var(--text-muted); font-size: 13px; white-space: nowrap; }
.timeline-notes { color: var(--text-hint); font-size: 13px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Section headers ──────────────────────────────────────────────── */
.section-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text);
}
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ── Forms ─────────────────────────────────────────────────────────── */
.form-group {
    margin-bottom: 14px;
    flex: 1;
}
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 4px;
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    color: var(--text);
    background: #fff;
    outline: none;
    transition: border-color 0.15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary-light);
}
.form-group textarea { resize: vertical; }

.form-row {
    display: flex;
    gap: 12px;
}
@media (max-width: 480px) {
    .form-row { flex-direction: column; gap: 0; }
}

.form-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.inline-form {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-wrap: wrap;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}
.inline-form input,
.inline-form select {
    padding: 8px 10px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    color: var(--text);
    outline: none;
    flex: 1;
    min-width: 100px;
}
.inline-form input:focus,
.inline-form select:focus { border-color: var(--primary-light); }

/* ── Alerts ───────────────────────────────────────────────────────── */
.alert {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 14px;
}
.alert-danger {
    background: var(--warning-bg);
    border: 1px solid var(--warning-border);
    color: var(--danger);
}
.alert-success {
    background: #E8F5E9;
    border: 1px solid var(--border);
    color: var(--primary);
}

/* ── Stats grid (farm settings) ───────────────────────────────────── */
.stats-grid {
    display: flex;
    gap: 12px;
    text-align: center;
}
.stat-item {
    flex: 1;
    padding: 12px;
    background: var(--surface);
    border-radius: 8px;
}
.stat-value { display: block; font-size: 24px; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 12px; color: var(--text-muted); }

/* ── Members (farm settings) ──────────────────────────────────────── */
.member-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid rgba(0,0,0,0.04);
}
.member-info { display: flex; flex-direction: column; gap: 2px; }
.member-role-form select {
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    color: var(--text);
}

/* ── Invite form ──────────────────────────────────────────────────── */
.invite-form {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* ── Empty state ──────────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 40px 16px;
    color: var(--text-muted);
}
.empty-icon { font-size: 48px; margin-bottom: 8px; }

/* ── Auth pages ───────────────────────────────────────────────────── */
.auth-body {
    background: var(--surface);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 16px;
}
.auth-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 32px 24px;
    width: 100%;
    max-width: 380px;
}
.auth-logo {
    text-align: center;
    font-size: 48px;
    margin-bottom: 8px;
}
.auth-title {
    text-align: center;
    font-size: 22px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 4px;
}
.auth-subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 20px;
}
.auth-footer {
    text-align: center;
    margin-top: 16px;
    font-size: 14px;
    color: var(--text-muted);
}

/* ── Text utilities ───────────────────────────────────────────────── */
.text-muted { color: var(--text-muted); font-size: 13px; }
.text-danger { color: var(--danger); }

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

/* ── Admin panel ──────────────────────────────────────────────────── */
.chip-admin {
    background: #1565C0;
    color: #fff;
    font-size: 12px;
    padding: 2px 10px;
    border-radius: 12px;
    font-weight: 600;
}

.btn-admin {
    background: #1565C0;
    color: #fff;
    padding: 6px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
}
.btn-admin:hover { opacity: 0.9; text-decoration: none; }

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

.admin-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
}

.admin-banner {
    background: #1565C0;
    color: #fff;
    text-align: center;
    padding: 8px 16px;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}
.admin-banner-exit {
    color: rgba(255,255,255,0.85);
    border: 1px solid rgba(255,255,255,0.4);
    padding: 2px 10px;
    border-radius: 6px;
    font-size: 13px;
    text-decoration: none;
}
.admin-banner-exit:hover { background: rgba(255,255,255,0.15); text-decoration: none; }

.admin-farm-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}
.admin-farm-row:last-child { border-bottom: none; }
.admin-farm-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}
.admin-farm-info strong { font-size: 15px; }

.admin-user-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}
.admin-user-row:last-of-type { border-bottom: none; }
.admin-user-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}
.admin-user-name {
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.admin-user-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    flex-shrink: 0;
}
.admin-reset-form {
    padding: 8px 0 12px 0;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

/* ── Desktop import ───────────────────────────────────────────────── */
.import-card { border-left: 3px solid var(--primary-light); }
.import-form { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.import-file-wrap { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 200px; }
.import-file-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 14px;
    background: #fff;
    transition: border-color 0.15s;
    white-space: nowrap;
}
.import-file-label:hover { border-color: var(--primary-light); }
.import-file-label input[type="file"] { display: none; }

/* ── Footer ───────────────────────────────────────────────────────── */
.site-footer {
    margin-top: 40px;
    border-top: 1px solid var(--border);
    background: #fff;
    padding: 24px 16px;
    box-sizing: border-box;
}
.footer-inner {
    max-width: 540px;
    margin-left: auto;
    margin-right: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-align: center;
}
.footer-made {
    color: var(--text-muted);
    font-size: 14px;
    margin: 0;
}
.footer-logo {
    width: 180px;
    max-width: 100%;
    height: auto;
    object-fit: contain;
    display: block;
}
.footer-paypal {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    width: 100%;
    text-align: left;
    font-size: 14px;
    color: var(--text);
    box-sizing: border-box;
}
.footer-paypal-icon { font-size: 28px; flex-shrink: 0; }
.footer-paypal a { color: var(--primary); font-weight: 500; }
.footer-disclaimer {
    font-size: 11px;
    color: var(--text-hint);
    line-height: 1.5;
    margin: 0;
    text-align: center;
}
