/* Main Styles for Urdu Text Editor */

:root {
    --primary-color: #373e98;
    --primary-hover: #2d3577;
    --secondary-color: #f16775;
    --success-color: #059669;
    --warning-color: #d97706;
    --error-color: #dc2626;
    --background-color: #ffffff;
    --surface-color: #f8fafc;
    --border-color: #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    --radius-sm: 0.25rem;
    --radius-md: 0.375rem;
    --radius-lg: 0.5rem;
}

/* Dark Theme Variables */
[data-theme="dark"] {
    --primary-color: #60a5fa;
    --primary-hover: #3b82f6;
    --secondary-color: #94a3b8;
    --success-color: #34d399;
    --warning-color: #fbbf24;
    --error-color: #f87171;
    --background-color: #1f2937;
    --surface-color: #374151;
    --border-color: #6b7280;
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.5);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.6);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.7);
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
}

.loading-content {
    text-align: center;
    color: white;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Header */
.app-header {
    background: var(--background-color);
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
    box-shadow: var(--shadow-sm);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1400px;
    margin: 0 auto;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-section h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary-color);
    font-family: 'Noto Nastaliq Urdu', serif;
}

.brand-text {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
}

.theme-toggle-btn, .keyboard-guide-btn, .language-toggle-btn, .install-btn, .share-btn {
    padding: 0.5rem 1rem;
    background: var(--primary-color);
    color: white;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    height: 36px;
}

.theme-toggle-btn:hover, .keyboard-guide-btn:hover, .language-toggle-btn:hover, 
.install-btn:hover, .share-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.language-toggle-btn {
    background: var(--success-color);
    min-width: 60px;
}

.language-toggle-btn:hover {
    background: #047857;
}

.language-toggle-btn.english-mode {
    background: var(--warning-color);
}

.language-toggle-btn.english-mode:hover {
    background: #b45309;
}

.lang-indicator {
    font-family: 'Noto Nastaliq Urdu', serif;
    font-size: 0.875rem;
    font-weight: 600;
}

/* Main Layout */
.app-main {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 120px);
}

/* Toolbar */
.toolbar {
    background: var(--background-color);
    border-bottom: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    box-shadow: var(--shadow-sm);
}

.toolbar-section {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.toolbar-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    transition: all 0.2s ease;
    position: relative;
}

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

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

.toolbar-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.toolbar-select {
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--background-color);
    color: var(--text-primary);
    min-width: 120px;
    font-size: 0.875rem;
}

.toolbar-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

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

.color-controls {
    display: flex;
    gap: 0.5rem;
}

.color-controls label {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.color-controls label:hover {
    background: var(--surface-color);
}

.color-picker {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

/* Content Area */
.content-area {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 320px;
    background: var(--surface-color);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    flex-shrink: 0;
}

.sidebar-content {
    padding: 1rem;
}

.stats-panel, .recent-docs-panel {
    background: var(--background-color);
    border-radius: var(--radius-lg);
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
}

.stats-panel h3, .recent-docs-panel h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

.stat-item:last-child {
    border-bottom: none;
}

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

.stat-value {
    font-weight: 500;
    color: var(--text-primary);
}

.ad-container {
    background: var(--background-color);
    border-radius: var(--radius-lg);
    padding: 1rem;
    margin-bottom: 1rem;
    text-align: center;
    box-shadow: var(--shadow-sm);
    min-height: 250px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.recent-docs-list {
    list-style: none;
}

.recent-docs-list li {
    padding: 0.5rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background-color 0.2s ease;
    font-size: 0.875rem;
}

.recent-docs-list li:hover {
    background: var(--surface-color);
}

.recent-docs-list .no-docs {
    color: var(--text-secondary);
    font-style: italic;
    cursor: default;
}

.recent-docs-list .no-docs:hover {
    background: transparent;
}

/* Editor Container */
.editor-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.document-header {
    background: var(--background-color);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem;
}

.document-title-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.document-title {
    flex: 1;
    font-size: 1.25rem;
    font-weight: 600;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-family: 'Noto Nastaliq Urdu', serif;
}

.document-title::placeholder {
    color: var(--text-secondary);
}

.save-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

#save-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.save-status.unsaved #save-indicator {
    color: var(--warning-color);
}

.save-status.saving #save-indicator {
    color: var(--primary-color);
    animation: pulse 1s infinite;
}

.save-status.saved #save-indicator {
    color: var(--success-color);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Editor Wrapper */
.editor-wrapper {
    flex: 1;
    overflow: auto;
    background: var(--surface-color);
    padding: 2rem;
}

.document-container {
    max-width: 210mm;
    margin: 0 auto;
    background: var(--background-color);
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.editor {
    min-height: 297mm;
    padding: 25mm;
    font-family: 'Noto Nastaliq Urdu', serif;
    font-size: 14px;
    line-height: 1.8;
    color: var(--text-primary);
    background: var(--background-color);
    border: none;
    outline: none;
    position: relative;
    /* Default to RTL for Urdu */
    direction: rtl;
    text-align: right;
    unicode-bidi: plaintext;
}

/* Urdu Mode - RTL */
.editor.urdu-mode {
    direction: rtl !important;
    text-align: right !important;
    font-family: 'Noto Nastaliq Urdu', serif !important;
}

/* English Mode - LTR */
.editor.english-mode {
    direction: ltr !important;
    text-align: left !important;
    font-family: 'Inter', sans-serif !important;
}

/* Default document direction - keep RTL for mixed content */
.editor.urdu-mode {
    /* Document stays RTL but allows inline LTR */
}

.editor.english-mode {
    /* Document becomes fully LTR for English mode */
}

.editor.english-mode * {
    direction: ltr;
    text-align: left;
    font-family: inherit;
}

/* BiDi (Bidirectional) Text Support - Enhanced */
.bidi-enabled {
    direction: rtl !important;
    text-align: right !important;
    unicode-bidi: plaintext !important;
}

/* Force RTL base direction for all block elements */
.bidi-enabled,
.bidi-enabled p,
.bidi-enabled div,
.bidi-enabled h1,
.bidi-enabled h2,
.bidi-enabled h3,
.bidi-enabled h4,
.bidi-enabled h5,
.bidi-enabled h6,
.bidi-enabled li,
.bidi-enabled blockquote {
    direction: rtl !important;
    text-align: right !important;
    unicode-bidi: plaintext !important;
}

/* LTR inline spans for English text and numbers */
.bidi-ltr {
    direction: ltr !important;
    unicode-bidi: embed !important;
    font-family: 'Inter', sans-serif !important;
    display: inline !important;
    text-align: left !important;
    writing-mode: horizontal-tb !important;
}

/* RTL inline spans for Urdu text (explicit) */
.bidi-rtl {
    direction: rtl !important;
    unicode-bidi: embed !important;
    font-family: 'Noto Nastaliq Urdu', serif !important;
    display: inline !important;
    text-align: right !important;
    writing-mode: horizontal-tb !important;
}

/* Prevent any child elements from overriding base RTL */
.bidi-enabled * {
    direction: inherit !important;
}

/* Special handling for table cells to maintain RTL */
.bidi-enabled table,
.bidi-enabled th,
.bidi-enabled td {
    direction: rtl !important;
    text-align: right !important;
}

/* Lists maintain RTL */
.bidi-enabled ul,
.bidi-enabled ol {
    direction: rtl !important;
    text-align: right !important;
    padding-right: 2em !important;
    padding-left: 0 !important;
}

/* Legacy support for existing inline language classes */
.inline-english {
    direction: ltr !important;
    unicode-bidi: embed !important;
    font-family: 'Inter', sans-serif !important;
    display: inline !important;
    text-align: left !important;
}

.inline-urdu {
    direction: rtl !important;
    unicode-bidi: embed !important;
    font-family: 'Noto Nastaliq Urdu', serif !important;
    display: inline !important;
    text-align: right !important;
}

/* Proper RTL text rendering for Urdu */
.editor.urdu-mode {
    writing-mode: horizontal-tb;
    unicode-bidi: plaintext;
    text-rendering: optimizeLegibility;
    -webkit-font-feature-settings: "liga", "kern", "calt";
    font-feature-settings: "liga", "kern", "calt";
}

/* Force proper paragraph direction */
.editor.urdu-mode p,
.editor.urdu-mode div,
.editor.urdu-mode span {
    direction: rtl !important;
    text-align: right !important;
}

.editor.english-mode p,
.editor.english-mode div,
.editor.english-mode span {
    direction: ltr !important;
    text-align: left !important;
}

/* Image Resize Controls */
.image-resize-container {
    position: relative !important;
    display: inline-block !important;
    border: 2px solid #007cba !important;
    border-radius: 4px !important;
    margin: 1rem 0 !important;
}

.resize-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #007cba;
    border: 2px solid white;
    border-radius: 50%;
    z-index: 1000;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.resize-handle:hover {
    background: #005a8b;
    transform: scale(1.2);
}

.resizable-image {
    transition: border-color 0.2s ease;
}

.resizable-image:hover {
    border-color: #007cba;
}

/* Dark mode support for image controls */
[data-theme="dark"] .image-resize-container {
    border-color: var(--primary-color);
}

[data-theme="dark"] .resize-handle {
    background: var(--primary-color);
    border-color: var(--background-color);
}

.editor:empty::before {
    content: attr(data-placeholder);
    color: var(--text-secondary);
    font-style: italic;
    pointer-events: none;
}

.editor:focus {
    outline: none;
}

/* Status Bar */
.status-bar {
    background: var(--background-color);
    border-top: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.status-left, .status-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.zoom-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    transition: background-color 0.2s ease;
}

.zoom-btn:hover {
    background: var(--surface-color);
}

.zoom-slider {
    width: 100px;
}

#zoom-level {
    font-weight: 500;
    min-width: 40px;
    text-align: center;
}

/* Footer styles removed for standalone integration */

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--background-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

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

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

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    transition: all 0.2s ease;
    font-size: 1.5rem;
}

.modal-close:hover {
    background: var(--surface-color);
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
}

/* Form Elements */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
}

.form-input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    background: var(--background-color);
    color: var(--text-primary);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-options {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.form-options label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    cursor: pointer;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

.btn {
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

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

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: transparent;
    border-color: var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--surface-color);
}

.export-options {
    display: grid;
    gap: 0.75rem;
}

.export-btn {
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--background-color);
    color: var(--text-primary);
    text-align: left;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
    cursor: pointer;
}

.export-btn:hover {
    border-color: var(--primary-color);
    background: var(--surface-color);
}

.export-btn i {
    font-size: 1.25rem;
    color: var(--primary-color);
}

/* Share Modal Styles */
.share-options {
    display: grid;
    gap: 0.75rem;
}

.share-option {
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--background-color);
    color: var(--text-primary);
    text-align: left;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
    cursor: pointer;
}

.share-option:hover {
    border-color: var(--primary-color);
    background: var(--surface-color);
    transform: translateY(-1px);
}

.share-option i {
    font-size: 1.25rem;
    color: var(--primary-color);
    min-width: 20px;
}

/* Keyboard Guide Styles */
.keyboard-guide-content {
    max-width: 900px;
    width: 95vw;
}

.guide-tabs {
    display: flex;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 1.5rem;
    gap: 0.5rem;
}

.guide-tab {
    padding: 0.75rem 1.5rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
    font-size: 0.875rem;
}

.guide-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.guide-tab:hover {
    color: var(--primary-color);
    background: var(--surface-color);
}

.guide-tab-content {
    display: none;
}

.guide-tab-content.active {
    display: block;
}

.keyboard-layout {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: center;
}

.keyboard-row {
    display: flex;
    gap: 0.25rem;
    justify-content: center;
}

.key {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--background-color);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.key:hover {
    border-color: var(--primary-color);
    background: var(--surface-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.key-char {
    color: var(--text-secondary);
    font-size: 0.7rem;
    margin-bottom: 2px;
}

.urdu-char {
    color: var(--primary-color);
    font-size: 1.1rem;
    font-family: 'Noto Nastaliq Urdu', serif;
    font-weight: 600;
}

.combination-grid, .shortcut-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.combination, .shortcut {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem;
    background: var(--surface-color);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.combination kbd, .shortcut kbd {
    background: var(--primary-color);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
}

.combination .urdu {
    font-family: 'Noto Nastaliq Urdu', serif;
    font-size: 1.25rem;
    color: var(--primary-color);
    font-weight: 600;
}

/* Dark theme adjustments for keyboard guide */
[data-theme="dark"] .key {
    border-color: var(--border-color);
    background: var(--surface-color);
}

[data-theme="dark"] .key:hover {
    background: var(--background-color);
}

/* Dark Mode Enhancements for Better Visibility */
[data-theme="dark"] {
    /* Modal improvements */
    .modal {
        background: rgba(0, 0, 0, 0.8);
    }
    
    /* Color picker visibility improvements */
    .color-picker {
        border: 2px solid var(--border-color);
        border-radius: var(--radius-sm);
        opacity: 1;
    }
    
    .color-controls {
        background: var(--surface-color);
        padding: 4px;
        border-radius: var(--radius-md);
        border: 1px solid var(--border-color);
    }
    
    .color-controls label {
        border: 2px solid var(--border-color);
        background: var(--background-color);
        position: relative;
    }
    
    .color-controls label::before {
        content: '';
        position: absolute;
        inset: 2px;
        border-radius: var(--radius-sm);
        background: var(--surface-color);
        z-index: -1;
    }
    
    .color-controls label:hover {
        border-color: var(--primary-color);
        background: var(--surface-color);
    }
    
    /* Specific color picker icons visibility */
    .toolbar-btn[title*="Color"] {
        border: 1px solid var(--border-color);
        background: var(--surface-color);
    }
    
    .toolbar-btn[title*="Color"]:hover {
        border-color: var(--primary-color);
        background: var(--background-color);
    }
    
    /* Toolbar improvements */
    .toolbar-btn {
        color: var(--text-primary);
    }
    
    .toolbar-btn:hover {
        background: var(--surface-color);
        color: var(--primary-color);
    }
    
    .toolbar-select {
        background: var(--surface-color);
        color: var(--text-primary);
        border-color: var(--border-color);
    }
    
    .toolbar-select:focus {
        border-color: var(--primary-color);
        background: var(--background-color);
    }
    
    /* Form improvements */
    .form-input {
        background: var(--surface-color);
        color: var(--text-primary);
        border-color: var(--border-color);
    }
    
    .form-input:focus {
        background: var(--background-color);
        border-color: var(--primary-color);
        box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2);
    }
    
    /* Button improvements */
    .btn-secondary {
        background: var(--surface-color);
        border-color: var(--border-color);
        color: var(--text-primary);
    }
    
    .btn-secondary:hover {
        background: var(--background-color);
        border-color: var(--primary-color);
    }
    
    /* Export and share option improvements */
    .export-btn, .share-option {
        background: var(--surface-color);
        border-color: var(--border-color);
        color: var(--text-primary);
    }
    
    .export-btn:hover, .share-option:hover {
        background: var(--background-color);
        border-color: var(--primary-color);
    }
    
    /* Table improvements */
    table {
        background: var(--surface-color);
        border-color: var(--border-color);
    }
    
    th, td {
        border-color: var(--border-color);
        background: var(--surface-color);
        color: var(--text-primary);
    }
    
    th {
        background: var(--background-color);
        font-weight: 600;
    }
    
    /* Resize handle improvements */
    .table-resize-wrapper, .image-resize-wrapper {
        border-color: var(--primary-color);
    }
    
    .resize-handle {
        background: var(--primary-color);
        border-color: var(--background-color);
        box-shadow: 0 2px 8px rgba(96, 165, 250, 0.3);
    }
    
    /* Width and dimension indicators */
    .table-width-indicator {
        background: var(--primary-color);
        color: var(--background-color);
    }
    
    .image-dimensions-indicator {
        background: var(--success-color);
        color: var(--background-color);
    }
    
    /* Notification improvements */
    .notification {
        background: var(--surface-color);
        border: 1px solid var(--border-color);
        color: var(--text-primary);
        box-shadow: var(--shadow-lg);
    }
    
    .notification.success {
        border-color: var(--success-color);
        background: rgba(52, 211, 153, 0.1);
    }
    
    .notification.error {
        border-color: var(--error-color);
        background: rgba(248, 113, 113, 0.1);
    }
    
    .notification.info {
        border-color: var(--primary-color);
        background: rgba(96, 165, 250, 0.1);
    }
    
    /* Placeholder text improvements */
    .editor:empty::before {
        color: var(--text-secondary);
        opacity: 0.8;
    }
}

/* Mixed Content Text Direction Support */
.ltr-text {
    direction: ltr;
    text-align: left;
    display: inline-block;
    unicode-bidi: embed;
}

.rtl-text {
    direction: rtl;
    text-align: right;
    display: inline-block;
    unicode-bidi: embed;
}

/* Ensure English text flows LTR in RTL context */
.editor [lang="en"], .editor .english-text {
    direction: ltr;
    unicode-bidi: embed;
}

/* Ensure Urdu text flows RTL */
.editor [lang="ur"], .editor .urdu-text {
    direction: rtl;
    unicode-bidi: embed;
}

/* Enhanced Table Resize Handles */
.resizable-table td, .resizable-table th {
    position: relative;
    border: 1px solid var(--border-color);
}

.cell-resizer {
    background: var(--primary-color) !important;
    border-radius: 2px;
}

.cell-resizer:hover {
    background: var(--primary-hover) !important;
    opacity: 1 !important;
}

.column-resizer:hover, .row-resizer:hover {
    background: rgba(37, 99, 235, 0.3) !important;
}

/* Table cell editing enhancements */
.resizable-table td:focus, .resizable-table th:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: -2px;
    background: rgba(37, 99, 235, 0.05);
}

.resizable-table td[contenteditable="true"]:empty::before,
.resizable-table th[contenteditable="true"]:empty::before {
    content: 'متن ٹائپ کریں / Type text';
    color: var(--text-secondary);
    font-style: italic;
    opacity: 0.7;
}

/* Dark mode table enhancements */
[data-theme="dark"] .resizable-table td:focus,
[data-theme="dark"] .resizable-table th:focus {
    background: rgba(96, 165, 250, 0.1);
    outline-color: var(--primary-color);
}

/* Image Text Wrapping Styles */
.resizable-image {
    transition: all 0.3s ease;
}

.wrap-inline {
    display: inline-block !important;
    vertical-align: middle;
}

.wrap-left {
    float: left !important;
    margin: 0 15px 15px 0 !important;
    shape-outside: margin-box;
}

.wrap-right {
    float: right !important;
    margin: 0 0 15px 15px !important;
    shape-outside: margin-box;
}

.wrap-center {
    display: block !important;
    margin: 15px auto !important;
    clear: both;
}

.wrap-behind {
    position: absolute !important;
    z-index: -1 !important;
    opacity: 0.3 !important;
}

.image-wrap-controls {
    flex-wrap: nowrap;
    white-space: nowrap;
}

.wrap-option-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* RTL text wrapping adjustments */
[dir="rtl"] .wrap-left {
    float: right !important;
    margin: 0 0 15px 15px !important;
}

[dir="rtl"] .wrap-right {
    float: left !important;
    margin: 0 15px 15px 0 !important;
}

/* Dark mode image controls */
[data-theme="dark"] .image-wrap-controls {
    background: var(--surface-color);
    border-color: var(--border-color);
}

[data-theme="dark"] .wrap-option-btn {
    background: var(--background-color);
    border-color: var(--border-color);
    color: var(--text-primary);
}

[data-theme="dark"] .wrap-option-btn:hover {
    background: var(--primary-color);
    color: white;
}

/* Enhanced dark mode text visibility improvements */
[data-theme="dark"] .editor {
    color: var(--text-primary) !important;
    background: var(--background-color) !important;
}

[data-theme="dark"] .bidi-ltr,
[data-theme="dark"] .bidi-rtl,
[data-theme="dark"] .inline-english,
[data-theme="dark"] .inline-urdu {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .editor p,
[data-theme="dark"] .editor div,
[data-theme="dark"] .editor span,
[data-theme="dark"] .editor h1,
[data-theme="dark"] .editor h2,
[data-theme="dark"] .editor h3,
[data-theme="dark"] .editor h4,
[data-theme="dark"] .editor h5,
[data-theme="dark"] .editor h6 {
    color: var(--text-primary) !important;
}

[data-theme="dark"] table td,
[data-theme="dark"] table th {
    color: var(--text-primary) !important;
    background-color: var(--surface-color) !important;
    border-color: var(--border-color) !important;
}

[data-theme="dark"] table thead th {
    background-color: var(--background-color) !important;
    font-weight: 600;
}

/* Dark mode placeholder text */
[data-theme="dark"] .editor:empty::before,
[data-theme="dark"] table td[contenteditable="true"]:empty::before,
[data-theme="dark"] table th[contenteditable="true"]:empty::before {
    color: var(--text-secondary) !important;
    opacity: 0.8;
}

/* Lists and other elements */
[data-theme="dark"] .editor ul,
[data-theme="dark"] .editor ol,
[data-theme="dark"] .editor li {
    color: var(--text-primary) !important;
}

/* Links in dark mode */
[data-theme="dark"] .editor a {
    color: var(--primary-color) !important;
}

[data-theme="dark"] .editor a:visited {
    color: #b794f6 !important;
}

/* Code and pre elements */
[data-theme="dark"] .editor code,
[data-theme="dark"] .editor pre {
    background-color: var(--surface-color) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-color) !important;
}

/* Blockquotes */
[data-theme="dark"] .editor blockquote {
    color: var(--text-secondary) !important;
    border-left: 4px solid var(--primary-color) !important;
    background-color: var(--surface-color) !important;
}

/* Enhanced Image Modal Styles */
.image-tabs {
    display: flex;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 1.5rem;
    gap: 0.5rem;
}

.image-tab {
    padding: 0.75rem 1.5rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
    font-size: 0.875rem;
}

.image-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.image-tab:hover {
    color: var(--primary-color);
    background: var(--surface-color);
}

.image-tab-content {
    display: none;
}

.image-tab-content.active {
    display: block;
}

.file-drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2rem;
    text-align: center;
    margin-top: 1rem;
    background: var(--surface-color);
    cursor: pointer;
    transition: all 0.2s ease;
}

.file-drop-zone:hover {
    border-color: var(--primary-color);
    background: rgba(37, 99, 235, 0.05);
}

.file-drop-zone.dragover {
    border-color: var(--primary-color);
    background: rgba(37, 99, 235, 0.1);
    transform: scale(1.02);
}

.file-drop-zone p {
    margin: 0 0 0.5rem 0;
    font-size: 1.125rem;
    color: var(--text-primary);
}

.file-drop-zone small {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.image-preview {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.image-preview h4 {
    margin: 0 0 1rem 0;
    color: var(--text-primary);
    font-size: 1rem;
}

.preview-info {
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.form-actions {
    margin-top: 1.5rem;
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

/* Dark mode image modal */
[data-theme="dark"] .file-drop-zone {
    background: var(--background-color);
    border-color: var(--border-color);
}

[data-theme="dark"] .file-drop-zone:hover {
    background: rgba(96, 165, 250, 0.1);
    border-color: var(--primary-color);
}

[data-theme="dark"] .image-preview {
    background: var(--background-color);
    border-color: var(--border-color);
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.text-left {
    text-align: left;
}

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }

.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }

.p-1 { padding: 0.25rem; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }

/* Move Tool Styles */
.drag-wrapper {
    position: relative !important;
    display: inline-block !important;
    border: 2px dashed var(--primary-color) !important;
    border-radius: var(--radius-md) !important;
    padding: 4px !important;
    margin: 8px !important;
    cursor: move !important;
    background: rgba(37, 99, 235, 0.05) !important;
    transition: all 0.2s ease;
}

.drag-wrapper:hover {
    border-color: var(--primary-hover) !important;
    background: rgba(37, 99, 235, 0.1) !important;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.drag-handle {
    position: absolute !important;
    top: -12px !important;
    left: -12px !important;
    width: 24px !important;
    height: 24px !important;
    background: var(--primary-color) !important;
    color: white !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: move !important;
    font-size: 12px !important;
    z-index: 1000 !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: all 0.2s ease;
}

.drag-handle:hover {
    background: var(--primary-hover) !important;
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.drag-handle i {
    pointer-events: none;
}

/* Move tool button active state */
#move-cursor-btn.active {
    background: var(--primary-color) !important;
    color: white !important;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

#move-cursor-btn.active:hover {
    background: var(--primary-hover) !important;
    transform: translateY(-1px);
}

/* Dark mode support for move tool */
[data-theme="dark"] .drag-wrapper {
    border-color: var(--primary-color) !important;
    background: rgba(96, 165, 250, 0.1) !important;
}

[data-theme="dark"] .drag-wrapper:hover {
    border-color: var(--primary-hover) !important;
    background: rgba(96, 165, 250, 0.15) !important;
    box-shadow: 0 4px 12px rgba(96, 165, 250, 0.25);
}

[data-theme="dark"] .drag-handle {
    background: var(--primary-color) !important;
    border: 2px solid var(--background-color);
}

[data-theme="dark"] .drag-handle:hover {
    background: var(--primary-hover) !important;
}

/* Cursor changes for move tool */
.move-tool-active {
    cursor: crosshair !important;
}

.move-tool-active .drag-wrapper {
    cursor: move !important;
}

.move-tool-active .drag-wrapper * {
    cursor: move !important;
}

/* Urdu Dictionary Auto-Suggestion Styles */
.suggestion-box {
    font-family: 'Noto Nastaliq Urdu', serif !important;
    border: 1px solid var(--border-color) !important;
    border-radius: var(--radius-md) !important;
    background: var(--background-color) !important;
    box-shadow: var(--shadow-lg) !important;
    z-index: 10000 !important;
}

.suggestion-item {
    border-bottom: 1px solid var(--border-color) !important;
    transition: all 0.2s ease !important;
}

.suggestion-item:last-child {
    border-bottom: none !important;
}

.suggestion-item:hover {
    background: var(--surface-color) !important;
    color: var(--primary-color) !important;
}

.suggestion-item.selected {
    background: var(--primary-color) !important;
    color: white !important;
}

/* Dark mode support for suggestions */
[data-theme="dark"] .suggestion-box {
    background: var(--surface-color) !important;
    border-color: var(--border-color) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4) !important;
}

[data-theme="dark"] .suggestion-item:hover {
    background: var(--background-color) !important;
    color: var(--primary-color) !important;
}

[data-theme="dark"] .suggestion-item.selected {
    background: var(--primary-color) !important;
    color: white !important;
}

/* Ensure proper text direction in suggestions */
.suggestion-item {
    direction: rtl !important;
    text-align: right !important;
}

/* Enhanced Table Cell Editing */
table td[contenteditable="true"],
table th[contenteditable="true"] {
    min-width: 100px;
    min-height: 30px;
    outline: none;
    position: relative;
    cursor: text;
}

table td[contenteditable="true"]:focus,
table th[contenteditable="true"]:focus {
    background-color: rgba(37, 99, 235, 0.1) !important;
    border: 2px solid var(--primary-color) !important;
    border-radius: 2px;
}

table td[contenteditable="true"]:empty::before,
table th[contenteditable="true"]:empty::before {
    content: 'یہاں لکھیں... / Type here...';
    color: var(--text-secondary);
    font-style: italic;
    opacity: 0.7;
}

table td[contenteditable="true"]:focus::before,
table th[contenteditable="true"]:focus::before {
    content: '';
}

/* Table cell editing in dark mode */
[data-theme="dark"] table td[contenteditable="true"]:focus,
[data-theme="dark"] table th[contenteditable="true"]:focus {
    background-color: rgba(96, 165, 250, 0.15) !important;
    border-color: var(--primary-color) !important;
}

/* BiDi support for table cells */
table td[contenteditable="true"],
table th[contenteditable="true"] {
    direction: rtl !important;
    text-align: right !important;
    unicode-bidi: plaintext !important;
}

table td .bidi-ltr,
table th .bidi-ltr {
    direction: ltr !important;
    unicode-bidi: embed !important;
    font-family: 'Inter', sans-serif !important;
    display: inline !important;
}

table td .bidi-rtl,
table th .bidi-rtl {
    direction: rtl !important;
    unicode-bidi: embed !important;
    font-family: 'Noto Nastaliq Urdu', serif !important;
    display: inline !important;
}