/* Enhanced Text block styles */
.text-block-content {
    position: relative;
}

.text-content {
    min-height: 0;
    outline: none;
    line-height: 1.6;
    color: var(--color-text);
    display: block;
    word-wrap: break-word;
    overflow-wrap: break-word;
    transition: all 0.2s ease;
    cursor: text;
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    pointer-events: auto;
    position: relative;
    z-index: 10;
}

/* Ensure text content always receives pointer events */
.text-content * {
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    pointer-events: auto;
}

/* Disable dragging on text blocks when editing */
.text-block[draggable="false"] {
    cursor: default;
}

.text-block[draggable="false"] .text-content {
    cursor: text;
}

/* Ensure text selection is always visible */
.text-content *::selection {
    background: var(--color-accent);
    color: white;
}

.text-content *::-moz-selection {
    background: var(--color-accent);
    color: white;
}

.text-content::selection {
    background: var(--color-accent);
    color: white;
}

.text-content::-moz-selection {
    background: var(--color-accent);
    color: white;
}

.text-content:focus {
    background: var(--color-accent-light);
    border-radius: var(--border-radius);
    padding: var(--spacing-xs);
    margin: calc(-1 * var(--spacing-xs));
    box-shadow: 0 0 0 2px var(--color-accent);
}

.text-content:empty:before {
    content: "Click to edit text...";
    color: var(--color-text-light);
    font-style: italic;
}

/* Formatting Toolbar */
.text-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 8px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    margin-bottom: 8px;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
    animation: slideDown 0.2s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.toolbar-btn {
    padding: 6px 8px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s ease;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    min-width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    outline: none;
}

.toolbar-btn:focus {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

.toolbar-btn:hover {
    background: var(--color-hover);
    border-color: var(--color-accent);
}

.toolbar-btn:active {
    background: var(--color-accent-light);
    transform: translateY(1px);
}

.toolbar-separator {
    width: 1px;
    height: 20px;
    background: var(--color-border);
    margin: 0 4px;
}

/* Toolbar Select Dropdowns */
.toolbar-select {
    padding: 4px 8px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s ease;
    outline: none;
    min-width: 80px;
    height: 28px;
    pointer-events: auto;
    position: relative;
    z-index: 200;
}

.font-family-select {
    min-width: 100px;
}

.font-size-select {
    min-width: 60px;
}

.toolbar-select:hover {
    background: var(--color-hover);
    border-color: var(--color-accent);
}

.toolbar-select:focus {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

/* Color Picker Styling */
.color-picker-container {
    position: relative;
    display: inline-block;
}

.color-picker-btn {
    min-width: 32px;
    height: 28px;
    padding: 6px;
}

.color-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    border: none;
    outline: none;
}

/* Enhanced toolbar layout */
.text-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    margin-bottom: 8px;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
    animation: slideDown 0.2s ease;
    align-items: center;
}

/* Responsive toolbar */
@media (max-width: 768px) {
    .text-toolbar {
        gap: 4px;
        padding: 8px;
    }
    
    .toolbar-select {
        font-size: 11px;
        min-width: 60px;
        height: 26px;
    }
    
    .font-family-select {
        min-width: 80px;
    }
    
    .toolbar-btn {
        min-width: 26px;
        height: 26px;
        font-size: 11px;
    }
}

.text-content h1,
.text-content h2,
.text-content h3,
.text-content h4,
.text-content h5,
.text-content h6 {
    margin: 0;
    font-weight: 600;
    line-height: 1.3;
}

.text-content h1 { font-size: 2em; }
.text-content h2 { font-size: 1.5em; }
.text-content h3 { font-size: 1.25em; }

.text-content p {
    margin: 0;
}

.text-content p:last-child {
    margin-bottom: 0;
}

.text-content ul,
.text-content ol {
    margin: 0 0 0 var(--spacing-lg);
    padding: 0;
}

.text-content li {
    margin-bottom: 0;
}

.text-content a {
    color: var(--color-accent);
    text-decoration: none;
}

.text-content a:hover {
    text-decoration: underline;
}

.text-content strong {
    font-weight: 600;
}

.text-content em {
    font-style: italic;
}

.text-content code {
    background: var(--color-bg-secondary);
    padding: 2px 4px;
    border-radius: var(--border-radius);
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    font-size: 0.9em;
}

.text-content blockquote {
    border-left: 3px solid var(--color-border);
    padding-left: var(--spacing-md);
    margin: var(--spacing-md) 0;
    color: var(--color-text-light);
    font-style: italic;
}