/* branchBuilder.css — Styles for visual branch creator sandbox (branch-builder.html) */

:root {
    --bb-bg: #0f172a;
    --bb-card-bg: #1e293b;
    --bb-card-border: #334155;
    --bb-text-main: #f8fafc;
    --bb-text-muted: #94a3b8;
    --bb-accent: #3b82f6;
    --bb-accent-hover: #2563eb;
    --bb-whatsapp: #25d366;
    --bb-whatsapp-hover: #1eb956;
    --bb-female: #db2777;
    --bb-male: #2563eb;
    --bb-ghost: #475569;
}

body.branch-builder-page {
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background-color: var(--bb-bg);
    color: var(--bb-text-main);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    display: flex;
    flex-direction: column;
}

/* ── Top Header Toolbar ──────────────────────────────────────────────────────── */
.bb-header {
    height: 60px;
    background: #1e293b;
    border-bottom: 1px solid #334155;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 100;
    gap: 12px;
}

.bb-header__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: inherit;
    flex-shrink: 0;
}

.bb-header__logo {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: #0f172a;
    border: 1px solid #334155;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.bb-header__title {
    font-size: 16px;
    font-weight: 700;
    margin: 0;
    line-height: 1.2;
}

.bb-header__subtitle {
    font-size: 11px;
    color: var(--bb-text-muted);
}

.bb-header__stats {
    background: #0f172a;
    border: 1px solid #334155;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    color: #38bdf8;
    display: flex;
    align-items: center;
    gap: 6px;
}

.bb-header__actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.bb-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    border: 1px solid transparent;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.bb-btn--default {
    background: #334155;
    color: #f8fafc;
    border-color: #475569;
}
.bb-btn--default:hover {
    background: #475569;
}

.bb-btn--primary {
    background: var(--bb-accent);
    color: #ffffff;
}
.bb-btn--primary:hover {
    background: var(--bb-accent-hover);
}

.bb-btn--whatsapp {
    background: var(--bb-whatsapp);
    color: #ffffff;
}
.bb-btn--whatsapp:hover {
    background: var(--bb-whatsapp-hover);
}

.bb-btn--danger {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border-color: rgba(239, 68, 68, 0.3);
}
.bb-btn--danger:hover {
    background: rgba(239, 68, 68, 0.25);
}

/* ── Main Canvas Layout ──────────────────────────────────────────────────────── */
.bb-main {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: radial-gradient(circle at center, #1e293b 0%, #0f172a 100%);
}

#bb-chart-container {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: row;
    overflow: hidden;
}

#bb-chart-container svg.main_svg {
    flex: 1;
    width: 100%;
    height: 100%;
}

#bb-chart-container #htmlSvg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

#bb-chart-container #htmlSvg .cards_view {
    pointer-events: all;
}

/* Slide-out Edit Pane styling matching create-tree demo */
#bb-chart-container .f3-form-cont {
    position: relative;
    right: 0;
    top: 0;
    height: 100%;
    background-color: #18181b !important;
    border-left: 1px solid #27272a;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.4);
    z-index: 100;
    transition: width 0.25s ease;
    overflow-y: auto;
}

#bb-chart-container .f3-form-cont.opened {
    width: 340px;
}

#bb-chart-container .f3-form {
    padding: 20px 18px;
    color: #f4f4f5;
    font-family: inherit;
}

#bb-chart-container .f3-form .f3-form-title {
    font-size: 16px;
    font-weight: 700;
    color: #fafafa;
    margin-bottom: 16px;
}

#bb-chart-container .f3-form-field label,
#bb-chart-container .f3-info-field-label {
    font-size: 12px;
    font-weight: 600;
    color: #a1a1aa;
    text-transform: capitalize;
    margin-bottom: 4px;
    display: block;
}

#bb-chart-container .f3-form input[type="text"],
#bb-chart-container .f3-form select {
    width: 100%;
    padding: 9px 12px;
    background: #27272a;
    border: 1px solid #3f3f46;
    border-radius: 6px;
    color: #fafafa;
    font-size: 13.5px;
    box-sizing: border-box;
    margin-bottom: 12px;
    outline: none;
    transition: border-color 0.15s ease;
}

#bb-chart-container .f3-form input[type="text"]:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

#bb-chart-container .f3-form-buttons {
    display: flex;
    gap: 8px;
    margin-top: 14px;
}

#bb-chart-container .f3-form button[type="submit"] {
    background: #16a34a !important;
    color: #ffffff !important;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    flex: 1;
}

#bb-chart-container .f3-form button[type="submit"]:hover {
    background: #15803d !important;
}

#bb-chart-container .f3-form .f3-form-cancel-btn {
    background: #3f3f46 !important;
    color: #fafafa !important;
    border: none;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
}

#bb-chart-container .f3-form .f3-delete-btn {
    width: 100%;
    margin-top: 10px;
    background: transparent !important;
    border: 1px solid #ef4444 !important;
    color: #f87171 !important;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12.5px;
    cursor: pointer;
}

#bb-chart-container .f3-form .f3-delete-btn:hover {
    background: rgba(239, 68, 68, 0.15) !important;
}

/* Float Floating Action & Navigation Bar */
.bb-canvas-controls {
    position: absolute;
    bottom: 20px;
    left: 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 90;
}

.bb-canvas-btn {
    width: 38px;
    height: 38px;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 8px;
    color: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: all 0.15s ease;
}

.bb-canvas-btn:hover {
    background: #334155;
    transform: scale(1.05);
}

/* Seed Anchor Banner */
.bb-seed-banner {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(30, 41, 59, 0.95);
    border: 1px solid #3b82f6;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 12.5px;
    color: #93c5fd;
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 80;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.bb-seed-banner__badge {
    background: #2563eb;
    color: #ffffff;
    font-size: 10.5px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
}

/* Instructions Toast */
.bb-instructions {
    position: absolute;
    bottom: 20px;
    right: 20px;
    max-width: 300px;
    background: rgba(30, 41, 59, 0.9);
    border: 1px solid #334155;
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 12px;
    color: #cbd5e1;
    backdrop-filter: blur(6px);
    z-index: 80;
    line-height: 1.5;
}

.bb-instructions strong {
    color: #f8fafc;
    display: block;
    margin-bottom: 4px;
}

/* ── Custom Card Styles for Canvas ───────────────────────────────────────────── */
.card-male .card-body-rect {
    fill: #1e3a8a !important;
    stroke: #3b82f6 !important;
}

.card-female .card-body-rect {
    fill: #831843 !important;
    stroke: #ec4899 !important;
}

.card_add .card-body-rect {
    fill: #334155 !important;
    stroke: #64748b !important;
    stroke-dasharray: 4, 4;
}

.card-outline {
    stroke: rgba(255, 255, 255, 0.2) !important;
}

/* ── Modal Dialog for JSON / Sharing Preview ─────────────────────────────────── */
.bb-modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    z-index: 200;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    padding: 16px;
    box-sizing: border-box;
}

.bb-modal-backdrop.is-open {
    display: flex;
}

.bb-modal {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 12px;
    max-width: 650px;
    width: 100%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.bb-modal__header {
    padding: 16px 20px;
    border-bottom: 1px solid #334155;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.bb-modal__title {
    font-size: 16px;
    font-weight: 700;
    color: #f8fafc;
    margin: 0;
}

.bb-modal__close {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 22px;
    cursor: pointer;
    padding: 0 6px;
}
.bb-modal__close:hover {
    color: #ffffff;
}

.bb-modal__body {
    padding: 20px;
    overflow-y: auto;
    font-size: 13.5px;
    color: #cbd5e1;
}

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

.bb-form-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #cbd5e1;
    margin-bottom: 5px;
}

.bb-form-input,
.bb-form-textarea {
    width: 100%;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 6px;
    padding: 9px 12px;
    color: #f8fafc;
    font-size: 13.5px;
    box-sizing: border-box;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s ease;
}

.bb-form-input:focus,
.bb-form-textarea:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25);
}

.bb-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #cbd5e1;
    cursor: pointer;
    margin-top: 10px;
}

.bb-modal-notif {
    padding: 10px 14px;
    border-radius: 6px;
    margin-bottom: 14px;
    font-size: 13px;
    line-height: 1.4;
}

.bb-modal-notif--success {
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid rgba(34, 197, 94, 0.4);
    color: #4ade80;
}

.bb-modal-notif--error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #f87171;
}

.bb-modal__footer {
    padding: 14px 20px;
    border-top: 1px solid #334155;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Mobile responsive */
@media (max-width: 768px), (max-height: 520px) and (max-width: 1024px) {
    .bb-header {
        height: auto;
        padding: 6px 10px;
        flex-wrap: wrap;
        gap: 6px;
    }

    .bb-header__title {
        font-size: 14px;
    }

    .bb-header__subtitle {
        display: none;
    }

    .bb-header__stats {
        display: none;
    }

    .bb-header__actions {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 2px;
        justify-content: flex-start;
        gap: 6px;
    }

    .bb-header__actions::-webkit-scrollbar {
        display: none;
    }

    .bb-btn {
        padding: 6px 10px;
        font-size: 12px;
    }

    .bb-instructions {
        display: none;
    }

    /* Dock Edit Pane in Lower Section on Mobile so Tree remains visible on top */
    #bb-chart-container .f3-form-cont {
        position: fixed !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        top: auto !important;
        width: 100% !important;
        height: 290px !important;
        max-height: 48vh !important;
        border-radius: 16px 16px 0 0 !important;
        border-left: none !important;
        border-top: 2px solid #3b82f6 !important;
        z-index: 250 !important;
        box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.7) !important;
        transform: translateY(100%);
        transition: transform 0.25s cubic-bezier(0.32, 0.72, 0, 1) !important;
        background-color: #18181b !important;
    }

    #bb-chart-container .f3-form-cont.opened {
        transform: translateY(0);
        width: 100% !important;
    }

    #bb-chart-container .f3-form {
        padding: 12px 14px 18px;
    }

    #bb-chart-container .f3-form .f3-form-title {
        font-size: 14px;
        margin-bottom: 8px;
    }

    #bb-chart-container .f3-form-field label,
    #bb-chart-container .f3-info-field-label {
        font-size: 11px;
        margin-bottom: 2px;
    }

    #bb-chart-container .f3-form input[type="text"],
    #bb-chart-container .f3-form select {
        padding: 6px 10px;
        font-size: 13px;
        margin-bottom: 6px;
    }

    #bb-chart-container .f3-form-buttons {
        margin-top: 8px;
        gap: 6px;
    }

    #bb-chart-container .f3-form button[type="submit"],
    #bb-chart-container .f3-form .f3-form-cancel-btn {
        padding: 7px 12px;
        font-size: 12px;
    }

    #bb-chart-container .f3-form .f3-delete-btn {
        margin-top: 6px;
        padding: 6px 10px;
        font-size: 11.5px;
    }
}
