/* AgriNexus — plain HTML/CSS (no Tailwind, no JS required for UI) */

:root {
    --color-bg: #f1f5f9;
    --color-surface: #ffffff;
    --color-text: #0f172a;
    --color-muted: #64748b;
    --color-border: #e2e8f0;
    --color-emerald-950: #022c22;
    --color-emerald-900: #064e3b;
    --color-emerald-800: #065f46;
    --color-emerald-700: #047857;
    --color-emerald-100: #d1fae5;
    --color-amber-100: #fef3c7;
    --color-rose-100: #ffe4e6;
    --font: system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    /* Buttons — same family as main menu (flat forest green) */
    --an-btn-radius: 10px;
    --an-btn-pad-y: 0.65rem;
    --an-btn-pad-x: 1.5rem;
    --an-btn-font-size: 0.875rem;
    --an-btn-weight: 700;
    --an-btn-primary: #007955;
    --an-btn-primary-hover: #009068;
    --an-btn-primary-active: #006648;
    /* Destructive: deep forest (still green + white) */
    --an-btn-danger: #064e3b;
    --an-btn-danger-hover: #022c22;
}

*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    color: var(--color-text);
    background: var(--color-bg);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--color-emerald-700); }
a:hover { text-decoration: underline; }

/* ——— App shell (sidebar layout) ——— */
.an-shell {
    display: flex;
    min-height: 100vh;
    background: var(--color-bg);
}

.an-sidebar {
    width: 16rem;
    flex-shrink: 0;
    background: var(--color-emerald-950);
    color: #ecfdf5;
    border-right: 1px solid var(--color-emerald-900);
    display: flex;
    flex-direction: column;
}

.an-brand {
    padding: 1.25rem 1rem;
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    border-bottom: 1px solid rgba(6, 78, 59, 0.6);
}

.an-nav {
    flex: 1;
    padding: 1rem 0;
}

.an-nav a {
    display: block;
    margin: 0 0.5rem 0.125rem;
    padding: 0.6rem 1rem;
    font-size: 0.875rem;
    color: rgba(236, 253, 245, 0.9);
    text-decoration: none;
    border-radius: 0.5rem;
}

.an-nav a:hover {
    background: rgba(6, 78, 59, 0.55);
}

.an-nav a.an-active {
    background: var(--color-emerald-800);
    color: #fff;
    font-weight: 500;
}

.an-sidebar-footer {
    padding: 0.75rem;
    border-top: 1px solid rgba(6, 78, 59, 0.6);
    font-size: 0.75rem;
    color: rgba(209, 250, 229, 0.75);
}

.an-sidebar-footer a {
    color: inherit;
}

.an-sidebar-footer-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.an-sidebar-footer-actions .an-btn {
    width: 100%;
    box-sizing: border-box;
}

.an-sidebar-footer-form {
    margin: 0;
}

.an-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.an-topbar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem 1rem;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}

.an-topbar-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.an-topbar h1 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
}

/* Main area menu — flat forest-green buttons (GET forms, no JS) */
.an-main-menu {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.65rem;
    padding: 0.15rem 0 0.65rem;
    border-bottom: 1px solid var(--color-border);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.an-main-menu-form {
    display: inline-flex;
    flex-shrink: 0;
    margin: 0;
    padding: 0;
    border: none;
    vertical-align: middle;
}

/* Shared button chrome: main menu + .an-btn */
.an-btn,
.an-main-menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: var(--an-btn-pad-y) var(--an-btn-pad-x);
    white-space: nowrap;
    font-size: var(--an-btn-font-size);
    font-weight: var(--an-btn-weight);
    font-family: inherit;
    line-height: 1.2;
    letter-spacing: 0.01em;
    text-decoration: none;
    border-radius: var(--an-btn-radius);
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    box-shadow: none;
    text-shadow: none;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, filter 0.12s ease;
}

.an-btn:focus-visible,
.an-main-menu-btn:focus-visible {
    outline: 2px solid var(--an-btn-primary);
    outline-offset: 3px;
    box-shadow: none;
}

.an-main-menu-btn {
    color: #fff;
    border: none;
    background: var(--an-btn-primary);
}

.an-main-menu-btn:hover {
    color: #fff;
    background: var(--an-btn-primary-hover);
    text-decoration: none;
    filter: none;
}

.an-main-menu-btn:active {
    background: var(--an-btn-primary-active);
}

/* Current section — same flat green as default */
.an-main-menu-btn-active {
    color: #fff !important;
    border: none !important;
    background: var(--an-btn-primary) !important;
    box-shadow: none !important;
    text-shadow: none !important;
}

.an-main-menu-btn-active:hover {
    color: #fff !important;
    background: var(--an-btn-primary-hover) !important;
    filter: none !important;
}

.an-nav-section-label {
    margin: 0.25rem 1rem 0.5rem;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: rgba(209, 250, 229, 0.55);
}

.an-nav-hr {
    padding-top: 0.25rem;
}

/* Farm profile — embedded OSM map */
.an-farm-map-wrap {
    margin-top: 0.5rem;
    border-radius: 0.5rem;
    overflow: hidden;
    border: 1px solid var(--color-border);
    background: #e2e8f0;
}

.an-farm-map-iframe {
    display: block;
    width: 100%;
    height: min(22rem, 50vh);
    min-height: 16rem;
    border: 0;
}

.an-tagline {
    font-size: 0.75rem;
    color: var(--color-muted);
}

@media (max-width: 768px) {
    .an-tagline { display: none; }
}

.an-content {
    padding: 1.5rem;
    max-width: 80rem;
    margin: 0 auto;
    width: 100%;
}

.an-content > * + * { margin-top: 1.5rem; }

/* ——— Cards & stats ——— */
.an-card {
    background: var(--color-surface);
    border-radius: 0.75rem;
    border: 1px solid var(--color-border);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    padding: 1.25rem;
}

.an-grid-dashboard {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
}

.an-stat strong {
    display: block;
    font-size: 1.5rem;
    font-weight: 600;
    margin-top: 0.25rem;
}

.an-stat .muted {
    font-size: 0.75rem;
    color: var(--color-muted);
}

/* ——— Pills ——— */
.an-pill {
    display: inline-flex;
    align-items: center;
    border-radius: 9999px;
    padding: 0.125rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 500;
}

.an-pill-ok { background: var(--color-emerald-100); color: #065f46; }
.an-pill-warn { background: var(--color-amber-100); color: #78350f; }
.an-pill-danger { background: var(--color-rose-100); color: #9f1239; }

/* ——— Buttons (variants share .an-btn shell above) ——— */
.an-btn {
    border-style: solid;
    border-width: 1px;
}

/* Primary + ghost: same green surface, white label (app-wide) */
.an-btn-primary,
.an-btn-ghost {
    background: var(--an-btn-primary);
    color: #fff;
    border-color: var(--an-btn-primary);
}

.an-btn-primary:hover,
.an-btn-ghost:hover {
    background: var(--an-btn-primary-hover);
    border-color: var(--an-btn-primary-hover);
    color: #fff;
    text-decoration: none;
}

.an-btn-primary:active,
.an-btn-ghost:active {
    background: var(--an-btn-primary-active);
    border-color: var(--an-btn-primary-active);
}

/* Inactive tab / dimmed primary (still green + white) */
.an-btn-primary.an-btn-dim,
a.an-btn.an-btn-primary.an-btn-dim {
    background: var(--an-btn-primary-active);
    border-color: var(--an-btn-primary-active);
    color: #fff;
}

.an-btn-primary.an-btn-dim:hover,
a.an-btn.an-btn-primary.an-btn-dim:hover {
    background: var(--an-btn-primary);
    border-color: var(--an-btn-primary);
    color: #fff;
}

.an-btn-danger {
    background: var(--an-btn-danger);
    color: #fff;
    border-color: var(--an-btn-danger);
}

.an-btn-danger:hover {
    background: var(--an-btn-danger-hover);
    border-color: var(--an-btn-danger-hover);
    color: #fff;
    text-decoration: none;
}

.an-btn-block {
    width: 100%;
}

.an-btn-inline {
    width: fit-content;
}

summary.an-btn {
    list-style: none;
    cursor: pointer;
}

summary.an-btn::-webkit-details-marker {
    display: none;
}

/* ——— Forms ——— */
.an-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-muted);
    margin-bottom: 0.25rem;
}

.an-input, select.an-input, textarea.an-input {
    width: 100%;
    max-width: 100%;
    padding: 0.5rem 0.65rem;
    font-size: 0.875rem;
    border: 1px solid #cbd5e1;
    border-radius: 0.5rem;
    font-family: inherit;
}

textarea.an-input { min-height: 4rem; }

.an-input:focus {
    outline: 2px solid var(--an-btn-primary);
    outline-offset: 1px;
    border-color: var(--an-btn-primary);
}

.form-error {
    color: #be123c;
    font-size: 0.8125rem;
    margin-top: 0.25rem;
}

.form-success { color: #047857; font-size: 0.875rem; }

/* ——— Flash / alerts ——— */
.flash {
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
}

.flash-success {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    color: #065f46;
}

.flash-warn {
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: #78350f;
}

.flash-error {
    background: #fff1f2;
    border: 1px solid #fecdd3;
    color: #9f1239;
}

.flash-error ul { margin: 0; padding-left: 1.25rem; }

/* ——— Tables ——— */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-table th {
    text-align: left;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-muted);
    border-bottom: 1px solid var(--color-border);
    padding: 0.5rem 0.5rem 0.75rem;
}

.data-table td {
    border-bottom: 1px solid #f1f5f9;
    padding: 0.5rem;
    vertical-align: top;
}

.overflow-x { overflow-x: auto; }

/* ——— Chat (HTML-only: <details>) ——— */
.an-chat-float {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    z-index: 50;
    font-size: 0.875rem;
}

.an-chat-float details {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 0.75rem;
    box-shadow: 0 10px 40px rgba(15, 23, 42, 0.12);
    width: 20rem;
    max-width: calc(100vw - 2rem);
}

.an-chat-float summary {
    list-style: none;
    cursor: pointer;
    padding: 0.75rem 1rem;
    font-weight: var(--an-btn-weight);
    background: var(--an-btn-primary);
    color: #fff;
    border-radius: 0.75rem 0.75rem 0 0;
}

.an-chat-float summary:hover {
    background: var(--an-btn-primary-hover);
}

.an-chat-float summary::-webkit-details-marker { display: none; }

.an-chat-float .an-chat-body {
    padding: 0.75rem;
    max-height: 18rem;
    overflow-y: auto;
}

.an-chat-float textarea {
    width: 100%;
    min-height: 3.5rem;
    margin-top: 0.5rem;
    resize: vertical;
}

.an-chat-float .an-chat-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.an-chat-float .an-chat-actions .an-btn {
    flex: 1;
}

.an-chat-reply {
    background: #f1f5f9;
    padding: 0.5rem 0.65rem;
    border-radius: 0.5rem;
    margin-bottom: 0.75rem;
    font-size: 0.8125rem;
}

/* ——— Pie chart (conic-gradient via inline style) ——— */
.pie-wrap {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.pie-chart {
    width: 10rem;
    height: 10rem;
    border-radius: 50%;
    flex-shrink: 0;
}

.pie-legend {
    font-size: 0.8125rem;
    color: var(--color-muted);
}

.pie-legend span {
    display: inline-block;
    width: 0.65rem;
    height: 0.65rem;
    border-radius: 2px;
    margin-right: 0.35rem;
    vertical-align: middle;
}

/* ——— Gantt (CSS bars) ——— */
.gantt-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.75rem;
    font-size: 0.8125rem;
    color: var(--color-muted);
}

.gantt-rail {
    position: relative;
    height: 2rem;
    background: #f8fafc;
    border: 1px solid var(--color-border);
    border-radius: 0.375rem;
    margin-bottom: 0.35rem;
}

.gantt-bar {
    position: absolute;
    top: 2px;
    bottom: 2px;
    border-radius: 0.25rem;
    background: var(--an-btn-primary);
    min-width: 4px;
}

.gantt-bar--critical { background: #be123c; }
.gantt-bar--blocked { background: #94a3b8; }

.gantt-row {
    margin-bottom: 1.25rem;
}

.gantt-row-title {
    font-size: 0.8125rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.gantt-row-meta {
    font-size: 0.7rem;
    color: var(--color-muted);
}

/* ——— Auth pages ——— */
.auth-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: var(--color-bg);
}

.auth-card {
    width: 100%;
    max-width: 26rem;
    background: var(--color-surface);
    border-radius: 0.75rem;
    border: 1px solid var(--color-border);
    box-shadow: 0 4px 24px rgba(15, 23, 42, 0.06);
    padding: 2rem;
}

.auth-logo {
    text-align: center;
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-emerald-800);
}

.auth-logo a { color: inherit; text-decoration: none; }

.form-stack > * + * { margin-top: 1rem; }

.auth-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: flex-end;
    align-items: center;
    margin-top: 1rem;
    font-size: 0.8125rem;
}

/* ——— Simple top nav (profile / breeze pages) ——— */
.app-simple {
    min-height: 100vh;
    background: var(--color-bg);
}

.app-simple-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    height: 3.5rem;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}

.app-simple-nav a { text-decoration: none; }
.app-simple-nav a:hover { text-decoration: underline; }

.app-simple-nav .nav-links {
    display: flex;
    gap: 1.25rem;
    align-items: center;
    font-size: 0.875rem;
}

.app-simple-main {
    max-width: 56rem;
    margin: 0 auto;
    padding: 1.5rem;
}

.app-simple-main .an-card + .an-card { margin-top: 1rem; }

/* ——— Utilities ——— */
.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.muted { color: var(--color-muted); font-size: 0.875rem; }

.timeline-dot {
    position: absolute;
    left: -5px;
    top: 0.35rem;
    width: 8px;
    height: 8px;
    background: var(--color-emerald-700);
    border-radius: 50%;
}

.timeline-item {
    position: relative;
    padding-left: 1rem;
    margin-left: 0.25rem;
    border-left: 2px solid var(--color-border);
    padding-bottom: 1rem;
    list-style: none;
}

.ring-focus {
    box-shadow: 0 0 0 2px var(--color-emerald-700);
}

/* ——— Layout helpers (replace Tailwind-style utilities) ——— */
.max-w-xl { max-width: 36rem; }
.max-w-2xl { max-width: 42rem; }
.stack > * + * { margin-top: 1rem; }
.stack-sm > * + * { margin-top: 0.5rem; }
.ml-auto { margin-left: auto; }
.font-semibold { font-weight: 600; }

.farm-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
}

.form-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
}

.form-grid-full {
    grid-column: 1 / -1;
}

.form-stack > * + * {
    margin-top: 1rem;
}

.filter-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.filter-nav a.an-active-filter {
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--an-btn-primary);
}

code.inline-code {
    background: #f1f5f9;
    padding: 0.125rem 0.35rem;
    border-radius: 0.25rem;
    font-size: 0.8125em;
}

/* HR sidebar uses same .an-nav links as main sidebar */
