/* Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Tajawal', sans-serif;
}

body {
    background-color: #F8FAFC;
    direction: rtl;
    color: #23262F;
    min-height: 100vh;
}

.main-container {
    width: 1248px;
    margin: 0 auto;
    padding: 24px;
}

/* Header and Breadcrumb Styles */
.page-header {
    margin-bottom: 32px;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    font-size: 14px;
    color: #777E91;
}

.breadcrumb a {
    color: #777E91;
    text-decoration: none;
}

.breadcrumb a:hover {
    color: #353945;
}

.breadcrumb span {
    color: #777E91;
}

.breadcrumb .current {
    color: #777E91;
    font-weight: 500;
}

.document-info {
    margin-top: 16px;
}

.document-description {
    font-size: 14px;
    color: #777E91;
    line-height: 1.5;
}

/* Editor Section */
.editor-section {
    background-color: #fff;
    border: 1px solid #E6E8EC;
    border-radius: 16px;
    padding: 25px;
    width: 864px;
    min-height: 765px;
    margin: 0 auto;
    box-shadow: 0px 4px 12px rgba(0, 0, 0, 0.04);
}

.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.editor-title {
    font-size: 20px;
    font-weight: 700;
    color: #23262F;
}

.editor-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    border-radius: 90px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    transition: all 0.2s ease;
}

.primary-btn {
    background-color: #3772FF;
    color: white;
}

.primary-btn:hover {
    background-color: #2954BF;
}

.save-btn {
    background-color: #FCFCFD;
    color: #777E91;
    border: 2px solid #E6E8EC;
}

.save-btn:hover {
    border-color: #777E91;
    color: #353945;
}

/* Rich Text Editor */
.rich-text-editor {
    border: 1px solid #E6E8EC;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 24px;
    background-color: #fff;
}

.editor-toolbar {
    display: flex;
    border-bottom: 1px solid #E6E8EC;
    padding: 12px;
    background-color: #FCFCFD;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: flex-start;
    border-radius: 12px 12px 0 0;
}

.toolbar-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    color: #777E91;
    font-size: 16px;
    transition: all 0.2s ease;
}

.toolbar-btn[title="تحويل النص"] {
    font-family: Arial, sans-serif;
    font-weight: 600;
    font-size: 14px;
}

.toolbar-btn:hover {
    background-color: #F4F5F6;
    color: #353945;
}

.toolbar-btn.active {
    background-color: #EEF2FF;
    color: #3772FF;
}

.editor-content {
    min-height: 500px;
    padding: 24px;
    outline: none;
    font-size: 14px;
    line-height: 1.6;
    background-color: #fff;
    color: #23262F;
    border-radius: 0 0 12px 12px;
}

/* Bottom Actions */
.bottom-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid #E6E8EC;
}

.left-actions, .right-actions {
    display: flex;
    gap: 12px;
}

.secondary-btn {
    background-color: #3772FF;
    color: white;
}

.secondary-btn:hover {
    background-color: #2954BF;
}

.danger-btn {
    background-color: #FCFCFD;
    color: #EF466F;
    border: 2px solid #EF466F;
}

.danger-btn:hover {
    background-color: #FFF1F3;
}

.danger-btn {
    background-color: #ffffff;
    color: #333;
    border: 1px solid #ddd;
    font-size: 13px;
}

.danger-btn:hover {
    background-color: #f8f9fa;
}

/* Make the editor responsive */
/* Large Tablets (992px - 1199px) */
@media (max-width: 1199px) {
    .main-container {
        width: 100%;
        max-width: 100%;
        padding: 20px 16px;
    }
    
    .editor-section {
        width: 100%;
        max-width: 800px;
        padding: 20px;
    }
}

/* Small Tablets (768px - 991px) */
@media (max-width: 991px) {
    .main-container {
        padding: 16px 12px;
    }
    
    .page-header {
        margin-bottom: 24px;
    }
    
    .breadcrumb {
        flex-wrap: wrap;
        gap: 6px;
        font-size: 13px;
    }
    
    .document-description {
        font-size: 13px;
    }
    
    .editor-section {
        max-width: 100%;
        padding: 16px;
        border-radius: 12px;
    }
    
    .editor-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    
    .editor-title {
        font-size: 18px;
    }
    
    .editor-actions {
        width: 100%;
        justify-content: flex-start;
    }
    
    .action-btn {
        padding: 10px 16px;
        font-size: 13px;
    }
    
    .editor-content {
        min-height: 400px;
        padding: 20px;
    }
}

/* Large Mobile (576px - 767px) */
@media (max-width: 767px) {
    .main-container {
        padding: 12px 8px;
    }
    
    .page-header {
        margin-bottom: 20px;
    }
    
    .breadcrumb {
        font-size: 12px;
        margin-bottom: 12px;
    }
    
    .document-description {
        font-size: 12px;
        line-height: 1.4;
    }
    
    .editor-section {
        padding: 16px 12px;
        border-radius: 8px;
        margin: 0;
    }
    
    .editor-header {
        margin-bottom: 16px;
    }
    
    .editor-title {
        font-size: 16px;
        margin-bottom: 12px;
        width: 100%;
    }
    
    .editor-actions {
        width: 100%;
        gap: 8px;
        flex-wrap: wrap;
    }
    
    .action-btn {
        padding: 12px 16px;
        font-size: 14px;
        min-height: 44px;
        border-radius: 8px;
        flex: 1;
        min-width: 120px;
    }
    
    .action-btn i {
        font-size: 16px;
    }
    
    /* Rich Text Editor Mobile */
    .rich-text-editor {
        border-radius: 8px;
        margin-bottom: 16px;
    }
    
    .editor-toolbar {
        padding: 8px;
        border-radius: 8px 8px 0 0;
        gap: 2px;
        justify-content: center;
    }
    
    .toolbar-btn {
        width: 40px;
        height: 40px;
        border-radius: 6px;
        font-size: 16px;
        min-width: 40px;
        min-height: 40px;
    }
    
    .toolbar-btn[title="تحويل النص"] {
        font-size: 12px;
    }
    
    .editor-content {
        min-height: 300px;
        padding: 16px;
        font-size: 15px;
        line-height: 1.5;
        border-radius: 0 0 8px 8px;
    }
    
    /* Bottom Actions Mobile */
    .bottom-actions {
        flex-direction: column-reverse;
        gap: 12px;
        margin-top: 16px;
        padding-top: 16px;
    }
    
    .left-actions,
    .right-actions {
        width: 100%;
        justify-content: center;
    }
    
    .left-actions .action-btn,
    .right-actions .action-btn {
        width: 100%;
        min-height: 48px;
        font-size: 15px;
    }
}

/* Small Mobile (< 576px) */
@media (max-width: 575px) {
    .main-container {
        padding: 8px 4px;
    }
    
    .page-header {
        margin-bottom: 16px;
    }
    
    .breadcrumb {
        font-size: 11px;
        gap: 4px;
    }
    
    .document-description {
        font-size: 11px;
    }
    
    .editor-section {
        padding: 12px 8px;
        min-height: auto;
    }
    
    .editor-title {
        font-size: 15px;
        margin-bottom: 10px;
    }
    
    .editor-actions {
        gap: 6px;
    }
    
    .action-btn {
        padding: 10px 12px;
        font-size: 13px;
        min-height: 42px;
        min-width: 100px;
    }
    
    .action-btn i {
        font-size: 14px;
    }
    
    .editor-toolbar {
        padding: 6px;
        gap: 1px;
    }
    
    .toolbar-btn {
        width: 36px;
        height: 36px;
        font-size: 14px;
        min-width: 36px;
        min-height: 36px;
    }
    
    .toolbar-btn[title="تحويل النص"] {
        font-size: 10px;
    }
    
    .editor-content {
        min-height: 250px;
        padding: 12px;
        font-size: 14px;
    }
    
    .bottom-actions {
        gap: 10px;
        margin-top: 12px;
        padding-top: 12px;
    }
    
    .left-actions .action-btn,
    .right-actions .action-btn {
        min-height: 44px;
        font-size: 14px;
    }
}

/* Extra Small Mobile (< 400px) */
@media (max-width: 399px) {
    .main-container {
        padding: 4px 2px;
    }
    
    .editor-section {
        padding: 8px 6px;
    }
    
    .editor-title {
        font-size: 14px;
    }
    
    .action-btn {
        padding: 8px 10px;
        font-size: 12px;
        min-height: 40px;
        min-width: 90px;
    }
    
    .toolbar-btn {
        width: 32px;
        height: 32px;
        font-size: 12px;
        min-width: 32px;
        min-height: 32px;
    }
    
    .toolbar-btn[title="تحويل النص"] {
        font-size: 9px;
    }
    
    .editor-content {
        min-height: 200px;
        padding: 10px;
        font-size: 13px;
    }
    
    .left-actions .action-btn,
    .right-actions .action-btn {
        min-height: 42px;
        font-size: 13px;
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    .toolbar-btn,
    .action-btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    .toolbar-btn:hover {
        background-color: #F4F5F6;
        color: #777E91;
    }
    
    .toolbar-btn:active {
        background-color: #EEF2FF;
        color: #3772FF;
        transform: scale(0.95);
    }
    
    .action-btn:active {
        transform: scale(0.98);
    }
    
    .primary-btn:active,
    .secondary-btn:active {
        background-color: #2954BF;
    }
    
    .save-btn:active {
        border-color: #777E91;
        color: #353945;
        background-color: #F4F5F6;
    }
    
    .danger-btn:active {
        background-color: #FFF1F3;
    }
}

/* Landscape Mobile Optimization */
@media (max-width: 767px) and (orientation: landscape) {
    .main-container {
        padding: 8px 12px;
    }
    
    .page-header {
        margin-bottom: 12px;
    }
    
    .editor-section {
        padding: 12px;
    }
    
    .editor-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 12px;
    }
    
    .editor-title {
        margin-bottom: 0;
        width: auto;
    }
    
    .editor-actions {
        width: auto;
        flex-wrap: nowrap;
    }
    
    .action-btn {
        min-width: 100px;
    }
    
    .editor-content {
        min-height: 200px;
    }
    
    .bottom-actions {
        flex-direction: row;
        justify-content: space-between;
    }
    
    .left-actions,
    .right-actions {
        width: auto;
    }
    
    .left-actions .action-btn,
    .right-actions .action-btn {
        width: auto;
        min-width: 120px;
    }
}

/* Toolbar Responsiveness */
@media (max-width: 767px) {
    .editor-toolbar {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(40px, 1fr));
        gap: 4px;
        padding: 10px;
        justify-items: center;
    }
}

@media (max-width: 575px) {
    .editor-toolbar {
        grid-template-columns: repeat(8, 1fr);
        gap: 2px;
        padding: 8px;
    }
}

@media (max-width: 399px) {
    .editor-toolbar {
        grid-template-columns: repeat(6, 1fr);
        gap: 1px;
        padding: 6px;
    }
}

/* High Density Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .editor-section {
        box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.06);
    }
    
    .rich-text-editor {
        border-width: 0.5px;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .toolbar-btn,
    .action-btn {
        transition: none;
    }
}
