/* ============================================ */
/* RICH TEXT EDITOR STYLES */
/* ============================================ */

.rte-container {
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: white;
    overflow: hidden;
}

/* Toolbar */
.rte-toolbar {
    background: var(--bg-gray);
    border-bottom: 2px solid var(--border-color);
    padding: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.rte-toolbar-group {
    display: flex;
    gap: 4px;
    padding: 0 8px;
    border-right: 1px solid var(--border-color);
}

.rte-toolbar-group:last-child {
    border-right: none;
}

.rte-btn {
    background: white;
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-dark);
    font-size: 14px;
    min-width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.rte-btn:hover {
    background: var(--primary-green);
    color: white;
    border-color: var(--primary-green);
}

.rte-btn:active {
    transform: scale(0.95);
}

.rte-btn.active {
    background: var(--primary-green);
    color: white;
    border-color: var(--primary-green);
}

/* Label for dropdowns */
.rte-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dark);
    margin-right: 8px;
    white-space: nowrap;
}

.rte-select {
    background: white;
    border: 2px solid var(--border-color);
    padding: 10px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 700;
    color: #000000;
    min-width: 100px;
    height: 44px;
    line-height: 24px;
    appearance: menulist;
    -webkit-appearance: menulist;
    -moz-appearance: menulist;
}

.rte-select:hover {
    border-color: var(--primary-green);
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.2);
}

.rte-select:focus {
    outline: none;
    border-color: var(--primary-green);
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
}

.rte-select option {
    color: #000000;
    background: white;
    font-weight: 700;
    font-size: 18px;
    padding: 12px;
    line-height: 28px;
}

/* Color Button */
.rte-color-btn {
    position: relative;
}

.color-indicator {
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 3px;
    border-radius: 2px;
    border: 1px solid rgba(0, 0, 0, 0.2);
}

/* Color Picker */
.rte-color-picker {
    position: fixed;
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    z-index: 100000;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 5px;
    width: 240px;
    animation: colorPickerFadeIn 0.2s ease-out;
}

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

.color-option {
    width: 24px;
    height: 24px;
    border: 2px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    transition: transform 0.2s;
}

.color-option:hover {
    transform: scale(1.2);
    border-color: var(--primary-green);
}

/* Editor Content Area */
.rte-editor {
    min-height: 200px;
    max-height: 500px;
    overflow-y: auto;
    padding: 20px;
    font-size: 15px;
    line-height: 1.7;
    color: var(--text-dark);
    outline: none;
}

.rte-editor:empty:before {
    content: attr(data-placeholder);
    color: var(--text-light);
    font-style: italic;
}

.rte-editor:focus {
    outline: none;
}

/* Formatting in editor */
.rte-editor img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 10px 0;
}

.rte-editor a {
    color: var(--primary-green);
    text-decoration: underline;
}

.rte-editor a:hover {
    color: var(--dark-green);
}

.rte-editor ul,
.rte-editor ol {
    margin: 10px 0;
    padding-left: 30px;
}

.rte-editor li {
    margin: 5px 0;
}

.rte-editor blockquote {
    border-left: 4px solid var(--primary-green);
    padding-left: 15px;
    margin: 15px 0;
    color: var(--text-light);
    font-style: italic;
}

/* Підтримка різних розмірів шрифту */
.rte-editor font,
.rte-editor span[style*="font-size"] {
    display: inline;
}

/* Підтримка кольорів */
.rte-editor font[color],
.rte-editor span[style*="color"] {
    display: inline;
}

/* Spoiler */
.spoiler {
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    margin: 15px 0;
    overflow: hidden;
    background: #f9fafb;
}

.spoiler-header {
    background: linear-gradient(135deg, #6b7280, #9ca3af);
    color: white;
    padding: 10px 15px;
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    user-select: none;
}

.spoiler-header:hover {
    background: linear-gradient(135deg, #4b5563, #6b7280);
}

.spoiler-content {
    padding: 15px;
    display: none;
}

.spoiler.revealed .spoiler-content {
    display: block;
}

.spoiler.revealed .spoiler-header i {
    transform: rotate(180deg);
}

/* Video Container */
.video-container {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 */
    height: 0;
    overflow: hidden;
    margin: 15px 0;
    border-radius: 8px;
}

.video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 8px;
}

/* Attachments */
.rte-attachments {
    padding: 15px;
    background: var(--bg-gray);
    border-top: 2px solid var(--border-color);
}

.rte-attachment {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 15px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-bottom: 8px;
}

.rte-attachment:last-child {
    margin-bottom: 0;
}

.rte-attachment i {
    color: var(--primary-green);
    font-size: 18px;
}

.rte-attachment .file-name {
    flex: 1;
    font-weight: 600;
    color: var(--text-dark);
}

.rte-attachment .file-size {
    color: var(--text-light);
    font-size: 13px;
}

.remove-attachment {
    background: none;
    border: none;
    color: #dc2626;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: background 0.2s;
}

.remove-attachment:hover {
    background: #fee2e2;
}

/* Footer */
.rte-footer {
    padding: 10px 15px;
    background: var(--bg-gray);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
}

.rte-char-count {
    font-size: 13px;
    color: var(--text-light);
}

.rte-char-count .current-count {
    font-weight: 600;
    color: var(--text-dark);
}

/* Image in editor */
.rte-image {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 10px 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: transform 0.3s;
}

.rte-image:hover {
    transform: scale(1.02);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .rte-toolbar {
        padding: 8px;
        gap: 6px;
    }

    .rte-toolbar-group {
        padding: 0 6px;
    }

    .rte-btn {
        padding: 6px 10px;
        min-width: 32px;
        height: 32px;
        font-size: 13px;
    }

    .rte-select {
        min-width: 100px;
        height: 32px;
        font-size: 13px;
    }

    .rte-editor {
        min-height: 150px;
        padding: 15px;
    }

    /* Hide text labels on mobile */
    .rte-toolbar-group:nth-child(2) {
        max-width: 100px;
    }
}

@media (max-width: 480px) {
    .rte-toolbar {
        gap: 4px;
    }

    .rte-toolbar-group {
        padding: 0 4px;
        gap: 2px;
    }

    .rte-btn {
        padding: 6px 8px;
        min-width: 30px;
        height: 30px;
        font-size: 12px;
    }

    .rte-select {
        min-width: 80px;
        height: 30px;
        font-size: 12px;
    }

    .rte-color-picker {
        grid-template-columns: repeat(6, 1fr);
        width: 180px;
    }
}

/* Content Display Styles (for viewing formatted content) */
.formatted-content {
    font-size: 15px;
    line-height: 1.7;
    color: var(--text-dark);
    word-wrap: break-word;
}

.formatted-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 10px 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.formatted-content a {
    color: var(--primary-green);
    text-decoration: underline;
}

.formatted-content a:hover {
    color: var(--dark-green);
}

.formatted-content ul,
.formatted-content ol {
    margin: 10px 0;
    padding-left: 30px;
}

.formatted-content li {
    margin: 5px 0;
}

/* Підтримка різних розмірів шрифту */
.formatted-content font,
.formatted-content span[style*="font-size"] {
    display: inline;
}

/* Підтримка кольорів */
.formatted-content font[color],
.formatted-content span[style*="color"] {
    display: inline;
}

.formatted-content .spoiler {
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    margin: 15px 0;
    overflow: hidden;
    background: #f9fafb;
}

.formatted-content .spoiler-header {
    background: linear-gradient(135deg, #6b7280, #9ca3af);
    color: white;
    padding: 10px 15px;
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    user-select: none;
}

.formatted-content .spoiler-header:hover {
    background: linear-gradient(135deg, #4b5563, #6b7280);
}

.formatted-content .spoiler-content {
    padding: 15px;
    display: none;
}

.formatted-content .spoiler.revealed .spoiler-content {
    display: block;
}

.formatted-content .video-container {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    margin: 15px 0;
    border-radius: 8px;
}

.formatted-content .video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 8px;
}

