/**
 * Team Portal - Quick Actions Styles
 * 
 * Components:
 * - Floating Action Button (FAB)
 * - Command Palette
 * - Context Menus
 * - Bulk Action Bar
 * 
 * @package TeamPortal
 * @version 1.5.0
 */

/* ============================================
   CSS Variables
   ============================================ */
:root {
    --tp-qa-primary: #2271b1;
    --tp-qa-primary-dark: #135e96;
    --tp-qa-danger: #dc3545;
    --tp-qa-success: #28a745;
    --tp-qa-warning: #ffc107;
    --tp-qa-info: #17a2b8;
    
    --tp-qa-bg: #ffffff;
    --tp-qa-bg-dark: #f0f0f1;
    --tp-qa-text: #2c3338;
    --tp-qa-text-light: #646970;
    
    --tp-qa-shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --tp-qa-shadow-md: 0 4px 8px rgba(0, 0, 0, 0.15);
    --tp-qa-shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.2);
    --tp-qa-shadow-xl: 0 12px 24px rgba(0, 0, 0, 0.25);
    
    --tp-qa-radius: 8px;
    --tp-qa-radius-full: 50%;
    
    --tp-qa-duration: 300ms;
    --tp-qa-easing: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   Floating Action Button (FAB)
   ============================================ */

.tp-fab {
    position: fixed;
    z-index: 9999;
    direction: ltr;
}

/* FAB Positions */
.tp-fab-bottom-right {
    bottom: 24px;
    right: 24px;
}

.tp-fab-bottom-left {
    bottom: 24px;
    left: 24px;
}

.tp-fab-top-right {
    top: 80px;
    right: 24px;
}

.tp-fab-top-left {
    top: 80px;
    left: 24px;
}

/* FAB Trigger Button */
.tp-fab-trigger {
    width: 56px;
    height: 56px;
    border: none;
    border-radius: var(--tp-qa-radius-full);
    background: var(--tp-qa-primary);
    color: #ffffff;
    font-size: 24px;
    cursor: pointer;
    box-shadow: var(--tp-qa-shadow-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--tp-qa-duration) var(--tp-qa-easing);
    position: relative;
    z-index: 2;
}

.tp-fab-trigger:hover {
    background: var(--tp-qa-primary-dark);
    box-shadow: var(--tp-qa-shadow-xl);
    transform: scale(1.05);
}

.tp-fab-trigger:active {
    transform: scale(0.95);
}

.tp-fab-icon {
    display: block;
    transition: transform var(--tp-qa-duration) var(--tp-qa-easing);
}

.tp-fab-active .tp-fab-icon {
    transform: rotate(45deg);
}

/* FAB Menu */
.tp-fab-menu {
    position: absolute;
    bottom: 70px;
    right: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    opacity: 0;
    visibility: hidden;
    transform: scale(0.8) translateY(20px);
    transition: all var(--tp-qa-duration) var(--tp-qa-easing);
}

.tp-fab-active .tp-fab-menu {
    opacity: 1;
    visibility: visible;
    transform: scale(1) translateY(0);
}

/* FAB Menu Items */
.tp-fab-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--tp-qa-bg);
    border: 1px solid #dcdcde;
    border-radius: var(--tp-qa-radius);
    box-shadow: var(--tp-qa-shadow-md);
    cursor: pointer;
    transition: all var(--tp-qa-duration) var(--tp-qa-easing);
    white-space: nowrap;
    min-width: 200px;
    text-align: right;
    direction: rtl;
}

.tp-fab-item:hover {
    background: var(--tp-qa-bg-dark);
    box-shadow: var(--tp-qa-shadow-lg);
    transform: translateX(-4px);
}

.tp-fab-item-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.tp-fab-item-label {
    font-size: 14px;
    color: var(--tp-qa-text);
    font-weight: 500;
}

/* FAB Animation Stagger */
.tp-fab-active .tp-fab-item {
    animation: tp-fab-item-in 0.3s var(--tp-qa-easing) backwards;
}

.tp-fab-active .tp-fab-item:nth-child(1) { animation-delay: 0.05s; }
.tp-fab-active .tp-fab-item:nth-child(2) { animation-delay: 0.1s; }
.tp-fab-active .tp-fab-item:nth-child(3) { animation-delay: 0.15s; }
.tp-fab-active .tp-fab-item:nth-child(4) { animation-delay: 0.2s; }
.tp-fab-active .tp-fab-item:nth-child(5) { animation-delay: 0.25s; }
.tp-fab-active .tp-fab-item:nth-child(6) { animation-delay: 0.3s; }

@keyframes tp-fab-item-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   Command Palette
   ============================================ */

.tp-command-palette {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 99999;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 100px;
    pointer-events: none; /* لا يمنع التفاعل عندما يكون مخفي */
}

.tp-command-palette.tp-palette-active {
    display: flex;
    pointer-events: auto; /* يسمح بالتفاعل عندما يكون نشط */
}

/* Palette Backdrop */
.tp-palette-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0; /* مخفي افتراضياً */
    pointer-events: none;
    transition: opacity var(--tp-qa-duration) var(--tp-qa-easing);
}

/* إظهار الـ backdrop فقط عندما يكون الـ palette نشط */
.tp-command-palette.tp-palette-active .tp-palette-backdrop {
    opacity: 1;
    pointer-events: auto;
    animation: tp-palette-backdrop-in var(--tp-qa-duration) var(--tp-qa-easing);
}

@keyframes tp-palette-backdrop-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Palette Container */
.tp-palette-container {
    position: relative;
    width: 90%;
    max-width: 640px;
    background: var(--tp-qa-bg);
    border-radius: var(--tp-qa-radius);
    box-shadow: var(--tp-qa-shadow-xl);
    max-height: 60vh;
    display: flex;
    flex-direction: column;
    animation: tp-palette-in var(--tp-qa-duration) var(--tp-qa-easing);
    overflow: hidden;
}

@keyframes tp-palette-in {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Palette Header */
.tp-palette-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border-bottom: 1px solid #dcdcde;
}

.tp-palette-search {
    flex: 1;
    border: none;
    outline: none;
    font-size: 16px;
    padding: 8px 0;
    color: var(--tp-qa-text);
    direction: rtl;
}

.tp-palette-search::placeholder {
    color: var(--tp-qa-text-light);
}

.tp-palette-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--tp-qa-text-light);
    font-size: 20px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tp-palette-close:hover {
    background: var(--tp-qa-bg-dark);
    color: var(--tp-qa-text);
}

/* Palette Body */
.tp-palette-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.tp-palette-results {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

/* Scrollbar */
.tp-palette-results::-webkit-scrollbar {
    width: 8px;
}

.tp-palette-results::-webkit-scrollbar-track {
    background: transparent;
}

.tp-palette-results::-webkit-scrollbar-thumb {
    background: #c3c4c7;
    border-radius: 4px;
}

.tp-palette-results::-webkit-scrollbar-thumb:hover {
    background: #a7aaad;
}

/* Palette Category */
.tp-palette-category {
    font-size: 12px;
    font-weight: 600;
    color: var(--tp-qa-text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 12px 12px 8px;
    direction: rtl;
}

/* Palette Item */
.tp-palette-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    direction: rtl;
}

.tp-palette-item:hover,
.tp-palette-item-selected {
    background: var(--tp-qa-bg-dark);
}

.tp-palette-item-selected {
    background: linear-gradient(90deg, rgba(34, 113, 177, 0.1) 0%, transparent 100%);
}

.tp-palette-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.tp-palette-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.tp-palette-label {
    font-size: 14px;
    color: var(--tp-qa-text);
}

.tp-palette-shortcut {
    font-size: 12px;
    color: var(--tp-qa-text-light);
    background: var(--tp-qa-bg-dark);
    padding: 4px 8px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
}

.tp-palette-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--tp-qa-text-light);
    font-size: 14px;
}

/* Palette Footer */
.tp-palette-footer {
    padding: 12px 16px;
    border-top: 1px solid #dcdcde;
    background: var(--tp-qa-bg-dark);
}

.tp-palette-hint {
    font-size: 12px;
    color: var(--tp-qa-text-light);
    display: flex;
    gap: 12px;
    justify-content: center;
}

.tp-palette-hint kbd {
    background: var(--tp-qa-bg);
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 11px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* ============================================
   Context Menu
   ============================================ */

.tp-context-menu {
    position: absolute;
    z-index: 99999;
    background: var(--tp-qa-bg);
    border-radius: var(--tp-qa-radius);
    box-shadow: var(--tp-qa-shadow-xl);
    min-width: 200px;
    padding: 4px;
    opacity: 0;
    visibility: hidden;
    transform: scale(0.95);
    transition: all 0.15s var(--tp-qa-easing);
}

.tp-context-menu.tp-context-menu-active {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
}

.tp-context-menu-items {
    display: flex;
    flex-direction: column;
}

/* Context Menu Item */
.tp-context-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: none;
    background: transparent;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
    text-align: right;
    direction: rtl;
    width: 100%;
}

.tp-context-menu-item:hover {
    background: var(--tp-qa-bg-dark);
}

.tp-context-menu-item:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.tp-context-menu-item:disabled:hover {
    background: transparent;
}

.tp-context-icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.tp-context-label {
    flex: 1;
    font-size: 14px;
    color: var(--tp-qa-text);
}

.tp-context-shortcut {
    font-size: 11px;
    color: var(--tp-qa-text-light);
    font-family: 'Courier New', monospace;
}

/* Context Menu Separator */
.tp-context-menu-item[data-action="separator"] {
    height: 1px;
    padding: 0;
    margin: 4px 0;
    background: #dcdcde;
    cursor: default;
    pointer-events: none;
}

.tp-context-menu-item[data-action="separator"]:hover {
    background: #dcdcde;
}

/* ============================================
   Bulk Action Bar
   ============================================ */

.tp-bulk-bar {
    position: fixed;
    bottom: -80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9998;
    background: var(--tp-qa-bg);
    border-radius: var(--tp-qa-radius);
    box-shadow: var(--tp-qa-shadow-xl);
    padding: 16px 24px;
    display: flex;
    align-items: center;
    gap: 24px;
    min-width: 400px;
    transition: bottom var(--tp-qa-duration) var(--tp-qa-easing);
    direction: rtl;
}

.tp-bulk-bar.tp-bulk-bar-active {
    bottom: 24px;
}

/* Bulk Info */
.tp-bulk-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--tp-qa-text);
}

.tp-bulk-count {
    font-weight: 600;
    color: var(--tp-qa-primary);
    font-size: 16px;
}

/* Bulk Actions */
.tp-bulk-actions {
    display: flex;
    gap: 8px;
}

.tp-bulk-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid #dcdcde;
    background: var(--tp-qa-bg);
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    color: var(--tp-qa-text);
    transition: all 0.2s;
}

.tp-bulk-btn:hover {
    background: var(--tp-qa-bg-dark);
    border-color: var(--tp-qa-primary);
    color: var(--tp-qa-primary);
}

.tp-bulk-btn span {
    font-size: 16px;
}

.tp-bulk-danger:hover {
    background: var(--tp-qa-danger);
    border-color: var(--tp-qa-danger);
    color: #ffffff;
}

/* Bulk Close */
.tp-bulk-close {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--tp-qa-text-light);
    font-size: 18px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: auto;
}

.tp-bulk-close:hover {
    background: var(--tp-qa-bg-dark);
    color: var(--tp-qa-text);
}

/* ============================================
   Responsive Design
   ============================================ */

@media (max-width: 768px) {
    /* FAB */
    .tp-fab-bottom-right,
    .tp-fab-bottom-left {
        bottom: 16px;
    }
    
    .tp-fab-bottom-right {
        right: 16px;
    }
    
    .tp-fab-bottom-left {
        left: 16px;
    }
    
    .tp-fab-trigger {
        width: 48px;
        height: 48px;
        font-size: 20px;
    }
    
    .tp-fab-menu {
        bottom: 60px;
    }
    
    .tp-fab-item {
        min-width: 160px;
        padding: 10px 14px;
    }
    
    /* Command Palette */
    .tp-palette-container {
        width: 95%;
        max-height: 70vh;
    }
    
    .tp-palette-search {
        font-size: 14px;
    }
    
    /* Bulk Bar */
    .tp-bulk-bar {
        min-width: auto;
        width: 90%;
        padding: 12px 16px;
        flex-wrap: wrap;
        gap: 12px;
    }
    
    .tp-bulk-actions {
        width: 100%;
        justify-content: space-between;
    }
    
    .tp-bulk-btn {
        flex: 1;
        justify-content: center;
        padding: 8px 12px;
        font-size: 13px;
    }
}

/* ============================================
   Dark Mode Support
   ============================================ */

@media (prefers-color-scheme: dark) {
    :root {
        --tp-qa-bg: #1e1e1e;
        --tp-qa-bg-dark: #2d2d2d;
        --tp-qa-text: #e0e0e0;
        --tp-qa-text-light: #a0a0a0;
    }
    
    .tp-fab-trigger {
        background: #3c8dbc;
    }
    
    .tp-fab-trigger:hover {
        background: #2c7aa8;
    }
    
    .tp-fab-item,
    .tp-palette-container,
    .tp-context-menu,
    .tp-bulk-bar {
        border-color: #3d3d3d;
    }
    
    .tp-palette-search::placeholder {
        color: #808080;
    }
    
    .tp-palette-results::-webkit-scrollbar-thumb {
        background: #4d4d4d;
    }
    
    .tp-palette-results::-webkit-scrollbar-thumb:hover {
        background: #606060;
    }
}

/* ============================================
   Print Styles
   ============================================ */

@media print {
    .tp-fab,
    .tp-command-palette,
    .tp-context-menu,
    .tp-bulk-bar {
        display: none !important;
    }
}

/* ============================================
   Accessibility
   ============================================ */

/* Focus Styles */
.tp-fab-trigger:focus,
.tp-fab-item:focus,
.tp-palette-search:focus,
.tp-palette-close:focus,
.tp-palette-item:focus,
.tp-context-menu-item:focus,
.tp-bulk-btn:focus,
.tp-bulk-close:focus {
    outline: 2px solid var(--tp-qa-primary);
    outline-offset: 2px;
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .tp-fab-trigger,
    .tp-fab-item,
    .tp-palette-container,
    .tp-context-menu,
    .tp-bulk-bar {
        border: 2px solid currentColor;
    }
}
