/* =========================================================
   BOVIlink — Design tokens
   Παλέτα εμπνευσμένη από ενώτια βοοειδών (ear-tags) και
   βοοτροφική μονάδα κρεοπαραγωγής: καστανό/σκουριά, ανθρακί,
   λαδί βαθύ πράσινο.
   ========================================================= */
:root {
    --ink:        #1C1B19;   /* βαθύ ανθρακί - κείμενο */
    --charcoal:   #23211E;   /* sidebar */
    --charcoal-2: #2E2B26;
    --paper:      #F6F3EC;   /* φόντο κύριου περιεχομένου */
    --card:       #FFFFFF;
    --line:       #E4DFD3;
    --rust:       #B5502E;   /* κύριο accent - ενώτιο */
    --rust-dark:  #8F3C21;
    --olive:      #4B5A3F;   /* δευτερεύον accent */
    --olive-soft: #EDF0E6;
    --gold:       #C89B3C;   /* στοιχεία έμφασης / tag */
    --muted:      #86807A;
    --danger:     #A83232;
    --radius:     10px;
    --shadow:     0 2px 10px rgba(28,27,25,0.06);
    --font-display: 'Space Grotesk', 'Segoe UI', sans-serif;
    --font-body:    'Inter', 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    font-family: var(--font-body);
    background: var(--paper);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* ---------- Layout shell ---------- */
.app-shell {
    display: grid;
    grid-template-columns: 250px 1fr;
    min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
    background: var(--charcoal);
    color: #EFEAE0;
    display: flex;
    flex-direction: column;
    padding: 24px 18px;
    position: sticky;
    top: 0;
    height: 100vh;
}
.brand {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 6px;
}
.brand .mark {
    width: 10px; height: 10px;
    border-radius: 2px;
    background: var(--rust);
    display: inline-block;
    transform: rotate(45deg);
}
.brand h1 {
    font-family: var(--font-display);
    font-size: 21px;
    letter-spacing: 0.3px;
    margin: 0;
    font-weight: 700;
}
.brand-sub {
    font-size: 11.5px;
    color: #A79F91;
    margin: 0 0 30px 0;
    letter-spacing: 0.4px;
    text-transform: uppercase;
}

.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; }
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    color: #D8D1C4;
    text-decoration: none;
    font-size: 14.5px;
    cursor: pointer;
    border: none;
    background: transparent;
    text-align: left;
    width: 100%;
    font-family: var(--font-body);
}
.nav-item:hover { background: var(--charcoal-2); color: #fff; }
.nav-item.active { background: var(--rust); color: #fff; }
.nav-item .dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: currentColor; opacity: .55; flex-shrink:0;
}

.sidebar-footer {
    margin-top: auto;
    font-size: 11px;
    color: #756E63;
    line-height: 1.5;
    padding-top: 20px;
    border-top: 1px solid #38352F;
}

/* ---------- Main content ---------- */
.main {
    padding: 30px 38px 60px;
    max-width: 1180px;
}
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 26px;
    flex-wrap: wrap;
    gap: 14px;
}
.topbar h2 {
    font-family: var(--font-display);
    font-size: 25px;
    margin: 0;
}
.topbar p { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; }

/* ---------- Buttons ---------- */
.btn {
    font-family: var(--font-body);
    font-size: 13.5px;
    font-weight: 600;
    padding: 10px 18px;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: background .15s, border-color .15s, transform .1s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--rust); color: #fff; }
.btn-primary:hover { background: var(--rust-dark); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: #EFEAE0; }
.btn-danger { background: transparent; color: var(--danger); border-color: #E6C9C0; }
.btn-danger:hover { background: #FBEEEA; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Stat cards ---------- */
.stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 28px;
}
.stat-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow);
}
.stat-card .num {
    font-family: var(--font-display);
    font-size: 30px;
    font-weight: 700;
    color: var(--rust);
    line-height: 1;
}
.stat-card .label {
    margin-top: 6px;
    font-size: 12.5px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .4px;
}

/* ---------- Card / panel ---------- */
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px;
    margin-bottom: 20px;
}
.card-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 16px;
    gap: 12px;
    flex-wrap: wrap;
}
.card-head h3 {
    font-family: var(--font-display);
    font-size: 16.5px;
    margin: 0;
}

/* ---------- Search ---------- */
.search-box {
    display: flex; align-items: center; gap: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px 12px;
    background: #FBFAF6;
    min-width: 240px;
}
.search-box input {
    border: none; outline: none; background: transparent;
    font-size: 13.5px; width: 100%; font-family: var(--font-body);
}

/* ---------- Table ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
    text-align: left;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .4px;
    color: var(--muted);
    padding: 0 12px 10px;
    border-bottom: 1px solid var(--line);
    font-weight: 600;
}
tbody td {
    padding: 12px;
    border-bottom: 1px solid #F0ECE2;
    vertical-align: middle;
}
tbody tr { cursor: pointer; }
tbody tr:hover td { background: #FBF8F1; }
tbody tr:last-child td { border-bottom: none; }
.code-pill {
    display: inline-flex; align-items: center;
    font-family: var(--font-display);
    font-weight: 700;
    background: var(--olive-soft);
    color: var(--olive);
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 12.5px;
    letter-spacing: .3px;
}
.badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: .3px;
}
.badge-active { background: #E9F1E4; color: #3E6B2C; }
.badge-sold   { background: #F2EBD8; color: var(--gold); }
.badge-dead   { background: #F3E2DE; color: var(--danger); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.empty-state {
    text-align: center;
    padding: 50px 20px;
    color: var(--muted);
}
.empty-state .big { font-size: 32px; margin-bottom: 10px; }

/* ---------- Tabs (animal profile) ---------- */
.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 20px;
}
.tab-btn {
    background: none; border: none;
    padding: 10px 16px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    font-family: var(--font-body);
}
.tab-btn:hover { color: var(--ink); }
.tab-btn.active { color: var(--rust); border-bottom-color: var(--rust); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- Forms ---------- */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px 16px;
}
.form-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--ink);
}
.field .hint { font-size: 11px; color: var(--muted); font-weight: 400; }
input, select, textarea {
    font-family: var(--font-body);
    font-size: 13.5px;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #FBFAF6;
    color: var(--ink);
    outline: none;
    width: 100%;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--rust);
    background: #fff;
}
textarea { resize: vertical; min-height: 64px; }
.form-actions {
    display: flex; justify-content: flex-end; gap: 10px;
    margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line);
}

/* ---------- Modal ---------- */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(28,27,25,0.5);
    display: flex; align-items: flex-start; justify-content: center;
    padding: 50px 20px;
    overflow-y: auto;
    z-index: 100;
}
.modal-overlay.hidden { display: none; }
.modal {
    background: #fff;
    border-radius: 14px;
    width: 100%;
    max-width: 640px;
    padding: 26px 28px 28px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}
.modal-head {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 18px;
}
.modal-head h3 { font-family: var(--font-display); margin: 0; font-size: 18px; }
.modal-close {
    background: none; border: none; font-size: 20px; cursor: pointer;
    color: var(--muted); line-height: 1;
}
.modal-close:hover { color: var(--ink); }

/* ---------- Sub-record list (vaccinations/weighings/rations) ---------- */
.sub-list { display: flex; flex-direction: column; gap: 8px; }
.sub-item {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #FBFAF6;
}
.sub-item .main-info { display: flex; flex-direction: column; gap: 2px; }
.sub-item .title { font-weight: 600; font-size: 13.5px; }
.sub-item .meta { font-size: 12px; color: var(--muted); }
.sub-item .value {
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--rust);
    font-size: 15px;
    white-space: nowrap;
}

/* ---------- Toast ---------- */
#toast {
    position: fixed; bottom: 24px; right: 24px;
    background: var(--ink); color: #fff;
    padding: 12px 18px; border-radius: 8px;
    font-size: 13.5px; box-shadow: var(--shadow);
    opacity: 0; transform: translateY(10px);
    transition: opacity .2s, transform .2s;
    pointer-events: none;
    z-index: 200;
    max-width: 320px;
}
#toast.show { opacity: 1; transform: translateY(0); }
#toast.error { background: var(--danger); }

/* ---------- Misc ---------- */
.muted { color: var(--muted); }
.mt-0 { margin-top: 0; }
.text-right { text-align: right; }

@media (max-width: 880px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { position: relative; height: auto; flex-direction: row; align-items: center; padding: 14px 18px; }
    .sidebar .nav { flex-direction: row; margin-top: 0; overflow-x: auto; }
    .sidebar-footer { display: none; }
    .brand-sub { display: none; }
    .brand { margin-bottom: 0; margin-right: 14px; }
    .main { padding: 22px 18px 50px; }
    .stats-row { grid-template-columns: repeat(2, 1fr); }
    .form-grid, .form-grid.cols-3 { grid-template-columns: 1fr; }
}
