:root {
    --surface: #ffffff;
    --surface-muted: #f4f6fb;
    --border: #e3e8f2;
    --text-main: #1c2333;
    --text-muted: #5f6b85;
    --primary: #0d47fb;
    --primary-dark: #0a2fa3;
    --accent: #8b5cf6;
    --shadow-soft: 0 20px 45px rgba(15, 23, 42, 0.08);
    --shadow-hover: 0 4px 12px rgba(13, 71, 251, 0.15);
    --gradient: linear-gradient(135deg, #0d47fb 0%, #8b5cf6 100%);
}

.bbcode-editor-section {
    margin-bottom: 40px;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: var(--shadow-soft);
    padding: 32px;
    transition: background 0.3s ease, border 0.3s ease;
}

.tool-card {
    margin-bottom: 40px;
}

.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 16px;
}

.header-left h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 4px;
}

.header-left p {
    font-size: 14px;
}

.header-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn-header {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-muted);
    color: var(--text-main);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-header:hover {
    background: rgba(13, 71, 251, 0.08);
    border-color: var(--primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-hover);
}

.btn-header i {
    font-size: 14px;
}

.editor-container {
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
    background: var(--surface);
    display: flex;
    flex-direction: column;
    min-height: auto;
    height: auto;
}

.editor-toolbar {
    background: var(--surface-muted);
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.toolbar-group {
    display: flex;
    gap: 4px;
    align-items: center;
}

.toolbar-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
}

.toolbar-btn:hover {
    background: rgba(13, 71, 251, 0.08);
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-1px);
}

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

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

.color-wrapper {
    position: relative;
}

.color-picker {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

.size-select {
    height: 36px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text-main);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.size-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13, 71, 251, 0.15);
}

.editor-main {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    overflow: hidden;
}

.editor-pane {
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    background: var(--surface);
    min-height: 0;
    overflow: hidden;
}

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

.pane-header {
    background: var(--surface-muted);
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.pane-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
}

.pane-title i {
    color: var(--text-muted);
    font-size: 13px;
}

.pane-actions {
    display: flex;
    gap: 4px;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 12px;
}

.btn-icon:hover {
    background: rgba(13, 71, 251, 0.08);
    border-color: var(--primary);
    color: var(--primary);
}

.editor-textarea {
    flex: 1;
    width: 100%;
    border: none;
    outline: none;
    resize: none;
    padding: 20px;
    
    font-size: 14px;
    line-height: 1.6;
    background: var(--surface);
    color: var(--text-main);
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.editor-textarea::placeholder {
    color: var(--text-muted);
    opacity: 0.6;
}

.preview-content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--surface);
    line-height: 1.7;
    color: var(--text-main);
    min-height: 0;
    max-height: 100%;
    word-wrap: break-word;
}

/* Custom scrollbar for preview */
.preview-content::-webkit-scrollbar {
    width: 8px;
}

.preview-content::-webkit-scrollbar-track {
    background: var(--surface-muted);
    border-radius: 4px;
}

.preview-content::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
    transition: background 0.2s ease;
}

.preview-content::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Custom scrollbar for textarea */
.editor-textarea::-webkit-scrollbar {
    width: 8px;
}

.editor-textarea::-webkit-scrollbar-track {
    background: var(--surface-muted);
    border-radius: 4px;
}

.editor-textarea::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
    transition: background 0.2s ease;
}

.editor-textarea::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.preview-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    text-align: center;
}

.preview-placeholder i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.preview-placeholder p {
    font-size: 16px;
    margin: 0;
}

.preview-content .bbcode-bold {
    font-weight: 700;
}

.preview-content .bbcode-italic {
    font-style: italic;
}

.preview-content .bbcode-underline {
    text-decoration: underline;
}

.preview-content .bbcode-strikethrough {
    text-decoration: line-through;
}

.preview-content .bbcode-code {
    background: var(--surface-muted);
    padding: 2px 6px;
    border-radius: 4px;
    
    font-size: 0.9em;
}

.preview-content .bbcode-quote {
    border-left: 4px solid var(--primary);
    margin: 16px 0;
    padding: 12px 16px;
    background: var(--surface-muted);
    border-radius: 4px;
}

.preview-content .bbcode-list {
    margin: 12px 0;
    padding-left: 24px;
}

.preview-content .bbcode-center {
    text-align: center;
}

.preview-content .bbcode-right {
    text-align: right;
}

.preview-content .bbcode-url {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s ease;
}

.preview-content .bbcode-url:hover {
    text-decoration: underline;
    color: var(--primary-dark);
}

.preview-content .bbcode-img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 8px 0;
    display: block;
}

.preview-content pre {
    overflow-x: auto;
    max-width: 100%;
}

.preview-content table {
    max-width: 100%;
    overflow-x: auto;
    display: block;
}

.preview-content details {
    margin: 12px 0;
    padding: 12px;
    background: var(--surface-muted);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.preview-content details summary {
    cursor: pointer;
    font-weight: 600;
    padding: 4px 0;
}

.editor-statusbar {
    background: var(--surface-muted);
    border-top: 1px solid var(--border);
    padding: 10px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted);
}

.status-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-item {
    font-weight: 500;
}

.status-separator {
    opacity: 0.5;
}

.emoji-picker {
    display: none;
    position: absolute;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    z-index: 1000;
    max-width: 320px;
    max-height: 400px;
    overflow-y: auto;
}

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

.emoji-btn {
    padding: 8px;
    border: none;
    background: none;
    font-size: 20px;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.2s ease;
}

.emoji-btn:hover {
    background: var(--surface-muted);
}

@media (max-width: 767px) {
    .panel {
        padding: 20px;
    }

    .editor-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .header-actions {
        width: 100%;
    }

    .btn-header {
        flex: 1;
        justify-content: center;
    }

    .btn-text {
        display: none;
    }

    .editor-container {
        min-height: auto;
    }

    .editor-main {
        grid-template-columns: 1fr;
        min-height: auto;
        max-height: none;
    }

    .editor-pane {
        border-right: none;
        border-bottom: 1px solid var(--border);
        min-height: 300px;
        max-height: 50vh;
    }

    .editor-pane:last-child {
        border-bottom: none;
    }

    .editor-textarea {
        min-height: 300px;
        font-size: 13px;
        padding: 16px;
    }

    .preview-content {
        min-height: 300px;
        padding: 16px;
        font-size: 14px;
        max-height: 100%;
    }

    .editor-toolbar {
        padding: 10px 12px;
        gap: 6px;
    }

    .toolbar-btn {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }

    .size-select {
        height: 32px;
        padding: 0 8px;
        font-size: 12px;
    }

    .editor-statusbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .status-group {
        width: 100%;
    }

    .emoji-picker {
        max-width: calc(100vw - 40px);
        max-height: 300px;
    }

    .emoji-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}

@media (max-width: 480px) {
    .panel {
        padding: 16px;
    }

    .editor-toolbar {
        padding: 8px;
    }

    .toolbar-group {
        gap: 2px;
    }

    .toolbar-separator {
        margin: 0 2px;
    }

    .emoji-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

