/* أداة البحث الأمامية */
.krp-widget {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 320px;
    max-width: 90vw;
    background: #ffffff;
    border: 1px solid #e1e1e1;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    font-size: 14px;
    line-height: 1.4;
    transition: all 0.3s ease-in-out;
}

.krp-widget.minimized {
    height: 50px;
    overflow: hidden;
}

.krp-widget.dragging {
    cursor: move;
    user-select: none;
}

/* رأس الأداة */
.krp-widget-header {
    background: linear-gradient(135deg, #2271b1 0%, #135e96 100%);
    color: white;
    padding: 12px 16px;
    border-radius: 8px 8px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: move;
    user-select: none;
}

.krp-widget-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.krp-widget-toggle {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease-in-out;
}

.krp-widget-toggle:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* محتوى الأداة */
.krp-widget-content {
    padding: 16px;
    max-height: 400px;
    overflow-y: auto;
}

/* نموذج البحث */
.krp-search-form {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

#krp-frontend-search {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #c3c4c7;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

#krp-frontend-search:focus {
    outline: none;
    border-color: #2271b1;
    box-shadow: 0 0 0 2px rgba(34, 113, 177, 0.2);
}

#krp-frontend-search-btn {
    padding: 10px 16px;
    background: #2271b1;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.15s ease-in-out;
    white-space: nowrap;
}

#krp-frontend-search-btn:hover {
    background: #135e96;
}

#krp-frontend-search-btn:active {
    background: #0a4b78;
}

/* النتائج */
.krp-widget-results {
    animation: slideDown 0.3s ease-in-out;
}

.krp-results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #f0f0f1;
}

.krp-results-title {
    font-weight: 600;
    color: #1d2327;
}

.krp-results-count {
    background: #2271b1;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.krp-results-list {
    max-height: 250px;
    overflow-y: auto;
}

.krp-frontend-result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    margin-bottom: 4px;
    background: #f6f7f7;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    border: 1px solid transparent;
}

.krp-frontend-result-item:hover {
    background: #e7f3ff;
    border-color: #2271b1;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(34, 113, 177, 0.15);
}

.krp-frontend-result-item:active {
    transform: translateY(0);
}

.krp-result-text {
    flex: 1;
    font-weight: 500;
    color: #1d2327;
}

.krp-result-meta {
    background: #646970;
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

/* حالات التحميل والخطأ */
.krp-widget-loading,
.krp-widget-error {
    text-align: center;
    padding: 20px;
    color: #646970;
    font-style: italic;
}

.krp-widget-error {
    color: #d63638;
    background: #fcf0f1;
    border: 1px solid #f0b7b8;
    border-radius: 6px;
}

/* الإشعارات الأمامية */
.krp-frontend-notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background: #00a32a;
    color: white;
    padding: 12px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    z-index: 1000000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: transform 0.3s ease-in-out;
    max-width: 300px;
    text-align: center;
}

.krp-frontend-notification.show {
    transform: translateX(-50%) translateY(0);
}

.krp-frontend-notification.krp-error {
    background: #d63638;
}

/* زر التفعيل */
.krp-trigger {
    display: inline-block;
    padding: 8px 16px;
    background: #2271b1;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.15s ease-in-out;
    border: none;
}

.krp-trigger:hover {
    background: #135e96;
    color: white;
    text-decoration: none;
}

/* تحسينات الاستجابة */
@media (max-width: 768px) {
    .krp-widget {
        top: 10px;
        right: 10px;
        left: 10px;
        width: auto;
        max-width: none;
    }
    
    .krp-search-form {
        flex-direction: column;
    }
    
    .krp-widget-content {
        max-height: 300px;
    }
    
    .krp-frontend-notification {
        left: 10px;
        right: 10px;
        transform: translateY(-100px);
        max-width: none;
    }
    
    .krp-frontend-notification.show {
        transform: translateY(0);
    }
}

@media (max-width: 480px) {
    .krp-widget-header {
        padding: 10px 12px;
    }
    
    .krp-widget-header h3 {
        font-size: 14px;
    }
    
    .krp-widget-content {
        padding: 12px;
    }
    
    #krp-frontend-search,
    #krp-frontend-search-btn {
        padding: 8px 10px;
        font-size: 13px;
    }
    
    .krp-frontend-result-item {
        padding: 8px 10px;
    }
}

/* تأثيرات الحركة */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.krp-frontend-result-item {
    animation: fadeIn 0.2s ease-in-out;
}

/* تحسينات إمكانية الوصول */
.krp-widget:focus-within {
    outline: 2px solid #2271b1;
    outline-offset: 2px;
}

.krp-frontend-result-item:focus {
    outline: 2px solid #2271b1;
    outline-offset: -2px;
}

.krp-widget-toggle:focus {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

/* تحسينات للوضع المظلم */
@media (prefers-color-scheme: dark) {
    .krp-widget {
        background: #1d2327;
        border-color: #3c434a;
        color: #f0f0f1;
    }
    
    #krp-frontend-search {
        background: #2c3338;
        border-color: #3c434a;
        color: #f0f0f1;
    }
    
    .krp-frontend-result-item {
        background: #2c3338;
        color: #f0f0f1;
    }
    
    .krp-frontend-result-item:hover {
        background: #3c434a;
    }
    
    .krp-results-header {
        border-bottom-color: #3c434a;
    }
    
    .krp-widget-error {
        background: #3c2327;
        border-color: #5c3338;
        color: #f0b7b8;
    }
}

/* تحسينات الطباعة */
@media print {
    .krp-widget,
    .krp-frontend-notification {
        display: none !important;
    }
}

/* تحسينات الأداء */
.krp-widget * {
    box-sizing: border-box;
}

.krp-widget {
    will-change: transform;
}

.krp-frontend-result-item {
    will-change: transform, background-color;
}

/* تخصيصات إضافية */
.krp-widget.krp-theme-minimal {
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border: none;
}

.krp-widget.krp-theme-minimal .krp-widget-header {
    background: #f6f7f7;
    color: #1d2327;
    border-bottom: 1px solid #e1e1e1;
}

.krp-widget.krp-theme-minimal .krp-widget-toggle {
    color: #646970;
}

.krp-widget.krp-theme-minimal .krp-widget-toggle:hover {
    background: rgba(0, 0, 0, 0.05);
}

