/* ============================================
   Shared component styles
   Used by nav.js (top nav) and analytics.js (consent banner).
   ============================================ */

/* ---- Top nav (nav.js) ---- */
#mainNav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--dark-slate);
    color: #fff;
    height: 56px;
    padding: 0 var(--space-5);
    font-family: var(--font-family);
    box-sizing: border-box;
}
.mn-left,
.mn-center,
.mn-right {
    display: flex;
    align-items: center;
}
.mn-left   { flex: 0 0 auto; }
.mn-center { flex: 1 1 auto; justify-content: center; }
.mn-right  { flex: 0 0 auto; gap: var(--space-3); }

.mn-brand {
    color: var(--brand-green);
    font-weight: bold;
    font-size: 1.25rem;
    text-decoration: none;
    white-space: nowrap;
}
.mn-brand:hover { opacity: 0.85; }

.mn-breadcrumb {
    font-size: var(--text-sm);
    color: var(--text-muted-on-dark);
    white-space: nowrap;
}
.mn-sep { margin: 0 6px; opacity: 0.5; }

.mn-email {
    color: var(--text-muted-on-dark);
    font-size: 0.78rem;
    white-space: nowrap;
}
.mn-link {
    color: var(--text-muted-on-dark);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.78rem;
    white-space: nowrap;
    transition: color 0.15s;
}
.mn-link:hover { color: var(--brand-green); }

@media (max-width: 768px) {
    #mainNav {
        height: 48px;
        padding: 0 var(--space-4);
    }
    .mn-center { display: none; }
    .mn-brand { font-size: 1.05rem; }
    .mn-link,
    .mn-email { font-size: 0.75rem; }
}

/* ---- Staging ribbon (staging-banner.js) ----
   Renders only on wings.agriterra.io. Fixed top-right, non-interactive,
   semi-transparent so it doesn't fully obscure underlying UI. */
#staging-banner {
    position: fixed;
    top: 8px;
    right: 8px;
    z-index: 10001;
    padding: 4px 10px;
    border: 2px solid var(--brand-green);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.85);
    color: var(--brand-green);
    font-family: var(--font-family);
    font-size: var(--text-xs);
    font-weight: 700;
    letter-spacing: 0.04em;
    pointer-events: none;
    user-select: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

/* ---- Cookie consent banner (analytics.js) ---- */
.cookie-consent {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #1e293b;
    color: #fff;
    padding: var(--space-3) 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    z-index: 10000;
    font-size: 0.85rem;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.2);
}
.cookie-consent__link {
    color: #4ade80;
    text-decoration: underline;
}
.cookie-consent__actions {
    display: flex;
    gap: var(--space-2);
}
.cookie-consent__btn {
    border: none;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
}
.cookie-consent__btn--accept {
    background: #4ade80;
    color: #1e293b;
}
.cookie-consent__btn--decline {
    background: transparent;
    color: #94a3b8;
    border: 1px solid var(--text-muted);
    font-weight: normal;
}

/* ---- Print: hide site-wide fixed UI ---- */
@media print {
    #mainNav,
    #staging-banner,
    .cookie-consent { display: none !important; }
}

/* ---- Accessibility: visually hidden but available to screen readers ---- */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ============================================================
   Form modals — used together with js/lib/modal.js. Markup:
     <div id="<name>Modal" class="modal-overlay">
       <div class="modal-content">
         <button class="modal-close">×</button>
         <h3>…</h3>
         <div class="modal-error"></div>
         <form>…
   Each page can override --modal-max-width on the overlay.
   ============================================================ */
.modal-overlay {
    display: none;
    position: fixed;
    z-index: 9999;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    align-items: flex-start;
    justify-content: center;
    padding-top: 60px;
    overflow-y: auto;
}
.modal-overlay.active { display: flex; }
.modal-content {
    background: white;
    padding: 32px;
    border-radius: 12px;
    max-width: var(--modal-max-width, 520px);
    width: 95%;
    position: relative;
    border-top: 6px solid var(--brand-green);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    margin-bottom: 60px;
}
.modal-content h3 {
    margin: 0 0 18px;
    color: var(--dark-slate);
    font-size: 1.15rem;
}
.modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
}
.modal-close:hover { color: var(--text-secondary); }
.modal-error {
    display: none;
    background: #fef2f2;
    border: 1px solid #fca5a5;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 0.82rem;
    color: #b91c1c;
    margin-bottom: 12px;
}
.modal-error.visible { display: block; }

/* ============================================================
   Form layout — shared by modal forms and inline page forms
   ============================================================ */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-group { margin-bottom: 14px; }
.form-group.full { grid-column: 1 / -1; }
.form-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--dark-slate);
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: inherit;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--brand-green);
}
.form-group textarea { resize: vertical; min-height: 60px; }
@media (max-width: 600px) {
    .form-row { grid-template-columns: 1fr; }
}

/* ============================================================
   Common buttons (add to section bar, submit a form)
   ============================================================ */
.btn-add {
    background: var(--brand-green);
    color: white;
    border: none;
    padding: 9px 16px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.82rem;
    cursor: pointer;
    transition: background 0.2s;
    min-height: 44px;
}
.btn-add:hover { background: #219150; }
.btn-submit {
    width: 100%;
    background: var(--brand-green);
    color: white;
    border: none;
    padding: 13px;
    border-radius: 8px;
    font-weight: bold;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-submit:hover { background: #219150; }
.btn-submit:disabled { background: #94a3b8; cursor: not-allowed; }

/* ============================================================
   Dashboard / page footer
   ============================================================ */
.dash-footer {
    text-align: center;
    font-size: 0.72rem;
    color: var(--text-muted);
    padding: 20px;
}

/* ============================================================
   Loading screen + spinner
   ============================================================ */
#loadingScreen {
    display: none;
    min-height: 100vh;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 16px;
    background: #f4f7f6;
}
#loadingScreen.active { display: flex; }
#loadingScreen p { color: var(--text-secondary); font-size: 0.95rem; }
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-light);
    border-top-color: var(--brand-green);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   Empty state — used when a list or table has no rows
   ============================================================ */
.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
    font-size: 0.9rem;
}
.empty-state a {
    color: var(--brand-green);
    font-weight: 600;
    text-decoration: none;
}
.empty-state p { margin: 0 0 12px; }
.empty-state.is-error { color: var(--text-secondary); }
.empty-state.is-error .empty-headline {
    color: #b91c1c;
    font-weight: 600;
    margin: 0 0 6px;
}

/* ============================================================
   Lease status badge color tiers (also used on dashboard).
   Pages set their own .badge font-size/padding inline.
   ============================================================ */
.badge.active   { background: #d1fae5; color: #065f46; }
.badge.expiring { background: #fef9c3; color: #713f12; }
.badge.urgent   { background: #fed7aa; color: #9a3412; }
.badge.expired  { background: #fee2e2; color: #991b1b; }

/* ============================================================
   F1 — provenance source line under metric cards / data grids.
   Always visible (never tooltip-only) so a skeptical reader can
   see where a cited figure came from. Mirrors the renderer's
   inline metric-source style for parity between web + PDF.
   ============================================================ */
.metric-source {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-top: 6px;
    font-style: italic;
    line-height: 1.4;
}
.metric-source--inline {
    margin-top: 2px;
    font-size: 0.72rem;
}
