/* ============================================================
   Anolira — Nordic Farm Journal Design System
   ============================================================ */

/* ── CSS Variables ─────────────────────────────────────────── */
:root {
  /* Bone & Copper workspace palette (design package alt) — sidebar uses sand,
     not forest. Forest is reserved for marketing/print spec. */
  --fs-sidebar:          var(--sand-100);
  --fs-sidebar-dark:     var(--sand-200);
  --fs-sidebar-text:     var(--ink-700);
  --fs-sidebar-muted:    var(--ink-500);
  --fs-sidebar-hover:    var(--sand-200);
  --fs-sidebar-active:   var(--forest-100);
  --fs-accent:           var(--forest-900);
  --fs-accent-light:     var(--forest-700);
  --fs-primary:          var(--forest-900);
  --fs-earth:            var(--bronze-500);
  --fs-parchment:        var(--bg);
  --fs-parchment-dark:   var(--bg-elevated);
  --fs-card:             var(--surface);
  --fs-border:           var(--border-soft);
  --fs-shadow:           var(--shd-1);
  --fs-shadow-hover:     var(--shd-2);
  --fs-radius:           var(--rad-3);
  --fs-radius-lg:        var(--rad-4);
  --fs-sidebar-width:    272px;
  --fs-bottom-nav-h:     64px;

  --font-display:        'Fraunces', Georgia, serif;
  --font-body:           'DM Sans', 'Helvetica Neue', sans-serif;
}

/* ── Base ───────────────────────────────────────────────────── */
html, body {
  font-family: var(--font-body) !important;
  background-color: var(--fs-parchment) !important;
  color: #1A1A1A;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Typography overrides ───────────────────────────────────── */
.mud-typography-h1,
.mud-typography-h2,
.mud-typography-h3,
.mud-typography-h4,
.mud-typography-h5,
.mud-typography-h6 {
  font-family: var(--font-display) !important;
  letter-spacing: -0.01em;
}

.mud-typography-body1,
.mud-typography-body2,
.mud-typography-caption,
.mud-typography-subtitle1,
.mud-typography-subtitle2,
.mud-typography-button {
  font-family: var(--font-body) !important;
}

/* ── Main Content Background ────────────────────────────────── */
.mud-main-content {
  background-color: var(--fs-parchment) !important;
  min-height: 100vh;
}

/* ── AppBar ─────────────────────────────────────────────────── */
.mud-appbar {
  background: var(--surface) !important;
  color: var(--ink-900) !important;
  border-bottom: 1px solid var(--border-soft) !important;
  box-shadow: none !important;
}

.mud-appbar .mud-typography-h6 {
  font-family: var(--font-display) !important;
  font-weight: 500;
  letter-spacing: -0.01em;
  font-size: 1.05rem;
  color: var(--ink-900);
}

/* ── Sidebar / Drawer ───────────────────────────────────────── */
.mud-drawer {
  background: var(--sand-100) !important;
  border-right: 1px solid var(--border-soft) !important;
  box-shadow: none !important;
}

.mud-drawer-content {
  background: transparent !important;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

/* Sidebar drawer header */
.mud-drawer-header {
  padding: 14px 16px 8px !important;
  border-bottom: 1px solid var(--border-soft) !important;
  background: transparent !important;
}

.mud-drawer-header .mud-typography {
  font-family: var(--font-display) !important;
  font-size: 1.1rem !important;
  font-weight: 500;
  color: var(--ink-900) !important;
  letter-spacing: -0.01em;
}

/* Nav group title */
.mud-nav-group .mud-nav-group-title {
  font-family: var(--font-body) !important;
  font-size: 0.68rem !important;
  font-weight: 600 !important;
  letter-spacing: 0.06em !important;
  text-transform: uppercase !important;
  color: var(--ink-500) !important;
  padding: 12px 16px 4px !important;
}

/* Nav group expand icon */
.mud-nav-group .mud-expand-icon,
.mud-nav-group .mud-expand-icon-rotated {
  color: var(--ink-500) !important;
}

/* Nav links */
.mud-nav-link {
  color: var(--ink-700) !important;
  border-radius: 6px !important;
  margin: 1px 0 !important;
  padding: 7px 12px 7px 16px !important;
  font-family: var(--font-body) !important;
  font-size: 0.82rem !important;
  font-weight: 400;
  transition: background 0.15s ease, color 0.15s ease !important;
  position: relative;
}

.mud-nav-link:hover {
  background: var(--sand-200) !important;
  color: var(--ink-900) !important;
}

.mud-nav-link.active {
  background: var(--forest-100) !important;
  color: var(--forest-900) !important;
  font-weight: 600;
}

/* Nav link icons */
.mud-nav-link .mud-icon-root {
  color: var(--ink-500) !important;
  font-size: 1.1rem !important;
  transition: color 0.15s ease !important;
}
.mud-nav-link:hover .mud-icon-root,
.mud-nav-link.active .mud-icon-root {
  color: var(--forest-900) !important;
}

/* Sidebar divider */
.mud-drawer .mud-divider {
  border-color: var(--border-soft) !important;
  margin: 8px 12px !important;
}

/* ── Cards ──────────────────────────────────────────────────── */
.mud-paper {
  background: var(--fs-card) !important;
  border-radius: var(--fs-radius) !important;
  border: 1px solid var(--fs-border);
  box-shadow: var(--fs-shadow) !important;
  transition: box-shadow 0.2s ease !important;
}

.mud-paper:hover {
  box-shadow: var(--fs-shadow-hover) !important;
}

/* Elevated papers (forms) */
.mud-paper[elevation="2"] {
  box-shadow: 0 4px 20px rgba(27,67,50,0.10), 0 1px 4px rgba(0,0,0,0.07) !important;
}

/* ── Stat Cards ─────────────────────────────────────────────── */
.fs-stat-card {
  position: relative;
  overflow: hidden;
  padding: 20px 24px;
  border-radius: var(--fs-radius-lg) !important;
  cursor: default;
  transition: transform 0.2s ease, box-shadow 0.2s ease !important;
}

.fs-stat-card:hover {
  transform: translateY(-2px);
}

.fs-stat-card .fs-stat-number {
  font-family: var(--font-display) !important;
  font-size: 2.4rem;
  font-weight: 700;
  line-height: 1.1;
  display: block;
}

.fs-stat-card .fs-stat-label {
  font-family: var(--font-body) !important;
  font-size: 0.78rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.7;
  margin-top: 4px;
  display: block;
}

.fs-stat-card::after {
  content: '';
  position: absolute;
  right: -20px;
  bottom: -20px;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: rgba(255,255,255,0.07);
}

/* Green stat card */
.fs-stat-green {
  background: linear-gradient(135deg, #2E7D32 0%, #1B5E20 100%) !important;
  color: #FFFFFF;
  border: none !important;
}

/* Earth/brown stat card */
.fs-stat-earth {
  background: linear-gradient(135deg, #795548 0%, #4E342E 100%) !important;
  color: #FFFFFF;
  border: none !important;
}

/* Amber stat card */
.fs-stat-amber {
  background: linear-gradient(135deg, #D4A017 0%, #B8860B 100%) !important;
  color: #FFFFFF;
  border: none !important;
}

/* Light neutral stat card */
.fs-stat-neutral {
  background: #FFFFFF !important;
  color: #1A1A1A;
}
.fs-stat-neutral .fs-stat-number {
  color: var(--fs-primary);
}

/* ── Quick Action Tiles ─────────────────────────────────────── */
.fs-quick-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 12px;
  border-radius: var(--fs-radius-lg) !important;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.15s ease !important;
  border: 1px solid var(--fs-border);
  background: var(--fs-card) !important;
  text-decoration: none;
  gap: 10px;
  min-height: 100px;
}

.fs-quick-tile:hover {
  transform: translateY(-3px);
  box-shadow: var(--fs-shadow-hover) !important;
  border-color: rgba(46,125,50,0.25);
  background: rgba(46,125,50,0.03) !important;
}

.fs-quick-tile .fs-tile-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
}

.fs-quick-tile .fs-tile-label {
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 500;
  color: #3D3D3D;
  text-align: center;
  line-height: 1.3;
}

/* ── Section Headers ────────────────────────────────────────── */
.fs-section-header {
  font-family: var(--font-display) !important;
  font-size: 1.15rem !important;
  font-weight: 600 !important;
  color: #1A1A1A;
  margin-bottom: 0 !important;
  display: flex;
  align-items: center;
  gap: 8px;
}

.fs-section-header::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--fs-border);
  margin-left: 8px;
}

/* ── MudDataGrid / Tables ───────────────────────────────────── */
.mud-table-root,
.mud-data-grid {
  border-radius: var(--fs-radius) !important;
  overflow: hidden;
  border: 1px solid var(--fs-border) !important;
}

.mud-table-head .mud-table-row .mud-table-cell {
  background: #F0EBE0 !important;
  font-family: var(--font-body) !important;
  font-size: 0.75rem !important;
  font-weight: 600 !important;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6D5C4E !important;
  border-bottom: 1px solid var(--fs-border) !important;
  padding: 10px 16px !important;
}

.mud-table-body .mud-table-row .mud-table-cell {
  font-family: var(--font-body) !important;
  font-size: 0.88rem !important;
  color: #2A2A2A;
  border-bottom: 1px solid rgba(121,85,72,0.06) !important;
  padding: 11px 16px !important;
  transition: background 0.12s ease;
}

.mud-table-body .mud-table-row:hover .mud-table-cell {
  background: rgba(46,125,50,0.04) !important;
}

.mud-table-body .mud-table-row:last-child .mud-table-cell {
  border-bottom: none !important;
}

/* ── MudChips ───────────────────────────────────────────────── */
.mud-chip {
  font-family: var(--font-body) !important;
  font-size: 0.75rem !important;
  font-weight: 500;
  border-radius: 6px !important;
}

/* ── Buttons ────────────────────────────────────────────────── */
.mud-button-filled {
  font-family: var(--font-body) !important;
  font-weight: 500 !important;
  letter-spacing: 0.03em !important;
  border-radius: 8px !important;
}

.mud-button-outlined {
  font-family: var(--font-body) !important;
  font-weight: 500 !important;
  border-radius: 8px !important;
}

/* ── Alerts ─────────────────────────────────────────────────── */
.mud-alert {
  border-radius: var(--fs-radius) !important;
  font-family: var(--font-body) !important;
}

/* ── Tabs ───────────────────────────────────────────────────── */
.mud-tabs .mud-tab {
  font-family: var(--font-body) !important;
  font-size: 0.85rem !important;
  font-weight: 500 !important;
  text-transform: none !important;
  letter-spacing: 0 !important;
}

.mud-tabs .mud-tab-slider {
  background: var(--fs-primary) !important;
}

/* ── Forms ──────────────────────────────────────────────────── */
.mud-input-label,
.mud-input-helper-text {
  font-family: var(--font-body) !important;
  font-size: 0.82rem !important;
}

/* ── MudSimpleTable ─────────────────────────────────────────── */
.mud-simple-table {
  border-collapse: separate !important;
  border-spacing: 0 !important;
}

.mud-simple-table thead th {
  font-family: var(--font-body) !important;
  font-size: 0.73rem !important;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #6D5C4E;
  padding: 8px 12px !important;
  background: #F5EFE4;
  border-bottom: 1px solid var(--fs-border) !important;
}

.mud-simple-table tbody td {
  font-family: var(--font-body) !important;
  font-size: 0.875rem;
  padding: 9px 12px !important;
  border-bottom: 1px solid rgba(121,85,72,0.06) !important;
}

/* ── Mobile Bottom Navigation (Anolira refresh) ─────────────────
   Light surface, forest-900 active, ink-500 inactive — matches
   design spec "MobileBottomNav". Badge uses bronze-500. */
.fs-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--fs-bottom-nav-h);
  background: rgba(250, 247, 241, 0.96); /* sand-50 @ ~96 */
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 1300;
  border-top: 1px solid rgba(0,0,0,0.06);
  box-shadow: 0 -1px 0 rgba(0,0,0,0.02), 0 -8px 24px rgba(0,0,0,0.04);
  justify-content: space-around;
  align-items: stretch;
  padding: 8px 8px env(safe-area-inset-bottom, 0px);
}

.fs-bottom-nav-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 4px 4px 6px;
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  color: rgba(26,31,28,0.55); /* ink-500 */
  transition: color 0.15s ease;
  flex: 1;
  min-width: 0;
}

.fs-bottom-nav-item:hover { color: rgba(26,31,28,0.85); }

.fs-bottom-nav-item.active {
  color: #1F372E; /* forest-900 */
}

/* Active dot indicator beneath label */
.fs-bottom-nav-item.active::after {
  content: "";
  position: absolute;
  bottom: 2px;
  width: 4px;
  height: 4px;
  border-radius: 99px;
  background: #1F372E;
}

.fs-bottom-nav-item .material-icons {
  font-size: 1.4rem;
  font-variation-settings: "wght" 400;
}
.fs-bottom-nav-item.active .material-icons {
  font-variation-settings: "wght" 500;
}

.fs-bottom-nav-item span.nav-label {
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.fs-bottom-nav-item.active span.nav-label { font-weight: 600; }

/* Notification badge (apply with .fs-bottom-nav-badge on a child <span>) */
.fs-bottom-nav-item .fs-bottom-nav-badge {
  position: absolute;
  top: 2px;
  right: calc(50% - 18px);
  min-width: 16px;
  height: 16px;
  padding: 0 5px;
  background: #C07C45; /* bronze-500 */
  color: #2A1F12;      /* mull-900 */
  font-size: 9px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  border-radius: 999px;
  box-shadow: 0 0 0 2px rgba(250,247,241,0.96);
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 959px) {
  .fs-bottom-nav {
    display: flex;
  }

  .mud-main-content {
    padding-bottom: calc(var(--fs-bottom-nav-h) + 8px) !important;
  }
}

@media (max-width: 599px) {
  .mud-container {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  /* Stack DataGrid to simple scroll on mobile */
  .mud-data-grid {
    overflow-x: auto;
  }

  /* Bigger touch targets */
  .mud-nav-link {
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  /* Compact page headers on mobile */
  .mud-typography-h5 {
    font-size: 1.2rem !important;
  }
}

/* ── Dashboard specific ──────────────────────────────────────── */
.fs-dashboard-greeting {
  border-left: 4px solid var(--fs-accent);
  padding-left: 16px;
  margin-bottom: 28px;
}

.fs-dashboard-greeting .date-text {
  font-size: 0.82rem;
  color: #8D7560;
  text-transform: capitalize;
  font-weight: 400;
}

/* ── Sidebar farm identity ──────────────────────────────────── */
.fs-sidebar-brand {
  display: flex;
  flex-direction: column;
  padding: 14px 16px 10px;
  background: transparent;
  border-bottom: 1px solid var(--border-soft);
}

.fs-sidebar-brand .farm-icon {
  font-size: 1.6rem;
  line-height: 1;
  margin-bottom: 4px;
  color: var(--forest-900);
}

.fs-sidebar-brand .farm-name {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--ink-900);
  letter-spacing: -0.01em;
}

.fs-sidebar-brand .farm-tagline {
  font-family: var(--font-body);
  font-size: 0.7rem;
  color: var(--ink-500);
  margin-top: 2px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── Module header pills ────────────────────────────────────── */
.fs-module-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}

.fs-module-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--fs-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
}

/* ── Blazor error / valid states ────────────────────────────── */
.valid.modified:not([type=checkbox]) {
  outline: 1px solid #26b050;
}

.invalid {
  outline: 1px solid #e50000;
}

.validation-message {
  color: #e50000;
  font-family: var(--font-body);
  font-size: 0.8rem;
}

.blazor-error-boundary {
  background: #b32121;
  padding: 1rem 1rem 1rem 3.7rem;
  color: white;
  border-radius: var(--fs-radius);
}

.blazor-error-boundary::after {
  content: "Ett fel inträffade.";
}

/* ── Dashboard page header ──────────────────────────────────── */
.fs-dashboard-header {
  border-left: 4px solid var(--fs-accent);
  padding-left: 16px;
}

.fs-page-title {
  font-family: var(--font-display) !important;
  font-weight: 700 !important;
  color: #1A1A1A;
}

.fs-page-subtitle {
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: #8D7560;
  text-transform: capitalize;
  margin-top: 2px;
}

/* ── Section labels (dashboard h6) ─────────────────────────── */
.fs-section-label {
  font-family: var(--font-display) !important;
  font-size: 1.05rem !important;
  font-weight: 600 !important;
  color: #3A3A3A;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.fs-section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--fs-border);
  margin-left: 8px;
}

/* ── Stat card value (alias for fs-stat-number) ─────────────── */
.fs-stat-card .fs-stat-value {
  font-family: var(--font-display) !important;
  font-size: 2.2rem;
  font-weight: 700;
  line-height: 1.1;
  display: block;
}

/* ── Link with arrow ────────────────────────────────────────── */
.fs-link-arrow {
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--fs-primary);
  text-decoration: none;
  transition: opacity 0.15s ease;
}

.fs-link-arrow:hover {
  opacity: 0.75;
  text-decoration: underline;
}

/* ── Empty State ─────────────────────────────────────────────────── */
.fs-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1.5rem;
    text-align: center;
}

.fs-empty-icon {
    font-size: 4rem !important;
    width: 4rem !important;
    height: 4rem !important;
    opacity: 0.3;
}

/* Language switcher — static <details> dropdown (works in server-static mode) */
.anolira-lang-switcher {
    position: relative;
    margin: 0 4px;
}
.anolira-lang-switcher > summary {
    list-style: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: #D1E8D7;
    user-select: none;
}
.anolira-lang-switcher > summary::-webkit-details-marker { display: none; }
.anolira-lang-switcher > summary:hover {
    background: rgba(255, 255, 255, 0.08);
}
.anolira-lang-switcher > summary .material-icons {
    font-size: 24px;
}
.anolira-lang-switcher > summary .anolira-lang-icon {
    width: 24px;
    height: 24px;
    color: #D1E8D7;
    display: block;
}
.anolira-lang-switcher > ul .anolira-lang-check {
    width: 18px;
    height: 18px;
    color: #2E7D32;
}
.anolira-lang-switcher[open] > summary {
    background: rgba(255, 255, 255, 0.12);
}
.anolira-lang-switcher > ul {
    position: absolute;
    top: 100%;
    right: 0;
    margin: 4px 0 0 0;
    padding: 6px 0;
    list-style: none;
    background: #FFFFFF;
    color: #1A1A1A;
    min-width: 180px;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
    z-index: 1300;
}
.anolira-lang-switcher > ul a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 14px;
    color: inherit;
    text-decoration: none;
    font-family: var(--font-body);
    font-size: 0.9rem;
}
.anolira-lang-switcher > ul a:hover {
    background: rgba(46, 125, 50, 0.08);
}
.anolira-lang-switcher > ul a.active {
    font-weight: 600;
    color: #2E7D32;
}
.anolira-lang-switcher > ul .check {
    font-size: 18px;
    color: #2E7D32;
}

/* MudDataGrid with RowClick navigation — visual affordance for clickable rows.
   Apply via Class="cursor-pointer-rows" on the <MudDataGrid>. */
.cursor-pointer-rows .mud-table-row {
    cursor: pointer;
}
.cursor-pointer-rows .mud-table-row:focus-visible {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: -2px;
}

/* Skogskarta — beståndsetikett ovanpå polygonen (text, ej vit ruta) */
.leaflet-tooltip.forest-stand-label {
    background: transparent;
    border: none;
    box-shadow: none;
    color: #fff;
    font-weight: 600;
    font-size: 0.8rem;
    text-shadow: 0 0 3px rgba(0, 0, 0, 0.85), 0 0 2px rgba(0, 0, 0, 0.85);
    pointer-events: none;
}
.leaflet-tooltip.forest-stand-label::before {
    display: none; /* ingen pekare/triangel */
}
