/* Contextual Editing Menu Styles - UPDATED: Compact Sider AI Style */
/* NEW: Two-tier compact system with primary toolbar and expandable secondary menu */

/* PRIMARY COMPACT MENU - Sider AI Style */
.contextual-menu-compact {
    position: fixed;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 8px;
    padding: 4px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15), 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 10000;
    opacity: 0;
    transform: translateY(-10px) scale(0.95);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 170px;
    max-width: 200px;
}

.contextual-menu-compact.contextual-menu-show {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* Arrow pointer like Sider AI */
.contextual-menu-compact::before {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid rgba(255, 255, 255, 0.95);
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

/* When positioned below selection */
.contextual-menu-compact.positioned-below::before {
    bottom: auto;
    top: -6px;
    border-top: none;
    border-bottom: 6px solid rgba(255, 255, 255, 0.95);
}

/* PRIMARY TOOLBAR */
.contextual-primary-bar {
    display: flex;
    gap: 2px;
    align-items: center;
}

/* COMPACT BUTTONS */
.contextual-btn {
    width: 28px;
    height: 28px;
    background: rgba(248, 250, 252, 0.8);
    border: 1px solid rgba(226, 232, 240, 0.6);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.contextual-btn:hover {
    background: #3b82f6;
    border-color: #3b82f6;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
}

.contextual-btn:hover .contextual-btn-icon {
    color: white;
    transform: scale(1.1);
}

.contextual-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2);
}

/* Button icon */
.contextual-btn-icon {
    font-size: 11px;
    color: #64748b;
    transition: all 0.15s ease;
    line-height: 1;
}

/* Expander button (More button) */
.contextual-btn-expander {
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.2);
}

.contextual-btn-expander .contextual-btn-icon {
    color: #3b82f6;
}

.contextual-btn-expander.expanded {
    background: #3b82f6;
    border-color: #3b82f6;
}

.contextual-btn-expander.expanded .contextual-btn-icon {
    color: white;
    transform: rotate(180deg);
}

/* SECONDARY MENU */
.contextual-secondary-menu {
    margin-top: 6px;
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 8px;
    padding: 6px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    opacity: 0;
    transform: translateY(-5px) scale(0.98);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.contextual-secondary-menu.contextual-secondary-show {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* Secondary menu sections */
.contextual-section {
    margin-bottom: 8px;
}

.contextual-section:last-child {
    margin-bottom: 0;
}

.contextual-section-header {
    font-size: 10px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    padding: 0 6px;
}

/* Secondary menu items */
.contextual-secondary-item {
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
    margin-bottom: 2px;
}

.contextual-secondary-item:last-child {
    margin-bottom: 0;
}

.contextual-secondary-item:hover {
    background: rgba(59, 130, 246, 0.08);
    color: #3b82f6;
}

.contextual-secondary-item.has-submenu:hover {
    background: rgba(16, 185, 129, 0.08);
    color: #10b981;
}

.secondary-item-icon {
    font-size: 11px;
    width: 16px;
    text-align: center;
    flex-shrink: 0;
    opacity: 0.8;
}

.secondary-item-label {
    font-size: 12px;
    font-weight: 500;
    flex: 1;
    line-height: 1.2;
}

.secondary-item-arrow {
    font-size: 8px;
    color: #94a3b8;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.contextual-secondary-item:hover .secondary-item-arrow {
    color: #10b981;
    transform: translateX(2px);
}

/* COMPACT SUBMENU */
.contextual-compact-submenu {
    position: absolute;
    left: 100%;
    top: 0;
    margin-left: 6px;
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 6px;
    padding: 4px;
    min-width: 120px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
    opacity: 0;
    transform: translateX(-8px) scale(0.95);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    z-index: 10001;
}

.contextual-compact-submenu.contextual-compact-submenu-show {
    opacity: 1;
    transform: translateX(0) scale(1);
    pointer-events: auto;
}

.contextual-compact-submenu-item {
    padding: 6px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 500;
    color: #374151;
    transition: all 0.15s ease;
    margin-bottom: 2px;
    line-height: 1.2;
}

.contextual-compact-submenu-item:last-child {
    margin-bottom: 0;
}

.contextual-compact-submenu-item:hover {
    background: #10b981;
    color: white;
    transform: translateX(2px);
}

/* LOADING INDICATOR */
.contextual-loading-indicator {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    padding: 16px 20px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    z-index: 10002;
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.9);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.contextual-loading-indicator.contextual-loading-show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.contextual-loading-content {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #374151;
    font-size: 13px;
    font-weight: 500;
}

.contextual-loading-spinner {
    width: 20px;
    height: 20px;
    color: #3b82f6;
    flex-shrink: 0;
}

.contextual-loading-spinner svg {
    animation: spin 1s linear infinite;
}

/* RESPONSIVE DESIGN */
@media (max-width: 768px) {
    .contextual-menu-compact {
        min-width: 160px;
        max-width: calc(100vw - 20px);
    }
    
    .contextual-btn {
        width: 32px;
        height: 32px;
    }
    
    .contextual-btn-icon {
        font-size: 12px;
    }
    
    .contextual-secondary-menu {
        margin-top: 8px;
    }
    
    .contextual-compact-submenu {
        position: fixed;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) scale(0.95);
        margin: 0;
        min-width: 140px;
        max-width: calc(100vw - 40px);
    }
    
    .contextual-compact-submenu.contextual-compact-submenu-show {
        transform: translate(-50%, -50%) scale(1);
    }
    
    .contextual-loading-indicator {
        padding: 12px 16px;
        max-width: calc(100vw - 40px);
    }
    
    .contextual-loading-content {
        gap: 10px;
        font-size: 12px;
    }
    
    .contextual-loading-spinner {
        width: 18px;
        height: 18px;
    }
}

@media (max-width: 480px) {
    .contextual-menu-compact {
        min-width: 150px;
        padding: 3px;
    }
    
    .contextual-primary-bar {
        gap: 1px;
    }
    
    .contextual-btn {
        width: 28px;
        height: 28px;
    }
    
    .contextual-btn-icon {
        font-size: 11px;
    }
    
    .contextual-secondary-item {
        padding: 5px 6px;
        gap: 6px;
    }
    
    .secondary-item-label {
        font-size: 11px;
    }
    
    .contextual-compact-submenu-item {
        padding: 5px 6px;
        font-size: 10px;
    }
}

/* HIGH CONTRAST MODE */
@media (prefers-contrast: high) {
    .contextual-menu-compact {
        border: 2px solid #000;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
        background: #fff;
    }
    
    .contextual-btn {
        border: 2px solid #333;
        background: #fff;
    }
    
    .contextual-btn:hover {
        background: #000;
        border-color: #000;
    }
    
    .contextual-btn:hover .contextual-btn-icon {
        color: #fff;
    }
    
    .contextual-secondary-menu {
        border: 2px solid #333;
        background: #fff;
    }
    
    .contextual-secondary-item:hover {
        background: #000;
        color: #fff;
    }
    
    .contextual-compact-submenu {
        border: 2px solid #333;
        background: #fff;
    }
    
    .contextual-compact-submenu-item:hover {
        background: #000;
        color: #fff;
    }
}

/* REDUCED MOTION */
@media (prefers-reduced-motion: reduce) {
    .contextual-menu-compact,
    .contextual-secondary-menu,
    .contextual-compact-submenu,
    .contextual-loading-indicator,
    .contextual-btn,
    .contextual-secondary-item,
    .contextual-compact-submenu-item {
        transition: none !important;
        animation: none !important;
    }
    
    .contextual-loading-spinner svg {
        animation: none !important;
    }
    
    .contextual-btn:hover,
    .contextual-secondary-item:hover,
    .contextual-compact-submenu-item:hover {
        transform: none !important;
    }
}

/* PRINT STYLES */
@media print {
    .contextual-menu-compact,
    .contextual-secondary-menu,
    .contextual-compact-submenu,
    .contextual-loading-indicator {
        display: none !important;
    }
}

/* ANIMATION KEYFRAMES */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* FOCUS STATES FOR ACCESSIBILITY */
.contextual-btn:focus-visible,
.contextual-secondary-item:focus-visible,
.contextual-compact-submenu-item:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* SPECIAL STATES */
.contextual-btn.processing {
    opacity: 0.6;
    pointer-events: none;
}

.contextual-btn.processing .contextual-btn-icon {
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ENHANCED VISUAL FEEDBACK */
.contextual-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.3) 50%, transparent 70%);
    transform: translateX(-100%);
    transition: transform 0.6s ease;
    pointer-events: none;
}

.contextual-btn:hover::before {
    transform: translateX(100%);
}

/* TOOLTIP ENHANCEMENT */
.contextual-btn[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 10px;
    white-space: nowrap;
    margin-bottom: 4px;
    opacity: 0;
    animation: fadeInTooltip 0.3s ease forwards;
    z-index: 10003;
}

@keyframes fadeInTooltip {
    to { opacity: 1; }
}