/* =========================================================
   BOVIlink — Design tokens
   Παλέτα: "βοσκότοπος / εργαλείο διαχείρισης" — χακί-πράσινο
   της υπαίθρου με ζεστό μπεζ φόντο, πιο βιομηχανική/utility
   αίσθηση (διαφορετική από το πιο "editorial" πράσινο-μπρονζέ
   της αιγοπροβατοτροφικής εφαρμογής).
   ========================================================= */
:root {
    --ink:        #1B2118;   /* βαθύ πράσινο-ανθρακί - κείμενο */
    --charcoal:   #202B1B;   /* sidebar - βαθύ λαδί/πεύκο */
    --charcoal-2: #29351F;
    --paper:      #F5F2E7;   /* φόντο κύριου περιεχομένου - ζεστό μπεζ */
    --card:       #FFFFFF;
    --line:       #E2DFCE;
    --rust:       #4C6B3A;   /* κύριο accent - χακί/βοσκότοπος πράσινο */
    --rust-dark:  #395228;
    --olive:      #8A7A3E;   /* δευτερεύον accent - χρυσοκίτρινο χακί */
    --olive-soft: #F1ECD8;
    --gold:       #AD8A42;   /* στοιχεία έμφασης / tag */
    --muted:      #7C8271;
    --danger:     #A83232;
    --radius:     10px;
    --shadow:     0 2px 10px rgba(27,33,24,0.07);
    --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: center;
    gap: 8px;
    margin-bottom: 6px;
}
.brand-icon { width: 26px; height: 26px; object-fit: contain; flex-shrink: 0; }
.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;
}
.sidebar-footer a { color: #A79F91; text-decoration: none; font-weight: 600; }
.sidebar-footer a:hover { color: #fff; text-decoration: underline; }

/* ---------- 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);
}
.filter-select {
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #FBFAF6;
    font-size: 13px;
    font-family: var(--font-body);
    color: var(--ink);
    cursor: pointer;
}

/* ---------- Bulk selection ---------- */
.hidden { display: none; }
.bulk-actions-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: var(--olive-soft);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 14px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--ink);
}
.checkbox-cell { width: 36px; }
.row-checkbox, #selectAllAnimals { width: 16px; height: 16px; cursor: pointer; accent-color: var(--rust); }

/* ---------- 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;
}
.sortable-th { cursor: pointer; user-select: none; white-space: nowrap; }
.sortable-th:hover { color: var(--ink); }
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); }
.badge-unknown { background: #EDEAE0; color: var(--muted); }
.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);
}

/* ---------- Searchable select (π.χ. επιλογή μοσχαριού στο ημερολόγιο σφαγής) ---------- */
.searchable-select { position: relative; }
.searchable-select input[type="text"] {
    width: 100%;
}
.searchable-select input[type="text"]:disabled {
    background: #F0ECE2;
    color: var(--muted);
    cursor: not-allowed;
}
.searchable-select-list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0; right: 0;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    max-height: 220px;
    overflow-y: auto;
    z-index: 50;
}
.searchable-select-option {
    padding: 9px 12px;
    font-size: 13.5px;
    cursor: pointer;
}
.searchable-select-option:hover,
.searchable-select-option.active {
    background: var(--olive-soft);
}
.searchable-select-empty {
    padding: 12px;
    font-size: 13px;
    color: var(--muted);
    text-align: center;
}

/* ---------- 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); }

/* ---------- Growth summary + chart (Ζυγίσεις tab) ---------- */
.weight-summary-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 18px;
}
.stat-card.sm { padding: 14px 16px; }
.stat-card.sm .num { font-size: 22px; }
.chart-wrap {
    background: #FBFAF6;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px 16px 10px;
    margin-bottom: 22px;
}

/* ---------- 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; }

/* ---------- Login page ---------- */
.login-body {
    background: var(--charcoal);
    background-image:
        radial-gradient(circle at 15% 20%, rgba(76,107,58,0.35), transparent 45%),
        radial-gradient(circle at 85% 80%, rgba(173,138,66,0.18), transparent 50%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.login-wrap { width: 100%; max-width: 380px; }
.login-brand { text-align: center; margin-bottom: 28px; }
.login-logo { max-width: 150px; max-height: 165px; margin-bottom: 6px; }
.fallback-mark { flex-direction: column; align-items: center; justify-content: center; margin-bottom: 12px; gap: 8px; }
.fallback-mark .mark {
    width: 16px; height: 16px; border-radius: 3px;
    background: #fff; display: inline-block; transform: rotate(45deg);
}
.login-brand h1 {
    font-family: var(--font-display);
    font-size: 24px;
    margin: 0;
    color: #fff;
}
.login-brand p {
    font-size: 12.5px;
    color: #C7CCC0;
    margin: 4px 0 0;
    text-transform: uppercase;
    letter-spacing: .4px;
}
.login-card {
    background: var(--card);
    border-radius: 16px;
    padding: 34px 34px 32px;
    box-shadow: 0 24px 60px rgba(0,0,0,0.35);
}
.login-heading {
    font-family: var(--font-display);
    font-size: 19px;
    margin: 0 0 20px;
    color: var(--ink);
    text-align: center;
}
.login-form { display: flex; flex-direction: column; gap: 16px; }
.login-credit {
    text-align: center;
    margin-top: 22px;
    font-size: 12px;
    color: #9AA192;
}
.login-credit a { color: #C7CCC0; font-weight: 600; text-decoration: none; }
.login-credit a:hover { text-decoration: underline; }
.login-submit { width: 100%; justify-content: center; padding: 11px; margin-top: 4px; }
.login-error {
    background: #FBEEEA;
    color: var(--danger);
    border: 1px solid #E6C9C0;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 16px;
    text-align: center;
}

/* ---------- Sidebar logo (logged-in app) ---------- */
.sidebar-logo-img { max-width: 130px; max-height: 40px; display: block; margin-bottom: 4px; }

/* =========================================================
   Mobile topbar + burger menu (κρυφά σε desktop)
   ========================================================= */
.mobile-topbar { display: none; }
.sidebar-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 250;
}
.sidebar-close-btn { display: none; }

@media (max-width: 880px) {
    .app-shell { grid-template-columns: 1fr; }

    /* Fixed mobile header */
    .mobile-topbar {
        display: flex;
        align-items: center;
        gap: 10px;
        position: fixed;
        top: 0; left: 0; right: 0;
        height: 56px;
        background: var(--charcoal);
        padding: 0 16px;
        z-index: 260;
        box-shadow: 0 2px 10px rgba(0,0,0,0.15);
    }
    .mobile-topbar-icon { width: 22px; height: 22px; object-fit: contain; }
    .mobile-topbar-title {
        font-family: var(--font-display);
        font-weight: 700;
        font-size: 17px;
        color: #fff;
        letter-spacing: .3px;
    }
    .burger-btn {
        background: none; border: none; padding: 8px; margin-left: -8px;
        display: flex; flex-direction: column; justify-content: center; gap: 4px;
        cursor: pointer;
    }
    .burger-btn span {
        display: block; width: 20px; height: 2px;
        background: #EFEAE0; border-radius: 2px;
        transition: transform .2s, opacity .2s;
    }

    /* Off-canvas sidebar drawer */
    .sidebar {
        position: fixed;
        top: 0; left: 0;
        height: 100vh;
        width: 260px;
        max-width: 82vw;
        transform: translateX(-100%);
        transition: transform .25s ease;
        z-index: 270;
        flex-direction: column;
        align-items: stretch;
        padding: 24px 18px;
        box-shadow: 4px 0 24px rgba(0,0,0,0.25);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar .nav { flex-direction: column; margin-top: 6px; overflow-x: visible; }
    .sidebar-footer { display: block; }
    .brand-sub { display: block; }
    .brand { margin-bottom: 6px; margin-right: 0; }
    .sidebar-close-btn {
        display: block;
        position: absolute; top: 16px; right: 16px;
        background: none; border: none; color: #D8D1C4;
        font-size: 26px; line-height: 1; cursor: pointer;
    }
    .sidebar-close-btn:hover { color: #fff; }

    /* Backdrop shown only while drawer is open */
    .sidebar-backdrop.show { display: block; }

    .main { padding: 22px 18px 50px; margin-top: 56px; }
    .stats-row { grid-template-columns: repeat(2, 1fr); }
    .form-grid, .form-grid.cols-3 { grid-template-columns: 1fr; }
    .weight-summary-row { grid-template-columns: 1fr; }
}
