/* Smart Poultry — mobile-first stylesheet, no framework */

:root {
    --primary: #2e7d32;
    --primary-dark: #1b5e20;
    --accent: #f9a825;
    --danger: #c62828;
    --warning: #ef6c00;
    --info: #0277bd;
    --bg: #f4f6f4;
    --card-bg: #ffffff;
    --text: #21322a;
    --muted: #6b7d73;
    --border: #dfe6e0;
    --radius: 10px;
    --sidebar-w: 230px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}
a { color: var(--primary-dark); text-decoration: none; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; letter-spacing: -.01em; }

/* ---------- App Shell ---------- */
.app-shell { min-height: 100vh; }

.topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
    position: sticky;
    top: 0;
    z-index: 20;
}
.topbar .page-title {
    flex: 1; min-width: 0; font-size: 1.1rem; margin: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.hamburger {
    display: inline-flex; flex-shrink: 0;
    background: none; border: none; font-size: 1.4rem; cursor: pointer; padding: 4px 8px;
}
.topbar-right { display: flex; align-items: center; gap: 14px; flex-shrink: 0; }
.user-chip { font-size: .85rem; color: var(--muted); white-space: nowrap; }
@media (max-width: 560px) {
    .user-chip { display: none; }
}
.bell { position: relative; font-size: 1.2rem; }
.badge {
    position: absolute; top: -6px; right: -10px;
    background: var(--danger); color: #fff; border-radius: 50%;
    font-size: .65rem; padding: 1px 5px; min-width: 16px; text-align: center;
}

.content { padding: 16px; max-width: 1200px; margin: 0 auto; }

/* ---------- Sidebar (off-canvas on mobile) ---------- */
.sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    background: var(--primary-dark);
    color: #eaf4ea;
    display: flex; flex-direction: column;
    padding: 16px 0;
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 40;
    overflow-y: auto;
}
.sidebar.open { transform: translateX(0); }
.sidebar { background: linear-gradient(180deg, var(--primary-dark) 0%, #123c17 100%); }
.sidebar .brand {
    display: flex; align-items: center; gap: 10px;
    font-weight: 800; font-size: 1.2rem; letter-spacing: -.02em;
    padding: 4px 18px 18px; margin-bottom: 6px; border-bottom: 1px solid rgba(255,255,255,.1);
}
.sidebar .brand-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border-radius: 10px; font-size: 1.3rem; flex-shrink: 0;
    background: linear-gradient(135deg, var(--accent), #ffca28);
    box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.sidebar .brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.sidebar .brand-tag { font-size: .65rem; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: #9ec4a1; }
.sidebar a {
    color: #d7ead9; padding: 10px 18px; font-size: .92rem; display: block;
    border-left: 3px solid transparent; transition: background .15s ease, border-color .15s ease;
}
.sidebar a.active { background: rgba(255,255,255,.12); color: #fff; border-left-color: var(--accent); font-weight: 600; }
.sidebar a:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar .nav-group {
    margin-top: 14px; padding: 0 18px 4px; font-size: .72rem; text-transform: uppercase;
    letter-spacing: .06em; color: #9ec4a1;
}
.sidebar a.logout { margin-top: auto; color: #ffcdd2; }
.sidebar-overlay {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 30;
}
.sidebar-overlay.open { display: block; }

@media (min-width: 900px) {
    .hamburger { display: none; }
    .sidebar { transform: translateX(0); }
    .sidebar-overlay { display: none !important; }
    .topbar, .content { margin-left: var(--sidebar-w); }
}

/* ---------- Cards / Stats ---------- */
.stats-grid {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 20px;
}
@media (min-width: 700px) { .stats-grid { grid-template-columns: repeat(4, 1fr); } }
.stat-card {
    background: var(--card-bg); border-radius: 12px; padding: 12px 14px;
    border: 1px solid var(--border); border-top: 3px solid var(--stat-color, var(--primary));
    display: flex; align-items: center; gap: 10px;
    box-shadow: 0 1px 2px rgba(20,40,25,.04);
    transition: transform .15s ease, box-shadow .15s ease;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(20,40,25,.09); }
.stat-card .icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border-radius: 9px; font-size: 1.05rem; flex-shrink: 0;
    background: color-mix(in srgb, var(--stat-color, var(--primary)) 14%, white);
}
.stat-card .value { font-size: 1.3rem; font-weight: 700; color: var(--primary-dark); line-height: 1.2; }
.stat-card .label { font-size: .72rem; color: var(--muted); }

.card {
    background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 18px; margin-bottom: 18px;
    box-shadow: 0 1px 2px rgba(20,40,25,.04);
    transition: box-shadow .15s ease;
}
.card:hover { box-shadow: 0 4px 14px rgba(20,40,25,.07); }
.card-grid { display: grid; gap: 14px; }
@media (min-width: 900px) { .card-grid.cols-2 { grid-template-columns: 1fr 1fr; } }

.card-compact { padding: 14px 16px; margin-bottom: 14px; }
.card-compact h2 {
    font-size: .92rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
    color: var(--muted); margin-bottom: 10px;
}

.empty-state { text-align: center; padding: 32px 16px; color: var(--muted); }
.empty-state .emoji { font-size: 2.2rem; display: block; margin-bottom: 8px; opacity: .7; }

/* ---------- Forms ---------- */
form.stack { display: flex; flex-direction: column; gap: 12px; max-width: 480px; }
.form-row { display: flex; flex-direction: column; gap: 4px; }
.form-row.inline { flex-direction: row; align-items: center; gap: 8px; flex-wrap: wrap; }
label { font-size: .85rem; font-weight: 600; color: var(--text); }
input, select, textarea {
    font-size: 1rem; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
    background: #fff; color: var(--text); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); border-color: var(--primary); }
button, .btn {
    font-size: .95rem; padding: 10px 18px; border-radius: 8px; border: none;
    background: var(--primary); color: #fff; cursor: pointer; display: inline-block;
    transition: background .15s ease, transform .1s ease;
}
button:hover, .btn:hover { background: var(--primary-dark); }
button:active, .btn:active { transform: scale(.97); }
.btn-secondary { background: #90a4ae; }
.btn-danger { background: var(--danger); }
.btn-sm { padding: 6px 12px; font-size: .82rem; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; background: var(--card-bg); }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { background: #eef4ee; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
tr:hover td { background: #fafcfa; }

/* ---------- Alerts / Notifications ---------- */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 14px; font-size: .9rem; }
.alert-success { background: #e8f5e9; color: #1b5e20; border: 1px solid #a5d6a7; }
.alert-error { background: #fdecea; color: #b71c1c; border: 1px solid #f5b3ae; }
.alert-warning { background: #fff8e1; color: #8a5700; border: 1px solid #ffe082; }
.alert-info { background: #e1f5fe; color: #01579b; border: 1px solid #81d4fa; }

.notif-list { display: flex; flex-direction: column; gap: 8px; }
.notif-item { padding: 10px 14px; border-radius: 8px; border-left: 4px solid var(--info); background: #f7fbff; font-size: .88rem; }
.notif-item.anomaly { border-color: var(--danger); background: #fff5f4; }
.notif-item.feed_low { border-color: var(--warning); background: #fffaf0; }
.notif-item.vaccination { border-color: var(--primary); background: #f4fbf4; }
.notif-item.billing { border-color: #6a1b9a; background: #faf5fc; }

/* ---------- Badges / Tags ---------- */
.tag { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.tag-active { background: #e8f5e9; color: #1b5e20; }
.tag-sold, .tag-closed { background: #eceff1; color: #455a64; }
.tag-pending { background: #fff8e1; color: #8a5700; }
.tag-done { background: #e8f5e9; color: #1b5e20; }
.tag-missed { background: #fdecea; color: #b71c1c; }

/* ---------- Auth pages ---------- */
.auth-wrap {
    min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
    background: linear-gradient(160deg, var(--primary-dark) 0%, var(--primary) 55%, #4c9a50 100%);
}
.auth-card {
    background: var(--card-bg); border-radius: 16px; padding: 36px 32px; width: 100%; max-width: 380px;
    border: 1px solid var(--border);
    box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.auth-logo {
    display: flex; align-items: center; justify-content: center; margin: 0 auto 16px;
    width: 64px; height: 64px; border-radius: 16px; font-size: 2rem;
    background: linear-gradient(135deg, var(--accent), #ffca28);
    box-shadow: 0 6px 16px rgba(249,168,37,.4);
}
.auth-card h1 { text-align: center; color: var(--primary-dark); font-size: 1.4rem; margin-bottom: 2px; }
.auth-card .sub { text-align: center; color: var(--muted); font-size: .85rem; margin-bottom: 20px; }

/* ---------- Chatbot widget ---------- */
.chatbot-toggle {
    position: fixed; bottom: 20px; right: 20px; width: 56px; height: 56px; border-radius: 50%;
    font-size: 1.5rem; box-shadow: 0 4px 14px rgba(0,0,0,.25); z-index: 50;
}
.chatbot-panel {
    position: fixed; bottom: 90px; right: 20px; width: min(340px, calc(100vw - 32px)); height: min(460px, 60vh);
    background: var(--card-bg); border-radius: var(--radius); box-shadow: 0 8px 30px rgba(0,0,0,.25);
    display: flex; flex-direction: column; z-index: 50; overflow: hidden;
}
.chatbot-panel.hidden { display: none; }
.chatbot-header {
    background: var(--primary-dark); color: #fff; padding: 12px 14px; display: flex; justify-content: space-between; align-items: center;
    font-weight: 600;
}
.chatbot-header button { background: none; border: none; color: #fff; font-size: 1rem; cursor: pointer; padding: 0; }
.chatbot-messages { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.msg { padding: 8px 12px; border-radius: 10px; font-size: .88rem; max-width: 85%; }
.msg.bot { background: #eef4ee; align-self: flex-start; }
.msg.user { background: var(--primary); color: #fff; align-self: flex-end; }
.chatbot-form { display: flex; border-top: 1px solid var(--border); }
.chatbot-form input { border: none; border-radius: 0; flex: 1; }
.chatbot-form button { border-radius: 0; }

/* ---------- Misc ---------- */
.muted { color: var(--muted); font-size: .85rem; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
