/**
 * Tegital Rich Text Editor - Styles
 * تصميم المحرر النصي
 */

/* الحاوية الرئيسية */
.tegital-editor {
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    font-family: Arial, sans-serif;
    direction: rtl;
    overflow: hidden;
    transition: all 0.3s ease;
}

/* وضع ملء الشاشة */
.tegital-editor.tegital-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    width: 100% !important;
    height: 100% !important;
    border-radius: 0;
    max-width: none !important;
}

.tegital-editor.tegital-fullscreen .tegital-editor-wrapper {
    height: calc(100vh - 50px) !important;
}

/* شريط الأدوات */
.tegital-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    padding: 8px 12px;
    background: linear-gradient(to bottom, #f8f9fa, #e9ecef);
    border-bottom: 1px solid #ddd;
    gap: 8px;
}

.tegital-toolbar-group {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 8px;
    border-left: 1px solid #ccc;
}

.tegital-toolbar-group:first-child {
    padding-right: 0;
}

.tegital-toolbar-group:last-child {
    border-left: none;
}

/* الأزرار */
.tegital-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 4px 8px;
    border: 1px solid transparent;
    border-radius: 4px;
    background: transparent;
    color: #333;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
}

.tegital-btn:hover {
    background: #fff;
    border-color: #007bff;
    color: #007bff;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.tegital-btn:active {
    transform: translateY(0);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* حالة الزر النشط */
.tegital-btn.active {
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: #fff;
    border-color: #0056b3;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.2);
    font-weight: bold;
}

.tegital-btn.active:hover {
    background: linear-gradient(135deg, #0056b3, #004494);
    transform: translateY(-1px);
}

/* القوائم المنسدلة */
.tegital-select {
    height: 32px;
    padding: 4px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #fff;
    color: #333;
    font-size: 14px;
    cursor: pointer;
    outline: none;
    transition: all 0.2s ease;
}

.tegital-select:hover,
.tegital-select:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.1);
}

/* منتقي الألوان */
.tegital-color-picker-wrapper {
    position: relative;
    display: inline-block;
}

.tegital-color-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

/* حاوية المحرر */
.tegital-editor-wrapper {
    position: relative;
    overflow: hidden;
}

/* منطقة التحرير */
.tegital-editor-area {
    width: 100%;
    height: 100%;
    padding: 16px;
    overflow-y: auto;
    font-size: 16px;
    line-height: 1.6;
    color: #333;
    outline: none;
    background: #fff;
}

/* placeholder */
.tegital-editor-area:empty:before {
    content: attr(data-placeholder);
    color: #999;
    font-style: italic;
    pointer-events: none;
}

.tegital-editor-area:focus:before {
    content: '';
}

/* تنسيق النصوص داخل المحرر */
.tegital-editor-area h1 {
    font-size: 2em;
    margin: 0.5em 0;
    font-weight: bold;
}

.tegital-editor-area h2 {
    font-size: 1.5em;
    margin: 0.5em 0;
    font-weight: bold;
}

.tegital-editor-area h3 {
    font-size: 1.17em;
    margin: 0.5em 0;
    font-weight: bold;
}

.tegital-editor-area p {
    margin: 0.5em 0;
}

.tegital-editor-area ul,
.tegital-editor-area ol {
    margin: 0.5em 0;
    padding-right: 40px;
    padding-left: 0;
}

.tegital-editor-area[dir="ltr"] ul,
.tegital-editor-area[dir="ltr"] ol {
    padding-left: 40px;
    padding-right: 0;
}

.tegital-editor-area li {
    margin: 0.25em 0;
}

.tegital-editor-area a {
    color: #007bff;
    text-decoration: underline;
}

.tegital-editor-area a:hover {
    color: #0056b3;
}

.tegital-editor-area img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 10px 0;
    border-radius: 4px;
}

.tegital-editor-area blockquote {
    border-right: 4px solid #007bff;
    margin: 1em 0;
    padding: 0.5em 1em;
    background: #f8f9fa;
    font-style: italic;
}

.tegital-editor-area[dir="ltr"] blockquote {
    border-right: none;
    border-left: 4px solid #007bff;
}

/* منطقة HTML */
.tegital-html-area {
    width: 100%;
    height: 100%;
    padding: 16px;
    border: none;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.5;
    color: #333;
    background: #f8f9fa;
    outline: none;
    resize: none;
    direction: ltr;
    text-align: left;
}

/* مؤشر التحميل */
.tegital-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.95);
    z-index: 1000;
    backdrop-filter: blur(2px);
}

.tegital-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007bff;
    border-radius: 50%;
    animation: tegital-spin 1s linear infinite;
    margin-bottom: 15px;
}

.tegital-loading-text {
    color: #333;
    font-size: 14px;
    font-weight: 500;
}

@keyframes tegital-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* رسائل الإشعارات */
.tegital-notification {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 12px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1001;
    opacity: 0;
    transform: translateY(-20px);
    transition: all 0.3s ease;
}

.tegital-notification.show {
    opacity: 1;
    transform: translateY(0);
}

.tegital-notification-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.tegital-notification-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.tegital-notification-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.tegital-notification-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

/* رسالة الخطأ */
.tegital-error-message {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 12px 20px;
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1001;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* شريط التمرير المخصص */
.tegital-editor-area::-webkit-scrollbar {
    width: 8px;
}

.tegital-editor-area::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.tegital-editor-area::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.tegital-editor-area::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* تصميم متجاوب للشاشات الصغيرة */
@media (max-width: 768px) {
    .tegital-toolbar {
        padding: 6px 8px;
        gap: 4px;
    }
    
    .tegital-toolbar-group {
        padding: 0 4px;
        gap: 2px;
    }
    
    .tegital-btn {
        min-width: 28px;
        height: 28px;
        font-size: 14px;
    }
    
    .tegital-select {
        height: 28px;
        font-size: 12px;
    }
    
    .tegital-editor-area {
        padding: 12px;
        font-size: 14px;
    }
}

/* تحسينات إضافية */
.tegital-editor * {
    box-sizing: border-box;
}

.tegital-editor-area:focus {
    outline: none;
}

/* أنماط الطباعة */
@media print {
    .tegital-toolbar {
        display: none;
    }
    
    .tegital-editor {
        border: none;
        box-shadow: none;
    }
    
    .tegital-editor-area {
        height: auto !important;
        overflow: visible !important;
    }
}

/* دعم الوضع الداكن */
@media (prefers-color-scheme: dark) {
    .tegital-editor {
        background: #2b2b2b;
        border-color: #444;
    }
    
    .tegital-toolbar {
        background: linear-gradient(to bottom, #333, #2b2b2b);
        border-bottom-color: #444;
    }
    
    .tegital-toolbar-group {
        border-left-color: #555;
    }
    
    .tegital-btn {
        color: #ddd;
    }
    
    .tegital-btn:hover {
        background: #444;
        color: #007bff;
    }
    
    .tegital-select {
        background: #333;
        color: #ddd;
        border-color: #555;
    }
    
    .tegital-editor-area {
        background: #2b2b2b;
        color: #ddd;
    }
    
    .tegital-editor-area:empty:before {
        color: #666;
    }
    
    .tegital-html-area {
        background: #1e1e1e;
        color: #ddd;
    }
}

/* تحسينات إمكانية الوصول */
.tegital-btn:focus-visible,
.tegital-select:focus-visible {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* أنماط للمحتوى المنسق */
.tegital-editor-area [style*="color"] {
    color: inherit !important;
}

.tegital-editor-area [style*="background-color"],
.tegital-editor-area [style*="background"] {
    padding: 2px 4px;
    border-radius: 2px;
}
