/**
 * Rich Text Editor Styles for Carwel
 * Supports light and dark themes
 */

.rte-container {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: var(--radius, 0.25rem);
    background: var(--bg-surface, #f8fafc);
    overflow: hidden;
    transition: border-color var(--transition, 300ms);
}

.rte-container:focus-within {
    border-color: var(--primary, #C11A1A);
    box-shadow: 0 0 0 3px rgba(193, 26, 26, 0.1);
}

/* Toolbar */
.rte-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    padding: 0.5rem;
    background: var(--bg-body, #ffffff);
    border-bottom: 1px solid var(--border-color, #e2e8f0);
}

.rte-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: var(--radius, 0.25rem);
    background: var(--bg-surface, #f8fafc);
    color: var(--text-primary, #0f172a);
    cursor: pointer;
    transition: all var(--transition, 300ms);
    font-size: 0.875rem;
    position: relative;
}

.rte-button:hover {
    background: var(--bg-body, #ffffff);
    border-color: var(--primary, #C11A1A);
    color: var(--primary, #C11A1A);
}

.rte-button:active,
.rte-button.active {
    background: var(--primary, #C11A1A);
    border-color: var(--primary, #C11A1A);
    color: #ffffff;
    transform: translateY(1px);
}

.rte-button.active:hover {
    background: var(--primary-dark, #9d1416);
    border-color: var(--primary-dark, #9d1416);
}

.rte-button sub {
    position: absolute;
    bottom: 2px;
    right: 4px;
    font-size: 0.6rem;
    font-weight: 600;
}

.rte-separator {
    width: 1px;
    height: 32px;
    background: var(--border-color, #e2e8f0);
    margin: 0 0.25rem;
}

/* Editor */
.rte-editor {
    min-height: 150px;
    max-height: 400px;
    padding: 1rem;
    overflow-y: auto;
    font-family: inherit;
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--text-primary, #0f172a);
    background: var(--bg-body, #ffffff);
    outline: none;
    text-align: left;
}

.rte-editor:empty:before {
    content: attr(data-placeholder);
    color: var(--text-secondary, #64748b);
    pointer-events: none;
}

/* Scrollbar styling */
.rte-editor::-webkit-scrollbar {
    width: 8px;
}

.rte-editor::-webkit-scrollbar-track {
    background: var(--bg-surface, #f8fafc);
}

.rte-editor::-webkit-scrollbar-thumb {
    background: var(--border-color, #e2e8f0);
    border-radius: 4px;
}

.rte-editor::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary, #64748b);
}

/* Content Formatting */
.rte-editor h1,
.rte-editor h2,
.rte-editor h3,
.rte-editor h4,
.rte-editor h5,
.rte-editor h6 {
    margin: 0.5em 0;
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary, #0f172a);
}

.rte-editor h1 { font-size: 1.875rem; }
.rte-editor h2 { font-size: 1.5rem; }
.rte-editor h3 { font-size: 1.25rem; }
.rte-editor h4 { font-size: 1.125rem; }
.rte-editor h5 { font-size: 1rem; }
.rte-editor h6 { font-size: 0.875rem; }

.rte-editor p {
    margin: 0.5em 0;
}

.rte-editor strong,
.rte-editor b {
    font-weight: 600;
}

.rte-editor em,
.rte-editor i {
    font-style: italic;
}

.rte-editor u {
    text-decoration: underline;
}

.rte-editor del,
.rte-editor s,
.rte-editor strike {
    text-decoration: line-through;
}

.rte-editor code {
    padding: 0.125rem 0.375rem;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.875em;
    background: var(--bg-surface, #f8fafc);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 0.25rem;
    color: var(--primary, #C11A1A);
}

.rte-editor a {
    color: var(--primary, #C11A1A);
    text-decoration: underline;
}

.rte-editor a:hover {
    color: var(--primary-dark, #9d1416);
}

.rte-editor ul,
.rte-editor ol {
    margin: 0.5em 0;
    padding-left: 1.5rem;
}

.rte-editor ul {
    list-style-type: disc;
}

.rte-editor ol {
    list-style-type: decimal;
}

.rte-editor li {
    margin: 0.25em 0;
}

/* Character Counter */
.rte-char-count {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
    color: var(--text-secondary, #64748b);
    background: var(--bg-surface, #f8fafc);
    border-top: 1px solid var(--border-color, #e2e8f0);
    text-align: right;
}

.rte-char-count.over-limit {
    color: #dc2626;
    font-weight: 600;
}

/* Dark Theme Support */
[data-theme="dark"] .rte-container {
    background: var(--bg-surface, #0f0f10);
    border-color: var(--border-color, #24262a);
}

[data-theme="dark"] .rte-toolbar {
    background: var(--bg-body, #000000);
    border-bottom-color: var(--border-color, #24262a);
}

[data-theme="dark"] .rte-button {
    background: var(--bg-surface, #0f0f10);
    border-color: var(--border-color, #24262a);
    color: var(--text-primary, #f5f7fb);
}

[data-theme="dark"] .rte-button:hover {
    background: var(--bg-body, #000000);
}

[data-theme="dark"] .rte-button:active,
[data-theme="dark"] .rte-button.active {
    background: var(--primary, #C11A1A);
    border-color: var(--primary, #C11A1A);
    color: #ffffff;
}

[data-theme="dark"] .rte-button.active:hover {
    background: var(--primary-dark, #9d1416);
    border-color: var(--primary-dark, #9d1416);
}

[data-theme="dark"] .rte-editor {
    background: var(--bg-body, #000000);
    color: var(--text-primary, #f5f7fb);
}

[data-theme="dark"] .rte-editor code {
    background: var(--bg-surface, #0f0f10);
    border-color: var(--border-color, #24262a);
}

[data-theme="dark"] .rte-char-count {
    background: var(--bg-surface, #0f0f10);
    border-top-color: var(--border-color, #24262a);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .rte-toolbar {
        padding: 0.375rem;
    }

    .rte-button {
        width: 28px;
        height: 28px;
        font-size: 0.8125rem;
    }

    .rte-editor {
        padding: 0.75rem;
        font-size: 0.875rem;
    }
}

/* Markdown Preview Styles (for vehicle.html) */
.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4,
.markdown-content h5,
.markdown-content h6 {
    margin: 0.75em 0 0.5em;
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary);
}

.markdown-content h1 { font-size: 1.875rem; }
.markdown-content h2 { font-size: 1.5rem; }
.markdown-content h3 { font-size: 1.25rem; }
.markdown-content h4 { font-size: 1.125rem; }
.markdown-content h5 { font-size: 1rem; }
.markdown-content h6 { font-size: 0.875rem; }

.markdown-content p {
    margin: 0.75em 0;
    line-height: 1.6;
}

.markdown-content strong,
.markdown-content b {
    font-weight: 600;
}

.markdown-content em,
.markdown-content i {
    font-style: italic;
}

.markdown-content u {
    text-decoration: underline;
}

.markdown-content del,
.markdown-content s {
    text-decoration: line-through;
}

.markdown-content code {
    padding: 0.125rem 0.375rem;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.875em;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
    color: var(--primary);
}

.markdown-content a {
    color: var(--primary);
    text-decoration: underline;
}

.markdown-content a:hover {
    color: var(--primary-dark);
}

.markdown-content ul,
.markdown-content ol {
    margin: 0.75em 0;
    padding-left: 1.5rem;
}

.markdown-content ul {
    list-style-type: disc;
}

.markdown-content ol {
    list-style-type: decimal;
}

.markdown-content li {
    margin: 0.5em 0;
    line-height: 1.6;
}
