/**
 * Create Rumour Modal - Fullscreen WYSIWYG Editor
 * Icon-based controls with AJAX updates
 */

/* Fullscreen Modal Overlay */
#createRumourModal {
    display: none;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(0, 0, 0, 0.95) !important;
    z-index: 9999999 !important;
    justify-content: center;
    align-items: center;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    box-sizing: border-box !important;
}

#createRumourModal.active {
    display: flex !important;
}

/* Fullscreen Modal Content - Override all theme styles */
#createRumourModal .modal-content {
    background: transparent !important;
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    min-width: 100% !important;
    min-height: 100% !important;
    overflow: hidden !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    display: block !important;
    box-sizing: border-box !important;
}

/* Close Button - Top Right - Absolutely positioned overlay */
#createRumourModal .modal-close {
    position: fixed !important;
    top: 20px !important;
    right: 20px !important;
    left: auto !important;
    bottom: auto !important;
    background: rgba(255, 255, 255, 0.1) !important;
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.2) !important;
    border-radius: 50% !important;
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
    max-width: 44px !important;
    max-height: 44px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    transition: all 0.2s ease;
    font-size: 24px !important;
    color: white !important;
    padding: 0 !important;
    margin: 0 !important;
    z-index: 100 !important;
    box-sizing: border-box !important;
    flex: none !important;
}

#createRumourModal .modal-close:hover {
    background: rgba(255, 255, 255, 0.2) !important;
    transform: scale(1.1);
}

/* 9:16 Preview Canvas - Fullscreen for editing */
#createRumourModal .rumour-preview-canvas {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    min-width: 100% !important;
    min-height: 100% !important;
    border-radius: 0 !important;
    overflow: hidden !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    box-sizing: border-box !important;
}

.rumour-preview-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #000;
    background-size: cover;
    background-position: center;
    transition: all 0.3s ease;
}

.rumour-preview-background.has-image {
    background-image: var(--bg-image);
}

.rumour-preview-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    text-align: center;
    color: white;
    font-size: 48px;
    font-weight: 700;
    line-height: 1.2;
    cursor: text;
    transition: all 0.2s ease;
    padding: 20px;
    word-wrap: break-word;
    outline: none;
    min-height: 60px;
}

.rumour-preview-text:hover {
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
}

.rumour-preview-text:focus {
    text-shadow: 0 0 30px rgba(255, 255, 255, 0.8);
    outline: 2px dashed rgba(255, 255, 255, 0.3);
    outline-offset: 8px;
}

.rumour-preview-text.empty::before {
    content: 'Tap to add text...';
    opacity: 0.6;
    font-style: italic;
}

.rumour-preview-text.empty:focus::before {
    content: '';
}

/* Word animation spans */
.rumour-word {
    display: inline-block;
    white-space: pre-wrap;
}

/* Control Icons - Fixed Positions */
.rumour-control-icon {
    position: fixed;
    width: 52px;
    height: 52px;
    background: rgba(139, 92, 246, 0.9);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: white;
    font-size: 22px;
    z-index: 10;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4);
}

.rumour-control-icon:hover {
    transform: scale(1.1);
    background: rgba(139, 92, 246, 1);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.6);
}

.rumour-control-icon.active {
    background: rgba(124, 58, 237, 1);
    border-color: rgba(255, 255, 255, 0.4);
}

/* Background Icon - Top Left */
.rumour-background-icon {
    top: 20px;
    left: 20px;
}

/* Metadata Icon - Bottom Left */
.rumour-metadata-icon {
    bottom: 20px;
    left: 20px;
}

/* Link Icon - Bottom Center (on canvas) */
.rumour-link-trigger {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: rgba(255, 255, 255, 0.7);
    font-size: 20px;
}

.rumour-link-trigger:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateX(-50%) scale(1.1);
    color: white;
}

.rumour-link-trigger.has-links {
    background: rgba(139, 92, 246, 0.4);
    border-color: rgba(139, 92, 246, 0.6);
    color: #8b5cf6;
}

/* Save Button - Bottom Right */
.rumour-btn-save {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 14px 28px;
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4);
    z-index: 10;
}

.rumour-btn-save:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.6);
}

.rumour-btn-save:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Character Counter Overlay */
.rumour-char-counter-overlay {
    position: absolute;
    bottom: 70px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.8);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.rumour-char-counter-overlay.active {
    opacity: 1;
}

.rumour-char-counter-overlay.warning {
    background: rgba(245, 158, 11, 0.9);
    color: white;
}

.rumour-char-counter-overlay.over {
    background: rgba(239, 68, 68, 0.9);
    color: white;
}

/* Settings Modal (Background/Metadata) */
.rumour-settings-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 99999999 !important;
    justify-content: center;
    align-items: center;
}

.rumour-settings-modal.active {
    display: flex;
}

.rumour-settings-modal-content {
    background: white;
    border-radius: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
    overflow: hidden;
    box-shadow: none !important;
}

.rumour-settings-header {
    padding: 20px 24px;
    background: white;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.rumour-settings-title {
    margin: 0;
    color: #1C2E3D;
    font-size: 20px;
    font-weight: 700;
}

.rumour-settings-close {
    background: none;
    border: none;
    font-size: 28px;
    color: #9ca3af;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.rumour-settings-close:hover {
    background: #f3f4f6;
    color: #1C2E3D;
}

.rumour-settings-body {
    padding: 24px;
    max-height: calc(100vh - 80px) !important;
    height: calc(100vh - 80px) !important;
    overflow-y: auto;
}

/* Form Fields */
.rumour-field-group {
    margin-bottom: 20px;
}

.rumour-field-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 8px;
}

.rumour-field-input,
.rumour-field-textarea,
.rumour-field-select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s ease;
}

.rumour-field-input:focus,
.rumour-field-textarea:focus,
.rumour-field-select:focus {
    outline: none;
    border-color: #8b5cf6;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.rumour-field-textarea {
    resize: vertical;
    min-height: 80px;
    font-family: inherit;
}

/* Color Picker */
.rumour-color-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.rumour-color-input {
    width: 60px;
    height: 40px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    cursor: pointer;
}

.rumour-color-hex {
    flex: 1;
}

/* Range Slider */
.rumour-range-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.rumour-range-input {
    flex: 1;
}

.rumour-range-value {
    min-width: 50px;
    text-align: center;
    font-weight: 600;
    color: #374151;
    font-size: 14px;
}

/* Button Group */
.rumour-button-group {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.rumour-option-btn {
    padding: 10px;
    border: 2px solid #e5e7eb;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    transition: all 0.2s ease;
}

.rumour-option-btn:hover {
    border-color: #8b5cf6;
    background: #f9fafb;
}

.rumour-option-btn.active {
    border-color: #8b5cf6;
    background: #8b5cf6;
    color: white;
}

/* Background Upload */
.rumour-upload-area {
    border: 2px dashed #d1d5db;
    border-radius: 12px;
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: white;
}

.rumour-upload-area:hover {
    border-color: #8b5cf6;
    background: #f9fafb;
}

.rumour-upload-area.has-file {
    border-color: #10b981;
    background: #d1fae5;
}

.rumour-upload-icon {
    font-size: 40px;
    margin-bottom: 10px;
    color: #9ca3af;
}

.rumour-upload-text {
    font-size: 14px;
    color: #6b7280;
}

.rumour-upload-input {
    display: none;
}

/* Related Content Panel */
.rumour-search-wrapper {
    position: relative;
    margin-bottom: 20px;
}

.rumour-search-input {
    width: 100%;
    padding: 12px 16px 12px 40px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
}

.rumour-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    font-size: 18px;
}

.rumour-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 300px;
    overflow-y: auto;
    background: white;
    border: 1px solid #d1d5db;
    border-top: none;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    display: none;
    z-index: 10;
}

.rumour-search-results.active {
    display: block;
}

.rumour-search-result {
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.2s ease;
    border-bottom: 1px solid #f3f4f6;
    display: flex;
    align-items: center;
    gap: 10px;
}

.rumour-search-result:hover {
    background: #f9fafb;
}

.rumour-result-type {
    font-size: 11px;
    padding: 2px 8px;
    background: #f0f4ff;
    color: #8b5cf6;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
}

.rumour-selected-items {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.rumour-selected-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #f0f4ff;
    border-radius: 16px;
    font-size: 13px;
}

.rumour-item-type {
    font-size: 10px;
    padding: 2px 6px;
    background: rgba(139, 92, 246, 0.2);
    border-radius: 3px;
    font-weight: 600;
}

.rumour-remove-item {
    background: none;
    border: none;
    font-size: 18px;
    color: #6b7280;
    cursor: pointer;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.rumour-remove-item:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #111827;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .rumour-preview-canvas {
        max-width: 320px;
    }
    
    .rumour-control-icon {
        width: 44px;
        height: 44px;
        font-size: 18px;
    }
    
    .rumour-background-icon,
    .rumour-metadata-icon {
        top: 10px;
        left: 10px;
    }
    
    .rumour-metadata-icon {
        top: 70px;
    }
    
    .rumour-btn-save {
        bottom: 10px;
        right: 10px;
    }
    
    #createRumourModal .modal-close {
        top: 10px;
        right: 10px;
    }
}
