/* Editor Container */
.editor-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    position: relative;
    overflow: hidden;
}

/* Formatting Toolbar */
.formatting-toolbar {
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 8px;
    border-right: 1px solid #dee2e6;
}

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

.toolbar-group.search-group {
    margin-left: auto;
    border-right: none;
    border-left: 1px solid #dee2e6;
    padding-left: 12px;
}

/* Font Controls */
.font-select, .size-select {
    border: 1px solid #ced4da;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 12px;
    background: #ffffff;
    color: #495057;
    cursor: pointer;
    transition: all 0.2s ease;
}

.font-select {
    min-width: 120px;
}

.size-select {
    min-width: 60px;
}

.font-select:hover, .size-select:hover {
    border-color: #adb5bd;
}

.font-select:focus, .size-select:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.25);
}

/* Format Buttons */
.format-btn {
    background: #ffffff;
    border: 1px solid #dee2e6;
    padding: 6px 8px;
    border-radius: 4px;
    cursor: pointer;
    color: #495057;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
}

.format-btn:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

.format-btn.active {
    background: #667eea;
    border-color: #667eea;
    color: #ffffff;
}

.format-btn:active {
    transform: translateY(1px);
}

.format-btn i {
    font-size: 12px;
}

/* Color Pickers */
.color-picker {
    width: 32px;
    height: 32px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    cursor: pointer;
    background: none;
    padding: 0;
    overflow: hidden;
}

.color-picker::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-picker::-webkit-color-swatch {
    border: none;
    border-radius: 3px;
}

/* Search Group */
.search-input {
    border: 1px solid #ced4da;
    border-radius: 4px 0 0 4px;
    padding: 6px 10px;
    font-size: 12px;
    background: #ffffff;
    color: #495057;
    width: 200px;
    transition: all 0.2s ease;
}

.search-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.25);
    outline: none;
}

.search-btn {
    background: #ffffff;
    border: 1px solid #ced4da;
    padding: 6px 8px;
    cursor: pointer;
    color: #495057;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
}

.search-btn:first-of-type {
    border-left: none;
    border-radius: 0;
}

.search-btn:last-of-type {
    border-radius: 0 4px 4px 0;
}

.search-btn:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

.search-btn i {
    font-size: 12px;
}

/* Editor Wrapper */
.editor-wrapper {
    flex: 1;
    padding: 20px;
    background: #ffffff;
    overflow: auto;
    position: relative;
}

/* TinyMCE Editor Styling */
#editor {
    width: 100%;
    height: 100%;
    border: none;
    resize: none;
    font-family: 'Times New Roman', serif;
    font-size: 12pt;
    line-height: 1.6;
    color: #212529;
    background: #ffffff;
    outline: none;
}

/* TinyMCE Container Overrides */
.tox-tinymce {
    border: none !important;
    border-radius: 0 !important;
}

.tox-editor-header {
    display: none !important;
}

.tox-toolbar-overlord {
    display: none !important;
}

.tox-statusbar {
    display: none !important;
}

.tox-edit-area {
    border: none !important;
}

.tox-edit-area__iframe {
    background: #ffffff !important;
}

/* Document Styling Inside Editor */
.mce-content-body {
    font-family: 'Times New Roman', serif !important;
    font-size: 12pt !important;
    line-height: 1.6 !important;
    max-width: 8.5in !important;
    margin: 0 auto !important;
    padding: 1in !important;
    background: #ffffff !important;
    min-height: 11in !important;
    box-shadow: 0 0 10px rgba(0,0,0,0.1) !important;
}

/* Print Layout Styles */
.print-layout .editor-wrapper {
    background: #e9ecef;
    padding: 40px;
}

.print-layout .mce-content-body {
    background: #ffffff !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15) !important;
    border-radius: 4px !important;
}

/* Web Layout Styles */
.web-layout .mce-content-body {
    max-width: none !important;
    padding: 20px !important;
    box-shadow: none !important;
    min-height: auto !important;
}

/* Focus Mode */
.focus-mode .formatting-toolbar {
    opacity: 0.3;
    transition: opacity 0.3s ease;
}

.focus-mode .formatting-toolbar:hover {
    opacity: 1;
}

.focus-mode .editor-wrapper {
    padding: 60px;
}

.focus-mode .mce-content-body {
    max-width: 700px !important;
    font-size: 14pt !important;
    line-height: 1.8 !important;
}

/* Ruler */
.ruler {
    height: 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    position: relative;
    overflow: hidden;
}

.ruler-marks {
    height: 100%;
    background-image: repeating-linear-gradient(
        to right,
        #adb5bd 0px,
        #adb5bd 1px,
        transparent 1px,
        transparent 10px
    );
    background-size: 10px 100%;
}

.ruler-numbers {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 100%;
    font-size: 10px;
    color: #6c757d;
    line-height: 20px;
}

/* Grammar and Spell Check Indicators */
.grammar-error {
    border-bottom: 2px wavy #dc3545 !important;
}

.spelling-error {
    border-bottom: 2px wavy #fd7e14 !important;
}

.style-suggestion {
    border-bottom: 2px wavy #28a745 !important;
}

/* Word Count Popup */
.word-count-popup {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
    min-width: 300px;
}

.word-count-popup h3 {
    margin-bottom: 16px;
    color: #212529;
    font-size: 16px;
}

.word-count-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.stat-item {
    text-align: center;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 6px;
}

.stat-number {
    display: block;
    font-size: 20px;
    font-weight: 600;
    color: #667eea;
}

.stat-label {
    font-size: 12px;
    color: #6c757d;
    margin-top: 4px;
}

/* Find and Replace Panel */
.find-replace-panel {
    position: absolute;
    top: 0;
    right: 0;
    width: 300px;
    background: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 0 0 0 8px;
    box-shadow: -2px 2px 8px rgba(0,0,0,0.1);
    z-index: 500;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.find-replace-panel.show {
    transform: translateX(0);
}

.find-replace-header {
    padding: 12px 16px;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: between;
    align-items: center;
}

.find-replace-header h4 {
    font-size: 14px;
    color: #212529;
    margin: 0;
}

.find-replace-close {
    background: none;
    border: none;
    color: #6c757d;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
}

.find-replace-close:hover {
    background: #e9ecef;
    color: #495057;
}

.find-replace-content {
    padding: 16px;
}

.find-replace-input {
    width: 100%;
    border: 1px solid #ced4da;
    border-radius: 4px;
    padding: 8px 10px;
    font-size: 12px;
    margin-bottom: 8px;
}

.find-replace-buttons {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
}

.find-replace-btn {
    flex: 1;
    background: #667eea;
    border: none;
    color: white;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    transition: all 0.2s ease;
}

.find-replace-btn:hover {
    background: #5a6fd8;
}

.find-replace-btn.secondary {
    background: #6c757d;
}

.find-replace-btn.secondary:hover {
    background: #5a6268;
}

/* Responsive Design */
@media (max-width: 768px) {
    .formatting-toolbar {
        padding: 6px 8px;
        gap: 8px;
    }
    
    .toolbar-group {
        gap: 4px;
        padding: 0 6px;
    }
    
    .search-group {
        width: 100%;
        margin-top: 8px;
        border-left: none;
        border-top: 1px solid #dee2e6;
        padding-top: 8px;
        padding-left: 0;
    }
    
    .search-input {
        width: 150px;
    }
    
    .editor-wrapper {
        padding: 12px;
    }
    
    .find-replace-panel {
        width: 100%;
        position: fixed;
        top: auto;
        bottom: 0;
        right: 0;
        border-radius: 8px 8px 0 0;
    }
}

/* Dark Mode */
@media (prefers-color-scheme: dark) {
    .editor-container {
        background: #1a202c;
    }
    
    .formatting-toolbar {
        background: #2d3748;
        border-bottom-color: #4a5568;
    }
    
    .format-btn, .search-btn {
        background: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }
    
    .format-btn:hover, .search-btn:hover {
        background: #4a5568;
    }
    
    .font-select, .size-select, .search-input {
        background: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }
    
    .editor-wrapper {
        background: #1a202c;
    }
    
    #editor {
        background: #1a202c;
        color: #e2e8f0;
    }
}
