/* Forms: drafts and the save bar (owner 4-Nov). Shared by the PG app, the admin console, Ladies Tailor, Bridal Mehendi
   and the Academy (public/js/forms/drafts.js). Works with both token sets: the PG app's (app.css) and the mini-apps'
   (apps/shared/miniapp.css), falling back from one to the other. The save bar reuses the admin settings bar's look
   (.adm-savebar): a frosted pill stuck to the bottom of the screen, above the tab bar and the phone's safe area. */
/* Declared on body too: the mini-apps set their accent on <body data-app>, and a variable that refers to another one is
   worked out where it is declared. */
:root, body {
  --gf-surface: var(--surface, #fff);
  --gf-chrome: var(--chrome, color-mix(in srgb, var(--surface, #fff) 86%, transparent));
  --gf-text: var(--text, var(--ink, #1F1A17));
  --gf-muted: var(--text-3, #756A61);
  --gf-line: var(--line, rgba(31, 26, 23, .10));
  --gf-accent: var(--accent, #9C6E0C);
  --gf-accent-text: var(--accent-text, var(--accent-deep, var(--accent, #7A5A0B)));
  --gf-on-accent: var(--text-on-accent, var(--on-accent, #fff));
  --gf-warn-bg: var(--warning-tint, #FFF3D6);
  --gf-warn-ink: var(--warning-ink, #8A5D00);
  --gf-danger: var(--danger-ink, #B23A2F);
  --gf-danger-solid: var(--danger-solid, #C2402F);
  --gf-ok: var(--success-ink, var(--good, #1B8F65));
  --gf-shadow: var(--sh-2, 0 1px 2px rgba(31, 26, 23, .06), 0 8px 24px rgba(31, 26, 23, .08));
  /* Where the bar sits: above the PG bottom tab bar on phones; mini-apps have no bottom tab bar. */
  --gf-bottom: calc(var(--tabbar-h, 0px) + var(--safe-b, env(safe-area-inset-bottom, 0px)) + 8px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']), :root:not([data-theme='light']) body { --gf-warn-bg: var(--warning-tint, #3A2E12); --gf-warn-ink: var(--warning-ink, #F2C46A); --gf-danger: var(--danger-ink, #F08A7E); }
}
:root[data-theme='dark'], :root[data-theme='dark'] body { --gf-warn-bg: var(--warning-tint, #3A2E12); --gf-warn-ink: var(--warning-ink, #F2C46A); --gf-danger: var(--danger-ink, #F08A7E); }
@media (min-width: 900px) { :root, body { --gf-bottom: 16px; } }

/* ---------- save bar ---------- */
.gf-savebar {
  position: sticky; bottom: var(--gf-bottom); z-index: 25;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 16px; padding: 8px 8px 8px 16px; min-height: 60px;
  border-radius: 24px; background: var(--gf-chrome); color: var(--gf-text);
  -webkit-backdrop-filter: blur(16px) saturate(1.5); backdrop-filter: blur(16px) saturate(1.5);
  box-shadow: 0 0 0 1px var(--gf-line), var(--gf-shadow);
}
.gf-savebar.is-dirty { box-shadow: 0 0 0 1.5px var(--gf-accent), var(--gf-shadow); }
.gf-savebar__text { min-width: 0; flex: 1 1 auto; display: grid; gap: 1px; font-size: 13px; line-height: 1.25; }
.gf-savebar__state { color: var(--gf-muted); }
.gf-savebar__state.is-saved { color: var(--gf-ok); }
.gf-savebar__state.is-local { color: var(--gf-warn-ink); }
.gf-savebar__state.is-error { color: var(--gf-danger); white-space: normal; }
.gf-savebar__miss { color: var(--gf-warn-ink); font-weight: 650; white-space: nowrap; }
.gf-savebar__btns { display: flex; align-items: center; gap: 6px; flex: none; }
.gf-savebar__go { white-space: nowrap; }
.gf-savebar .btn { min-height: 44px; }
.gf-savebar__btns .btn--plain { padding-left: 10px; padding-right: 10px; }
/* Mini-apps: no bottom tab bar, the page has its own padding. */
.gf-savebar--mini { --gf-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
.gf-savebar--mini .ma-btn { min-height: 44px; padding: 0 18px; font-size: 15px; }
@media (max-width: 380px) {
  .gf-savebar { padding-left: 12px; gap: 8px; }
  .gf-savebar__go { padding-left: 14px !important; padding-right: 14px !important; }
}

/* Status line inside a sheet footer or a mini-app bottom bar (the button is already always visible there). */
.gf-status { display: block; font-size: 12px; line-height: 1.3; color: var(--gf-muted); text-align: center; }
.gf-status.is-error { color: var(--gf-danger); }
.ma-bar .gf-status { text-align: left; margin-top: 2px; }

/* ---------- banners ---------- */
.gf-banners { display: grid; gap: 8px; margin: 0 0 12px; }
.gf-banner { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 10px 14px; border-radius: 14px;
  background: var(--accent-tint, color-mix(in srgb, var(--gf-accent) 12%, var(--gf-surface))); color: var(--gf-text); font-size: 14px; }
.gf-banner--warn { background: var(--gf-warn-bg); color: var(--gf-warn-ink); font-weight: 550; }
.gf-link { appearance: none; border: 0; background: none; padding: 6px 2px; min-height: 32px; font: inherit; font-weight: 650; color: var(--gf-accent-text); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.gf-banner--warn .gf-link { color: inherit; }

/* The box pressing Save sent her to. */
.gf-attn { animation: gf-attn 2.4s ease-out; border-radius: 14px; }
@keyframes gf-attn { 0%, 30% { box-shadow: 0 0 0 3px var(--gf-warn-ink); background: var(--gf-warn-bg); } 100% { box-shadow: 0 0 0 0 transparent; } }
@media (prefers-reduced-motion: reduce) { .gf-attn { animation: none; box-shadow: 0 0 0 3px var(--gf-warn-ink); } }

/* ---------- sheets (leave / delete) ---------- */
.gf-scrim { position: fixed; inset: 0; z-index: 1000; display: grid; align-items: end; justify-items: center; background: rgba(15, 10, 8, .5); padding: 0; }
.gf-sheet { width: 100%; max-width: 480px; background: var(--gf-surface); color: var(--gf-text); border-radius: 24px 24px 0 0;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom, 0px)); box-shadow: var(--gf-shadow); }
.gf-sheet h3 { margin: 0 0 6px; font-size: 19px; }
.gf-sheet p { margin: 0 0 16px; color: var(--gf-muted); font-size: 15px; }
.gf-sheet__btns { display: grid; gap: 8px; }
.gf-btn { appearance: none; border: 0; border-radius: 999px; min-height: 48px; padding: 0 20px; font: inherit; font-weight: 650; cursor: pointer; background: var(--gf-accent); color: var(--gf-on-accent); }
.gf-btn--ghost { background: transparent; color: var(--gf-text); box-shadow: 0 0 0 1px var(--gf-line) inset; }
.gf-btn--danger { background: var(--gf-danger-solid); color: #fff; }
@media (min-width: 600px) { .gf-scrim { align-items: center; } .gf-sheet { border-radius: 24px; } }

/* ---------- My drafts ---------- */
.gf-drafts__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.gf-drafts__row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 12px 12px 16px; border-radius: 16px;
  background: var(--gf-surface); box-shadow: 0 0 0 1px var(--gf-line); }
.gf-drafts__main { min-width: 0; display: grid; gap: 2px; }
.gf-drafts__main b { font-size: 15px; overflow-wrap: anywhere; line-height: 1.3; }
.gf-drafts__main span { font-size: 13px; color: var(--gf-muted); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.gf-drafts__btns { display: flex; gap: 4px; flex: none; }
.gf-drafts__btns .ma-btn { min-height: 40px; padding: 0 14px; font-size: 14px; }
.gf-drafts__del { color: var(--gf-danger) !important; }
.gf-muted { color: var(--gf-muted); font-size: 14px; }

/* DraftForm: the form's own Save button moves into the save bar (it is pressed from there). */
.gf-form--bar [data-draft-save] { display: none !important; }
.gf-form > .gf-status { text-align: left; margin: 0 0 8px; }
/* Inside a sheet or dialog the bar sits at the bottom of the sheet. */
.sheet .gf-savebar, .modal .gf-savebar, .ma-sheet .gf-savebar, .gf-sheet .gf-savebar { --gf-bottom: 0px; position: sticky; margin-bottom: 2px; }
