/* ===========================================
   OSRS Chatlogger - Rich Text Editor Styles
   BBCode/WYSIWYG Editor with Forum Features
   =========================================== */

/* ========== Editor Container ========== */
.rich-editor-container {
    background: rgba(26, 15, 7, 0.8);
    border: 1px solid #4a3321;
    border-radius: 8px;
    overflow: hidden;
}

/* ========== Toolbar ========== */
.editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 8px;
    background: linear-gradient(180deg, #3a2515 0%, #2d1f11 100%);
    border-bottom: 1px solid #4a3321;
}

.editor-toolbar-group {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    padding: 2px 4px;
    border-right: 1px solid #4a3321;
    margin-bottom: 2px;
}

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

/* Responsive toolbar - stack on smaller screens */
@media (max-width: 768px) {
    .editor-toolbar {
        justify-content: center;
    }
    .editor-toolbar-group {
        border-right: none;
        border-bottom: 1px solid #4a3321;
        padding-bottom: 4px;
        margin-bottom: 4px;
    }
}

.editor-btn {
    min-width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1a0f07;
    border: 1px solid #4a3321;
    border-radius: 4px;
    color: #c9aa71;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
    padding: 0 6px;
    white-space: nowrap;
}

/* Wide buttons with text */
.editor-btn-wide {
    min-width: auto;
    padding: 0 10px;
    gap: 4px;
}

.editor-btn-wide .btn-icon {
    font-size: 14px;
}

.editor-btn-wide .btn-text {
    font-size: 12px;
}

.editor-btn:hover {
    background: #4a3321;
    border-color: #c9aa71;
    color: #f5deb3;
}

.editor-btn.active {
    background: #c9aa71;
    color: #1a0f07;
    border-color: #f5deb3;
}

.editor-btn[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 4px 8px;
    background: #1a0f07;
    border: 1px solid #4a3321;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    z-index: 100;
}

/* ========== Color/Size Dropdowns ========== */
.editor-dropdown {
    position: relative;
}

.editor-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    background: #2d1f11;
    border: 1px solid #4a3321;
    border-radius: 4px;
    padding: 8px;
    z-index: 1000;
    display: none;
    min-width: 150px;
    max-width: 280px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

/* Position dropdowns that would overflow to the right */
.editor-toolbar-group:nth-last-child(-n+3) .editor-dropdown-menu {
    left: auto;
    right: 0;
}

.editor-dropdown.open .editor-dropdown-menu {
    display: block;
}

.color-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
}

.color-swatch {
    width: 20px;
    height: 20px;
    border-radius: 3px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.color-swatch:hover {
    transform: scale(1.2);
    border-color: white;
}

.font-size-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.font-size-item {
    padding: 4px 8px;
    cursor: pointer;
    border-radius: 3px;
    color: #c9aa71;
}

.font-size-item:hover {
    background: #4a3321;
}

/* ========== Editor Content Area ========== */
.editor-content {
    min-height: 200px;
    max-height: 500px;
    overflow-y: auto;
    padding: 16px;
    color: #c9aa71;
    font-size: 14px;
    line-height: 1.6;
}

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

.editor-content:empty::before {
    content: attr(data-placeholder);
    color: #8b7355;
    pointer-events: none;
}

/* ========== BBCode Preview ========== */
.bbcode-preview {
    padding: 16px;
    background: #1a0f07;
    border-top: 1px solid #4a3321;
    color: #c9aa71;
    min-height: 100px;
}

/* ========== BBCode Rendered Styles ========== */
.bb-bold { font-weight: bold; }
.bb-italic { font-style: italic; }
.bb-underline { text-decoration: underline; }
.bb-strike { text-decoration: line-through; }

.bb-quote {
    border-left: 4px solid #c9aa71;
    padding: 12px 16px;
    margin: 8px 0;
    background: rgba(74, 51, 33, 0.3);
    border-radius: 0 4px 4px 0;
}

.bb-quote-author {
    font-weight: bold;
    color: #f5deb3;
    margin-bottom: 8px;
}

.bb-code {
    font-family: 'Courier New', monospace;
    background: #0d0705;
    padding: 12px;
    border-radius: 4px;
    overflow-x: auto;
    display: block;
    margin: 8px 0;
    border: 1px solid #4a3321;
}

.bb-code-inline {
    font-family: 'Courier New', monospace;
    background: #0d0705;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.9em;
}

.bb-spoiler {
    background: #4a3321;
    color: #4a3321;
    padding: 2px 8px;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.3s;
}

.bb-spoiler.revealed,
.bb-spoiler:hover {
    color: #c9aa71;
    background: #2d1f11;
}

.bb-url {
    color: #fbbf24;
    text-decoration: underline;
}

.bb-url:hover {
    color: #fcd34d;
}

.bb-img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    margin: 8px 0;
}

.bb-center { text-align: center; }
.bb-left { text-align: left; }
.bb-right { text-align: right; }

.bb-list {
    margin: 8px 0;
    padding-left: 24px;
}

.bb-list li {
    margin: 4px 0;
}

/* YouTube Embed */
.bb-youtube {
    position: relative;
    width: 100%;
    max-width: 640px;
    padding-bottom: 56.25%;
    margin: 12px 0;
    border-radius: 8px;
    overflow: hidden;
}

.bb-youtube iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* ========== Media Insert Modal ========== */
.editor-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.editor-modal-content {
    background: #2d1f11;
    border: 2px solid #4a3321;
    border-radius: 8px;
    padding: 24px;
    max-width: 500px;
    width: 90%;
}

.editor-modal-title {
    font-size: 18px;
    font-weight: bold;
    color: #f5deb3;
    margin-bottom: 16px;
}

.editor-modal input,
.editor-modal textarea {
    width: 100%;
    padding: 10px;
    margin-bottom: 12px;
    background: #1a0f07;
    border: 1px solid #4a3321;
    border-radius: 4px;
    color: #c9aa71;
}

.editor-modal-buttons {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* ========== Emoji Picker ========== */
.emoji-dropdown-menu {
    width: 280px !important;
    max-width: 280px !important;
}

.emoji-picker {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
    max-height: 200px;
    overflow-y: auto;
    padding: 8px;
}

.emoji-btn {
    font-size: 20px;
    padding: 4px;
    background: transparent;
    border: none;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

.emoji-btn:hover {
    background: #4a3321;
}

/* ========== BBCode Rendered Styles (for display) ========== */
.bbcode-quote {
    border-left: 4px solid #c9aa71;
    padding: 12px 16px;
    margin: 8px 0;
    background: rgba(74, 51, 33, 0.3);
    border-radius: 0 4px 4px 0;
}

.bbcode-quote cite {
    display: block;
    font-weight: bold;
    color: #f5deb3;
    margin-bottom: 8px;
    font-style: normal;
}

.bbcode-code {
    background: #1a0f07;
    border: 1px solid #4a3321;
    padding: 12px 16px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    overflow-x: auto;
    white-space: pre;
}

.bbcode-spoiler {
    background: #2d1f11;
    border: 1px solid #4a3321;
    border-radius: 4px;
    margin: 8px 0;
}

.bbcode-spoiler summary {
    padding: 8px 12px;
    cursor: pointer;
    color: #c9aa71;
    font-weight: bold;
}

.bbcode-spoiler summary:hover {
    background: #4a3321;
}

.bbcode-spoiler[open] > summary {
    border-bottom: 1px solid #4a3321;
}

.bbcode-spoiler > *:not(summary) {
    padding: 12px;
}

.video-embed {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    max-width: 100%;
    margin: 8px 0;
}

.video-embed iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* ========== Character Counter ========== */
.editor-footer {
    display: flex;
    justify-content: space-between;
    padding: 8px 16px;
    background: #1a0f07;
    border-top: 1px solid #4a3321;
    font-size: 12px;
    color: #8b7355;
}

.char-count.warning { color: #fbbf24; }
.char-count.danger { color: #ef4444; }

/* ========== Special Role Badges (Animated) ========== */
.special-role-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Developer Badge - Rainbow Gradient Animation */
.badge-developer {
    background: linear-gradient(90deg, #ff0000, #ff7f00, #ffff00, #00ff00, #0000ff, #4b0082, #9400d3, #ff0000);
    background-size: 400% 100%;
    animation: rainbow-shift 3s linear infinite;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

@keyframes rainbow-shift {
    0% { background-position: 0% 50%; }
    100% { background-position: 400% 50%; }
}

/* Donator Badge - Gold Shimmer */
.badge-donator {
    background: linear-gradient(90deg, #b8860b, #ffd700, #ffec8b, #ffd700, #b8860b);
    background-size: 200% 100%;
    animation: gold-shimmer 2s ease-in-out infinite;
    color: #1a0f07;
    text-shadow: 0 1px 1px rgba(255,255,255,0.3);
}

@keyframes gold-shimmer {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

/* VIP Badge - Purple Glow */
.badge-vip {
    background: linear-gradient(135deg, #9333ea, #c084fc, #9333ea);
    background-size: 200% 200%;
    animation: purple-pulse 2s ease-in-out infinite;
    color: #fff;
    box-shadow: 0 0 10px rgba(147, 51, 234, 0.5);
}

@keyframes purple-pulse {
    0%, 100% { 
        background-position: 0% 50%;
        box-shadow: 0 0 10px rgba(147, 51, 234, 0.5);
    }
    50% { 
        background-position: 100% 50%;
        box-shadow: 0 0 20px rgba(147, 51, 234, 0.8);
    }
}

/* Moderator Badge - Blue Wave with Silver Crown */
.badge-moderator {
    background: linear-gradient(90deg, #1e40af, #3b82f6, #60a5fa, #3b82f6, #1e40af);
    background-size: 200% 100%;
    animation: blue-wave 2.5s ease-in-out infinite, osrs-bounce 0.6s ease-in-out infinite;
    color: #fff;
    padding-left: 24px;
    position: relative;
}

.badge-moderator::before {
    content: '';
    position: absolute;
    left: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    background: url('/static/images/silver_crown.png') no-repeat center;
    background-size: contain;
}

@keyframes blue-wave {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

/* Admin Badge - Red Fire with Gold Crown */
.badge-admin {
    background: linear-gradient(135deg, #dc2626, #f97316, #fbbf24, #f97316, #dc2626);
    background-size: 300% 300%;
    animation: fire-flicker 1.5s ease-in-out infinite, osrs-bounce 0.6s ease-in-out infinite;
    color: #fff;
    text-shadow: 0 0 4px rgba(0,0,0,0.5);
    padding-left: 24px;
    position: relative;
}

.badge-admin::before {
    content: '';
    position: absolute;
    left: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    background: url('/static/images/gold_crown.png') no-repeat center;
    background-size: contain;
}

@keyframes fire-flicker {
    0%, 100% { background-position: 0% 50%; }
    25% { background-position: 50% 100%; }
    50% { background-position: 100% 50%; }
    75% { background-position: 50% 0%; }
}

/* OSRS-style bounce animation */
@keyframes osrs-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-1px); }
}

/* Helper Badge - Green Glow */
.badge-helper {
    background: linear-gradient(90deg, #15803d, #22c55e, #86efac, #22c55e, #15803d);
    background-size: 200% 100%;
    animation: green-glow 2s ease-in-out infinite;
    color: #fff;
}

@keyframes green-glow {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

/* Verified Badge - Cyan Pulse */
.badge-verified {
    background: linear-gradient(90deg, #0891b2, #22d3ee, #67e8f9, #22d3ee, #0891b2);
    background-size: 200% 100%;
    animation: cyan-pulse 2s ease-in-out infinite;
    color: #1a0f07;
}

@keyframes cyan-pulse {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

/* OG Badge - Retro */
.badge-og {
    background: linear-gradient(45deg, #78716c, #a8a29e, #d6d3d1, #a8a29e, #78716c);
    background-size: 200% 200%;
    animation: retro-flash 3s ease-in-out infinite;
    color: #1a0f07;
    border: 1px solid #57534e;
}

@keyframes retro-flash {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 100%; }
}

/* Badge hover effects */
.special-role-badge:hover {
    transform: scale(1.1);
    transition: transform 0.2s ease;
}

/* Multiple badges container */
.user-badges {
    display: inline-flex;
    gap: 4px;
    flex-wrap: wrap;
}

/* Owner Badge - Golden with animation */
.badge-owner {
    background: linear-gradient(135deg, #ffd700 0%, #ff8c00 25%, #ffd700 50%, #ff6600 75%, #ffd700 100%);
    background-size: 200% 200%;
    animation: owner-gradient 3s ease infinite;
    color: #000;
    font-weight: bold;
    text-shadow: 0 1px 0 rgba(255,255,255,0.3);
    border: 1px solid #ff8c00;
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.5);
}

@keyframes owner-gradient {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Animated badges for all special roles */
.badge-donator {
    background: linear-gradient(90deg, #ec4899, #f472b6, #ec4899);
    background-size: 200% 100%;
    animation: badge-shimmer 2s linear infinite;
    color: #fff;
}

.badge-vip {
    background: linear-gradient(90deg, #8b5cf6, #a78bfa, #8b5cf6);
    background-size: 200% 100%;
    animation: badge-shimmer 2s linear infinite;
    color: #fff;
}

.badge-helper {
    background: linear-gradient(90deg, #10b981, #34d399, #10b981);
    background-size: 200% 100%;
    animation: badge-shimmer 2s linear infinite;
    color: #fff;
}

.badge-og {
    background: linear-gradient(90deg, #f59e0b, #fbbf24, #f59e0b);
    background-size: 200% 100%;
    animation: badge-shimmer 2s linear infinite;
    color: #000;
}

.badge-verified {
    background: linear-gradient(90deg, #3b82f6, #60a5fa, #3b82f6);
    background-size: 200% 100%;
    animation: badge-shimmer 2s linear infinite;
    color: #fff;
}

@keyframes badge-shimmer {
    0% { background-position: 0% 50%; }
    100% { background-position: 200% 50%; }
}

/* Enhanced Quote Styles - Phase 2 */
.bbcode-quote {
    background: linear-gradient(135deg, #1a1209 0%, #2d1f11 100%);
    border-left: 4px solid #d97706;
    border-radius: 8px;
    margin: 16px 0;
    padding: 0;
    overflow: hidden;
}

.bbcode-quote .quote-header {
    background: rgba(217, 119, 6, 0.15);
    padding: 8px 16px;
    border-bottom: 1px solid rgba(217, 119, 6, 0.3);
    font-size: 13px;
    color: #d97706;
}

.bbcode-quote .quote-author {
    font-weight: bold;
    color: #fbbf24;
}

.bbcode-quote .quote-content {
    padding: 12px 16px;
    color: #c9aa71;
    font-style: italic;
    line-height: 1.6;
}

/* Nested quotes */
.bbcode-quote .bbcode-quote {
    margin: 12px 0;
    background: rgba(0, 0, 0, 0.2);
    border-left-color: #8b7355;
}

.bbcode-quote .bbcode-quote .quote-header {
    background: rgba(139, 115, 85, 0.15);
    border-bottom-color: rgba(139, 115, 85, 0.3);
    color: #8b7355;
}

.bbcode-quote .bbcode-quote .quote-author {
    color: #c9aa71;
}
