/* ── Tokens ──────────────────────────────────────────────────── */
:root {
    --navy:        #003F87;
    --navy-dark:   #002d62;
    --navy-light:  #1a5ba8;
    --gold:        #FDB813;
    --gold-dark:   #e0a20f;
    --surface:     #f4f6fb;
    --card-bg:     #ffffff;
    --border:      rgba(0, 0, 0, 0.07);
    --shadow-sm:   0 1px 4px rgba(0,0,0,0.06), 0 2px 12px rgba(0,0,0,0.06);
    --shadow-md:   0 4px 16px rgba(0,0,0,0.10), 0 1px 4px rgba(0,0,0,0.06);
    --radius:      0.75rem;
    --radius-sm:   0.5rem;
    --radius-pill: 50rem;
}

/* ── Base ────────────────────────────────────────────────────── */
body {
    font-family: 'Rubik', system-ui, sans-serif;
    background: var(--surface);
    color: #1a1f2e;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    letter-spacing: -0.01em;
}

/* ── Bootstrap overrides ─────────────────────────────────────── */
[data-bs-theme="light"] {
    --bs-primary:     #003F87;
    --bs-primary-rgb: 0, 63, 135;
    --bs-body-bg:     var(--surface);
    --bs-link-color:       #003F87;
    --bs-link-hover-color: #002d62;

    --bs-danger:     #a04040;
    --bs-danger-rgb: 160, 64, 64;
}

.form-control, .form-select {
    border-radius: var(--radius-sm);
    border-color: #d0d7e8;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus, .form-select:focus {
    border-color: var(--navy);
    box-shadow: 0 0 0 3px rgba(0,63,135,0.12);
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
    font-weight: 500;
    border-radius: var(--radius-pill);
    transition: all 0.15s ease;
}
.btn-primary {
    background: var(--navy);
    border-color: var(--navy);
}
.btn-primary:hover, .btn-primary:active {
    background: var(--navy-dark);
    border-color: var(--navy-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,63,135,0.25);
}
.btn-outline-primary {
    color: var(--navy);
    border-color: var(--navy);
}
.btn-outline-primary:hover {
    background: var(--navy);
    border-color: var(--navy);
}
.btn-outline-secondary {
    border-radius: var(--radius-pill);
}
.btn-sm { border-radius: var(--radius-pill); }

/* ── Navbar ──────────────────────────────────────────────────── */
.navbar {
    background: linear-gradient(135deg, var(--navy-dark) 0%, var(--navy) 60%, var(--navy-light) 100%) !important;
    box-shadow: 0 2px 12px rgba(0,0,0,0.18);
    padding-top: 0.85rem;
    padding-bottom: 0.85rem;
}
.navbar-brand {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}
.navbar-brand .bi {
    color: var(--gold);
}

/* ── Cards ───────────────────────────────────────────────────── */
.card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card-bg);
    box-shadow: var(--shadow-sm);
}
.card-header {
    border-radius: var(--radius) var(--radius) 0 0 !important;
    border-bottom: 1px solid var(--border);
}
.card-footer {
    border-radius: 0 0 var(--radius) var(--radius) !important;
    border-top: 1px solid var(--border);
    background: #fafbfd !important;
}

/* ── List groups ─────────────────────────────────────────────── */
.list-group {
    --bs-list-group-bg: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.list-group-item {
    border-color: var(--border);
}

/* ── Badges ──────────────────────────────────────────────────── */
.badge {
    font-weight: 500;
    border-radius: var(--radius-pill);
    padding: 0.35em 0.75em;
    font-size: 0.75rem;
    letter-spacing: 0.02em;
}
.badge.status-active    { background-color: #1a9c5b !important; }
.badge.status-draft     { background-color: #7c8fa6 !important; }
.badge.status-suspended { background-color: #a04040 !important; }
.badge.status-archived  { background-color: #4a4f57 !important; }

/* Flex children need min-width:0 before text-truncate can shorten them.
   Bootstrap ships no such utility, and the form-row templates already
   assume this class exists. */
.min-w-0 { min-width: 0; }

/* Form type on list rows — tinted text, not a filled badge, so it reads as
   a quiet label rather than competing with the status pill below it. */
.form-type-marker {
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    opacity: 0.85;
    white-space: nowrap;
}
.form-type-marker i { font-size: 0.8rem; vertical-align: -0.05em; }
.form-type-marker-label { margin-left: 0.2em; }
/* Narrow screens: the icon alone carries the meaning (title attr has the rest). */
@media (max-width: 575.98px) {
    .form-type-marker-label { display: none; }
}

/* ── Sortable table headers (interest CRM) ───────────────────── */
/* A <button>, because nothing navigates — stripped back to read as a table
   header, with the caret as the only affordance that stands out. */
.crm-sort {
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    color: inherit;
    text-align: left;
    cursor: pointer;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
}
.crm-sort:hover { color: var(--navy); }
.crm-sort i { font-size: 0.7rem; }
/* Unsorted columns keep a faint caret rather than hiding it until hover:
   on a phone there is no hover, and an invisible affordance is no affordance. */
.crm-sort-idle { opacity: 0.25; transition: opacity 0.12s ease; }
.crm-sort:hover .crm-sort-idle,
.crm-sort:focus-visible .crm-sort-idle { opacity: 0.7; }
.crm-sort-active { color: var(--navy); font-weight: 600; }

/* ── Pack/unit header (dashboard) ────────────────────────────── */
.pack-header {
    background: linear-gradient(135deg, var(--navy-dark) 0%, var(--navy) 60%, var(--navy-light) 100%);
    color: #fff;
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}
.pack-header::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at top right, rgba(253,184,19,0.15), transparent 65%);
    pointer-events: none;
}
.pack-header .pack-number {
    color: var(--gold);
    font-weight: 700;
}

/* ── Public form ─────────────────────────────────────────────── */
.public-form .form-label { font-weight: 500; }
.public-form .required-marker { color: #a04040; margin-left: 0.2rem; }

/* ── Landing hero ────────────────────────────────────────────── */
.hero {
    background: linear-gradient(135deg, var(--navy-dark) 0%, var(--navy) 55%, var(--navy-light) 100%);
    color: #fff;
    border-radius: var(--radius);
    padding: 4rem 2rem;
    margin-bottom: 2rem;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-md);
}
.hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at bottom left, rgba(253,184,19,0.18), transparent 60%);
    pointer-events: none;
}
.hero h1 { color: #fff; }
.hero .lead { color: rgba(255,255,255,0.8); }
.hero .btn-hero {
    background: var(--gold);
    color: var(--navy-dark);
    border: none;
    font-weight: 700;
    font-size: 1.05rem;
    padding: 0.7rem 2rem;
}
.hero .btn-hero:hover {
    background: var(--gold-dark);
    color: var(--navy-dark);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(253,184,19,0.35);
}

/* ── Feature icons (landing) ─────────────────────────────────── */
.feature-icon {
    width: 3.5rem;
    height: 3.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 1rem;
    background: rgba(0,63,135,0.08);
    color: var(--navy);
    font-size: 1.5rem;
    margin-bottom: 0.75rem;
}

/* ── Tool cards (hub) ────────────────────────────────────────── */
.tool-card {
    transition: transform 0.15s, box-shadow 0.15s;
}
a:hover > .tool-card:not(.tool-card-disabled) {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}
.tool-card-disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ── Field builder items ─────────────────────────────────────── */
.field-item {
    cursor: default;
    border-left: 3px solid transparent;
    transition: border-color 0.2s, box-shadow 0.15s;
    border-radius: var(--radius-sm);
}
.field-item:hover {
    border-left-color: var(--gold);
    box-shadow: var(--shadow-sm);
}
.field-item.dragging { opacity: 0.5; }

/* ── Misc ────────────────────────────────────────────────────── */
.copy-feedback { animation: fadeInOut 2s ease; }
@keyframes fadeInOut { 0%{opacity:0} 20%{opacity:1} 80%{opacity:1} 100%{opacity:0} }

.breadcrumb { font-size: 0.875rem; }

footer { color: #8a95a8; font-size: 0.85rem; }

/* ── QR code generator ───────────────────────────────────────── */
/* Fixed square so the box holds its shape while a new code loads — the QR
   repaints in place instead of the frame collapsing and reflowing. */
.qr-code-frame { width: 100%; max-width: 260px; aspect-ratio: 1 / 1; margin: 0 auto; }
.qr-code-frame img { width: 100%; height: 100%; object-fit: contain; display: block; }

/* QR reader dropzone — drag/paste/click target for decoding an existing code */
.qr-dropzone {
    border: 2px dashed #adb5bd;
    border-radius: 0.5rem;
    padding: 1.25rem;
    text-align: center;
    cursor: pointer;
    color: #6c757d;
    transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}
.qr-dropzone:hover,
.qr-dropzone:focus-visible {
    border-color: var(--navy);
    color: var(--navy);
}
.qr-dropzone.qr-dropzone-active {
    border-color: var(--navy);
    background-color: rgba(0, 63, 135, 0.06);
    color: var(--navy);
}
.qr-dropzone i { font-size: 1.5rem; }
#qr-reader-status:empty { display: none; }

/* Non-production environment banner. Deliberately loud: it exists because the
   two environments were previously indistinguishable, which caused real data to
   be created on prod by mistake. Static (not fixed) so it never overlaps the
   navbar or needs a body offset. */
.env-banner {
  background: repeating-linear-gradient(
    45deg, #b45309, #b45309 12px, #92400e 12px, #92400e 24px
  );
  color: #fff;
  text-align: center;
  padding: 0.35rem 0.75rem;
  font-size: 0.875rem;
  letter-spacing: 0.03em;
  line-height: 1.3;
}
.env-banner strong { letter-spacing: 0.08em; }
