/**
 * Custom Buttons Houzez - Frontend Styles
 * تنسيقات الواجهة الأمامية للأزرار المخصصة
 */

/* تحميل خط Tajawal كـ fallback */
@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@200;300;400;500;600;700;800;900&display=swap');

/* الحاوي الأساسي للأزرار */
.cbh-button-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 20px 0;
    font-family: 'Tajawal', Arial, sans-serif;
}

/* الزر الأساسي */
.cbh-custom-button {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    border: none;
    outline: none;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    
    /* تأثيرات الظل */
    box-shadow: 
        0 4px 15px rgba(0, 0, 0, 0.1),
        0 2px 4px rgba(0, 0, 0, 0.06);
    
    /* تحسين الأداء */
    will-change: transform, box-shadow;
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* حالات الزر */
.cbh-custom-button:hover {
    transform: translateY(-2px);
    box-shadow: 
        0 8px 25px rgba(0, 0, 0, 0.15),
        0 4px 10px rgba(0, 0, 0, 0.1);
}

.cbh-custom-button:active {
    transform: translateY(0) scale(0.98);
    box-shadow: 
        0 2px 10px rgba(0, 0, 0, 0.1),
        0 1px 3px rgba(0, 0, 0, 0.06);
}

.cbh-custom-button:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

/* حاوي الأيقونة */
.cbh-icon-container {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: width, background-color;
}

/* الأيقونة */
.cbh-icon-container svg {
    transition: all 0.3s ease;
    will-change: transform, fill;
}

.cbh-custom-button:hover .cbh-icon-container svg {
    transform: scale(1.1) rotate(5deg);
}

/* نص الزر */
.cbh-button-text {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: inherit;
    letter-spacing: 0.025em;
    will-change: transform, color;
}

/* تأثيرات الحركة المختلفة */

/* Hover Expand Animation */
.cbh-animation-hover_expand:hover .cbh-icon-container {
    width: calc(100% - 8px) !important;
}

.cbh-animation-hover_expand:hover .cbh-button-text {
    transform: translateX(24px);
    color: #ffffff !important;
    font-weight: 700;
}

.cbh-animation-hover_expand:hover .cbh-icon-container svg {
    fill: #ffffff !important;
}

/* Hover Scale Animation */
.cbh-animation-hover_scale:hover {
    transform: scale(1.05) translateY(-2px);
}

.cbh-animation-hover_scale:hover .cbh-button-text {
    color: #ffffff !important;
}

.cbh-animation-hover_scale:hover .cbh-icon-container {
    background-color: rgba(0, 0, 0, 0.2) !important;
}

/* Hover Slide Animation */
.cbh-animation-hover_slide .cbh-button-text {
    transition: transform 0.3s ease;
}

.cbh-animation-hover_slide:hover .cbh-button-text {
    transform: translateX(8px);
}

.cbh-animation-hover_slide:hover .cbh-icon-container {
    transform: translateX(-4px);
}

/* أحجام الأزرار */
.cbh-size-small {
    width: 160px;
    height: 48px;
    font-size: 14px;
}

.cbh-size-small .cbh-icon-container {
    width: 40px;
    height: 40px;
}

.cbh-size-small .cbh-icon-container svg {
    width: 20px;
    height: 20px;
}

.cbh-size-medium {
    width: 192px;
    height: 56px;
    font-size: 16px;
}

.cbh-size-medium .cbh-icon-container {
    width: 48px;
    height: 48px;
}

.cbh-size-medium .cbh-icon-container svg {
    width: 24px;
    height: 24px;
}

.cbh-size-large {
    width: 224px;
    height: 64px;
    font-size: 18px;
}

.cbh-size-large .cbh-icon-container {
    width: 56px;
    height: 56px;
}

.cbh-size-large .cbh-icon-container svg {
    width: 28px;
    height: 28px;
}

.cbh-size-xl {
    width: 256px;
    height: 72px;
    font-size: 20px;
}

.cbh-size-xl .cbh-icon-container {
    width: 64px;
    height: 64px;
}

.cbh-size-xl .cbh-icon-container svg {
    width: 32px;
    height: 32px;
}

/* Border Radius */
.cbh-radius-none { border-radius: 0; }
.cbh-radius-sm { border-radius: 4px; }
.cbh-radius-md { border-radius: 8px; }
.cbh-radius-lg { border-radius: 12px; }
.cbh-radius-xl { border-radius: 16px; }
.cbh-radius-2xl { border-radius: 24px; }
.cbh-radius-full { border-radius: 50px; }

.cbh-radius-none .cbh-icon-container { border-radius: 0; }
.cbh-radius-sm .cbh-icon-container { border-radius: 2px; }
.cbh-radius-md .cbh-icon-container { border-radius: 6px; }
.cbh-radius-lg .cbh-icon-container { border-radius: 8px; }
.cbh-radius-xl .cbh-icon-container { border-radius: 12px; }
.cbh-radius-2xl .cbh-icon-container { border-radius: 16px; }
.cbh-radius-full .cbh-icon-container { border-radius: 50%; }

/* خطوط مختلفة */
.cbh-font-tajawal { font-family: 'Tajawal', Arial, sans-serif; }
.cbh-font-cairo { font-family: 'Cairo', 'Tajawal', Arial, sans-serif; }
.cbh-font-amiri { font-family: 'Amiri', 'Tajawal', Arial, sans-serif; }
.cbh-font-noto { font-family: 'Noto Sans Arabic', 'Tajawal', Arial, sans-serif; }
.cbh-font-arial { font-family: Arial, sans-serif; }

/* أوزان الخط */
.cbh-weight-300 { font-weight: 300; }
.cbh-weight-400 { font-weight: 400; }
.cbh-weight-500 { font-weight: 500; }
.cbh-weight-600 { font-weight: 600; }
.cbh-weight-700 { font-weight: 700; }
.cbh-weight-800 { font-weight: 800; }

/* تصميم متجاوب */
@media (max-width: 768px) {
    .cbh-button-container {
        margin: 15px 0;
    }
    
    .cbh-custom-button {
        width: 90% !important;
        max-width: 280px;
        font-size: 14px !important;
    }
    
    .cbh-button-text {
        padding: 0 16px !important;
    }
    
    /* تقليل حجم الأيقونات في الشاشات الصغيرة */
    .cbh-size-large .cbh-icon-container,
    .cbh-size-xl .cbh-icon-container {
        width: 48px !important;
        height: 48px !important;
    }
    
    .cbh-size-large .cbh-icon-container svg,
    .cbh-size-xl .cbh-icon-container svg {
        width: 24px !important;
        height: 24px !important;
    }
}

@media (max-width: 480px) {
    .cbh-custom-button {
        width: 95% !important;
        max-width: 240px;
        height: 48px !important;
        font-size: 13px !important;
    }
    
    .cbh-button-text {
        padding: 0 12px !important;
    }
    
    .cbh-icon-container {
        width: 40px !important;
        height: 40px !important;
    }
    
    .cbh-icon-container svg {
        width: 20px !important;
        height: 20px !important;
    }
}

/* تحسينات للأداء */
@media (prefers-reduced-motion: reduce) {
    .cbh-custom-button,
    .cbh-icon-container,
    .cbh-icon-container svg,
    .cbh-button-text {
        transition: none;
    }
    
    .cbh-custom-button:hover {
        transform: none;
    }
    
    .cbh-custom-button:hover .cbh-icon-container svg {
        transform: none;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .cbh-custom-button {
        box-shadow: 
            0 4px 15px rgba(255, 255, 255, 0.1),
            0 2px 4px rgba(255, 255, 255, 0.06);
    }
    
    .cbh-custom-button:hover {
        box-shadow: 
            0 8px 25px rgba(255, 255, 255, 0.15),
            0 4px 10px rgba(255, 255, 255, 0.1);
    }
}

/* تأثيرات تفاعلية إضافية */
.cbh-custom-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transform: translateX(-100%);
    transition: transform 0.6s;
    pointer-events: none;
}

.cbh-custom-button:hover::before {
    transform: translateX(100%);
}

/* تحسينات إمكانية الوصول */
.cbh-custom-button:focus-visible {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

/* تأثيرات للأزرار المعطلة */
.cbh-custom-button:disabled,
.cbh-custom-button.cbh-disabled {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

/* تأثيرات التحميل */
.cbh-custom-button.cbh-loading {
    pointer-events: none;
}

.cbh-custom-button.cbh-loading .cbh-button-text {
    opacity: 0.7;
}

.cbh-custom-button.cbh-loading .cbh-icon-container::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: cbh-spin 1s linear infinite;
}

@keyframes cbh-spin {
    to {
        transform: rotate(360deg);
    }
}

/* تخصيصات لـ RTL */
[dir="rtl"] .cbh-button-text {
    text-align: right;
}

[dir="rtl"] .cbh-icon-container {
    left: auto;
    right: 4px;
}

[dir="rtl"] .cbh-animation-hover_expand:hover .cbh-button-text {
    transform: translateX(-24px);
}

[dir="rtl"] .cbh-animation-hover_slide:hover .cbh-button-text {
    transform: translateX(-8px);
}

[dir="rtl"] .cbh-animation-hover_slide:hover .cbh-icon-container {
    transform: translateX(4px);
}

/* الأزرار الفارغة */
.cbh-custom-button.cbh-empty-button {
    opacity: 0.7;
    cursor: not-allowed;
    position: relative;
}

.cbh-custom-button.cbh-empty-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 2px,
        rgba(255, 255, 255, 0.1) 2px,
        rgba(255, 255, 255, 0.1) 4px
    );
    pointer-events: none;
    border-radius: inherit;
}

.cbh-custom-button.cbh-empty-button:hover {
    transform: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.cbh-custom-button.cbh-empty-button .cbh-icon-container {
    background: #ccc !important;
}

.cbh-custom-button.cbh-empty-button .cbh-button-text small {
    font-size: 0.8em;
    opacity: 0.8;
    font-weight: normal;
}

/* تأثير النبضة للأزرار الفارغة */
.cbh-custom-button.cbh-empty-button .cbh-icon-container {
    animation: cbh-pulse-empty 2s infinite;
}

@keyframes cbh-pulse-empty {
    0%, 100% {
        opacity: 0.7;
    }
    50% {
        opacity: 0.4;
    }
}

/* طباعة */
@media print {
    .cbh-custom-button {
        box-shadow: none;
        border: 1px solid #ccc;
    }
    
    .cbh-custom-button::before {
        display: none;
    }
    
    .cbh-custom-button.cbh-empty-button {
        display: none;
    }
}

/* تنسيقات الحقول المختلفة */
.cbh-field-container {
    margin: 15px 0;
    padding: 15px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    font-family: 'Tajawal', Arial, sans-serif;
    transition: all 0.3s ease;
}

.cbh-field-container:hover {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    border-color: #d1d5db;
}

.cbh-field-label {
    font-weight: 600;
    font-size: 14px;
    color: #374151;
    margin-bottom: 8px;
    display: block;
}

.cbh-field-value {
    font-size: 16px;
    color: #111827;
    line-height: 1.5;
    word-wrap: break-word;
}

.cbh-empty-value {
    color: #9ca3af;
    font-style: italic;
    opacity: 0.8;
}

/* حقل النص */
.cbh-text-field .cbh-field-value {
    padding: 8px 12px;
    background: #f9fafb;
    border-radius: 4px;
    border: 1px solid #e5e7eb;
}

/* حقل الرقم */
.cbh-number-field {
    text-align: center;
}

.cbh-number-field .cbh-field-value {
    font-weight: 700;
    font-size: 20px;
    color: #059669;
    padding: 10px;
    background: linear-gradient(135deg, #ecfdf5 0%, #f0fdf4 100%);
    border-radius: 6px;
    border: 1px solid #d1fae5;
}

/* حقل النص الطويل */
.cbh-textarea-field .cbh-field-value {
    padding: 12px;
    background: #f9fafb;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
    max-height: 200px;
    overflow-y: auto;
}

/* حقل القائمة المنسدلة */
.cbh-select-field .cbh-field-value {
    position: relative;
    padding: 10px 35px 10px 12px;
    background: #f9fafb;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
    cursor: pointer;
}

.cbh-select-indicator {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #6b7280;
    font-size: 12px;
}

/* حقل الاختيار المتعدد */
.cbh-multiselect-field .cbh-field-value {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.cbh-multi-item {
    background: #3b82f6;
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

/* حقل الخانات المربعة */
.cbh-checkbox-field .cbh-field-value {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cbh-checkbox-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
    color: #059669;
    font-weight: 500;
}

/* حقل الراديو */
.cbh-radio-field .cbh-field-value {
    position: relative;
    padding: 10px 12px 10px 35px;
    background: #f9fafb;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
}

.cbh-radio-indicator {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #3b82f6;
    font-size: 14px;
}

/* تحسينات responsive للحقول */
@media (max-width: 768px) {
    .cbh-field-container {
        margin: 10px 0;
        padding: 12px;
    }
    
    .cbh-field-label {
        font-size: 13px;
    }
    
    .cbh-field-value {
        font-size: 15px;
    }
    
    .cbh-number-field .cbh-field-value {
        font-size: 18px;
    }
    
    .cbh-multi-item {
        font-size: 11px;
        padding: 3px 6px;
    }
}

/* تأثيرات خاصة للحقول الفارغة */
.cbh-field-container:has(.cbh-empty-value) {
    opacity: 0.7;
    border-style: dashed;
}

.cbh-field-container:has(.cbh-empty-value):hover {
    opacity: 0.9;
}
