/* ============================================================================
   TOOL CORE CSS - Shared styles for all LoreBench tools
   ============================================================================
   Uses site CSS variables (--lb-*) for theming consistency.
   All tools should import this file for consistent UI.
   ============================================================================ */

/* ============================================================================
   CONTAINER & LAYOUT
   ============================================================================ */

.lb-tool-container {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: var(--lb-font-family);
}

/* Canvas touch support - prevent browser default gestures */
.lb-tool-container canvas,
canvas[id*="Canvas"],
canvas[id*="canvas"] {
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* ============================================================================
   TOP TOOLBAR
   ============================================================================ */

.lb-tool-toolbar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: var(--lb-spacing-md);
    padding: var(--lb-spacing-sm) var(--lb-spacing-md);
    background: var(--lb-bg-elevated);
    border-bottom: 1px solid var(--lb-border-default);
    backdrop-filter: blur(8px);
}

.lb-tool-toolbar-group {
    display: flex;
    align-items: center;
    gap: var(--lb-spacing-sm);
}

.lb-tool-toolbar-separator {
    width: 1px;
    height: 20px;
    background: var(--lb-border-default);
}

.lb-tool-toolbar-label {
    color: var(--lb-text-muted);
    font-size: var(--lb-font-size-xs);
}

.lb-tool-toolbar-spacer {
    flex: 1;
}

/* ============================================================================
   BUTTONS
   ============================================================================ */

.lb-tool-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 28px;
    padding: 0 var(--lb-spacing-sm);
    background: var(--lb-bg-elevated-2);
    color: var(--lb-text-primary);
    border: 1px solid var(--lb-border-subtle);
    border-radius: var(--lb-radius-sm);
    cursor: pointer;
    font-family: var(--lb-font-family);
    font-size: var(--lb-font-size-sm);
    white-space: nowrap;
    transition: all var(--lb-transition-fast);
}

.lb-tool-btn:hover {
    background: var(--lb-bg-hover);
    border-color: var(--lb-accent-primary);
    color: var(--lb-accent-primary);
}

.lb-tool-btn:active {
    background: var(--lb-accent-primary-dark);
}

.lb-tool-btn.active,
.lb-tool-btn[data-active="true"],
.lb-tool-btn[data-active="1"] {
    background: rgba(212, 175, 55, 0.2);
    border-color: var(--lb-accent-primary);
    color: var(--lb-accent-primary);
}

.lb-tool-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.lb-tool-btn-sm {
    height: 24px;
    min-width: 24px;
    padding: 0 var(--lb-spacing-xs);
    font-size: var(--lb-font-size-xs);
}

.lb-tool-btn-icon {
    width: 28px;
    padding: 0;
}

.lb-tool-btn-group {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.lb-tool-btn.small {
    height: 24px;
    padding: 0 6px;
    font-size: var(--lb-font-size-xs);
}

/* ============================================================================
   MODE LABELS & SECTION HEADERS
   ============================================================================ */

.lb-tool-mode-label {
    color: var(--lb-text-muted);
    font-size: 11px;
    font-weight: var(--lb-font-weight-medium);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.lb-tool-section-label {
    color: var(--lb-text-muted);
    font-size: 10px;
    font-weight: var(--lb-font-weight-medium);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 4px;
}

.lb-tool-separator {
    height: 1px;
    background: var(--lb-border-default);
    margin: 4px 0;
}

/* ============================================================================
   SIDE PANELS (Left info panel, Right selector panel)
   ============================================================================ */

.lb-tool-panel {
    position: absolute;
    top: 48px; /* Below toolbar */
    z-index: 10;
    display: flex;
    flex-direction: column;
    max-height: calc(100% - 80px);
    overflow: hidden;
    background: var(--lb-bg-elevated);
    border: 1px solid var(--lb-border-default);
    border-radius: var(--lb-radius-md);
    backdrop-filter: blur(8px);
}

.lb-tool-panel-left {
    left: var(--lb-spacing-md);
    width: 220px;
}

.lb-tool-panel-right {
    right: var(--lb-spacing-md);
    width: 260px;
}

.lb-tool-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--lb-spacing-sm) var(--lb-spacing-md);
    border-bottom: 1px solid var(--lb-border-default);
    flex-shrink: 0;
}

.lb-tool-panel-title {
    color: var(--lb-accent-primary);
    font-size: var(--lb-font-size-xs);
    font-weight: var(--lb-font-weight-semibold);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.lb-tool-panel-collapse {
    width: 20px;
    height: 20px;
    padding: 0;
    background: transparent;
    border: none;
    color: var(--lb-text-muted);
    cursor: pointer;
    font-size: 10px;
    transition: color var(--lb-transition-fast);
}

.lb-tool-panel-collapse:hover {
    color: var(--lb-accent-primary);
}

.lb-tool-panel-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--lb-spacing-sm) var(--lb-spacing-md);
}

.lb-tool-panel-section {
    margin-bottom: var(--lb-spacing-md);
}

.lb-tool-panel-section-title {
    color: var(--lb-text-muted);
    font-size: var(--lb-font-size-xs);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: var(--lb-spacing-xs);
}

/* ============================================================================
   SELECTOR / TREE LIST
   ============================================================================ */

.lb-tool-selector-search {
    padding: var(--lb-spacing-sm) var(--lb-spacing-md);
    border-bottom: 1px solid var(--lb-border-default);
    flex-shrink: 0;
}

.lb-tool-selector-input {
    width: 100%;
    padding: var(--lb-spacing-xs) var(--lb-spacing-sm);
    background: var(--lb-bg-elevated-2);
    border: 1px solid var(--lb-border-subtle);
    border-radius: var(--lb-radius-sm);
    color: var(--lb-text-primary);
    font-size: var(--lb-font-size-sm);
    outline: none;
    box-sizing: border-box;
}

.lb-tool-selector-input:focus {
    border-color: var(--lb-accent-primary);
}

.lb-tool-selector-input::placeholder {
    color: var(--lb-text-muted);
}

.lb-tool-selector-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.lb-tool-selector-item {
    display: flex;
    align-items: center;
    padding: var(--lb-spacing-xs) var(--lb-spacing-xs);
    border-radius: var(--lb-radius-sm);
    color: var(--lb-text-primary);
    font-size: var(--lb-font-size-xs);
    min-height: 24px;
    cursor: pointer;
    transition: all var(--lb-transition-fast);
}

.lb-tool-selector-item:hover {
    background: var(--lb-bg-hover);
}

.lb-tool-selector-item.selected,
.lb-tool-selector-item[data-selected="true"] {
    background: rgba(var(--lb-accent-primary), 0.15);
    border-left: 2px solid var(--lb-accent-primary);
}

.lb-tool-selector-item-toggle {
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: var(--lb-text-muted);
    flex-shrink: 0;
    transition: transform var(--lb-transition-fast);
}

.lb-tool-selector-item-toggle.expanded {
    transform: rotate(90deg);
}

.lb-tool-selector-item-icon {
    margin-right: var(--lb-spacing-xs);
    font-size: 9px;
    flex-shrink: 0;
    width: 12px;
    text-align: center;
}

.lb-tool-selector-item-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lb-tool-selector-item-lock {
    width: 18px;
    height: 18px;
    padding: 0;
    background: transparent;
    border: none;
    color: var(--lb-text-subtle);
    cursor: pointer;
    font-size: 10px;
    flex-shrink: 0;
    transition: color var(--lb-transition-fast);
}

.lb-tool-selector-item-lock:hover {
    color: var(--lb-accent-primary);
}

.lb-tool-selector-item-lock.locked {
    color: var(--lb-accent-primary);
}

/* Indent levels for tree */
.lb-tool-selector-item[data-indent="1"] { padding-left: calc(var(--lb-spacing-xs) + 10px); }
.lb-tool-selector-item[data-indent="2"] { padding-left: calc(var(--lb-spacing-xs) + 20px); }
.lb-tool-selector-item[data-indent="3"] { padding-left: calc(var(--lb-spacing-xs) + 30px); }
.lb-tool-selector-item[data-indent="4"] { padding-left: calc(var(--lb-spacing-xs) + 40px); }

/* ============================================================================
   INFO PANEL (Object details)
   ============================================================================ */

.lb-tool-info-row {
    display: flex;
    justify-content: space-between;
    padding: var(--lb-spacing-xs) 0;
    font-size: var(--lb-font-size-xs);
    border-bottom: 1px solid var(--lb-border-subtle);
}

.lb-tool-info-label {
    color: var(--lb-text-muted);
}

.lb-tool-info-value {
    color: var(--lb-text-primary);
    text-align: right;
}

.lb-tool-info-value.accent {
    color: var(--lb-accent-primary);
}

/* ============================================================================
   HINT BAR (Bottom)
   ============================================================================ */

.lb-tool-hint {
    position: absolute;
    bottom: var(--lb-spacing-md);
    left: var(--lb-spacing-md);
    padding: var(--lb-spacing-sm) var(--lb-spacing-md);
    background: var(--lb-bg-elevated);
    border: 1px solid var(--lb-border-default);
    border-radius: var(--lb-radius-md);
    backdrop-filter: blur(8px);
    color: var(--lb-text-muted);
    font-size: var(--lb-font-size-xs);
}

.lb-tool-hint-accent {
    color: var(--lb-accent-primary);
}

/* ============================================================================
   INPUTS
   ============================================================================ */

.lb-tool-input {
    padding: var(--lb-spacing-xs) var(--lb-spacing-sm);
    background: var(--lb-bg-input);
    border: 1px solid var(--lb-border-default);
    border-radius: var(--lb-radius-sm);
    color: var(--lb-text-primary);
    font-family: var(--lb-font-family);
    font-size: var(--lb-font-size-sm);
    outline: none;
}

.lb-tool-input:focus {
    border-color: var(--lb-accent-primary);
}

.lb-tool-input-sm {
    height: 24px;
    padding: 0 var(--lb-spacing-xs);
    font-size: var(--lb-font-size-xs);
}

.lb-tool-select {
    padding: var(--lb-spacing-xs) var(--lb-spacing-sm);
    background: var(--lb-bg-input);
    border: 1px solid var(--lb-border-default);
    border-radius: var(--lb-radius-sm);
    color: var(--lb-text-primary);
    font-family: var(--lb-font-family);
    font-size: var(--lb-font-size-sm);
    outline: none;
    cursor: pointer;
}

.lb-tool-select:focus {
    border-color: var(--lb-accent-primary);
}

/* ============================================================================
   CHECKBOX / TOGGLE
   ============================================================================ */

.lb-tool-checkbox {
    display: flex;
    align-items: center;
    gap: var(--lb-spacing-xs);
    cursor: pointer;
    font-size: var(--lb-font-size-sm);
    color: var(--lb-text-secondary);
}

.lb-tool-checkbox input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: var(--lb-accent-primary);
}

.lb-tool-toggle {
    position: relative;
    width: 36px;
    height: 20px;
    background: var(--lb-bg-elevated-3);
    border-radius: var(--lb-radius-full);
    cursor: pointer;
    transition: background var(--lb-transition-fast);
}

.lb-tool-toggle.active {
    background: var(--lb-accent-primary);
}

.lb-tool-toggle-slider {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: var(--lb-text-primary);
    border-radius: var(--lb-radius-full);
    transition: transform var(--lb-transition-fast);
}

.lb-tool-toggle.active .lb-tool-toggle-slider {
    transform: translateX(16px);
}

/* ============================================================================
   DIVIDERS
   ============================================================================ */

.lb-tool-divider {
    height: 1px;
    background: var(--lb-border-default);
    margin: var(--lb-spacing-sm) 0;
}

/* ============================================================================
   COLLAPSED STATE
   ============================================================================ */

.lb-tool-panel.collapsed {
    width: 40px;
}

.lb-tool-panel.collapsed .lb-tool-panel-content,
.lb-tool-panel.collapsed .lb-tool-selector-search,
.lb-tool-panel.collapsed .lb-tool-panel-title {
    display: none;
}

/* ============================================================================
   ZOOM DISPLAY
   ============================================================================ */

.lb-tool-zoom-display {
    min-width: 50px;
    text-align: center;
    color: var(--lb-accent-primary);
    font-size: var(--lb-font-size-xs);
    font-family: var(--lb-font-family-mono);
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */

@media (max-width: 768px) {
    .lb-tool-panel-left,
    .lb-tool-panel-right {
        width: 200px;
    }

    .lb-tool-toolbar {
        padding: var(--lb-spacing-xs) var(--lb-spacing-sm);
        gap: var(--lb-spacing-sm);
    }
}
