/* Text Editor Styles */

/* Page Header */
.page-header {
    text-align: center;
    margin-bottom: 40px;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    margin-bottom: 20px;
    padding: 8px 16px;
    border-radius: 8px;
    transition: all 0.3s;
}

.back-link:hover {
    color: var(--accent-color);
    background: var(--bg-primary);
    transform: translateX(-4px);
}

.back-link svg {
    width: 20px;
    height: 20px;
}

.page-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 10px 0;
}

.page-description {
    color: var(--text-secondary);
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
}

/* Editor Container */
.editor-container {
    max-width: 1200px;
    margin: 0 auto;
}

/* Toolbar */
.editor-toolbar {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px 12px 0 0;
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

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

.toolbar-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
    color: var(--text-primary);
}

.toolbar-btn:hover {
    background: var(--bg-primary);
    border-color: var(--border-color);
}

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

.toolbar-btn svg {
    width: 18px;
    height: 18px;
}

.toolbar-divider {
    width: 1px;
    height: 24px;
    background: var(--border-color);
}

/* Toolbar Select Dropdowns */
.toolbar-select {
    height: 36px;
    padding: 0 12px;
    background: var(--card-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
}

.toolbar-select:hover {
    background: var(--bg-primary);
    border-color: var(--accent-color);
}

.toolbar-select:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.1);
}

.toolbar-select option {
    background: var(--card-bg);
    color: var(--text-primary);
    padding: 8px;
}

#fontSelect {
    min-width: 160px;
}

#fontSizeSelect {
    min-width: 80px;
}

#formatBlock {
    min-width: 140px;
}

/* Dropdown Menu */
.dropdown-wrapper {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px var(--shadow-color);
    min-width: 180px;
    padding: 8px;
    display: none;
    flex-direction: column;
    gap: 4px;
    z-index: 1000;
}

.dropdown-menu.active {
    display: flex;
}

.dropdown-item {
    background: transparent;
    border: none;
    padding: 10px 14px;
    text-align: left;
    color: var(--text-primary);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s;
    white-space: nowrap;
}

.dropdown-item:hover {
    background: var(--accent-color);
    color: white;
}

/* Color Picker */
.color-picker-wrapper {
    position: relative;
}

.color-indicator {
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 3px;
    border-radius: 2px;
    background: currentColor;
}

#textColorIndicator {
    background: #000000;
}

#highlightIndicator {
    background: #ffff00;
}

/* Modal Dialogs */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeIn 0.2s ease;
}

.modal-dialog {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    min-width: 400px;
    max-width: 90%;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.125rem;
    color: var(--text-primary);
    font-weight: 600;
}

.modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.form-input {
    padding: 10px 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.875rem;
    outline: none;
    transition: all 0.2s ease;
    font-family: inherit;
}

.form-input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.1);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    color: var(--text-primary);
    cursor: pointer;
}

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

.btn-primary {
    padding: 10px 20px;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    padding: 10px 20px;
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background: var(--bg-primary);
    border-color: var(--accent-color);
}

/* Editor Wrapper */
.editor-wrapper {
    background: var(--card-bg);
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    min-height: 500px;
    position: relative;
    overflow: auto;
}

/* Rich Text Editor Content */
.editor-content {
    flex: 1;
    padding: 40px 60px;
    border: none;
    outline: none;
    background: var(--card-bg);
    color: var(--text-primary);
    font-family: 'Calibri', sans-serif;
    font-size: 16px;
    line-height: 1.6;
    min-height: 500px;
    max-width: 100%;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

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

.editor-content p {
    margin: 0 0 1em 0;
    min-height: 1.6em;
}

.editor-content p:empty::before {
    content: attr(data-placeholder);
    color: var(--text-secondary);
    opacity: 0.5;
}

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

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

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

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

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

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

.editor-content h1,
.editor-content h2,
.editor-content h3,
.editor-content h4,
.editor-content h5,
.editor-content h6 {
    margin: 0.75em 0 0.5em 0;
    font-weight: bold;
}

.editor-content h1 {
    font-size: 2em;
}

.editor-content h2 {
    font-size: 1.75em;
}

.editor-content h3 {
    font-size: 1.5em;
}

.editor-content h4 {
    font-size: 1.25em;
}

.editor-content h5 {
    font-size: 1.1em;
}

.editor-content h6 {
    font-size: 1em;
}

.editor-content pre {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 12px;
    margin: 1em 0;
    overflow-x: auto;
    font-family: 'Courier New', monospace;
}

.editor-content blockquote {
    border-left: 4px solid var(--accent-color);
    margin: 1em 0;
    padding: 0.5em 1em;
    background: var(--bg-primary);
    font-style: italic;
}

.editor-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 1em 0;
}

.editor-content table th,
.editor-content table td {
    border: 1px solid var(--border-color);
    padding: 8px;
}

.editor-content table th {
    background: var(--bg-primary);
    font-weight: bold;
    text-align: left;
}

.editor-content hr {
    border: none;
    border-top: 2px solid var(--border-color);
    margin: 2em 0;
}

.editor-content a {
    color: var(--accent-color);
    text-decoration: underline;
}

.editor-content a:hover {
    opacity: 0.8;
}

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

.editor-content sub,
.editor-content sup {
    font-size: 0.75em;
}

/* Status Bar */
.editor-statusbar {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 0 0 12px 12px;
    padding: 8px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.status-left,
.status-right {
    display: flex;
    gap: 16px;
}

.status-item {
    white-space: nowrap;
}

/* Find & Replace Panel */
.find-panel {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-top: none;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    animation: slideDown 0.3s ease;
}

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

.find-row,
.replace-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.find-input {
    flex: 1;
    padding: 8px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.875rem;
    outline: none;
    transition: border-color 0.3s;
}

.find-input:focus {
    border-color: var(--accent-color);
}

.find-actions {
    display: flex;
    gap: 4px;
    align-items: center;
}

.find-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
    color: var(--text-primary);
}

.find-btn:hover {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: white;
}

.find-btn svg {
    width: 16px;
    height: 16px;
}

.find-btn.close-btn {
    font-size: 20px;
    font-weight: bold;
}

.find-count {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    min-width: 40px;
    text-align: center;
}

.replace-action-btn {
    padding: 6px 12px;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.8125rem;
    cursor: pointer;
    transition: opacity 0.3s;
}

.replace-action-btn:hover {
    opacity: 0.9;
}

.find-options {
    display: flex;
    gap: 16px;
    padding-left: 4px;
}

.find-option {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.find-option input[type="checkbox"] {
    cursor: pointer;
}

/* Statistics Panel */
.stats-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    min-width: 400px;
    max-width: 90%;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.stats-header,
.settings-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stats-header h3,
.settings-header h3 {
    margin: 0;
    font-size: 1.125rem;
    color: var(--text-primary);
}

.close-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    font-size: 20px;
    color: var(--text-primary);
    transition: all 0.3s;
}

.close-btn:hover {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: white;
}

.stats-grid {
    padding: 20px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-label {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-color);
}

/* Settings Panel */
.settings-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    min-width: 450px;
    max-width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    animation: fadeIn 0.3s ease;
}

.settings-content {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.setting-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.setting-select {
    padding: 8px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
    outline: none;
    transition: border-color 0.3s;
}

.setting-select:focus {
    border-color: var(--accent-color);
}

.slider-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.setting-slider {
    flex: 1;
    height: 6px;
    background: var(--bg-primary);
    border-radius: 10px;
    outline: none;
    -webkit-appearance: none;
    border: 1px solid var(--border-color);
}

.setting-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: var(--accent-color);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.setting-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.setting-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--accent-color);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    transition: all 0.3s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.setting-slider::-moz-range-thumb:hover {
    transform: scale(1.15);
}

.slider-value {
    min-width: 50px;
    text-align: right;
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.setting-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    color: var(--text-primary);
    cursor: pointer;
}

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

.setting-actions {
    margin-top: 10px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.setting-btn {
    width: 100%;
    padding: 10px 16px;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.3s;
}

.setting-btn:hover {
    opacity: 0.9;
}

/* Info Panel */
.info-panel {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(139, 92, 246, 0.1));
    padding: 20px;
    border-radius: 10px;
    border: 1px solid var(--accent-color);
    margin-top: 30px;
}

.info-header {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    color: var(--accent-color);
    margin-bottom: 12px;
    font-size: 1rem;
}

.info-header svg {
    width: 20px;
    height: 20px;
}

.info-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.info-list li {
    color: var(--text-secondary);
    font-size: 0.9375rem;
    padding: 6px 0;
    padding-left: 24px;
    position: relative;
}

.info-list li::before {
    content: '•';
    position: absolute;
    left: 8px;
    color: var(--accent-color);
    font-weight: 700;
}

/* Responsive Design */
@media (max-width: 768px) {
    .toolbar-divider.mobile-hide,
    .toolbar-group.mobile-hide {
        display: none;
    }

    .editor-toolbar {
        padding: 8px;
        gap: 4px;
    }

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

    .toolbar-btn svg {
        width: 16px;
        height: 16px;
    }

    .editor-content {
        font-size: 14px;
        padding: 20px 16px;
    }

    .editor-wrapper {
        min-height: 400px;
    }

    .editor-statusbar {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
        padding: 10px 12px;
    }

    .status-left,
    .status-right {
        flex-wrap: wrap;
        gap: 8px;
    }

    .stats-panel,
    .settings-panel {
        min-width: 90%;
        max-height: 85vh;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        padding: 16px;
    }

    .stat-value {
        font-size: 1.25rem;
    }

    .settings-content {
        padding: 16px;
    }

    .find-panel {
        padding: 10px;
    }

    .find-row,
    .replace-row {
        flex-wrap: wrap;
    }

    .find-input {
        min-width: 100%;
    }

    .find-options {
        flex-wrap: wrap;
        gap: 12px;
    }

    .page-title {
        font-size: 1.75rem;
    }
}

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

    .toolbar-btn {
        width: 30px;
        height: 30px;
    }

    .editor-content {
        font-size: 13px;
        padding: 16px 12px;
    }

    .info-panel {
        padding: 16px;
    }

    .info-list li {
        font-size: 0.875rem;
    }
}

/* Dark mode specific adjustments */
[data-theme="dark"] .editor-textarea {
    caret-color: white;
}

[data-theme="dark"] .find-input {
    caret-color: white;
}

/* Selection highlight */
.editor-textarea::selection {
    background: var(--accent-color);
    color: white;
}

/* Print Styles */
@media print {
    body {
        background: white !important;
    }

    .page-header,
    .editor-toolbar,
    .editor-statusbar,
    .back-link,
    .info-panel {
        display: none !important;
    }

    .editor-container {
        max-width: 100% !important;
        margin: 0 !important;
    }

    .editor-wrapper {
        border: none !important;
        background: white !important;
    }

    .editor-content {
        background: white !important;
        color: black !important;
        padding: 0 !important;
        min-height: 0 !important;
    }

    .editor-content * {
        color: black !important;
    }

    .editor-content a {
        color: #0066cc !important;
    }

    .editor-content pre {
        background: #f5f5f5 !important;
        border: 1px solid #ddd !important;
    }

    .editor-content blockquote {
        background: #f9f9f9 !important;
        border-left: 4px solid #0066cc !important;
    }

    .editor-content table th {
        background: #f0f0f0 !important;
    }

    @page {
        margin: 2cm;
    }
}
