/* ══════════════════════════════════════════════════════════════
   Forest Farmers — App Shell
   Shared styles for top bar, sidebar, notification drawer,
   and user menu. Included by line-designer.html, species-db.html,
   and my-lines.html.
   ══════════════════════════════════════════════════════════════ */

/* ── CSS variables (mirrors each page's :root if not already set) ── */
:root {
  --shell-top: 64px;
  --shell-sidebar-full: 220px;
  --shell-sidebar-icon: 56px;
}

/* ── Body adjustments ─────────────────────────────────────────────── */
body.ff-shell-active {
  padding-top: var(--shell-top);
}
body.ff-shell-sidebar-expanded {
  padding-left: var(--shell-sidebar-full);
}
body.ff-shell-sidebar-icon {
  padding-left: var(--shell-sidebar-icon);
}

/* ── Top bar ──────────────────────────────────────────────────────── */
.ff-shell-topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--shell-top);
  background: var(--white, #fff);
  border-bottom: 1px solid var(--border, #e2ddd8);
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  z-index: 1000;
  gap: .9rem;
}

.ff-shell-brand {
  font-size: .82rem;
  font-weight: 700;
  color: var(--green-700, #15803d);
  text-transform: uppercase;
  letter-spacing: .06em;
  white-space: nowrap;
  text-decoration: none;
  flex-shrink: 0;
}

.ff-shell-page-title {
  font-size: .88rem;
  font-weight: 600;
  color: var(--text, #1a1a1a);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ff-shell-topbar-spacer { flex: 1; }

.ff-shell-topbar-right {
  display: flex;
  align-items: center;
  gap: .65rem;
  flex-shrink: 0;
}

/* ── Designer controls in top bar (lang toggle + help) ───────────── */
/* ── Save state indicator ─────────────────────────────────────────── */
.ff-shell-save-state {
  font-size: .72rem;
  color: var(--muted, #6b7280);
  margin-right: .5rem;
  white-space: nowrap;
  opacity: 0;
  transition: opacity .3s;
}
.ff-shell-save-state.visible { opacity: 1; }
.ff-shell-save-state.saving  { color: var(--muted, #6b7280); }
.ff-shell-save-state.saved   { color: var(--green-700, #15803d); }
.ff-shell-save-state.error   { color: #dc2626; }

/* ── Designer controls in top bar (lang toggle + help) ───────────── */
.ff-shell-lang-btns {
  display: flex;
  gap: .2rem;
  margin-right: .15rem;
}
.ff-shell-lang-btn {
  font-size: .72rem;
  font-weight: 600;
  padding: .2rem .45rem;
  border-radius: 5px;
  border: 1.5px solid var(--border, #e2ddd8);
  background: transparent;
  color: var(--muted, #6b7280);
  cursor: pointer;
  font-family: inherit;
  transition: all .1s;
}
.ff-shell-lang-btn.active {
  background: var(--green-700, #15803d);
  color: #fff;
  border-color: var(--green-700, #15803d);
}

.ff-shell-help-btn {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 1.5px solid var(--border, #e2ddd8);
  background: transparent;
  color: var(--muted, #6b7280);
  font-size: .82rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color .1s, color .1s;
  margin-right: .4rem;
}
.ff-shell-help-btn:hover {
  border-color: var(--green-700, #15803d);
  color: var(--green-700, #15803d);
}

/* ── Notification bell ────────────────────────────────────────────── */
.ff-shell-bell {
  position: relative;
  background: none;
  border: none;
  cursor: pointer;
  padding: .38rem;
  border-radius: 8px;
  color: var(--muted, #6b7280);
  display: flex;
  align-items: center;
  transition: background .12s, color .12s;
}
.ff-shell-bell:hover {
  background: var(--green-50, #f0faf4);
  color: var(--green-700, #15803d);
}
.ff-shell-bell svg { display: block; }

.ff-shell-bell-badge {
  position: absolute;
  top: 1px; right: 1px;
  background: #dc2626;
  color: #fff;
  font-size: .6rem;
  font-weight: 700;
  border-radius: 9999px;
  min-width: 16px;
  height: 16px;
  padding: 0 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  pointer-events: none;
}
.ff-shell-bell-badge.hidden { display: none; }

/* ── Avatar and user menu ─────────────────────────────────────────── */
.ff-shell-avatar-wrap { position: relative; }

.ff-shell-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--green-700, #15803d);
  color: #fff;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .03em;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  flex-shrink: 0;
  transition: opacity .12s;
}
.ff-shell-avatar:hover { opacity: .82; }

.ff-shell-signin {
  font-size: .78rem;
  font-weight: 600;
  padding: .28rem .75rem;
  border: 1.5px solid var(--green-700, #15803d);
  color: var(--green-700, #15803d);
  border-radius: 6px;
  background: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, color .12s;
  font-family: inherit;
}
.ff-shell-signin:hover {
  background: var(--green-700, #15803d);
  color: #fff;
}

/* User dropdown */
.ff-shell-usermenu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--white, #fff);
  border: 1px solid var(--border, #e2ddd8);
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0,0,0,.13);
  min-width: 210px;
  z-index: 2000;
  overflow: hidden;
  display: none;
}
.ff-shell-usermenu.open { display: block; }

.ff-shell-usermenu-header {
  padding: .85rem 1rem .75rem;
  border-bottom: 1px solid var(--border, #e2ddd8);
}
.ff-shell-usermenu-name {
  font-size: .85rem;
  font-weight: 600;
  color: var(--text, #1a1a1a);
  margin-bottom: .18rem;
  min-height: 1.2em;
}
.ff-shell-usermenu-email {
  font-size: .72rem;
  color: var(--muted, #6b7280);
  word-break: break-all;
}

.ff-shell-usermenu-items { padding: .35rem 0; }

.ff-shell-usermenu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: .48rem 1rem;
  font-size: .82rem;
  color: var(--text, #1a1a1a);
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: background .08s;
  text-decoration: none;
  white-space: nowrap;
}
.ff-shell-usermenu-item:hover { background: var(--green-50, #f0faf4); }
.ff-shell-usermenu-item.danger { color: #dc2626; }
.ff-shell-usermenu-item.danger:hover { background: #fee2e2; }

.ff-shell-usermenu-sep {
  height: 1px;
  background: var(--border, #e2ddd8);
  margin: .35rem 0;
}

/* ── Left sidebar ─────────────────────────────────────────────────── */
.ff-shell-sidebar {
  position: fixed;
  top: var(--shell-top);
  left: 0;
  bottom: 0;
  width: var(--shell-sidebar-full);
  background: var(--white, #fff);
  border-right: 1px solid var(--border, #e2ddd8);
  z-index: 999;
  display: flex;
  flex-direction: column;
  padding: .65rem 0;
  transition: width .18s ease;
  overflow: hidden;
}
.ff-shell-sidebar.icon-only { width: var(--shell-sidebar-icon); }
.ff-shell-sidebar.hidden { display: none; }

.ff-shell-nav-item {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .52rem .82rem;
  margin: .08rem .4rem;
  border-radius: 8px;
  font-size: .84rem;
  font-weight: 500;
  color: var(--muted, #6b7280);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  transition: background .1s, color .1s;
  border: none;
  background: none;
  font-family: inherit;
  cursor: pointer;
}
.ff-shell-nav-item:hover {
  background: var(--green-50, #f0faf4);
  color: var(--green-700, #15803d);
}
.ff-shell-nav-item.active {
  background: var(--green-50, #f0faf4);
  color: var(--green-700, #15803d);
  font-weight: 600;
}

.ff-shell-nav-icon {
  font-size: 1.05rem;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ff-shell-nav-label { flex: 1; }

.ff-shell-sidebar.icon-only .ff-shell-nav-label { display: none; }
.ff-shell-sidebar.icon-only .ff-shell-nav-item {
  padding: .52rem;
  justify-content: center;
  margin: .08rem .32rem;
}

.ff-shell-nav-sep {
  height: 1px;
  background: var(--border, #e2ddd8);
  margin: .5rem .82rem;
}

/* ── Notification drawer ──────────────────────────────────────────── */
.ff-shell-drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1500;
  display: none;
}
.ff-shell-drawer-backdrop.open { display: block; }

.ff-shell-drawer {
  position: fixed;
  top: var(--shell-top);
  right: 0;
  bottom: 0;
  width: 360px;
  background: var(--white, #fff);
  border-left: 1px solid var(--border, #e2ddd8);
  z-index: 1600;
  transform: translateX(100%);
  transition: transform .22s ease;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: -4px 0 24px rgba(0,0,0,.09);
}
.ff-shell-drawer.open { transform: translateX(0); }

.ff-shell-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.1rem .85rem;
  border-bottom: 1px solid var(--border, #e2ddd8);
  flex-shrink: 0;
}
.ff-shell-drawer-title {
  font-size: .95rem;
  font-weight: 700;
  color: var(--text, #1a1a1a);
}
.ff-shell-drawer-head-right {
  display: flex;
  gap: .5rem;
  align-items: center;
}
.ff-shell-drawer-mark-all {
  font-size: .75rem;
  font-weight: 600;
  color: var(--green-700, #15803d);
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  padding: .2rem .4rem;
  border-radius: 5px;
  transition: background .1s;
}
.ff-shell-drawer-mark-all:hover { background: var(--green-50, #f0faf4); }

.ff-shell-drawer-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--muted, #6b7280);
  padding: .2rem .38rem;
  border-radius: 5px;
  line-height: 1;
  transition: background .1s;
}
.ff-shell-drawer-close:hover {
  background: var(--border, #e2ddd8);
  color: var(--text, #1a1a1a);
}

.ff-shell-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: .5rem 0;
}

.ff-shell-notif {
  padding: .7rem 1.1rem;
  border-left: 3px solid transparent;
  margin: .18rem .5rem;
  border-radius: 0 7px 7px 0;
}
.ff-shell-notif.unread-approved { border-left-color: var(--green-700, #15803d); }
.ff-shell-notif.unread-rejected { border-left-color: #dc2626; }
.ff-shell-notif.read { opacity: .7; }

.ff-shell-notif-title {
  font-size: .82rem;
  font-weight: 600;
  color: var(--text, #1a1a1a);
  margin-bottom: .2rem;
  line-height: 1.45;
}
.ff-shell-notif.read .ff-shell-notif-title {
  font-weight: 500;
  color: var(--muted, #6b7280);
}
.ff-shell-notif-body {
  font-size: .75rem;
  color: var(--muted, #6b7280);
  line-height: 1.5;
  margin-bottom: .15rem;
}
.ff-shell-notif-time {
  font-size: .68rem;
  color: var(--muted, #6b7280);
  margin-top: .22rem;
}
.ff-shell-notif-action {
  font-size: .72rem;
  font-weight: 600;
  color: var(--green-700, #15803d);
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
  margin-top: .28rem;
  display: inline-block;
  text-decoration: underline;
}

.ff-shell-drawer-empty {
  text-align: center;
  color: var(--muted, #6b7280);
  font-size: .82rem;
  padding: 3rem 1.5rem;
  line-height: 1.6;
}

/* ── Feedback modal ───────────────────────────────────────────────── */
.ff-feedback-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 8500;
  display: none;
  align-items: center;
  justify-content: center;
}
.ff-feedback-backdrop.open { display: flex; }

.ff-feedback-modal {
  background: var(--white, #fff);
  border-radius: 14px;
  padding: 1.5rem 1.5rem 1.25rem;
  width: min(440px, 95vw);
  box-shadow: 0 16px 48px rgba(0,0,0,.18);
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
}
.ff-feedback-close {
  position: absolute;
  top: .75rem;
  right: .75rem;
  background: none;
  border: none;
  font-size: 1.1rem;
  color: var(--muted, #6b7280);
  cursor: pointer;
  line-height: 1;
  padding: .2rem;
}
.ff-feedback-close:hover { color: var(--text, #1a1a1a); }

.ff-feedback-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: .2rem;
}
.ff-feedback-sub {
  font-size: .78rem;
  color: var(--muted, #6b7280);
  margin-bottom: 1rem;
  line-height: 1.5;
}

.ff-feedback-field {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  margin-bottom: .7rem;
}
.ff-feedback-field label {
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted, #6b7280);
}
.ff-feedback-field select,
.ff-feedback-field textarea {
  border: 1px solid var(--border, #e2ddd8);
  border-radius: 7px;
  padding: .4rem .55rem;
  font-size: .84rem;
  font-family: inherit;
  color: var(--text, #1a1a1a);
  background: var(--cream, #f8f5f0);
  outline: none;
  transition: border-color .12s;
  width: 100%;
}
.ff-feedback-field select:focus,
.ff-feedback-field textarea:focus {
  border-color: #9ca3af;
  background: var(--white, #fff);
}
.ff-feedback-field textarea {
  min-height: 100px;
  resize: vertical;
}

.ff-feedback-err {
  font-size: .75rem;
  color: #dc2626;
  margin-bottom: .5rem;
  display: none;
}
.ff-feedback-actions {
  display: flex;
  gap: .6rem;
  justify-content: flex-end;
  margin-top: .5rem;
}
.ff-feedback-success {
  text-align: center;
  padding: 1.5rem 1rem;
}
.ff-feedback-success-icon {
  font-size: 2rem;
  margin-bottom: .5rem;
}
.ff-feedback-success-title {
  font-size: .92rem;
  font-weight: 700;
  margin-bottom: .3rem;
}
.ff-feedback-success-desc {
  font-size: .8rem;
  color: var(--muted, #6b7280);
  line-height: 1.5;
}
