/**
 * Vanilla Editor Styles
 * WordPress-like editor styling
 */

.vanilla-editor-container {
    border: 1px solid #dee2e6;
    border-radius: 4px;
    background: #fff;
    margin-bottom: 1rem;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.vanilla-editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 8px;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    border-radius: 4px 4px 0 0;
    align-items: center;
}

.vanilla-editor-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 4px 8px;
    background: #fff;
    border: 1px solid #ced4da;
    border-radius: 3px;
    cursor: pointer;
    font-size: 14px;
    color: #495057;
    transition: all 0.15s ease-in-out;
    white-space: nowrap;
}

.vanilla-editor-button:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

.vanilla-editor-button:active,
.vanilla-editor-button.active {
    background: #007bff;
    border-color: #007bff;
    color: #fff;
}

.vanilla-editor-button:focus {
    outline: none;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Font Awesome icon styling in buttons */
.vanilla-editor-button i {
    font-size: 14px;
    line-height: 1;
    display: inline-block;
}

.vanilla-editor-format-select {
    height: 32px;
    padding: 4px 8px;
    background: #fff;
    border: 1px solid #ced4da;
    border-radius: 3px;
    cursor: pointer;
    font-size: 14px;
    color: #495057;
    min-width: 120px;
}

.vanilla-editor-format-select:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

.vanilla-editor-format-select:focus {
    outline: none;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
    border-color: #80bdff;
}

.vanilla-editor-separator {
    display: inline-flex;
    align-items: center;
    padding: 0 4px;
    color: #ced4da;
    user-select: none;
}

.vanilla-editor-wrapper {
    position: relative;
}

.vanilla-editor-content {
    padding: 12px;
    min-height: 400px;
    max-height: 600px;
    overflow-y: auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: #212529;
    background: #fff;
    border-radius: 0 0 4px 4px;
}

.vanilla-editor-content:focus {
    outline: none;
}

.vanilla-editor-content p {
    margin: 0 0 1em 0;
}

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

.vanilla-editor-content ul,
.vanilla-editor-content ol {
    margin: 0 0 1em 0;
    padding-left: 2em;
}

.vanilla-editor-content ul {
    list-style-type: disc;
}

.vanilla-editor-content ol {
    list-style-type: decimal;
}

.vanilla-editor-content li {
    margin: 0.25em 0;
}

.vanilla-editor-content a {
    color: #007bff;
    text-decoration: underline;
}

.vanilla-editor-content a:hover {
    color: #0056b3;
}

.vanilla-editor-content strong,
.vanilla-editor-content b {
    font-weight: bold;
}

.vanilla-editor-content em,
.vanilla-editor-content i {
    font-style: italic;
}

.vanilla-editor-content u {
    text-decoration: underline;
}

.vanilla-editor-content s,
.vanilla-editor-content strike {
    text-decoration: line-through;
}

.vanilla-editor-content h1,
.vanilla-editor-content h2,
.vanilla-editor-content h3,
.vanilla-editor-content h4,
.vanilla-editor-content h5,
.vanilla-editor-content h6 {
    margin: 1em 0 0.5em 0;
    font-weight: bold;
    line-height: 1.3;
    color: #212529;
}

.vanilla-editor-content h1:first-child,
.vanilla-editor-content h2:first-child,
.vanilla-editor-content h3:first-child,
.vanilla-editor-content h4:first-child,
.vanilla-editor-content h5:first-child,
.vanilla-editor-content h6:first-child {
    margin-top: 0;
}

.vanilla-editor-content h1 { font-size: 2.5em; }
.vanilla-editor-content h2 { font-size: 2em; }
.vanilla-editor-content h3 { font-size: 1.75em; }
.vanilla-editor-content h4 { font-size: 1.5em; }
.vanilla-editor-content h5 { font-size: 1.25em; }
.vanilla-editor-content h6 { font-size: 1em; }

.vanilla-editor-content blockquote {
    margin: 1em 0;
    padding: 0.5em 1em;
    border-left: 4px solid #007bff;
    background: #f8f9fa;
    color: #495057;
    font-style: italic;
}

.vanilla-editor-content blockquote p {
    margin: 0;
}

.vanilla-editor-content code {
    padding: 2px 4px;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.875em;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 3px;
}

.vanilla-editor-content pre {
    margin: 1em 0;
    padding: 1em;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 3px;
    overflow-x: auto;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.875em;
    line-height: 1.5;
}

.vanilla-editor-content pre code {
    padding: 0;
    background: none;
    border: none;
}

.vanilla-editor-content hr {
    margin: 2em 0;
    border: none;
    border-top: 2px solid #dee2e6;
}

/* Table styles */
.vanilla-editor-content table,
.vanilla-editor-content .vanilla-editor-table {
    width: 100%;
    margin: 1em 0;
    border-collapse: collapse;
    border: 1px solid #dee2e6;
}

.vanilla-editor-content table th,
.vanilla-editor-content table td,
.vanilla-editor-content .vanilla-editor-table th,
.vanilla-editor-content .vanilla-editor-table td {
    padding: 8px 12px;
    border: 1px solid #dee2e6;
    text-align: left;
}

.vanilla-editor-content table th,
.vanilla-editor-content .vanilla-editor-table th {
    background: #f8f9fa;
    font-weight: bold;
    color: #212529;
}

.vanilla-editor-content table tr:nth-child(even),
.vanilla-editor-content .vanilla-editor-table tbody tr:nth-child(even) {
    background: #f8f9fa;
}

.vanilla-editor-content table tr:hover,
.vanilla-editor-content .vanilla-editor-table tbody tr:hover {
    background: #e9ecef;
}

/* Text alignment */
.vanilla-editor-content [style*="text-align: left"] {
    text-align: left;
}

.vanilla-editor-content [style*="text-align: center"] {
    text-align: center;
}

.vanilla-editor-content [style*="text-align: right"] {
    text-align: right;
}

.vanilla-editor-content [style*="text-align: justify"] {
    text-align: justify;
}

/* Images */
.vanilla-editor-content img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 1em 0;
}

.vanilla-editor-content img[style*="float: left"] {
    float: left;
    margin: 0 1em 1em 0;
}

.vanilla-editor-content img[style*="float: right"] {
    float: right;
    margin: 0 0 1em 1em;
}

.vanilla-editor-code-view {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 13px;
    line-height: 1.5;
    resize: vertical;
    border-radius: 0 0 4px 4px;
}

/* Empty state */
.vanilla-editor-content:empty:before {
    content: attr(data-placeholder);
    color: #6c757d;
    font-style: italic;
}

/* Disabled state */
.vanilla-editor-container.vanilla-editor-disabled {
    background: #f8f9fa;
    opacity: 0.85;
}

.vanilla-editor-container.vanilla-editor-disabled .vanilla-editor-toolbar {
    opacity: 0.6;
}

.vanilla-editor-container.vanilla-editor-disabled .vanilla-editor-content {
    background: #f8f9fa;
    cursor: not-allowed;
}

.vanilla-editor-container.vanilla-editor-disabled .vanilla-editor-button,
.vanilla-editor-container.vanilla-editor-disabled .vanilla-editor-format-select {
    cursor: not-allowed;
}

/* Focus state for container */
.vanilla-editor-container:focus-within {
    border-color: #80bdff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Indentation */
.vanilla-editor-content blockquote blockquote {
    margin-left: 2em;
}

.vanilla-editor-content ul ul,
.vanilla-editor-content ul ol,
.vanilla-editor-content ol ul,
.vanilla-editor-content ol ol {
    margin-top: 0.25em;
    margin-bottom: 0.25em;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .vanilla-editor-toolbar {
        gap: 2px;
        padding: 4px;
    }

    .vanilla-editor-button {
        min-width: 28px;
        height: 28px;
        padding: 2px 6px;
        font-size: 12px;
    }

    .vanilla-editor-button i {
        font-size: 12px;
    }

    .vanilla-editor-format-select {
        height: 28px;
        font-size: 12px;
        min-width: 100px;
    }

    .vanilla-editor-content {
        padding: 8px;
    }

    .vanilla-editor-content h1 { font-size: 2em; }
    .vanilla-editor-content h2 { font-size: 1.75em; }
    .vanilla-editor-content h3 { font-size: 1.5em; }
    .vanilla-editor-content h4 { font-size: 1.25em; }

    .vanilla-editor-content table th,
    .vanilla-editor-content table td,
    .vanilla-editor-content .vanilla-editor-table th,
    .vanilla-editor-content .vanilla-editor-table td {
        padding: 4px 8px;
        font-size: 13px;
    }
}

/* Link Dialog Modal */
.vanilla-editor-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.vanilla-editor-link-dialog {
    background: #fff;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.vanilla-editor-dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #dee2e6;
    background: #f8f9fa;
}

.vanilla-editor-dialog-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #212529;
    display: flex;
    align-items: center;
    gap: 8px;
}

.vanilla-editor-dialog-header h3 i {
    color: #007bff;
}

.vanilla-editor-dialog-close {
    background: none;
    border: none;
    font-size: 20px;
    color: #6c757d;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    transition: color 0.15s;
}

.vanilla-editor-dialog-close:hover {
    color: #212529;
}

.vanilla-editor-dialog-body {
    padding: 20px;
    overflow-y: auto;
}

.vanilla-editor-form-group {
    margin-bottom: 16px;
}

.vanilla-editor-form-group:last-child {
    margin-bottom: 0;
}

.vanilla-editor-form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 14px;
    color: #495057;
}

.vanilla-editor-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.vanilla-editor-input:focus {
    outline: none;
    border-color: #80bdff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.vanilla-editor-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.vanilla-editor-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.vanilla-editor-checkbox span {
    font-size: 14px;
    color: #495057;
}

.vanilla-editor-dialog-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 20px;
    border-top: 1px solid #dee2e6;
    background: #f8f9fa;
}

.vanilla-editor-btn {
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.vanilla-editor-btn:focus {
    outline: none;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.vanilla-editor-btn-primary {
    background: #007bff;
    color: #fff;
    border-color: #007bff;
}

.vanilla-editor-btn-primary:hover {
    background: #0056b3;
    border-color: #0056b3;
}

.vanilla-editor-btn-secondary {
    background: #6c757d;
    color: #fff;
    border-color: #6c757d;
}

.vanilla-editor-btn-secondary:hover {
    background: #5a6268;
    border-color: #5a6268;
}

.vanilla-editor-btn-danger {
    background: #dc3545;
    color: #fff;
    border-color: #dc3545;
    margin-right: auto;
}

.vanilla-editor-btn-danger:hover {
    background: #c82333;
    border-color: #c82333;
}

/* Print styles */
@media print {
    .vanilla-editor-toolbar {
        display: none;
    }

    .vanilla-editor-container {
        border: none;
        box-shadow: none;
    }

    .vanilla-editor-content {
        padding: 0;
        max-height: none;
    }

    .vanilla-editor-dialog-overlay {
        display: none;
    }
}
