/**
 * ============================================
 * Quick Add FAB - زر الإضافة السريعة
 * ============================================
 * 
 * @version 1.1.0
 * @description زر مدمج في شريط الإجراءات السريعة (Quick Actions Bar)
 * @features
 * - زر إضافة مدمج في الشريط السفلي الداكن
 * - قائمة منسدلة للخيارات (عميل، مستخدم، مهمة، مستند)
 * - تصميم متناسق مع شريط الإجراءات السريعة
 * - تأثيرات حركية سلسة
 */

/* ============================================
   1. Quick Add Button in Quick Actions Bar
   ============================================ */
/* Container داخل الشريط السريع */
.quick-add-container {
    position: relative;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

/* الزر الرئيسي - مدمج في الشريط */
.quick-action-btn.fab-main-btn {
    width: auto;
    min-width: 120px;
    height: 44px;
    padding: 0 20px;
    border-radius: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    box-shadow: 
        0 4px 12px rgba(102, 126, 234, 0.3),
        0 2px 6px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: white;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.quick-action-btn.fab-main-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        45deg,
        transparent 30%,
        rgba(255, 255, 255, 0.15) 50%,
        transparent 70%
    );
    animation: shimmer 3s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.quick-action-btn.fab-main-btn:hover {
    transform: translateY(-2px);
    box-shadow: 
        0 6px 20px rgba(102, 126, 234, 0.4),
        0 3px 10px rgba(0, 0, 0, 0.2);
}

.quick-action-btn.fab-main-btn:active {
    transform: translateY(0);
}

.quick-action-btn.fab-main-btn i {
    position: relative;
    z-index: 1;
    font-size: 18px;
    transition: transform 0.3s ease;
}

.quick-action-btn.fab-main-btn.active i {
    transform: rotate(45deg);
}

.quick-action-btn.fab-main-btn span {
    position: relative;
    z-index: 1;
}

/* ============================================
   2. Quick Add Menu (Dropdown)
   ============================================ */
.fab-menu {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 220px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    z-index: 100000;
}

.fab-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
    pointer-events: all;
}

/* عناصر القائمة */
.fab-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    padding: 14px 20px;
    border-radius: 12px;
    box-shadow: 
        0 4px 16px rgba(0, 0, 0, 0.12),
        0 2px 8px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.fab-menu.active .fab-menu-item {
    animation: slideInUp 0.3s ease forwards;
}

.fab-menu.active .fab-menu-item:nth-child(1) { animation-delay: 0.05s; }
.fab-menu.active .fab-menu-item:nth-child(2) { animation-delay: 0.1s; }
.fab-menu.active .fab-menu-item:nth-child(3) { animation-delay: 0.15s; }
.fab-menu.active .fab-menu-item:nth-child(4) { animation-delay: 0.2s; }

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fab-menu-item:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 
        0 8px 20px rgba(0, 0, 0, 0.15),
        0 4px 10px rgba(0, 0, 0, 0.1);
    border-color: rgba(0, 0, 0, 0.12);
}

.fab-menu-item-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: white;
    flex-shrink: 0;
}

/* ألوان الأيقونات */
.fab-menu-item[data-action="add-client"] .fab-menu-item-icon {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.fab-menu-item[data-action="add-user"] .fab-menu-item-icon {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
}

.fab-menu-item[data-action="add-task"] .fab-menu-item-icon {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.fab-menu-item[data-action="add-document"] .fab-menu-item-icon {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
}

.fab-menu-item-text {
    font-size: 14px;
    font-weight: 600;
    color: #2d3748;
}

/* ============================================
   3. Add Client Modal
   ============================================ */
.add-client-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100000;
    display: none;
    align-items: center;
    justify-content: center;
}

.add-client-modal.active {
    display: flex;
}

.add-client-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.add-client-modal-container {
    position: relative;
    width: 90%;
    max-width: 900px;
    max-height: 85vh;
    background: white;
    border-radius: 24px;
    box-shadow: 
        0 30px 90px rgba(0, 0, 0, 0.3),
        0 0 0 1px rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modalSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(50px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* رأس النموذج */
.add-client-modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 24px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}

.add-client-modal-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 50%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(255, 255, 255, 0.1) 0%, transparent 50%);
    pointer-events: none;
}

.add-client-modal-title {
    display: flex;
    align-items: center;
    gap: 16px;
    position: relative;
    z-index: 1;
}

.add-client-modal-title-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
}

.add-client-modal-title h2 {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.add-client-modal-close {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    z-index: 1;
}

.add-client-modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

/* محتوى النموذج */
.add-client-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
}

.add-client-form-section {
    margin-bottom: 32px;
}

.add-client-form-section:last-child {
    margin-bottom: 0;
}

.add-client-form-section-title {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid #e2e8f0;
}

.add-client-form-section-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.add-client-form-section-title h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: #2d3748;
}

/* حقول النموذج */
.add-client-form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.add-client-form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.add-client-form-label {
    font-size: 13px;
    font-weight: 600;
    color: #4a5568;
    display: flex;
    align-items: center;
    gap: 6px;
}

.add-client-form-label .required {
    color: #ef4444;
}

.add-client-form-input,
.add-client-form-select,
.add-client-form-textarea {
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 14px;
    color: #2d3748;
    transition: all 0.3s ease;
    font-family: inherit;
}

.add-client-form-input:focus,
.add-client-form-select:focus,
.add-client-form-textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.add-client-form-textarea {
    min-height: 100px;
    resize: vertical;
}

.add-client-form-help {
    font-size: 12px;
    color: #718096;
}

/* ذيل النموذج */
.add-client-modal-footer {
    padding: 20px 32px;
    background: #f7fafc;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.add-client-modal-footer-info {
    font-size: 13px;
    color: #718096;
}

.add-client-modal-footer-actions {
    display: flex;
    gap: 12px;
}

.add-client-modal-btn {
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.add-client-modal-btn-secondary {
    background: white;
    color: #4a5568;
    border: 2px solid #e2e8f0;
}

.add-client-modal-btn-secondary:hover {
    background: #f7fafc;
    border-color: #cbd5e0;
}

.add-client-modal-btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.add-client-modal-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

.add-client-modal-btn-primary:active {
    transform: translateY(0);
}

/* ============================================
   4. Print Options Panel
   ============================================ */
.print-options-wrapper {
    position: relative;
    display: inline-block;
    margin-left: 12px;
    vertical-align: middle;
}

/* إخفاء زر الطباعة السفلي - نستخدم الزر العلوي بدلاً منه */
.print-options-btn {
    display: none !important; /* مخفي - استخدم #advanced-print-btn في شريط الأدوات */
}

/* استمرار في عرض اللوحة فقط */
.print-options-wrapper .print-options-panel {
    display: block; /* اللوحة تظهر عند التفعيل من الزر العلوي */
}
}

.print-options-btn i {
    font-size: 16px;
}

.print-options-btn span {
    letter-spacing: 0.3px;
}

/* تأثير النبض عند التحميل */
.print-options-btn.new {
    animation: pulse 2s ease-in-out 3;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.print-options-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 350px;
    background: white;
    border-radius: 16px;
    box-shadow: 
        0 12px 32px rgba(0, 0, 0, 0.15),
        0 4px 12px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
}

.print-options-panel.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.print-options-header {
    padding: 20px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.print-options-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: #2d3748;
}

.print-options-select-all {
    font-size: 13px;
    color: #667eea;
    cursor: pointer;
    font-weight: 600;
}

.print-options-select-all:hover {
    text-decoration: underline;
}

.print-options-body {
    padding: 16px;
    max-height: 400px;
    overflow-y: auto;
}

.print-options-group {
    margin-bottom: 16px;
}

.print-options-group:last-child {
    margin-bottom: 0;
}

.print-options-group-title {
    font-size: 12px;
    font-weight: 700;
    color: #718096;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.print-option-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.print-option-item:hover {
    background: #f7fafc;
}

.print-option-checkbox {
    width: 18px;
    height: 18px;
    border: 2px solid #cbd5e0;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.print-option-item input[type="checkbox"] {
    display: none;
}

.print-option-item input[type="checkbox"]:checked + .print-option-checkbox {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: #667eea;
}

.print-option-checkbox i {
    color: white;
    font-size: 12px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.print-option-item input[type="checkbox"]:checked + .print-option-checkbox i {
    opacity: 1;
}

.print-option-label {
    flex: 1;
    font-size: 14px;
    color: #2d3748;
}

.print-options-footer {
    padding: 16px 20px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 12px;
}

.print-options-footer button {
    flex: 1;
    padding: 10px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
}

.print-options-cancel {
    background: #f7fafc;
    color: #4a5568;
}

.print-options-cancel:hover {
    background: #e2e8f0;
}

.print-options-print {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.print-options-print:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

/* ============================================
   5. Responsive Design
   ============================================ */
@media (max-width: 768px) {
    .quick-add-fab {
        bottom: 70px;
    }
    
    .fab-main-btn {
        width: 56px;
        height: 56px;
        font-size: 24px;
    }
    
    .add-client-modal-container {
        width: 95%;
        max-height: 90vh;
    }
    
    .add-client-modal-header,
    .add-client-modal-body,
    .add-client-modal-footer {
        padding: 20px;
    }
    
    .add-client-form-row {
        grid-template-columns: 1fr;
    }
    
    .print-options-panel {
        width: 300px;
        right: auto;
        left: 0;
    }
}

/* ============================================
   6. Dark Mode Support
   ============================================ */
@media (prefers-color-scheme: dark) {
    .fab-menu-item {
        background: #2d3748;
    }
    
    .fab-menu-item-text {
        color: #e2e8f0;
    }
    
    .add-client-modal-container {
        background: #1a202c;
    }
    
    .add-client-form-section-title h3 {
        color: #e2e8f0;
    }
    
    .add-client-form-input,
    .add-client-form-select,
    .add-client-form-textarea {
        background: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }
    
    .add-client-modal-footer {
        background: #2d3748;
        border-top-color: #4a5568;
    }
    
    .print-options-panel {
        background: #2d3748;
        border-color: #4a5568;
    }
    
    .print-option-item:hover {
        background: #1a202c;
    }
}

/* ============================================
   7. Loading State
   ============================================ */
.add-client-modal-btn-primary.loading {
    position: relative;
    color: transparent;
    pointer-events: none;
}

.add-client-modal-btn-primary.loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin-left: -10px;
    margin-top: -10px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================
   8. Integration with Quick Actions Bar
   ============================================ */
/* التأكد من التناسق مع شريط الإجراءات السريعة */
.quick-actions-bar .quick-add-container {
    margin-right: auto; /* دفع الزر إلى اليسار */
}

/* تنسيق الزر ليتناسب مع أزرار الشريط الأخرى */
.quick-actions-bar .quick-action-btn.fab-main-btn {
    height: auto;
    padding: 10px 20px;
}

/* Dark mode adjustments for Quick Actions Bar integration */
body.dark-mode .quick-action-btn.fab-main-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 
        0 4px 12px rgba(102, 126, 234, 0.4),
        0 2px 6px rgba(0, 0, 0, 0.2);
}

body.dark-mode .fab-menu-item {
    background: rgba(45, 55, 72, 0.98);
    border-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode .fab-menu-item-text {
    color: #e2e8f0;
}

body.dark-mode .fab-menu-item:hover {
    background: rgba(26, 32, 44, 0.98);
    border-color: rgba(102, 126, 234, 0.3);
}

/* تنسيق زر خيارات الطباعة */
body.dark-mode .print-options-btn {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

body.dark-mode .print-options-panel {
    background: #2d3748;
    border-color: #4a5568;
}

body.dark-mode .print-options-header,
body.dark-mode .print-options-body {
    border-bottom-color: #4a5568;
}

body.dark-mode .print-options-group-title,
body.dark-mode .print-option-label {
    color: #e2e8f0;
}

body.dark-mode .print-option-item:hover {
    background: rgba(26, 32, 44, 0.5);
}

body.dark-mode .print-options-cancel {
    background: #1a202c;
    color: #e2e8f0;
}

body.dark-mode .print-options-cancel:hover {
    background: #2d3748;
}

/* تنسيق متجاوب */
@media (max-width: 768px) {
    .print-options-wrapper {
        margin-left: 8px;
    }
    
    .print-options-btn {
        padding: 8px 12px;
        font-size: 13px;
    }
    
    .print-options-btn span {
        display: none;
    }
    
    .print-options-btn i {
        font-size: 18px;
        margin: 0;
    }
    
    .print-options-panel {
        width: 300px;
        right: auto;
        left: 50%;
        transform: translateX(-50%) translateY(-10px);
    }
    
    .print-options-panel.active {
        transform: translateX(-50%) translateY(0);
    }
}
