﻿/* DHULMAAL Livestock Management - mobile-first styles */
:root {
    --green: #0b5d32;
    --green-dark: #084423;
    --green-soft: #e6f4ec;
    --orange: #f7821b;
    --orange-soft: #fff1e3;
    --bg: #f4f9f5;
    --card: #ffffff;
    --text: #14281c;
    --muted: #6b7c72;
    --red: #d63a3a;
    --radius: 18px;
    --shadow: 0 4px 16px rgba(11, 93, 50, .08);
    --nav-h: 68px;
}

* { -webkit-tap-highlight-color: transparent; }
body { font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; color: var(--text); background: #dfe9e2; }
a { color: var(--green); text-decoration: none; }
h1, h2 { font-weight: 700; }

/* ---------- App shell (centered on desktop) ---------- */
.app-body { min-height: 100vh; }
.app-shell {
    max-width: 480px; margin: 0 auto; min-height: 100vh; background: var(--bg);
    position: relative; box-shadow: 0 0 40px rgba(0,0,0,.08);
}
.app-bar {
    position: sticky; top: 0; z-index: 20; height: 60px; padding: 0 16px;
    display: flex; align-items: center; justify-content: space-between;
    background: #fff; box-shadow: 0 1px 8px rgba(0,0,0,.06);
    padding-top: env(safe-area-inset-top);
}
.app-bar-logo img { height: 46px; width: auto; display: block; }
.app-bar-title { font-weight: 700; font-size: 1.05rem; }
.app-bar-back, .app-bar-spacer { width: 40px; height: 40px; }
.app-bar-back { display: flex; align-items: center; justify-content: center; font-size: 1.4rem; color: var(--text); border-radius: 50%; }
.app-bar-back:active { background: var(--green-soft); }
.avatar {
    width: 38px; height: 38px; border-radius: 50%; background: var(--green); color: #fff;
    display: inline-flex; align-items: center; justify-content: center; font-size: .85rem; font-weight: 700;
}
.avatar-lg { width: 46px; height: 46px; flex: none; }

.app-main { padding: 16px 16px calc(var(--nav-h) + 28px); }
.app-alert { border-radius: 14px; border: 0; font-size: .92rem; }
.auth-alert { max-width: 420px; margin: 12px auto; position: relative; z-index: 5; }

.page-head h1 { font-size: 1.6rem; margin: 0; }
.page-head p { color: var(--muted); margin-bottom: 14px; }

/* ---------- Bottom navigation ---------- */
.bottom-nav {
    position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
    width: 100%; max-width: 480px; height: var(--nav-h); z-index: 30;
    background: #fff; display: flex; align-items: center; justify-content: space-around;
    border-radius: 22px 22px 0 0; box-shadow: 0 -4px 20px rgba(0,0,0,.08);
    padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav a { flex: 1; text-align: center; color: var(--muted); font-size: .7rem; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.bottom-nav a i { font-size: 1.35rem; }
.bottom-nav a.active { color: var(--green); font-weight: 600; }
.bottom-nav .nav-add {
    flex: none; width: 58px; height: 58px; margin-top: -30px; border-radius: 50%;
    background: var(--orange); color: #fff; justify-content: center;
    box-shadow: 0 6px 16px rgba(247,130,27,.45); border: 4px solid #fff;
}
.bottom-nav .nav-add i { font-size: 1.6rem; }

/* ---------- Buttons & forms ---------- */
.btn { border-radius: 14px; padding: 13px 18px; font-weight: 600; }
.btn-brand { background: var(--green); color: #fff; border: 0; }
.btn-brand:hover, .btn-brand:active, .btn-brand:focus { background: var(--green-dark); color: #fff; }
.btn-accent { background: var(--orange); color: #fff; border: 0; }
.btn-accent:hover, .btn-accent:active { background: #e07210; color: #fff; }
.btn-outline-brand { border: 2px solid var(--green); color: var(--green); background: #fff; }
.btn-outline-brand:hover, .btn-outline-brand:active { background: var(--green-soft); color: var(--green); }
.btn-sm { padding: 6px 12px; border-radius: 10px; }

.form-control, .form-select { border-radius: 12px; padding: 12px 14px; border: 1.5px solid #d7e3db; background: #fff; }
.form-control:focus, .form-select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(11,93,50,.12); }
.form-label-sm { font-size: .82rem; font-weight: 600; margin-bottom: 4px; display: block; }
.form-check-input:checked { background-color: var(--green); border-color: var(--green); }

.input-icon { position: relative; }
.input-icon > i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.input-icon .form-control { padding-left: 42px; }
.toggle-pass { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--muted); padding: 8px; }

.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice input { position: absolute; opacity: 0; }
.choice span {
    display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 14px 8px;
    background: #fff; border: 2px solid #d7e3db; border-radius: 14px; font-weight: 600;
}
.choice span i { font-size: 1.5rem; color: var(--green); }
.choice span small { color: var(--muted); font-weight: 400; }
.choice-sm span { flex-direction: row; justify-content: center; gap: 8px; padding: 12px; }
.choice-sm span i { font-size: 1.1rem; }
.choice input:checked + span { border-color: var(--orange); background: var(--orange-soft); }
.choice input:focus-visible + span { box-shadow: 0 0 0 3px rgba(247,130,27,.3); }

.photo-preview { width: 100%; max-height: 220px; object-fit: cover; border-radius: 14px; margin-bottom: 8px; }

/* ---------- Cards ---------- */
.app-card { background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card-title-sm { font-size: .95rem; margin-bottom: 10px; }
.section-head { display: flex; justify-content: space-between; align-items: center; margin: 22px 0 10px; }
.section-head h2 { font-size: 1.1rem; margin: 0; }
.empty { text-align: center; color: var(--muted); padding: 26px 10px; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat-grid-3 { grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.stat-card {
    border-radius: 16px; padding: 14px; display: flex; align-items: center; gap: 10px;
    box-shadow: var(--shadow); min-height: 74px;
}
.stat-card > i { font-size: 1.7rem; }
.stat-card small { display: block; font-size: .72rem; color: #4a5b52; }
.stat-card strong { font-size: 1.6rem; line-height: 1.1; }
.stat-grid-3 .stat-card { padding: 10px; flex-direction: column; align-items: flex-start; gap: 0; min-height: 0; }
.stat-grid-3 .stat-card strong { font-size: 1.35rem; }
.tone-green  { background: #dff3e7; } .tone-green  > i { color: var(--green); }
.tone-orange { background: var(--orange-soft); } .tone-orange > i { color: var(--orange); }
.tone-pink   { background: #fde8ef; } .tone-pink   > i { color: #e8618c; }
.tone-blue   { background: #e5f0fd; } .tone-blue   > i { color: #2f7de1; }
.tone-purple { background: #eee9fb; } .tone-purple > i { color: #7a56d6; }
.tone-red    { background: #fde8e8; } .tone-red    > i { color: var(--red); }

/* donut + bars (pure CSS charts) */
.chart-card { text-align: center; height: 100%; }
.donut {
    --p: 50; width: 96px; height: 96px; border-radius: 50%; margin: 4px auto 10px;
    background: conic-gradient(var(--c1) calc(var(--p) * 1%), var(--c2) 0);
    display: flex; align-items: center; justify-content: center; position: relative;
}
.donut::before { content: ""; position: absolute; inset: 14px; background: #fff; border-radius: 50%; }
.donut span { position: relative; font-weight: 700; font-size: 1.2rem; }
.legend { list-style: none; padding: 0; margin: 0; font-size: .78rem; color: var(--muted); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; font-size: .85rem; }
.bar-label { width: 62px; }
.bar-num { width: 36px; text-align: right; font-weight: 600; }
.bar-track { flex: 1; height: 10px; background: #edf2ee; border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; }
.bar-fill.alive { background: var(--green); }
.bar-fill.removed { background: var(--orange); }
.bar-fill.dead { background: var(--red); }
.bar-fill.pink { background: #e8618c; }

/* ---------- Animal list / chips / badges ---------- */
.search-box { position: relative; margin-bottom: 12px; }
.search-box i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-box .form-control { padding-left: 42px; border-radius: 14px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 8px 16px; border-radius: 20px; background: #fff; border: 1.5px solid #d7e3db; color: var(--text); font-size: .85rem; font-weight: 600; }
.chip.active { background: var(--green); border-color: var(--green); color: #fff; }
.status-tabs { display: flex; border-bottom: 2px solid #e3ece6; margin-bottom: 12px; }
.status-tabs a { flex: 1; text-align: center; padding: 10px 2px; font-size: .8rem; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -2px; }
.status-tabs a.active { color: var(--green); border-color: var(--green); font-weight: 700; }

.animal-row {
    display: flex; align-items: center; gap: 12px; background: #fff; padding: 10px 12px;
    border-radius: 16px; margin-bottom: 10px; box-shadow: var(--shadow); color: var(--text);
}
.animal-row:active { background: var(--green-soft); }
.animal-row.no-link:active { background: #fff; }
.animal-thumb { width: 54px; height: 54px; border-radius: 12px; object-fit: cover; background: var(--green-soft); flex: none; }
.animal-info { flex: 1; min-width: 0; }
.animal-info strong, .animal-info small { display: block; }
.animal-info small { color: var(--muted); }
.chev { color: #b3c0b8; }
.badge-status { font-size: .72rem; font-weight: 700; padding: 5px 11px; border-radius: 14px; flex: none; }
.badge-status.alive { background: #dff3e7; color: var(--green); }
.badge-status.removed { background: var(--orange-soft); color: #c4640a; }
.badge-status.dead { background: #fde8e8; color: var(--red); }

/* ---------- Animal details ---------- */
.detail-photo { width: 100%; height: 240px; object-fit: cover; border-radius: var(--radius); box-shadow: var(--shadow); background: var(--green-soft); }
.detail-head { display: flex; justify-content: space-between; align-items: center; margin: 14px 0; }
.detail-head h1 { font-size: 1.5rem; margin: 0; }
.detail-head small { color: var(--muted); }
.tabs { display: flex; gap: 6px; padding: 0; margin-bottom: 14px; list-style: none; background: #e9f1ec; border-radius: 14px; padding: 4px; }
.tabs li { flex: 1; }
.tabs button { width: 100%; border: 0; background: transparent; padding: 8px 2px; border-radius: 10px; font-size: .82rem; font-weight: 600; color: var(--muted); }
.tabs button.active { background: var(--green); color: #fff; }
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.info-grid > div { background: #fff; border-radius: 14px; padding: 12px; box-shadow: var(--shadow); position: relative; }
.info-grid i { color: var(--green); font-size: 1.1rem; position: absolute; right: 12px; top: 12px; }
.info-grid small { display: block; color: var(--muted); font-size: .72rem; }
.info-grid strong { font-size: .98rem; word-break: break-word; }
.photo-full { width: 100%; border-radius: var(--radius); }
.action-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 20px; }

.timeline { position: relative; padding-left: 4px; }
.timeline-item { display: flex; gap: 12px; padding-bottom: 16px; position: relative; }
.timeline-item::before { content: ""; position: absolute; left: 16px; top: 34px; bottom: 0; width: 2px; background: #d7e3db; }
.timeline-item:last-child::before { display: none; }
.timeline .dot { width: 34px; height: 34px; border-radius: 50%; background: var(--green-soft); color: var(--green); display: flex; align-items: center; justify-content: center; flex: none; }
.timeline .dot.dead { background: #fde8e8; color: var(--red); }
.timeline .dot.removed { background: var(--orange-soft); color: var(--orange); }
.timeline-note { font-size: .85rem; margin-top: 2px; }

/* ---------- Status change ---------- */
.status-option { display: block; position: relative; }
.status-option input { position: absolute; opacity: 0; }
.status-option span {
    display: flex; align-items: center; gap: 12px; padding: 14px; background: #fff;
    border: 2px solid #d7e3db; border-radius: 14px; margin-bottom: 10px; flex-wrap: wrap; width: 100%;
}
.status-option span i { font-size: 1.5rem; }
.status-option span b { display: block; }
.status-option span small { display: block; width: calc(100% - 48px); margin-left: 36px; margin-top: -8px; color: var(--muted); }
.status-option input:checked + span { border-color: var(--green); background: var(--green-soft); }
.text-orange { color: var(--orange); }

/* ---------- Settings ---------- */
.app-accordion .accordion-item { border: 0; border-radius: var(--radius) !important; margin-bottom: 10px; overflow: hidden; box-shadow: var(--shadow); }
.app-accordion .accordion-button { font-weight: 600; gap: 10px; }
.app-accordion .accordion-button:not(.collapsed) { background: var(--green-soft); color: var(--green); box-shadow: none; }
.menu-list { margin-top: 14px; }
.menu-list > a {
    display: flex; align-items: center; gap: 12px; background: #fff; padding: 14px 16px;
    border-radius: 16px; margin-bottom: 10px; color: var(--text); box-shadow: var(--shadow); font-weight: 600;
}
.menu-list > a .chev { margin-left: auto; }
.menu-list .logout { color: var(--red); }
.about-box { text-align: center; background: #fff; border-radius: 16px; padding: 16px; margin-bottom: 10px; box-shadow: var(--shadow); }
.about-box img { height: 54px; margin-bottom: 8px; }

/* ---------- Splash & login ---------- */
.auth-body { background: linear-gradient(#fff, #eef7f1); min-height: 100vh; }
.splash { max-width: 480px; margin: 0 auto; min-height: 100vh; position: relative; background: linear-gradient(#fff 0%, #eef7f1 60%, #cfe8d6 100%); overflow: hidden; display: flex; flex-direction: column; align-items: center; }
.splash-top { text-align: center; padding-top: 14vh; z-index: 2; }
.splash-logo { width: 220px; max-width: 70%; animation: pop .8s ease both; }
.splash-sub { margin-top: 14px; font-size: 1.1rem; color: var(--green); font-weight: 600; letter-spacing: .5px; }
.splash-hills { position: absolute; bottom: 0; left: 0; right: 0; }
.splash-hills img { width: 100%; display: block; }
.splash-bottom { position: absolute; bottom: 28px; left: 0; right: 0; text-align: center; z-index: 3; color: #fff; }
.splash-tagline { font-style: italic; font-weight: 600; margin-bottom: 12px; }
.splash-bar { width: 90px; height: 5px; border-radius: 3px; background: rgba(255,255,255,.35); margin: 0 auto; overflow: hidden; }
.splash-bar span { display: block; height: 100%; background: var(--orange); animation: load 1.8s linear forwards; }
@keyframes load { from { width: 0; } to { width: 100%; } }
@keyframes pop { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: none; } }

.login-wrap { max-width: 480px; margin: 0 auto; min-height: 100vh; padding: 8vh 20px 0; position: relative; overflow: hidden; }
.login-card { text-align: center; position: relative; z-index: 2; }
.login-card form { text-align: left; }
.login-logo { width: 190px; max-width: 65%; margin-bottom: 18px; }
.login-title { font-size: 1.6rem; margin-bottom: 4px; }
.login-hint { color: var(--muted); font-size: .85rem; margin: 18px 0 0; }
.login-hills { position: absolute; bottom: 0; left: 0; width: 100%; opacity: .3; z-index: 0; pointer-events: none; }

/* ---------- Desktop: keep it app-like, centered ---------- */
@media (min-width: 600px) {
    .app-shell { margin-top: 0; }
    .bottom-nav { border-radius: 22px 22px 0 0; }
}
@media (prefers-reduced-motion: reduce) {
    .splash-logo, .splash-bar span { animation: none; }
}

