/* Article Writer Step 8 Contextual Editing Styles */
/* Based on main app contextual-editing.css - Sider AI Style */
/* Targets: .contextual-menu-compact.article-contextual-menu */

/* =============================================== */
/* PRIMARY COMPACT MENU - Sider AI Style */
/* =============================================== */

.contextual-menu-compact.article-contextual-menu {
    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.article-contextual-menu.contextual-menu-show {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* Arrow pointer like Sider AI */
.contextual-menu-compact.article-contextual-menu::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.article-contextual-menu.positioned-below::before {
    bottom: auto;
    top: -6px;
    border-top: none;
    border-bottom: 6px solid rgba(255, 255, 255, 0.95);
}

/* =============================================== */
/* PRIMARY TOOLBAR */
/* =============================================== */

.contextual-menu-compact.article-contextual-menu .contextual-primary-bar {
    display: flex;
    gap: 2px;
    align-items: center;
}

/* =============================================== */
/* COMPACT BUTTONS */
/* =============================================== */

.contextual-menu-compact.article-contextual-menu .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-menu-compact.article-contextual-menu .contextual-btn:hover {
    background: #3b82f6;
    border-color: #3b82f6;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
}

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

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

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

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

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

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

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

/* =============================================== */
/* SECONDARY MENU */
/* =============================================== */

.contextual-menu-compact.article-contextual-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-menu-compact.article-contextual-menu .contextual-secondary-menu.contextual-secondary-show {
    opacity: 1;
    transform: translateY(0) scale(1);
}

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

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

.contextual-menu-compact.article-contextual-menu .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-menu-compact.article-contextual-menu .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-menu-compact.article-contextual-menu .contextual-secondary-item:last-child {
    margin-bottom: 0;
}

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

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

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

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

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

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

/* =============================================== */
/* CURRENT MODEL ITEM STYLING (Article-specific) */
/* =============================================== */

.contextual-menu-compact.article-contextual-menu .current-model-item {
    background: linear-gradient(135deg, #fef7ed, #fed7aa);
    border: 1px solid #fdba74;
    border-radius: 6px;
    padding: 6px 8px;
    margin: 2px 0;
    transition: all 0.15s ease;
}

.contextual-menu-compact.article-contextual-menu .current-model-item:hover {
    background: linear-gradient(135deg, #fed7aa, #fb923c);
    border-color: #f97316;
    transform: translateX(2px);
}

.contextual-menu-compact.article-contextual-menu .current-model-item .secondary-item-icon {
    color: #ea580c;
}

.contextual-menu-compact.article-contextual-menu .current-model-item .secondary-item-label {
    color: #c2410c;
    font-weight: 600;
    font-size: 11px;
}

.contextual-menu-compact.article-contextual-menu .current-model-item .secondary-item-arrow {
    color: #f97316;
}

/* =============================================== */
/* COMPACT SUBMENU */
/* =============================================== */

.contextual-menu-compact.article-contextual-menu .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-menu-compact.article-contextual-menu .contextual-compact-submenu.contextual-compact-submenu-show {
    opacity: 1;
    transform: translateX(0) scale(1);
    pointer-events: auto;
}

.contextual-menu-compact.article-contextual-menu .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-menu-compact.article-contextual-menu .contextual-compact-submenu-item:last-child {
    margin-bottom: 0;
}

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

/* =============================================== */
/* LOADING INDICATOR */
/* =============================================== */

#article-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(59, 130, 246, 0.1);
    border-radius: 12px;
    padding: 16px 20px;
    box-shadow: 0 8px 32px rgba(59, 130, 246, 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);
}

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

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

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

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

/* =============================================== */
/* ENHANCED VISUAL FEEDBACK */
/* =============================================== */

.contextual-menu-compact.article-contextual-menu .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-menu-compact.article-contextual-menu .contextual-btn:hover::before {
    transform: translateX(100%);
}

/* =============================================== */
/* TOOLTIP ENHANCEMENT */
/* =============================================== */

.contextual-menu-compact.article-contextual-menu .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; 
    }
}

/* =============================================== */
/* SPECIAL STATES */
/* =============================================== */

.contextual-menu-compact.article-contextual-menu .contextual-btn.processing {
    opacity: 0.6;
    pointer-events: none;
}

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

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

/* =============================================== */
/* FOCUS STATES FOR ACCESSIBILITY */
/* =============================================== */

.contextual-menu-compact.article-contextual-menu .contextual-btn:focus-visible,
.contextual-menu-compact.article-contextual-menu .contextual-secondary-item:focus-visible,
.contextual-menu-compact.article-contextual-menu .contextual-compact-submenu-item:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* =============================================== */
/* SUCCESS FEEDBACK */
/* =============================================== */

.contextual-edit-success {
    position: fixed;
    top: 20px;
    right: 20px;
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    z-index: 10001;
    animation: slideInRight 0.3s ease-out, fadeOut 0.3s ease-in 2.7s forwards;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

/* =============================================== */
/* RESPONSIVE DESIGN */
/* =============================================== */

@media (max-width: 768px) {
    .contextual-menu-compact.article-contextual-menu {
        min-width: 160px;
        max-width: calc(100vw - 20px);
    }
    
    .contextual-menu-compact.article-contextual-menu .contextual-btn {
        width: 32px;
        height: 32px;
    }
    
    .contextual-menu-compact.article-contextual-menu .contextual-btn-icon {
        font-size: 12px;
    }
    
    .contextual-menu-compact.article-contextual-menu .contextual-secondary-menu {
        margin-top: 8px;
    }
    
    .contextual-menu-compact.article-contextual-menu .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-menu-compact.article-contextual-menu .contextual-compact-submenu.contextual-compact-submenu-show {
        transform: translate(-50%, -50%) scale(1);
    }
    
    #article-contextual-loading-indicator {
        padding: 12px 16px;
        max-width: calc(100vw - 40px);
    }
    
    #article-contextual-loading-indicator .contextual-loading-content {
        gap: 10px;
        font-size: 12px;
    }
    
    #article-contextual-loading-indicator .contextual-loading-spinner {
        width: 18px;
        height: 18px;
    }
    
    .contextual-edit-success {
        top: 10px;
        right: 10px;
        left: 10px;
        text-align: center;
        font-size: 12px;
    }
}

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

/* =============================================== */
/* HIGH CONTRAST MODE */
/* =============================================== */

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

/* =============================================== */
/* REDUCED MOTION */
/* =============================================== */

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

/* =============================================== */
/* PRINT STYLES */
/* =============================================== */

@media print {
    .contextual-menu-compact.article-contextual-menu,
    .contextual-menu-compact.article-contextual-menu .contextual-secondary-menu,
    .contextual-menu-compact.article-contextual-menu .contextual-compact-submenu,
    #article-contextual-loading-indicator,
    .contextual-edit-success {
        display: none !important;
    }
}

/* =============================================== */
/* ANIMATION KEYFRAMES */
/* =============================================== */

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

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

/* =============================================== */
/* ARTICLE-SPECIFIC ENHANCEMENTS */
/* =============================================== */

/* Enhanced contextual editing notice for Step 8 */
.article-step[data-step="8"] .contextual-editing-notice {
    background: linear-gradient(135deg, #dbeafe, #e0e7ff);
    border: 1px solid #93c5fd;
    border-radius: 12px;
    padding: 16px;
    margin: 0px 20px 20px 20px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    font-size: 14px;
    text-align: center;
    animation: slideInDown 0.4s ease-out;
}

.article-step[data-step="8"] .contextual-editing-notice .notice-icon {
    font-size: 18px;
    flex-shrink: 0;
    margin-top: 2px;
    animation: sparkle 2s ease-in-out infinite;
}

.article-step[data-step="8"] .contextual-editing-notice .notice-content {
    flex: 1;
    line-height: 1.6;
    color: #374151;
}

.article-step[data-step="8"] .contextual-editing-notice .notice-content strong {
    color: #1d4ed8;
    font-weight: 600;
}

/* Enhanced text selection styling */
.article-step[data-step="8"] .ql-editor::selection {
    background: rgba(59, 130, 246, 0.2);
}

.article-step[data-step="8"] .ql-editor::-moz-selection {
    background: rgba(59, 130, 246, 0.2);
}

/* Highlight selected text when contextual menu is active */
.article-step[data-step="8"] .ql-editor .contextual-selected {
    background: rgba(59, 130, 246, 0.15);
    border-radius: 4px;
    padding: 1px 2px;
    animation: pulseSelection 2s ease-in-out infinite;
}

/* Additional Animation Keyframes */
@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes sparkle {
    0%, 100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
    50% {
        transform: scale(1.1) rotate(10deg);
        opacity: 0.8;
    }
}

@keyframes pulseSelection {
    0%, 100% {
        background: rgba(59, 130, 246, 0.15);
    }
    50% {
        background: rgba(59, 130, 246, 0.25);
    }
}

/* =============================================== */
/* MOBILE RESPONSIVE ENHANCEMENTS */
/* =============================================== */

@media (max-width: 768px) {
    .article-step[data-step="8"] .contextual-editing-notice {
        padding: 12px;
        font-size: 12px;
        flex-direction: column;
        text-align: center;
    }
    
    .article-step[data-step="8"] .contextual-editing-notice .notice-icon {
        font-size: 16px;
        margin-top: 0;
        margin-bottom: 8px;
    }
}

/* =============================================== */
/* DARK MODE SUPPORT (if implemented) */
/* =============================================== */

@media (prefers-color-scheme: dark) {
    .contextual-menu-compact.article-contextual-menu {
        background: rgba(31, 41, 55, 0.95);
        border-color: rgba(75, 85, 99, 0.3);
    }
    
    .contextual-menu-compact.article-contextual-menu::before {
        border-top-color: rgba(31, 41, 55, 0.95);
    }
    
    .contextual-menu-compact.article-contextual-menu.positioned-below::before {
        border-bottom-color: rgba(31, 41, 55, 0.95);
    }
    
    .contextual-menu-compact.article-contextual-menu .contextual-btn {
        background: rgba(55, 65, 81, 0.8);
        border-color: rgba(75, 85, 99, 0.6);
    }
    
    .contextual-menu-compact.article-contextual-menu .contextual-btn-icon {
        color: #9ca3af;
    }
    
    .contextual-menu-compact.article-contextual-menu .contextual-secondary-menu {
        background: rgba(31, 41, 55, 0.98);
        border-color: rgba(75, 85, 99, 0.3);
    }
    
    .contextual-menu-compact.article-contextual-menu .contextual-section-header {
        color: #9ca3af;
    }
    
    .contextual-menu-compact.article-contextual-menu .secondary-item-label {
        color: #d1d5db;
    }
    
    .contextual-menu-compact.article-contextual-menu .current-model-item {
        background: linear-gradient(135deg, rgba(251, 146, 60, 0.1), rgba(251, 146, 60, 0.05));
        border-color: rgba(251, 146, 60, 0.3);
    }
    
    .contextual-menu-compact.article-contextual-menu .current-model-item .secondary-item-label {
        color: #fb923c;
    }
}