/* ===================== BirdManager — Design System ===================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
    --green: #1f8a4c;
    --green-dark: #14532d;
    --green-600: #16794a;
    --green-soft: #e8f3ec;
    --green-soft2: #f0f7f2;
    --amber-soft: #fdf2d9;
    --purple-soft: #ede8fb;
    --blue-soft: #e3f0fb;
    --ink: #1a2e22;
    --muted: #6b7c73;
    --line: #e8ece9;
    --bg: #f3f6f4;
    --radius: 16px;
    --shadow: 0 1px 3px rgba(16,40,28,.06), 0 8px 24px rgba(16,40,28,.05);
}

* { box-sizing: border-box; }

html, body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--ink);
    margin: 0;
}

h1, h2, h3, h4, h5 { font-weight: 700; color: var(--ink); }
a { color: var(--green); text-decoration: none; }

/* ----- Blazor essentials ----- */
.valid.modified:not([type=checkbox]) { outline: 1px solid #26b050; }
.invalid { outline: 1px solid #e50000; }
.validation-message { color: #e50000; }

#blazor-error-ui {
    background: lightyellow; bottom: 0; box-shadow: 0 -1px 2px rgba(0,0,0,.2);
    display: none; left: 0; padding: .6rem 1.25rem .7rem 1.25rem; position: fixed; width: 100%; z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }

.loading-progress { position: relative; display: block; width: 8rem; height: 8rem; margin: 20vh auto 1rem auto; }
.loading-progress circle { fill: none; stroke: #e0e0e0; stroke-width: .6rem; transform-origin: 50% 50%; transform: rotate(-90deg); }
.loading-progress circle:last-child { stroke: var(--green); stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * .8), 500%; transition: stroke-dasharray .05s ease-in-out; }
.loading-progress-text { position: absolute; text-align: center; font-weight: bold; inset: calc(20vh + 3.25rem) 0 auto 0; }
.loading-progress-text:after { content: var(--blazor-load-percentage-text, "Carregando"); }

/* ===================== App shell ===================== */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 264px; flex-shrink: 0; position: sticky; top: 0; height: 100vh;
    background: linear-gradient(180deg, #1f8a4c 0%, #0f3d22 100%);
    display: flex; flex-direction: column; color: #fff; overflow: hidden;
}
.app-main { flex: 1; min-width: 0; }
.app-content { padding: 2rem 2.25rem; max-width: 1320px; }

/* ----- Sidebar brand ----- */
.sidebar-brand { display: flex; align-items: center; gap: .7rem; padding: 1.4rem 1.25rem; }
.brand-logo {
    width: 42px; height: 42px; border-radius: 50%; background: rgba(255,255,255,.18);
    display: flex; align-items: center; justify-content: center; font-size: 1.4rem;
}
.brand-name { font-weight: 800; font-size: 1.15rem; }
.brand-sub { font-size: .72rem; opacity: .8; }

/* ----- Sidebar nav ----- */
.sidebar-nav { display: flex; flex-direction: column; gap: .15rem; padding: .5rem .75rem; flex: 0 0 auto; }
.side-link {
    display: flex; align-items: center; gap: .8rem; padding: .7rem .85rem; border-radius: 10px;
    color: rgba(255,255,255,.85); font-size: .92rem; font-weight: 500; transition: background .15s;
}
.side-link:hover { background: rgba(255,255,255,.12); color: #fff; }
.side-link.active { background: rgba(255,255,255,.95); color: var(--green-dark); font-weight: 600; }
.side-ico { display: inline-flex; width: 20px; height: 20px; }
.side-ico svg { width: 20px; height: 20px; }

/* ----- Sidebar photo + user ----- */
.sidebar-photo {
    flex: 1; margin: .5rem 0 0; min-height: 80px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Crect fill='%230f3d22' width='100' height='100'/%3E%3C/svg%3E") center/cover;
    opacity: .35;
}
.sidebar-user {
    display: flex; align-items: center; gap: .6rem; padding: .9rem 1rem;
    background: rgba(0,0,0,.18); border-top: 1px solid rgba(255,255,255,.1);
}
.user-avatar {
    width: 38px; height: 38px; border-radius: 50%; background: rgba(255,255,255,.9); color: var(--green-dark);
    display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: .82rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: .7rem; opacity: .75; }
.user-logout { background: none; border: none; color: rgba(255,255,255,.8); cursor: pointer; padding: 4px; display: flex; }
.user-logout:hover { color: #fff; }

/* ===================== Page header ===================== */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.75rem; }
.page-head-left { display: flex; align-items: center; gap: .9rem; }
.page-title { font-size: 1.9rem; font-weight: 800; margin: 0; line-height: 1.1; }
.page-sub { color: var(--muted); margin: .25rem 0 0; font-size: .95rem; }
.back-btn {
    width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--line); background: #fff;
    display: flex; align-items: center; justify-content: center; color: var(--green); cursor: pointer; flex-shrink: 0;
}
.back-btn:hover { background: var(--green-soft); }
.head-action {
    display: inline-flex; align-items: center; gap: .5rem; padding: .65rem 1.1rem; border-radius: 12px;
    border: 1px solid var(--line); background: #fff; color: var(--ink); font-weight: 600; font-size: .9rem; cursor: pointer;
}
.head-action:hover { background: #f7faf8; }

/* ===================== Cards / panels ===================== */
.panel { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); }
.panel-head { padding: 1.25rem 1.5rem; display: flex; align-items: center; gap: .6rem; }
.panel-head .sec-ico { width: 26px; height: 26px; color: var(--green); display: inline-flex; }
.panel-head .sec-ico svg { width: 26px; height: 26px; }
.panel-title { font-size: 1.05rem; font-weight: 700; color: var(--green); margin: 0; }
.panel-body { padding: 0 1.5rem 1.5rem; }

/* ===================== Forms ===================== */
.field { margin-bottom: 1.1rem; }
.field label { display: block; font-size: .82rem; font-weight: 600; color: #3a4a40; margin-bottom: .4rem; }
.field .req { color: #e15b64; }
.field .hint { color: var(--muted); font-weight: 400; }
.fc {
    width: 100%; padding: .7rem .85rem; border: 1px solid var(--line); border-radius: 11px;
    font-size: .92rem; font-family: inherit; color: var(--ink); background: #fff; transition: border .15s, box-shadow .15s;
}
.fc:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
textarea.fc { resize: vertical; min-height: 70px; }
.input-suffix { position: relative; }
.input-suffix .suffix { position: absolute; right: .85rem; top: 50%; transform: translateY(-50%); color: var(--green); font-size: .85rem; font-weight: 600; }

/* Toggle (Macho/Fêmea, Fértil/Infértil) */
.toggle-group { display: flex; gap: .6rem; }
.toggle-opt {
    flex: 1; display: flex; align-items: center; justify-content: center; gap: .5rem;
    padding: .7rem; border: 1px solid var(--line); border-radius: 11px; background: #fff; cursor: pointer;
    font-size: .9rem; font-weight: 600; color: var(--muted); transition: all .15s;
}
.toggle-opt:hover { border-color: var(--green); }
.toggle-opt.on { background: var(--green-soft); border-color: var(--green); color: var(--green-dark); }

/* Buttons */
.btn-grn {
    display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
    padding: .7rem 1.3rem; border-radius: 12px; border: none; background: var(--green); color: #fff;
    font-weight: 600; font-size: .92rem; cursor: pointer; transition: background .15s;
}
.btn-grn:hover { background: var(--green-600); }
.btn-grn:disabled { opacity: .6; cursor: default; }
.btn-grn-block { width: 100%; }
.btn-ghost {
    display: inline-flex; align-items: center; gap: .5rem; padding: .7rem 1.3rem; border-radius: 12px;
    border: 1px solid var(--line); background: #fff; color: var(--ink); font-weight: 600; font-size: .92rem; cursor: pointer;
}
.btn-ghost:hover { background: #f7faf8; }
.btn-icon-del { background: none; border: 1px solid #f3d3d3; color: #e15b64; border-radius: 9px; padding: .4rem; cursor: pointer; display: inline-flex; }
.btn-icon-del:hover { background: #fdeeee; }

.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 1.25rem; }
.form-grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 1.25rem; }
.col-span-2 { grid-column: span 2; }
.col-span-3 { grid-column: span 3; }
@media (max-width: 900px) { .form-grid, .form-grid-2 { grid-template-columns: 1fr; } .col-span-2, .col-span-3 { grid-column: span 1; } }

.form-section-divider { border: none; border-top: 1px solid var(--line); margin: 1.5rem 0; }
.section-label { display: flex; align-items: center; gap: .6rem; margin: 0 0 1.25rem; }
.section-label .sec-ico { color: var(--green); width: 24px; height: 24px; display: inline-flex; }
.section-label .sec-ico svg { width: 24px; height: 24px; }
.section-label h3 { color: var(--green); font-size: 1.05rem; margin: 0; }

.form-actions { display: flex; justify-content: flex-end; gap: .75rem; margin-top: 1.5rem; }

/* Layout form + aside dicas */
.form-layout { display: grid; grid-template-columns: 1fr 320px; gap: 1.5rem; align-items: start; }
@media (max-width: 1100px) { .form-layout { grid-template-columns: 1fr; } }
.tips-aside { display: flex; flex-direction: column; gap: 1.1rem; }
.tip-item { display: flex; gap: .8rem; }
.tip-ico { width: 38px; height: 38px; border-radius: 10px; background: var(--green-soft); color: var(--green); flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.tip-ico svg { width: 20px; height: 20px; }
.tip-item h4 { font-size: .9rem; margin: 0 0 .15rem; }
.tip-item p { font-size: .8rem; color: var(--muted); margin: 0; line-height: 1.4; }
.tip-highlight { background: var(--green-soft2); border-radius: 12px; padding: 1rem; }

/* ===================== Dashboard ===================== */
.stat-card { background: #fff; border-radius: var(--radius); padding: 1.4rem; display: flex; align-items: center; gap: 1rem; box-shadow: var(--shadow); border: 1px solid var(--line); }
.stat-icon { width: 56px; height: 56px; border-radius: 14px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 1.7rem; }
.icon-green { background: var(--green-soft); } .icon-amber { background: var(--amber-soft); } .icon-purple { background: var(--purple-soft); } .icon-blue { background: var(--blue-soft); }
.stat-label { font-size: .82rem; color: var(--muted); }
.stat-value { font-size: 1.9rem; font-weight: 800; line-height: 1.1; }
.stat-sub { font-size: .74rem; color: #aab5ad; margin-top: .15rem; }

.bar-chart { display: flex; align-items: flex-end; justify-content: space-around; gap: .5rem; height: 210px; padding-top: 1rem; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; }
.bar-value { font-size: .8rem; font-weight: 700; color: #495057; margin-bottom: .25rem; }
.bar { width: 56%; max-width: 44px; min-height: 4px; background: linear-gradient(180deg, #36b06f, var(--green)); border-radius: 7px 7px 0 0; transition: height .4s ease; }
.bar-label { font-size: .72rem; color: #aab5ad; margin-top: .4rem; }

.donut-wrap { display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; }
.donut { width: 168px; height: 168px; flex-shrink: 0; }
.donut-num { font-size: 6px; font-weight: 800; text-anchor: middle; fill: var(--ink); }
.donut-cap { font-size: 2.6px; text-anchor: middle; fill: #aab5ad; }
.donut-legend { flex: 1; min-width: 170px; }
.legend-row { display: flex; align-items: center; gap: .55rem; padding: .3rem 0; font-size: .85rem; }
.legend-dot { width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0; }
.legend-name { flex: 1; color: #495057; }
.legend-val { color: #aab5ad; font-size: .76rem; }

/* ===================== Tables ===================== */
.bm-table { width: 100%; border-collapse: collapse; }
.bm-table th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); padding: .6rem .75rem; border-bottom: 1px solid var(--line); }
.bm-table td { padding: .8rem .75rem; border-bottom: 1px solid var(--line); font-size: .9rem; }
.bm-table tr:last-child td { border-bottom: none; }
.bm-table tr:hover td { background: #f9fbfa; }
.badge-pill { display: inline-block; padding: .25rem .6rem; border-radius: 20px; font-size: .74rem; font-weight: 600; }
.bg-ok { background: var(--green-soft); color: var(--green-dark); }
.bg-warn { background: var(--amber-soft); color: #8a6d1a; }
.bg-neutral { background: #eef1ef; color: #5a6b60; }
.bg-bad { background: #fdeaea; color: #b3261e; }

/* ----- Catalog list rows ----- */
.cat-list { display: flex; flex-direction: column; gap: .5rem; }
.cat-row { display: flex; align-items: center; gap: .7rem; padding: .7rem .85rem; border: 1px solid var(--line); border-radius: 12px; }
.cat-row-ico { width: 36px; height: 36px; border-radius: 9px; background: var(--green-soft); color: var(--green); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.cat-row-ico svg { width: 18px; height: 18px; }
.cat-row-main { flex: 1; min-width: 0; }
.cat-row-name { font-weight: 600; font-size: .9rem; }
.cat-row-sub { font-size: .76rem; color: var(--muted); }
.cat-count { color: var(--green); font-weight: 600; }

/* ===================== Login ===================== */
.login-split { display: grid; grid-template-columns: 1fr 1fr; min-height: 100vh; }
@media (max-width: 900px) { .login-split { grid-template-columns: 1fr; } .login-aside { display: none; } }
.login-aside { background: linear-gradient(135deg, #eef7f1 0%, #dbeede 100%); padding: 3.5rem; display: flex; flex-direction: column; justify-content: center; position: relative; overflow: hidden; }
.login-aside-brand { display: flex; align-items: center; gap: .8rem; margin-bottom: 2.5rem; }
.login-aside h2 { font-size: 2.1rem; color: var(--green-dark); line-height: 1.2; margin: 0 0 1rem; }
.login-aside p { color: #4a5d50; margin: 0 0 2rem; max-width: 380px; }
.login-feature { display: flex; align-items: center; gap: .8rem; margin-bottom: 1rem; color: #2c3d33; font-weight: 500; }
.login-feature .lf-ico { width: 38px; height: 38px; border-radius: 50%; background: #fff; color: var(--green); display: flex; align-items: center; justify-content: center; }
.login-feature .lf-ico svg { width: 18px; height: 18px; }
.login-main { display: flex; align-items: center; justify-content: center; padding: 2rem; background: #f6f8f7; }
.login-card { background: #fff; border-radius: 22px; padding: 2.75rem 2.5rem; width: 100%; max-width: 440px; box-shadow: 0 20px 60px rgba(16,40,28,.12); }
.login-lock { width: 76px; height: 76px; border-radius: 50%; background: var(--green-soft); color: var(--green); display: flex; align-items: center; justify-content: center; margin: 0 auto 1.25rem; }
.login-lock svg { width: 30px; height: 30px; }
.login-card h1 { text-align: center; font-size: 1.6rem; margin: 0 0 .35rem; }
.login-card .login-cap { text-align: center; color: var(--muted); margin: 0 0 1.75rem; }
.login-tabs { display: flex; gap: .4rem; background: #f0f3f1; padding: .3rem; border-radius: 12px; margin-bottom: 1.5rem; }
.login-tab { flex: 1; padding: .55rem; border: none; background: transparent; border-radius: 9px; font-size: .82rem; font-weight: 600; color: var(--muted); cursor: pointer; }
.login-tab.on { background: #fff; color: var(--green-dark); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.login-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.25rem; font-size: .85rem; }
.alert-box { padding: .7rem .9rem; border-radius: 11px; font-size: .85rem; margin-bottom: 1rem; }
.alert-ok { background: var(--green-soft); color: var(--green-dark); }
.alert-err { background: #fdeaea; color: #b3261e; }

/* ===================== Modal ===================== */
.modal-backdrop-custom { position: fixed; inset: 0; background: rgba(16,30,22,.5); z-index: 1040; }
.modal-custom { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background: #fff; border-radius: var(--radius); z-index: 1050; width: 100%; max-width: 760px; max-height: 92vh; display: flex; flex-direction: column; box-shadow: 0 24px 70px rgba(0,0,0,.3); }
.modal-custom-header { display: flex; justify-content: space-between; align-items: center; padding: 1.1rem 1.5rem; border-bottom: 1px solid var(--line); }
.modal-custom-header h5 { margin: 0; font-size: 1.1rem; }
.modal-x { background: none; border: none; font-size: 1.3rem; line-height: 1; color: var(--muted); cursor: pointer; }
.modal-custom-body { padding: 1.5rem; overflow-y: auto; }
.modal-custom-footer { display: flex; justify-content: flex-end; gap: .6rem; padding: 1rem 1.5rem; border-top: 1px solid var(--line); }

/* Checkbox grid (mutações) */
.check-grid { display: flex; flex-wrap: wrap; gap: .6rem .9rem; border: 1px solid var(--line); border-radius: 11px; padding: .85rem; }
.check-item { display: flex; align-items: center; gap: .4rem; font-size: .88rem; }
.check-item input { width: 16px; height: 16px; accent-color: var(--green); }

/* ----- Chips de mutação ----- */
.mut-chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .7rem; }
.mut-chips-sm { margin-bottom: 0; }
.mut-chip {
    display: inline-flex; align-items: center; gap: .35rem;
    background: var(--green-soft); color: var(--green-dark);
    padding: .22rem .6rem; border-radius: 20px; font-size: .76rem; font-weight: 600;
}
.mut-chip-x { background: none; border: none; color: var(--green-dark); cursor: pointer; font-size: .95rem; line-height: 1; padding: 0; opacity: .6; }
.mut-chip-x:hover { opacity: 1; }
