/* Treatment Builder – 3D GLB Edition */
.tb-wrapper {
    --tb-primary: #6c63ff;
    --tb-bg: #f0f0f5;
    --tb-text: #1a1a2e;
    --tb-muted: #888;
    --tb-border: #e8e8e8;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    display: flex;
    width: 100%;
    min-height: 700px;
    overflow: hidden;
    line-height: 1.5;
    box-sizing: border-box;
}
.tb-wrapper *, .tb-wrapper *::before, .tb-wrapper *::after { box-sizing: border-box; }

/* ── LEFT: 3D viewport ── */
.tb-left-panel {
    flex: 1;
    background: var(--tb-bg);
    display: flex;
    flex-direction: column;
    position: relative;
    min-height: 700px;
}
.tb-figure-area {
    flex: 1;
    position: relative;
    overflow: hidden;
}

/* Wrapper receives drag events; canvas is inside with pointer-events:none */
#tb-canvas-wrapper {
    position: absolute;
    inset: 0;
    cursor: grab;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}
#tb-canvas-wrapper:active { cursor: grabbing; }

/* Canvas – pointer-events set none via JS */
#tb-canvas-wrapper canvas {
    display: block;
    position: absolute;
    top: 0; left: 0;
    width: 100% !important;
    height: 100% !important;
    z-index: 1;
}

/* ── LOADING SPINNER ── */
#tb-loading {
    display: none;
    position: absolute;
    inset: 0;
    align-items: center;
    justify-content: center;
    z-index: 30;
    pointer-events: none;
}
.tb-spinner {
    width: 44px; height: 44px;
    border: 3px solid rgba(108,99,255,0.2);
    border-top-color: var(--tb-primary);
    border-radius: 50%;
    animation: tb-spin 0.75s linear infinite;
}
@keyframes tb-spin { to { transform: rotate(360deg); } }

/* ── WELCOME OVERLAY ── */
/* Positioned near top-center so it sits above the model, not over the crotch */
.tb-body-welcome {
    position: absolute;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    z-index: 20;
    pointer-events: none;
}
.tb-body-welcome > * { pointer-events: all; }

/* Pulsing ring button – like treatment-builder.com reference */
.tb-pulse-wrapper {
    position: relative;
    width: 72px;
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

/* The two pulsing rings */
.tb-pulse-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid var(--tb-primary);
    animation: tb-ring-pulse 2s ease-out infinite;
    opacity: 0;
}
.tb-pulse-ring:nth-child(2) { animation-delay: 0.7s; }

@keyframes tb-ring-pulse {
    0%   { transform: scale(1);   opacity: 0.7; }
    100% { transform: scale(2.2); opacity: 0;   }
}

/* The solid center button */
#tb-click-start {
    position: relative;
    width: 58px; height: 58px;
    border-radius: 50%;
    background: var(--tb-primary);
    border: none;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    color: #fff;
    box-shadow: 0 4px 20px rgba(108,99,255,0.5);
    transition: transform 0.2s, box-shadow 0.2s;
    z-index: 1;
}
#tb-click-start:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 28px rgba(108,99,255,0.65);
}
#tb-click-start:active { transform: scale(0.96); }

.tb-click-text {
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    background: var(--tb-primary);
    padding: 7px 18px;
    border-radius: 24px;
    cursor: pointer;
    box-shadow: 0 3px 12px rgba(108,99,255,0.4);
    white-space: nowrap;
    letter-spacing: 0.2px;
}
.tb-click-text:hover { background: #5a52e0; }

/* ── DRAG HINT ── */
.tb-drag-hint {
    position: absolute;
    bottom: 20px; left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.55);
    color: #fff;
    font-size: 13px; font-weight: 500;
    padding: 7px 20px;
    border-radius: 24px;
    pointer-events: none;
    z-index: 25;
    white-space: nowrap;
    display: flex; align-items: center; gap: 8px;
}
.tb-drag-hint span { font-size: 20px; }

/* ── HOTSPOTS ── */
.tb-hotspot {
    position: absolute;
    width: 32px; height: 32px;
    border-radius: 50%;
    border: 2px solid var(--tb-primary);
    background: rgba(255,255,255,0.9);
    cursor: pointer;
    transform: translate(-50%, -50%);
    padding: 0;
    z-index: 10;
    pointer-events: all;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.15s, background 0.15s, box-shadow 0.15s;
    box-shadow: 0 2px 8px rgba(108,99,255,0.25);
}
.tb-hotspot::before, .tb-hotspot::after {
    content: '';
    position: absolute;
    background: var(--tb-primary);
    border-radius: 1px;
    pointer-events: none;
    transition: background 0.15s;
}
.tb-hotspot::before { width: 13px; height: 2px; top: 50%; left: 50%; transform: translate(-50%,-50%); }
.tb-hotspot::after  { width: 2px; height: 13px; top: 50%; left: 50%; transform: translate(-50%,-50%); }
.tb-hotspot:hover {
    transform: translate(-50%,-50%) scale(1.2);
    box-shadow: 0 4px 14px rgba(108,99,255,0.4);
}
.tb-hotspot:active { transform: translate(-50%,-50%) scale(0.93); }
.tb-hotspot.active,
.tb-hotspot.has-selections {
    background: var(--tb-primary);
    box-shadow: 0 3px 12px rgba(108,99,255,0.45);
}
.tb-hotspot.active::before, .tb-hotspot.active::after,
.tb-hotspot.has-selections::before, .tb-hotspot.has-selections::after {
    background: #fff;
}
.tb-hotspot.has-selections {
    animation: tb-hs-pulse 2.2s ease-in-out infinite;
}
@keyframes tb-hs-pulse {
    0%,100% { box-shadow: 0 0 0 0   rgba(108,99,255,0.5); }
    50%     { box-shadow: 0 0 0 9px rgba(108,99,255,0);   }
}

/* ── BOTTOM CONTROLS ── */
.tb-bottom-controls {
    padding: 12px 20px 20px;
    display: flex; flex-direction: column; gap: 8px;
    background: rgba(240,240,245,0.97);
    border-top: 1px solid var(--tb-border);
}
.tb-link-btn {
    display: inline-flex; align-items: center; gap: 8px;
    color: rgba(0,0,0,0.5); text-decoration: none;
    font-size: 14px; transition: color 0.2s; padding: 4px 0;
}
.tb-link-btn:hover { color: var(--tb-primary); }

/* ── RIGHT PANEL ── */
.tb-right-panel {
    width: 400px;
    background: #f5f5f8;
    padding: 36px 28px;
    overflow-y: auto;
    max-height: 700px;
    display: flex; flex-direction: column;
    border-left: 1px solid var(--tb-border);
}
.tb-right-panel h2 { color: var(--tb-text); font-size: 20px; font-weight: 700; margin: 0 0 10px; }

.tb-welcome-view { text-align: center; }
.tb-welcome-view h2 { font-size: 22px; margin-bottom: 10px; }
.tb-welcome-subtitle { color: var(--tb-muted); font-size: 14px; margin-bottom: 28px; line-height: 1.7; }
.tb-steps { text-align: left; display: flex; flex-direction: column; gap: 10px; }
.tb-step {
    display: flex; align-items: flex-start; gap: 14px;
    padding: 14px 16px; background: #fff; border-radius: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.tb-step-num { color: var(--tb-primary); font-size: 15px; font-weight: 700; flex-shrink: 0; min-width: 24px; padding-top: 1px; }
.tb-step span:last-child { font-size: 14px; color: var(--tb-text); line-height: 1.5; }

.tb-selections-view { flex: 1; display: flex; flex-direction: column; }
.tb-empty-msg { color: var(--tb-muted); font-size: 14px; line-height: 1.6; margin: 0 0 8px; }
.tb-selections-group {
    margin-bottom: 12px; padding: 14px 16px;
    background: #fff; border-radius: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.tb-selections-group h4 {
    font-size: 11px; font-weight: 700; margin: 0 0 10px;
    text-transform: uppercase; letter-spacing: 0.6px; color: var(--tb-primary);
}
.tb-selection-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 7px 0; font-size: 13px; color: #444;
    border-bottom: 1px solid #f0f0f0;
}
.tb-selection-item:last-child { border-bottom: none; }
.tb-selection-remove {
    background: none; border: none; color: #ccc;
    cursor: pointer; font-size: 18px; padding: 0 4px;
    transition: color 0.2s; line-height: 1;
}
.tb-selection-remove:hover { color: #f44; }

.tb-concerns-view { flex: 1; display: flex; flex-direction: column; }
.tb-back-link {
    display: inline-flex; align-items: center; gap: 6px;
    color: var(--tb-primary); text-decoration: none;
    font-size: 14px; font-weight: 500; margin-bottom: 18px;
    transition: opacity 0.2s;
}
.tb-back-link:hover { opacity: 0.7; text-decoration: underline; }
.tb-concerns-list { flex: 1; overflow-y: auto; margin-bottom: 16px; }
.tb-concern-item {
    display: flex; align-items: center;
    padding: 13px 16px; border: 1.5px solid var(--tb-border);
    border-radius: 50px; margin-bottom: 8px; cursor: pointer;
    transition: all 0.18s; gap: 12px; background: #fff;
}
.tb-concern-item:hover { border-color: var(--tb-primary); }
.tb-concern-item.selected { border-color: var(--tb-primary); background: rgba(108,99,255,0.04); }
.tb-concern-checkbox {
    width: 20px; height: 20px; border-radius: 50%;
    border: 2px solid #d0d0d0;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; transition: all 0.18s;
}
.tb-concern-item.selected .tb-concern-checkbox { background: var(--tb-primary); border-color: var(--tb-primary); }
.tb-concern-item.selected .tb-concern-checkbox::after { content:''; width:7px; height:7px; border-radius:50%; background:#fff; }
.tb-concern-name { font-size: 14px; color: var(--tb-text); }

.tb-btn { border:none; padding:14px 20px; border-radius:10px; font-size:15px; font-weight:600; cursor:pointer; transition:all 0.2s; width:100%; text-align:center; }
.tb-btn-submit { background:var(--tb-primary); color:#fff; margin-top:auto; }
.tb-btn-submit:hover { opacity:0.88; transform:translateY(-1px); }
.tb-btn-submit:disabled { opacity:0.6; transform:none; cursor:not-allowed; }
.tb-btn-add { background:#222; color:#fff; flex-shrink:0; }
.tb-btn-add:hover { background:#000; }

.tb-modal { position:fixed; inset:0; background:rgba(0,0,0,0.6); display:flex; align-items:center; justify-content:center; z-index:999999; padding:20px; }
.tb-modal-content { background:#fff; border-radius:20px; padding:40px 36px; max-width:460px; width:100%; text-align:center; box-shadow:0 24px 64px rgba(0,0,0,0.25); }
.tb-modal-content h2 { font-size:22px; margin-bottom:10px; }
.tb-modal-content p  { color:#666; font-size:14px; line-height:1.6; margin-bottom:12px; }
.tb-privacy-note { font-size:12px !important; color:#bbb !important; }
.tb-contact-form { text-align:left; }
.tb-contact-form h2, .tb-contact-form > p { text-align:center; }
.tb-form-row { display:flex; gap:10px; margin-bottom:10px; }
.tb-form-row input { flex:1; padding:12px 16px; border:1.5px solid var(--tb-border); border-radius:10px; font-size:14px; outline:none; transition:border-color 0.2s; color:var(--tb-text); }
.tb-form-row input:focus { border-color:var(--tb-primary); }
.tb-contact-form .tb-btn { margin-top:10px; }
.tb-success-icon { width:60px; height:60px; border-radius:50%; background:#22c55e; color:#fff; font-size:28px; display:flex; align-items:center; justify-content:center; margin:0 auto 16px; }

@media (max-width: 900px) {
    .tb-wrapper { flex-direction:column; min-height:auto; }
    .tb-left-panel { min-height:520px; }
    .tb-right-panel { width:100%; max-height:none; }
}
@media (max-width: 600px) {
    .tb-right-panel { padding:20px 16px; }
    .tb-form-row { flex-direction:column; }
}

/* ══════════════════════════════════════════════
   APP HEADER  — Complete Treat 360
══════════════════════════════════════════════ */
.tb-app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    height: 76px;
    background: #ffffff;
    /* Material Design elevation 2 */
    box-shadow: 0 2px 4px -1px rgba(0,0,0,0.10),
                0 4px 5px 0   rgba(0,0,0,0.06),
                0 1px 10px 0  rgba(0,0,0,0.05);
    position: relative;
    z-index: 100;
}

.tb-app-header-left,
.tb-app-header-right {
    flex: 1;
    display: flex;
    align-items: center;
}
.tb-app-header-right { justify-content: flex-end; }

.tb-app-header-logo {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
}
.tb-header-logo-img {
    height: 60px;
    width: auto;
    max-width: 220px;
    object-fit: contain;
    display: block;
}
.tb-header-logo-text {
    font-size: 16px;
    font-weight: 700;
    color: #1a1a2e;
    letter-spacing: -0.3px;
    white-space: nowrap;
}

.tb-header-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border: none;
    background: none;
    color: #555;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 8px;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
    font-family: inherit;
}
.tb-header-btn:hover {
    background: rgba(108,99,255,0.08);
    color: var(--tb-primary, #6c63ff);
}
.tb-header-btn svg { flex-shrink: 0; }

.tb-header-back { color: #444; }
.tb-header-exit { color: #666; }

@media (max-width: 600px) {
    .tb-app-header { padding: 0 12px; height: 52px; }
    .tb-header-btn span { display: none; }
    .tb-header-btn { padding: 8px; border-radius: 50%; }
    .tb-header-logo-img { height: 28px; }
    .tb-header-logo-text { font-size: 14px; }
}

/* ── Loading progress bar ── */
#tb-load-progress {
    position: absolute;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%);
    width: 160px;
    text-align: center;
    z-index: 10;
}
.tb-load-bar {
    width: 100%;
    height: 4px;
    background: rgba(108,99,255,0.15);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 6px;
}
.tb-load-fill {
    height: 100%;
    width: 0%;
    background: var(--tb-primary, #6c63ff);
    border-radius: 4px;
    transition: width 0.2s ease;
}
.tb-load-pct {
    font-size: 12px;
    color: rgba(108,99,255,0.7);
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* ── Face-view: head "expand" control + back button (v2.6.0) ───────────── */
.tb-hotspot-expand {
    width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
    color: var(--tb-primary);
    background: rgba(255,255,255,0.95);
    animation: tb-expand-pulse 2s ease-out infinite;
}
/* hide the default +/- cross on the expand control */
.tb-hotspot-expand::before, .tb-hotspot-expand::after { display: none; }
.tb-hotspot-expand svg { width: 20px; height: 20px; pointer-events: none; }
.tb-hotspot-expand:hover { background: var(--tb-primary); color: #fff; }

@keyframes tb-expand-pulse {
    0%   { box-shadow: 0 2px 8px rgba(108,99,255,0.25), 0 0 0 0 rgba(108,99,255,0.45); }
    70%  { box-shadow: 0 2px 8px rgba(108,99,255,0.25), 0 0 0 14px rgba(108,99,255,0); }
    100% { box-shadow: 0 2px 8px rgba(108,99,255,0.25), 0 0 0 0 rgba(108,99,255,0); }
}

#tb-viewfull-btn {
    position: absolute; top: 12px; right: 12px; z-index: 20;
    display: none; align-items: center; gap: 6px;
    padding: 7px 14px;
    font-size: 13px; font-weight: 600; line-height: 1;
    color: var(--tb-text);
    background: rgba(255,255,255,0.94);
    border: 1px solid var(--tb-border); border-radius: 20px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    -webkit-tap-highlight-color: transparent;
    transition: color 0.15s, border-color 0.15s;
}
#tb-viewfull-btn:hover { color: var(--tb-primary); border-color: var(--tb-primary); }
#tb-viewfull-btn svg { pointer-events: none; }
