/* Trade Tools — compact Apple-style mobile workspace + floating action dock.
   Shared by every tool in the trade-tools category. Desktop is unchanged. */

[data-trade-guide-start] {
    display: block;
    height: 1px;
    margin: 0;
    padding: 0;
    border: 0;
    overflow: hidden;
    pointer-events: none;
}

/* ── Shop-owner hero: short, readable, left-aligned on a phone ─────────── */
@media (max-width: 639px) {
    .trade-tool-hero {
        padding-top: 0.1rem !important;
        padding-bottom: 0.55rem !important;
        text-align: left !important;
    }

    .trade-tool-hero h1 {
        font-size: 1.375rem !important;
        line-height: 1.2 !important;
        margin-bottom: 0.28rem !important;
        letter-spacing: -0.035em;
    }

    .trade-tool-hero .trade-tool-lead-desktop {
        display: none !important;
    }

    .trade-tool-hero .trade-tool-lead-mobile {
        display: block !important;
        font-size: 0.8125rem !important;
        line-height: 1.45 !important;
        max-width: none !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        color: #52525b;
    }

    html.dark .trade-tool-hero .trade-tool-lead-mobile {
        color: #a1a1aa;
    }

    .trade-tool-workspace {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
        padding-bottom: 0.5rem !important;
    }

    /* Keep the last calculator controls above the dock */
    .trade-tool-workspace > .grid:first-of-type {
        margin-bottom: 0.5rem !important;
        padding-bottom: calc(5.75rem + env(safe-area-inset-bottom, 0px));
    }

    .trade-tool-workspace .apple-glass {
        padding: 0.7rem !important;
        border-radius: 1rem !important;
        box-shadow: 0 8px 24px -16px rgba(0, 0, 0, 0.18) !important;
    }

    .trade-tool-workspace .text-4xl,
    .trade-tool-workspace .text-5xl,
    .trade-tool-workspace .text-6xl {
        font-size: 1.55rem !important;
        line-height: 1.12 !important;
        letter-spacing: -0.04em;
    }

    /* 16px avoids iOS zoom; keep height tight so the form stays a list, not cards */
    .trade-tool-workspace input[type="number"],
    .trade-tool-workspace input[type="text"],
    .trade-tool-workspace input[type="tel"],
    .trade-tool-workspace input[type="date"],
    .trade-tool-workspace select,
    .trade-tool-workspace textarea {
        font-size: 16px !important;
    }

    .trade-tool-workspace input[type="number"]:not(.bg-transparent):not(.wos-qty):not(.wos-rate):not(.wos-item),
    .trade-tool-workspace input[type="text"]:not(.bg-transparent):not(.wos-item),
    .trade-tool-workspace input[type="tel"]:not(.bg-transparent),
    .trade-tool-workspace input[type="date"]:not(.bg-transparent) {
        min-height: 36px;
        border-radius: 0.65rem !important;
    }

    .trade-tool-workspace [class*="min-h-[52px"],
    .trade-tool-workspace [class*="min-h-[56px"] {
        min-height: 40px !important;
    }

    /* WhatsApp order lines: flat list, no nested pills */
    .trade-tool-workspace #wos-rows {
        display: flex;
        flex-direction: column;
        gap: 0 !important;
    }

    .trade-tool-workspace .wos-row {
        padding: 0.4rem 0 !important;
        margin: 0 !important;
        border: none !important;
        border-bottom: 1px solid rgba(0, 0, 0, 0.07) !important;
        border-radius: 0 !important;
        background: transparent !important;
        box-shadow: none !important;
    }

    html.dark .trade-tool-workspace .wos-row {
        border-bottom-color: rgba(255, 255, 255, 0.08) !important;
        background: transparent !important;
    }

    .trade-tool-workspace .wos-row:hover {
        box-shadow: none !important;
        border-color: transparent !important;
        border-bottom-color: rgba(0, 0, 0, 0.07) !important;
    }

    .trade-tool-workspace .wos-row .grid {
        gap: 0.3rem !important;
    }

    .trade-tool-workspace .wos-row input,
    .trade-tool-workspace .wos-row select {
        min-height: 0 !important;
        height: 1.85rem !important;
        border-radius: 0.45rem !important;
        background: transparent !important;
        border-color: transparent !important;
        box-shadow: none !important;
        padding-top: 0 !important;
        padding-bottom: 0 !important;
    }

    .trade-tool-workspace .wos-row input.wos-item {
        border-bottom: 1px solid rgba(0, 0, 0, 0.08) !important;
        border-radius: 0 !important;
        padding-left: 0.15rem !important;
        font-weight: 600;
    }

    html.dark .trade-tool-workspace .wos-row input.wos-item {
        border-bottom-color: rgba(255, 255, 255, 0.12) !important;
    }

    .trade-tool-workspace .wos-row .wos-qty,
    .trade-tool-workspace .wos-row .wos-rate,
    .trade-tool-workspace .wos-row .wos-unit {
        background: rgba(0, 0, 0, 0.035) !important;
        border: none !important;
        font-size: 16px !important;
        height: 2rem !important;
    }

    html.dark .trade-tool-workspace .wos-row .wos-qty,
    html.dark .trade-tool-workspace .wos-row .wos-rate,
    html.dark .trade-tool-workspace .wos-row .wos-unit {
        background: rgba(255, 255, 255, 0.06) !important;
    }

    .trade-tool-workspace .wos-row .wos-line-total {
        height: 1.85rem !important;
        background: transparent !important;
        border: none !important;
        font-size: 12px !important;
        font-weight: 800;
        justify-content: flex-end;
        padding: 0 !important;
    }

    .trade-tool-workspace .wos-row .wos-row-num {
        width: 1rem;
        height: 1rem;
        font-size: 9px;
        background: transparent;
        color: #a1a1aa;
    }

    .trade-tool-workspace .wos-row .wos-remove {
        width: 1.5rem !important;
        height: 1.5rem !important;
        background: transparent !important;
    }

    .trade-tool-workspace #wos-add-item,
    .trade-tool-workspace #wos-load-example,
    .trade-tool-workspace #wos-reset-btn {
        min-height: 30px !important;
        font-size: 11px !important;
        border-radius: 0.5rem !important;
        padding-left: 0.55rem !important;
        padding-right: 0.55rem !important;
    }

    .trade-tool-workspace .flex.flex-col.gap-6 {
        gap: 0.75rem;
    }

    .trade-tool-workspace .space-y-6 > :not([hidden]) ~ :not([hidden]) {
        margin-top: 0.85rem;
    }

    /* Compact long-form guides so they read like Notes, not a brochure */
    .trade-tool-workspace article.apple-glass {
        padding: 1rem !important;
        border-radius: 1.05rem !important;
    }

    .trade-tool-workspace article.apple-glass h2 {
        font-size: 1.05rem !important;
        line-height: 1.3 !important;
    }

    .trade-tool-workspace > .max-w-4xl,
    .trade-tool-workspace > .w-full.max-w-7xl {
        margin-top: 1.25rem !important;
    }
}

@media (min-width: 640px) {
    .trade-tool-hero .trade-tool-lead-mobile {
        display: none !important;
    }
}

/* ── Floating action dock (above the site tab bar, below lg) ───────────── */
.trade-mobile-dock {
    position: fixed;
    left: 0.75rem;
    right: 0.75rem;
    bottom: calc(4.65rem + env(safe-area-inset-bottom, 0px));
    z-index: 45;
    pointer-events: none;
    transform: translateY(0);
    opacity: 1;
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1),
                opacity 0.22s ease,
                bottom 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.trade-mobile-dock.is-dock-hidden {
    transform: translateY(calc(100% + 1.75rem));
    opacity: 0;
    pointer-events: none;
}

.trade-mobile-dock__inner {
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
    max-width: 28rem;
    margin: 0 auto;
    padding: 0.5rem 0.55rem 0.5rem 0.9rem;
    border-radius: 1.15rem;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 10px 32px -8px rgba(0, 0, 0, 0.22),
                0 0 0 0.5px rgba(255, 255, 255, 0.6) inset;
    backdrop-filter: blur(18px) saturate(1.4);
    -webkit-backdrop-filter: blur(18px) saturate(1.4);
}

html.dark .trade-mobile-dock__inner {
    background: rgba(18, 18, 21, 0.92);
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 12px 36px -10px rgba(0, 0, 0, 0.55),
                0 0 0 0.5px rgba(255, 255, 255, 0.08) inset;
}

.trade-mobile-dock__sum {
    min-width: 0;
    flex: 1;
}

.trade-mobile-dock__label {
    display: block;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #a1a1aa;
    line-height: 1;
    margin-bottom: 0.18rem;
}

.trade-mobile-dock__amount {
    display: block;
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    color: #18181b;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-variant-numeric: tabular-nums;
}

html.dark .trade-mobile-dock__amount {
    color: #fafafa;
}

.trade-mobile-dock__actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
}

.trade-mobile-dock__copy,
.trade-mobile-dock__primary {
    min-height: 40px;
    border-radius: 0.75rem;
    font-size: 0.75rem;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0 0.8rem;
    cursor: pointer;
    border: 1px solid transparent;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.12s ease, filter 0.12s ease;
}

.trade-mobile-dock__copy:active,
.trade-mobile-dock__primary:active {
    transform: scale(0.96);
}

.trade-mobile-dock__copy {
    background: #f4f4f5;
    color: #18181b;
    border-color: #e4e4e7;
}

html.dark .trade-mobile-dock__copy {
    background: #27272a;
    color: #f4f4f5;
    border-color: rgba(255, 255, 255, 0.12);
}

.trade-mobile-dock__primary {
    background: linear-gradient(135deg, #25d366 0%, #128c7e 100%);
    color: #ffffff !important;
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.32);
}

.trade-mobile-dock__primary,
.trade-mobile-dock__primary span,
.trade-mobile-dock__primary i {
    color: #ffffff !important;
}

.trade-mobile-dock__primary.is-amber {
    background: linear-gradient(135deg, #f59e0b 0%, #f43f5e 100%);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.32);
}

@media (min-width: 1024px) {
    .trade-mobile-dock {
        display: none !important;
    }
}

/* Extra page padding while the dock is visible so last inputs aren't covered */
@media (max-width: 1023px) {
    body.is-tool-page:has([data-trade-mobile-dock]:not(.is-dock-hidden)) {
        padding-bottom: calc(9.25rem + env(safe-area-inset-bottom, 0px));
    }

    body.is-tool-page:has([data-trade-mobile-dock]:not(.is-dock-hidden)) #scrollTopBtn {
        bottom: calc(9.75rem + env(safe-area-inset-bottom, 0px));
    }

    /* When the site tab bar tucks away on scroll, drop the dock with it */
    body.is-tool-page:has(#mobileTabBar.translate-y-28) .trade-mobile-dock:not(.is-dock-hidden) {
        bottom: calc(1.15rem + env(safe-area-inset-bottom, 0px));
    }
}

@media (prefers-reduced-motion: reduce) {
    .trade-mobile-dock {
        transition: none;
    }
}
