/* =================================================================
   WORD BUBBLE EDITOR - Shared CSS
   Version 1.0 - December 2025
   Used by: SentenceReviewBuilder, TeacherPlanBuilder
   ================================================================= */

/* === LAYOUT === */
.wbe-layout {
    display: flex;
    flex-direction: column;
    width: 100%;
    background: var(--bg-tertiary, #f3f4f6);
    border-radius: 12px;
    padding: 16px;
    position: relative;
}

/* === BUBBLES ROW === */
.wbe-bubbles-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: flex-start;
    min-height: 50px;
    padding: 8px 0;
    position: relative;
    z-index: 3;
}

/* === WORD BUBBLE === */
.wbe-word-bubble {
    position: relative;
    min-width: 60px;
    max-width: 180px;
    padding: 8px 14px;
    background: var(--bg-primary, #fff);
    border: 2px solid var(--primary, #6366f1);
    border-radius: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 2;
}

.wbe-word-bubble:hover {
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25);
    border-color: var(--primary-dark, #4a47a3);
}

.wbe-word-bubble.function-word {
    background: var(--bg-tertiary, #f3f4f6);
    border-style: dashed;
    border-color: var(--border-color, #e5e7eb);
}

.wbe-word-bubble.function-word:hover {
    border-color: var(--text-secondary, #6b7280);
}

.wbe-word-bubble.needs-resolution {
    border-color: var(--warning, #f59e0b);
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2);
}

.wbe-word-bubble.selected {
    border-color: var(--warning, #f59e0b);
    background: rgba(245, 158, 11, 0.1);
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.3);
}

/* === BUBBLE TEXT === */
.wbe-bubble-text {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary, #111827);
    word-break: break-word;
}

.wbe-root-hint {
    display: block;
    font-size: 0.7rem;
    font-weight: 400;
    color: var(--text-secondary, #6b7280);
    margin-top: 2px;
}

.wbe-affix-hint {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--lw-affix-color, #8b5cf6);
    background: rgba(139, 92, 246, 0.1);
    padding: 1px 4px;
    border-radius: 4px;
    margin-left: 4px;
}

.wbe-bubble-warning {
    position: absolute;
    top: -6px;
    right: -6px;
    font-size: 12px;
}

/* === BUBBLE ACTIONS === */
.wbe-bubble-actions {
    position: absolute;
    top: -10px;
    right: -10px;
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.15s;
}

.wbe-word-bubble:hover .wbe-bubble-actions {
    opacity: 1;
}

.wbe-bubble-actions button {
    width: 22px;
    height: 22px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    transition: transform 0.15s, background 0.15s;
}

.wbe-bubble-edit-btn {
    background: var(--primary, #6366f1);
    color: white;
}

.wbe-bubble-edit-btn:hover {
    background: var(--primary-dark, #4a47a3);
    transform: scale(1.1);
}

.wbe-bubble-link-btn {
    background: var(--success, #22c55e);
    color: white;
}

.wbe-bubble-link-btn:hover {
    background: #16a34a;
    transform: scale(1.1);
}

.wbe-bubble-delete-btn {
    background: var(--error, #e53935);
    color: white;
}

.wbe-bubble-delete-btn:hover {
    background: #c62828;
    transform: scale(1.1);
}

/* === DRAG HANDLE === */
.wbe-drag-handle {
    position: absolute;
    left: -8px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary, #6b7280);
    opacity: 0;
    transition: opacity 0.15s;
    cursor: grab;
    font-size: 10px;
}

.wbe-word-bubble:hover .wbe-drag-handle {
    opacity: 1;
}

.wbe-drag-handle:active {
    cursor: grabbing;
}

/* === SORTABLE STATES === */
.wbe-sortable-ghost {
    opacity: 0.4;
}

.wbe-sortable-chosen {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transform: scale(1.05);
}

/* === WORD GROUP ([] Choices) === */
.wbe-word-group {
    display: flex;
    gap: 4px;
    padding: 6px;
    background: rgba(245, 158, 11, 0.1);
    border: 2px dashed var(--warning, #f59e0b);
    border-radius: 12px;
    position: relative;
}

.wbe-word-group .wbe-word-bubble {
    border-color: var(--warning, #f59e0b);
}

.wbe-group-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: var(--warning, #f59e0b);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 10px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s, background 0.15s;
}

.wbe-group-badge:hover {
    background: #d97706;
    transform: scale(1.1);
}

/* === ADD WORD BUTTON === */
.wbe-add-word-btn {
    width: 36px;
    height: 36px;
    border: 2px dashed var(--primary, #6366f1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--primary, #6366f1);
    font-size: 14px;
    transition: all 0.2s;
    background: transparent;
}

.wbe-add-word-btn:hover {
    background: rgba(99, 102, 241, 0.1);
    transform: scale(1.1);
}

/* === CONNECTION LINES SVG === */
.wbe-connection-lines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.wbe-connection-line {
    stroke: var(--primary, #6366f1);
    stroke-width: 2;
    stroke-opacity: 0.4;
    stroke-linecap: round;
}

/* === PICTURES ROW === */
.wbe-pictures-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: flex-start;
    min-height: 70px;
    padding: 12px 0 0 0;
    border-top: 1px dashed var(--border-color, #e5e7eb);
    margin-top: 12px;
    position: relative;
    z-index: 2;
}

/* === PICTURE SLOT === */
.wbe-picture-slot {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.wbe-picture-slot.no-picture {
    width: 30px;
    height: 30px;
    justify-content: center;
}

.wbe-slot-card {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    background: white;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.wbe-slot-card:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.wbe-slot-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.wbe-slot-label {
    font-size: 10px;
    color: var(--text-secondary, #6b7280);
    text-align: center;
    max-width: 60px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wbe-multi-link-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 18px;
    height: 18px;
    background: var(--primary, #6366f1);
    color: white;
    border-radius: 50%;
    font-size: 10px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.wbe-no-picture-dot {
    width: 6px;
    height: 6px;
    background: var(--border-color, #e5e7eb);
    border-radius: 50%;
    opacity: 0.5;
}

/* === TOOLBAR === */
.wbe-toolbar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color, #e5e7eb);
}

.wbe-toolbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid var(--border-color, #e5e7eb);
    background: var(--bg-primary, #fff);
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    color: var(--text-primary, #111827);
}

.wbe-toolbar-btn:hover {
    border-color: var(--primary, #6366f1);
    color: var(--primary, #6366f1);
    background: rgba(99, 102, 241, 0.05);
}

.wbe-toolbar-btn.disabled,
.wbe-toolbar-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.wbe-toolbar-btn.disabled:hover,
.wbe-toolbar-btn:disabled:hover {
    border-color: var(--border-color, #e5e7eb);
    color: var(--text-primary, #111827);
    background: var(--bg-primary, #fff);
}

.wbe-toolbar-btn.group-btn {
    border-color: var(--warning, #f59e0b);
    color: #92400e;
    background: rgba(245, 158, 11, 0.1);
}

.wbe-toolbar-btn.group-btn:hover:not(.disabled) {
    background: rgba(245, 158, 11, 0.2);
}

.wbe-toolbar-btn.affix-btn {
    border-color: var(--lw-affix-color, #8b5cf6);
    color: #6b21a8;
    background: rgba(139, 92, 246, 0.1);
}

.wbe-toolbar-btn.affix-btn:hover:not(.disabled) {
    background: rgba(139, 92, 246, 0.2);
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .wbe-layout {
        padding: 12px;
    }

    .wbe-word-bubble {
        padding: 6px 10px;
        min-width: 50px;
    }

    .wbe-bubble-text {
        font-size: 0.85rem;
    }

    .wbe-slot-card {
        width: 40px;
        height: 40px;
    }

    .wbe-toolbar {
        flex-direction: column;
    }

    .wbe-toolbar-btn {
        width: 100%;
        justify-content: center;
    }
}
