/*
 * Beverage Product Builder – Frontend Styles
 *
 * Scoped under .beverage-builder-root to avoid theme/plugin conflicts.
 * Mobile-first responsive design.
 */

/* ═══════════════════════════════════════════
   CSS Custom Properties
   ═══════════════════════════════════════════ */
.beverage-builder-root {
    --bb-primary: #0090CC;
    --bb-primary-dark: #115F8E;
    --bb-primary-light: #7DD8F5;
    --bb-accent: #0090CC;
    --bb-gradient: linear-gradient(135deg, #23caff 0%, #0090CC 100%);
    --bb-gradient-soft: linear-gradient(135deg, rgb(102 190 234 / 8%) 0%, rgb(75 133 162 / 8%) 100%);

    --bb-success: #10b981;
    --bb-warning: #f59e0b;
    --bb-danger: #ef4444;
    --bb-info: #3b82f6;

    --bb-bg: #ffffff;
    --bb-bg-subtle: #f8fafc;
    --bb-bg-muted: #f1f5f9;
    --bb-surface: #ffffff;
    --bb-border: #e2e8f0;
    --bb-border-light: #f1f5f9;

    --bb-text: #1e293b;
    --bb-text-muted: #64748b;
    --bb-text-subtle: #94a3b8;

    --bb-radius-sm: 8px;
    --bb-radius: 12px;
    --bb-radius-lg: 16px;
    --bb-radius-xl: 24px;

    --bb-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --bb-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
    --bb-shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
    --bb-shadow-xl: 0 20px 50px -12px rgba(0, 0, 0, 0.15);

    --bb-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --bb-transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);

    font-family: var(--bb-font);
    color: var(--bb-text);
    line-height: 1.6;
    box-sizing: border-box;
    max-width: 1100px;
    margin: 0 auto;
}

.beverage-builder-root *,
.beverage-builder-root *::before,
.beverage-builder-root *::after {
    box-sizing: border-box;
}

/* ═══════════════════════════════════════════
   Landing Screen
   ═══════════════════════════════════════════ */
.bb-landing {
    min-height: 420px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 24px;
    background: var(--bb-gradient-soft);
    border-radius: var(--bb-radius-xl);
    border: 1px solid var(--bb-border-light);
}

.bb-landing-inner {
    text-align: center;
    max-width: 520px;
}

.bb-landing-icon {
    margin-bottom: 24px;
    animation: bb-float 3s ease-in-out infinite;
}

@keyframes bb-float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.bb-landing-title {
    font-size: 2rem;
    font-weight: 800;
    background: var(--bb-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0 0 12px 0;
    letter-spacing: -0.02em;
}

.bb-landing-subtitle {
    font-size: 1.05rem;
    color: var(--bb-text-muted);
    margin: 0 0 32px 0;
    line-height: 1.7;
}

/* ═══════════════════════════════════════════
   Buttons
   ═══════════════════════════════════════════ */
.bb-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--bb-radius-sm);
    font-family: var(--bb-font);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--bb-transition);
    text-decoration: none;
    white-space: nowrap;
}

.bb-btn:focus-visible {
    outline: 2px solid var(--bb-primary);
    outline-offset: 2px;
}

.bb-btn-primary {
    background: var(--bb-gradient);
    color: #fff;
    box-shadow: 0 4px 14px rgba(102, 126, 234, 0.35);
}

.bb-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.45);
}

.bb-btn-accent {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: #fff;
    box-shadow: 0 4px 14px rgba(245, 87, 108, 0.3);
}

.bb-btn-accent:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(245, 87, 108, 0.4);
}

.bb-btn-outline {
    background: transparent;
    color: var(--bb-primary);
    border: 1.5px solid var(--bb-primary);
}

.bb-btn-outline:hover {
    background: var(--bb-gradient-soft);
}

.bb-btn-ghost {
    background: transparent;
    color: var(--bb-text-muted);
}

.bb-btn-ghost:hover {
    color: var(--bb-text);
    background: var(--bb-bg-muted);
}

.bb-btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.bb-btn-lg {
    padding: 14px 28px;
    font-size: 1rem;
}

.bb-btn-full {
    width: 100%;
    justify-content: center;
}

.bb-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.bb-add-ingredient-btn {
    background: var(--bb-gradient);
    color: white;
    padding: 0 20px;
}

/* ═══════════════════════════════════════════
   Tab Navigation
   ═══════════════════════════════════════════ */
.bb-tabs-nav {
    display: flex;
    gap: 4px;
    padding: 6px;
    background: var(--bb-bg-muted);
    border-radius: var(--bb-radius);
    margin-bottom: 4px;
    overflow-x: auto;
}

.bb-tab-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    border: none;
    background: transparent;
    border-radius: var(--bb-radius-sm);
    font-family: var(--bb-font);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--bb-text-muted);
    cursor: pointer;
    transition: all var(--bb-transition);
    white-space: nowrap;
}

.bb-tab-btn:hover {
    color: var(--bb-text);
    background: rgba(255, 255, 255, 0.6);
}

.bb-tab-btn.active {
    background: var(--bb-surface);
    color: var(--bb-primary-dark);
    box-shadow: var(--bb-shadow-sm);
    font-weight: 600;
}

.bb-tab-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--bb-bg-muted);
    font-size: 0.75rem;
    font-weight: 700;
    transition: all var(--bb-transition);
}

.bb-tab-btn.active .bb-tab-num {
    background: var(--bb-gradient);
    color: #fff;
}

.bb-tab-btn.completed .bb-tab-num {
    background: var(--bb-success);
    color: #fff;
}

.bb-tab-btn.bb-blocked {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

/* ═══════════════════════════════════════════
   Progress Bar
   ═══════════════════════════════════════════ */
.bb-progress {
    height: 3px;
    background: var(--bb-bg-muted);
    border-radius: 3px;
    margin-bottom: 24px;
    overflow: hidden;
}

.bb-progress-bar {
    height: 100%;
    background: var(--bb-gradient);
    border-radius: 3px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ═══════════════════════════════════════════
   Tab Panels
   ═══════════════════════════════════════════ */
.bb-tab-panel {
    animation: bb-fade-in 0.35s ease-out;
}

@keyframes bb-fade-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.bb-panel-content {
    min-height: 400px;
}

.bb-section {
    margin-bottom: 28px;
}

.bb-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.bb-section-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--bb-text);
    margin: 0 0 16px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.bb-section-header .bb-section-title {
    margin-bottom: 0;
}

/* ═══════════════════════════════════════════
   Tab Actions (bottom bar)
   ═══════════════════════════════════════════ */
.bb-tab-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding: 20px 0;
    border-top: 1px solid var(--bb-border-light);
    margin-top: 24px;
    flex-wrap: wrap;
}

/* ═══════════════════════════════════════════
   Tab 1 – Two-Column Design Layout
   ═══════════════════════════════════════════ */
.bb-design-layout {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 24px;
    align-items: start;
}

.bb-design-left {
    display: flex;
    flex-direction: column;
    gap: 0;
    overflow-y: auto;
    max-height: 720px;
    padding-right: 4px;
}

.bb-design-right {
    position: sticky;
    top: 16px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    /* Prevent canvas from overflowing viewport */
    max-height: calc(100vh - 160px);
}

/* ═══════════════════════════════════════════
   Package Type Selector (Tab 1)
   ═══════════════════════════════════════════ */
.bb-package-types {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.bb-package-card {
    border: 2px solid var(--bb-border);
    border-radius: var(--bb-radius);
    padding: 14px 10px;
    text-align: center;
    cursor: pointer;
    transition: all var(--bb-transition);
    background: var(--bb-surface);
    position: relative;
}

.bb-package-card:hover {
    border-color: var(--bb-primary-light);
    box-shadow: var(--bb-shadow);
    transform: translateY(-2px);
}

.bb-package-card.active {
    border-color: var(--bb-primary);
    background: var(--bb-gradient-soft);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

.bb-package-card svg,
.bb-package-card img {
    max-height: 72px;
    margin-bottom: 8px;
}

.bb-package-card-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--bb-text);
    line-height: 1.3;
}

/* ═══════════════════════════════════════════
   Canvas Editor – Toolbar (Tab 1)
   ═══════════════════════════════════════════ */
.bb-editor-toolbar {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Default icon-only tool button (legacy, unused in Tab1 now) */
.bb-tool-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 8px;
    border: 1px solid var(--bb-border);
    border-radius: var(--bb-radius-sm);
    background: var(--bb-surface);
    color: var(--bb-text-muted);
    cursor: pointer;
    font-size: 0.7rem;
    font-family: var(--bb-font);
    font-weight: 500;
    transition: all var(--bb-transition);
}

/* Wide tool button: icon + text in a row */
.bb-tool-btn--wide {
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--bb-text);
    border-radius: var(--bb-radius-sm);
    border: 1.5px solid var(--bb-border);
    width: 100%;
    text-align: left;
}

.bb-tool-btn:hover {
    color: var(--bb-primary);
    border-color: var(--bb-primary-light);
    background: var(--bb-gradient-soft);
}

.bb-tool-btn--wide:hover {
    color: var(--bb-primary);
}

.bb-tool-danger:hover {
    color: var(--bb-danger);
    border-color: #fecaca;
    background: #fef2f2;
}

/* Outer wrapper – holds border, shadow and constrains canvas size */
.bb-canvas-container-wrap {
    width: 100%;
    border-radius: var(--bb-radius);
    border: 1px solid var(--bb-border);
    box-shadow: var(--bb-shadow-lg);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 0;
    transition: border-color var(--bb-transition), box-shadow var(--bb-transition);
    background: #fff;
}

/* Drop-zone drag-over highlight on the wrap */
.bb-canvas-container-wrap.bb-drag-over {
    border-color: var(--bb-primary);
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.2), var(--bb-shadow-lg);
    background: var(--bb-gradient-soft);
}

.bb-canvas-container {
    /*
     * 90% of the wrap's width, strict 1:1 – height never auto-stretches.
     */
    width: 90%;
    aspect-ratio: 1 / 1;
    height: auto;
    /* ensure height is driven by aspect-ratio only */
    max-height: none;
    /* prevent viewport-based height cap */
    background: transparent;
    border-radius: calc(var(--bb-radius) - 1px);
    overflow: hidden;
    position: relative;
}

/* Drop-zone drag-over placeholder highlight */
.bb-canvas-container-wrap.bb-drag-over .bb-canvas-placeholder {
    color: var(--bb-primary);
}

/* Placeholder – shown when no label is uploaded */
/* Sits at z-index 15: above mockup (10) but below controls (20) */
.bb-canvas-placeholder {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: var(--bb-text-subtle);
    z-index: 15;
    pointer-events: none;
    width: auto;
    height: auto;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(6px);
    border-radius: 40px;
    padding: 10px 20px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--bb-border-light);
    flex-direction: row;
    white-space: nowrap;
}

.bb-canvas-placeholder svg {
    opacity: 0.5;
    flex-shrink: 0;
}

.bb-canvas-placeholder span {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--bb-text-muted);
    padding: 0;
}

/* ── Layer 1: Label image – sits BELOW the mockup overlay ── */
.bb-label-image {
    position: absolute;
    z-index: 2;
    object-fit: fill;
    pointer-events: none;
    /* handled by .bb-label-controls above */
    user-select: none;
    /* position & size set by JS */
}

/* ── Layer 2: Mockup overlay (non-interactive) ── */
.bb-mockup-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    pointer-events: none;
    z-index: 10;
    user-select: none;
    /* Smooth transition when switching package type */
    transition: opacity 0.3s ease;
}

/* Drag-over pulse on placeholder */
.bb-canvas-container-wrap.bb-drag-over .bb-canvas-placeholder {
    color: var(--bb-primary);
    border-color: rgba(102, 126, 234, 0.3);
    background: rgba(102, 126, 234, 0.08);
    animation: bb-pulse-badge 0.8s ease-in-out infinite alternate;
}

@keyframes bb-pulse-badge {
    from {
        transform: translateX(-50%) scale(1);
    }

    to {
        transform: translateX(-50%) scale(1.04);
    }
}

/* ── Layer 3: Controls – ABOVE the mockup, always visible ── */
.bb-label-controls {
    position: absolute;
    z-index: 20;
    cursor: move;
    user-select: none;
    touch-action: none;
    /* position & size synced with label image by JS */
}

/* Selection border – always visible when controls shown */
.bb-label-border {
    position: absolute;
    inset: 0;
    border: 2px dashed #0d9488;
    pointer-events: none;
}

/* Resize handles – always visible */
.bb-resize-handle {
    position: absolute;
    width: 26px;
    height: 26px;
    background: #0d9488;
    border-radius: 50%;
    z-index: 25;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    cursor: pointer;
}

.bb-resize-handle svg {
    width: 14px;
    height: 14px;
    display: block;
}

/* Corner handles */
.bb-handle-nw {
    top: -13px;
    left: -13px;
    cursor: nw-resize;
}

.bb-handle-ne {
    top: -13px;
    right: -13px;
    cursor: ne-resize;
}

.bb-handle-sw {
    bottom: -13px;
    left: -13px;
    cursor: sw-resize;
}

.bb-handle-se {
    bottom: -13px;
    right: -13px;
    cursor: se-resize;
}

/* Edge handles – centered on each side */
.bb-handle-n {
    top: -13px;
    left: 50%;
    transform: translateX(-50%);
    cursor: n-resize;
}

.bb-handle-s {
    bottom: -13px;
    left: 50%;
    transform: translateX(-50%);
    cursor: s-resize;
}

.bb-handle-w {
    left: -13px;
    top: 50%;
    transform: translateY(-50%);
    cursor: w-resize;
}

.bb-handle-e {
    right: -13px;
    top: 50%;
    transform: translateY(-50%);
    cursor: e-resize;
}

/* Hidden export canvas */
.bb-canvas-container canvas {
    display: none;
}

/* ═══════════════════════════════════════════
   AI Form (Tab 1)
   ═══════════════════════════════════════════ */
.bb-ai-form {
    background: var(--bb-gradient-soft);
    border: 1px solid rgba(102, 126, 234, 0.15);
    border-radius: var(--bb-radius);
    padding: 20px;
}

.bb-form-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.bb-form-group {
    margin-bottom: 16px;
}

.bb-form-group label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--bb-text);
    margin-bottom: 6px;
}

.bb-input,
.bb-select,
.bb-textarea {
    width: 100%;
    border: 1.5px solid var(--bb-border) !important;
    border-radius: var(--bb-radius-sm) !important;
    font-family: var(--bb-font);
    color: var(--bb-text);
    background: var(--bb-surface);
    transition: border-color var(--bb-transition), box-shadow var(--bb-transition);
    outline: none;
    min-height: 3rem;
}

/* Custom dropdown arrow for <select> */
.bb-select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    padding-right: 36px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M4 6l4 4 4-4' stroke='%236b7280' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px 16px;
    cursor: pointer;
}

.bb-input:focus,
.bb-select:focus,
.bb-textarea:focus {
    border-color: var(--bb-primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.12);
}

.bb-select:focus {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M4 6l4 4 4-4' stroke='%23667eea' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.bb-input.bb-input-error {
    border-color: var(--bb-danger);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.bb-ai-status {
    margin-top: 12px;
    padding: 12px 16px;
    border-radius: var(--bb-radius-sm);
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.bb-ai-status.loading {
    background: #eff6ff;
    color: var(--bb-info);
}

.bb-ai-status.success {
    background: #ecfdf5;
    color: var(--bb-success);
}

.bb-ai-status.error {
    background: #fef2f2;
    color: var(--bb-danger);
}

/* ═══════════════════════════════════════════
   Formula Tab (Tab 2)
   ═══════════════════════════════════════════ */
.bb-formula-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 24px;
    align-items: start;
}

.bb-ingredients-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.bb-ingredient-row {
    display: grid;
    /* handle | name | slider | num-input | to-100 | remove */
    grid-template-columns: 24px 1fr 28% 70px auto 36px;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    background: var(--bb-surface);
    border: 1px solid var(--bb-border-light);
    border-radius: var(--bb-radius-sm);
    transition: all var(--bb-transition);
    cursor: default;
}

.bb-ingredient-row:hover {
    border-color: var(--bb-border);
    box-shadow: var(--bb-shadow-sm);
}

.bb-ingredient-row.dragging {
    opacity: 0.5;
    box-shadow: var(--bb-shadow-lg);
}

.bb-ingredient-row input,
.bb-ingredient-row button {
    margin-bottom: 0;
}



.bb-drag-handle {
    color: var(--bb-text-subtle);
    cursor: grab;
    display: flex;
    align-items: center;
}

.bb-ingredient-name {
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--bb-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bb-ingredient-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--bb-bg-muted);
    outline: none;
    transition: background var(--bb-transition);
}

.bb-ingredient-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--bb-gradient);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.3);
    transition: transform 0.15s ease;
}

.bb-ingredient-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.bb-ingredient-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--bb-gradient);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.3);
}

.bb-ingredient-input {
    width: 60px;
    padding: 6px 8px;
    border: 1px solid var(--bb-border) !important;
    border-radius: 6px !important;
    font-family: var(--bb-font);
    font-size: 0.85rem;
    font-weight: 600;
    text-align: center;
    color: var(--bb-text) !important;
    outline: none;
    -moz-appearance: textfield;
    appearance: textfield !important;
    min-width: 70px;
}

.bb-ingredient-input::-webkit-inner-spin-button,
.bb-ingredient-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.bb-ingredient-input:focus {
    border-color: var(--bb-primary);
}

.bb-ingredient-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--bb-border);
    background: var(--bb-bg-subtle);
    color: var(--bb-text-muted);
    cursor: pointer;
    border-radius: 6px;
    transition: all var(--bb-transition);
    flex-shrink: 0;
    padding: 0;
}

.bb-ingredient-remove:hover {
    color: var(--bb-danger);
    background: #fef2f2;
    border-color: #fecaca;
}

/* "to 100%" per-row balance button */
.bb-ingredient-to100 {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 8px;
    border: 1px solid var(--bb-primary-light);
    border-radius: 6px;
    background: var(--bb-gradient-soft);
    color: var(--bb-primary-dark);
    font-family: var(--bb-font);
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--bb-transition);
    flex-shrink: 0;
    margin-right: 0;
}

.bb-ingredient-to100:hover {
    background: var(--bb-gradient);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

/* Recipe selector */
.bb-recipe-section {
    margin-bottom: 20px;
}

.bb-recipe-section .bb-section-label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--bb-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 8px;
}

.bb-recipe-section .bb-select {
    width: 100%;
}

/* Searchable ingredient picker */
.bb-add-dropdown {
    position: relative;
}

.bb-ingredient-picker {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 200;
    width: 320px;
    background: var(--bb-surface);
    border: 1px solid var(--bb-border);
    border-radius: var(--bb-radius-sm);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
    overflow: hidden;
}

.bb-picker-search {
    padding: 10px;
    border-bottom: 1px solid var(--bb-border-light);
}

.bb-picker-search input {
    width: 100%;
    box-sizing: border-box;
    padding: 7px 10px;
    border: 1px solid var(--bb-border);
    border-radius: var(--bb-radius-sm);
    background: var(--bb-bg);
    color: var(--bb-text);
    font-family: var(--bb-font);
    font-size: 0.85rem;
    outline: none;
    transition: border-color var(--bb-transition);
}

.bb-picker-search input:focus {
    border-color: var(--bb-primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

.bb-picker-list {
    max-height: 300px;
    overflow-y: auto;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.bb-picker-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    text-align: left;
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--bb-text);
    font-family: var(--bb-font);
    font-size: 0.85rem;
    cursor: pointer;
    transition: background var(--bb-transition);
}

.bb-picker-item:hover:not(.disabled) {
    background: var(--bb-gradient-soft);
    color: var(--bb-primary-dark);
}

.bb-picker-item.disabled {
    opacity: 0.45;
    cursor: default;
}

.bb-picker-badge {
    font-size: 0.7rem;
    padding: 1px 6px;
    border-radius: 10px;
    background: var(--bb-border-light);
    color: var(--bb-text-muted);
    flex-shrink: 0;
}

.bb-picker-empty {
    padding: 14px 12px;
    color: var(--bb-text-muted);
    font-size: 0.83rem;
    text-align: center;
}

.bb-picker-group-header {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 6px 10px;
    margin: 2px 0 0;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--bb-text-muted);
    background: var(--bb-bg);
    border-bottom: 1px solid var(--bb-border-light);
}

/* Output Panel */
.bb-output-panel {
    position: sticky;
    top: 24px;
    background: var(--bb-surface);
    border: 1px solid var(--bb-border-light);
    border-radius: var(--bb-radius);
    padding: 20px;
    box-shadow: var(--bb-shadow-sm);
}

.bb-output-card {
    padding: 14px 0;
    border-bottom: 1px solid var(--bb-border-light);
}

.bb-output-card:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.bb-output-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--bb-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}

.bb-output-value {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--bb-text);
}

.bb-output-big {
    font-size: 1.8rem;
    background: var(--bb-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.bb-output-highlight {
    background: var(--bb-gradient-soft);
    margin: 0 -20px;
    padding: 14px 20px !important;
    border-bottom: none !important;
}

.bb-output-highlight:first-of-type {
    border-radius: var(--bb-radius-sm) var(--bb-radius-sm) 0 0;
}

/* Total Bar */
.bb-total-bar {
    height: 10px;
    background: var(--bb-bg-muted);
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 6px;
}

.bb-total-bar-fill {
    height: 100%;
    border-radius: 5px;
    transition: width 0.3s ease, background-color 0.3s ease;
    background: var(--bb-success);
}

.bb-total-bar-fill.over,
.bb-total-bar-fill.under {
    background: var(--bb-danger);
}

/* Total row: value + auto-fill button side by side */
.bb-total-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 4px;
}

.bb-total-value {
    font-size: 1.1rem;
    font-weight: 700;
}

.bb-total-value.valid {
    color: var(--bb-success);
}

.bb-total-value.invalid {
    color: var(--bb-danger);
}

/* Auto-fill button */
.bb-autofill-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    border: 1.5px solid var(--bb-primary-light);
    border-radius: var(--bb-radius-sm);
    background: var(--bb-gradient-soft);
    color: var(--bb-primary-dark);
    font-family: var(--bb-font);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--bb-transition);
    white-space: nowrap;
}

.bb-autofill-btn:hover {
    background: var(--bb-gradient);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 3px 10px rgba(102, 126, 234, 0.3);
}

/* Warnings */
.bb-warnings-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.bb-warning-item {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    font-size: 0.82rem;
    color: var(--bb-warning);
    line-height: 1.4;
}

.bb-warning-item::before {
    content: "";
    display: inline-block;
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    margin-top: 2px;
    background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3'/%3E%3Cpath d='M12 9v4'/%3E%3Cpath d='M12 17h.01'/%3E%3C/svg%3E") no-repeat center / contain;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3'/%3E%3Cpath d='M12 9v4'/%3E%3Cpath d='M12 17h.01'/%3E%3C/svg%3E") no-repeat center / contain;
}

.bb-error-item {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    font-size: 0.82rem;
    color: var(--bb-danger);
    line-height: 1.4;
    font-weight: 600;
}

.bb-error-item::before {
    content: "";
    display: inline-block;
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    margin-top: 2px;
    background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='m15 9-6 6'/%3E%3Cpath d='m9 9 6 6'/%3E%3C/svg%3E") no-repeat center / contain;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='m15 9-6 6'/%3E%3Cpath d='m9 9 6 6'/%3E%3C/svg%3E") no-repeat center / contain;
}

/* When formula has hard errors, block Next visually */
.bb-next-btn.bb-blocked {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

/* ═══════════════════════════════════════════
   Production Tab (Tab 3)
   ═══════════════════════════════════════════ */
.bb-production-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    align-items: start;
}

.bb-radio-group {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.bb-radio {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
}

.bb-radio input[type="radio"] {
    accent-color: var(--bb-primary);
    width: 16px;
    height: 16px;
}

.bb-multiplier-info {
    margin-top: 12px;
    font-size: 0.82rem;
    color: var(--bb-text-muted);
    line-height: 1.6;
}

.bb-multiplier-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-right: 4px;
    margin-bottom: 4px;
}

.bb-multiplier-tag.active {
    background: #fef3c7;
    color: #92400e;
}

/* ═══════════════════════════════════════════
   Summary Tab (Tab 4)
   ═══════════════════════════════════════════ */
.bb-summary-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.bb-summary-card {
    background: var(--bb-surface);
    border: 1px solid var(--bb-border-light);
    border-radius: var(--bb-radius);
    padding: 20px;
    box-shadow: var(--bb-shadow-sm);
}

.bb-summary-card h4 {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--bb-text-muted);
    margin: 0 0 14px 0;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--bb-border-light);
}

.bb-summary-design-preview {
    text-align: center;
}

.bb-summary-design-preview img {
    max-width: 100%;
    max-height: 320px;
    border-radius: var(--bb-radius-sm);
    border: 1px solid var(--bb-border);
    -webkit-user-select: none;
    user-select: none;
    -webkit-user-drag: none;
}

.bb-summary-design-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 40px 16px;
    color: var(--bb-text-muted);
    font-size: 0.85rem;
}

.bb-summary-card h4 svg,
.bb-summary-card h5 svg {
    vertical-align: -3px;
    margin-right: 4px;
    opacity: 0.75;
}

.bb-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    font-size: 0.88rem;
    border-bottom: 1px solid var(--bb-border-light);
}

.bb-summary-row:last-child {
    border-bottom: none;
}

.bb-summary-row-label {
    color: var(--bb-text-muted);
}

.bb-summary-row-value {
    font-weight: 600;
    color: var(--bb-text);
}

/* Feasibility Score */
.bb-feasibility {
    text-align: center;
    padding: 16px;
}

.bb-feasibility-score {
    font-size: 3rem;
    font-weight: 800;
    margin-bottom: 4px;
}

.bb-feasibility-badge {
    display: inline-block;
    padding: 4px 16px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.bb-feasibility-badge.high {
    background: #ecfdf5;
    color: #065f46;
}

.bb-feasibility-badge.medium {
    background: #fef3c7;
    color: #92400e;
}

.bb-feasibility-badge.low {
    background: #fef2f2;
    color: #991b1b;
}

/* AI Suggestion */
.bb-ai-suggestion {
    background: var(--bb-gradient-soft);
    border: 1px solid rgba(102, 126, 234, 0.15);
    border-radius: var(--bb-radius);
    padding: 16px;
    margin-top: 12px;
}

.bb-ai-suggestion h5 {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--bb-primary-dark);
    margin: 0 0 8px 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.bb-ai-suggestion p {
    font-size: 0.88rem;
    color: var(--bb-text);
    margin: 0;
    line-height: 1.6;
}

/* ═══════════════════════════════════════════
   Lead Modal
   ═══════════════════════════════════════════ */
.bb-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: bb-overlay-in 0.2s ease-out;
}

@keyframes bb-overlay-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.bb-modal {
    background: var(--bb-surface);
    border-radius: var(--bb-radius-lg);
    box-shadow: var(--bb-shadow-xl);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: bb-modal-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes bb-modal-in {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.bb-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    border: none;
    background: var(--bb-bg-muted);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--bb-text-muted);
    transition: all var(--bb-transition);
    z-index: 1;
}

.bb-modal-close:hover {
    color: var(--bb-text);
    background: var(--bb-border);
}

.bb-modal-body {
    padding: 36px 32px 32px;
}

.bb-modal-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin: 0 0 6px 0;
    color: var(--bb-text);
}

.bb-modal-subtitle {
    font-size: 0.9rem;
    color: var(--bb-text-muted);
    margin: 0 0 24px 0;
}

.bb-required {
    color: var(--bb-danger);
}

.bb-lead-form .bb-form-group {
    margin-bottom: 14px;
}

.bb-lead-status {
    margin-top: 12px;
    padding: 10px 14px;
    border-radius: var(--bb-radius-sm);
    font-size: 0.85rem;
    text-align: center;
}

.bb-lead-status.error {
    background: #fef2f2;
    color: var(--bb-danger);
}

.bb-lead-success {
    text-align: center;
    padding: 20px 0;
}

.bb-lead-success h3 {
    font-size: 1.3rem;
    margin: 16px 0 8px;
    color: var(--bb-success);
}

.bb-lead-success p {
    color: var(--bb-text-muted);
    font-size: 0.9rem;
}

/* ═══════════════════════════════════════════
   Skeleton Loading
   ═══════════════════════════════════════════ */
.bb-skeleton {
    position: relative;
    overflow: hidden;
    background: var(--bb-bg-muted);
    border-radius: var(--bb-radius-sm);
}

.bb-skeleton::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.5) 50%, transparent 100%);
    animation: bb-shimmer 1.5s infinite;
}

@keyframes bb-shimmer {
    from {
        transform: translateX(-100%);
    }

    to {
        transform: translateX(100%);
    }
}

.bb-skeleton-cards {
    height: 160px;
}

.bb-skeleton-list {
    height: 300px;
}

.bb-skeleton-summary {
    height: 400px;
    grid-column: 1 / -1;
}

/* ═══════════════════════════════════════════
   Spinner
   ═══════════════════════════════════════════ */
.bb-spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: bb-spin 0.6s linear infinite;
}

.bb-spinner-dark {
    border-color: rgba(0, 0, 0, 0.1);
    border-top-color: var(--bb-primary);
}

@keyframes bb-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ═══════════════════════════════════════════
   Ingredient Add Dropdown
   ═══════════════════════════════════════════ */
.bb-add-dropdown {
    position: relative;
}

.bb-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 240px;
    background: var(--bb-surface);
    border: 1px solid var(--bb-border);
    border-radius: var(--bb-radius-sm);
    box-shadow: var(--bb-shadow-lg);
    z-index: 100;
    max-height: 240px;
    overflow-y: auto;
    animation: bb-fade-in 0.15s ease-out;
}

.bb-dropdown-item {
    display: block;
    width: 100%;
    padding: 10px 16px;
    border: none;
    background: transparent;
    text-align: left;
    font-family: var(--bb-font);
    font-size: 0.88rem;
    color: var(--bb-text);
    cursor: pointer;
    transition: background 0.15s ease;
}

.bb-dropdown-item:hover {
    background: var(--bb-gradient-soft);
}

.bb-dropdown-item.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ═══════════════════════════════════════════
   Responsive
   ═══════════════════════════════════════════ */
@media (max-width: 768px) {
    .beverage-builder-root {
        margin: 0 -8px;
    }

    .bb-landing {
        padding: 40px 20px;
        min-height: 320px;
    }

    .bb-landing-title {
        font-size: 1.5rem;
    }

    .bb-tabs-nav {
        gap: 2px;
        padding: 4px;
    }

    .bb-tab-btn {
        padding: 8px 10px;
        font-size: 0.75rem;
        flex-direction: column;
        gap: 4px;
    }

    .bb-tab-label {
        display: none;
    }

    .bb-design-layout {
        grid-template-columns: 1fr;
    }

    .bb-design-right {
        position: static;
        justify-content: center;
    }

    .bb-design-left {
        max-height: none;
        overflow-y: visible;
    }

    .bb-package-types {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .bb-form-row {
        grid-template-columns: 1fr;
    }

    .bb-formula-layout {
        grid-template-columns: 1fr;
    }

    .bb-formula-right {
        order: -1;
    }

    .bb-output-panel {
        position: static;
    }

    .bb-ingredient-row {
        grid-template-columns: 24px 1fr 22% 60px auto 32px;
        gap: 6px;
        padding: 10px 12px;
    }

    .bb-production-layout {
        grid-template-columns: 1fr;
    }

    .bb-summary-layout {
        grid-template-columns: 1fr;
    }

    .bb-tab-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .bb-tab-actions .bb-btn {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .bb-modal-body {
        padding: 28px 20px 24px;
    }

    .bb-ingredient-row {
        grid-template-columns: 1fr 1fr auto auto;
        gap: 6px;
    }

    .bb-ingredient-row .bb-drag-handle {
        display: none;
    }

    .bb-ingredient-to100 {
        display: none;
    }

    .bb-ingredient-slider {
        grid-column: 1 / -1;
    }
}