/**
 * Toast UI Editor AI Assistant Styles
 * Professional mobile-first responsive design
 *
 * @version 2.0.0
 * @author Havasi Balázs Archibald
 * @license Proprietary
 */

/* Main icon for the AI assistant - Mobile First */
.toast-ai-assistant-icon {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1001;
    border: 2px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    -webkit-tap-highlight-color: transparent;
    tap-highlight-color: transparent;
    outline: none;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Clean AI-specific star icon using CSS */
.toast-ai-assistant-icon::before {
    content: '✨';
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    filter: brightness(1.2);
}

.toast-ai-assistant-icon:hover,
.toast-ai-assistant-icon:focus {
    transform: scale(1.05);
    box-shadow: 0 4px 16px rgba(40, 167, 69, 0.4);
    background: linear-gradient(135deg, #218838 0%, #1e7e34 100%);
}

.toast-ai-assistant-icon:active {
    transform: scale(0.95);
    transition: transform 0.1s;
}

/* Fix positioning after click - ensure icon stays centered */
.toast-ai-assistant-icon:active::before,
.toast-ai-assistant-icon.clicked::before {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Main prompt window - Mobile First Modal Design */
.toast-ai-assistant-prompt {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: calc(100vw - 32px);
    max-width: 400px;
    max-height: calc(100vh - 32px);
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    z-index: 10000;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    cursor: default;
    border: 2px solid #28a745;
    animation: aiModalFadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Modal backdrop */
.toast-ai-assistant-prompt::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    z-index: -1;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

/* Header with better mobile design */
.toast-ai-prompt-header {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 16px;
    position: relative;
    cursor: move;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Close button - Much more visible and mobile-friendly */
.toast-ai-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    opacity: 0.9;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    tap-highlight-color: transparent;
    outline: none;
    font-weight: normal;
    line-height: 1;
    padding: 0;
    margin: 0;
}

.toast-ai-close-btn:hover,
.toast-ai-close-btn:focus {
    opacity: 1;
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.toast-ai-close-btn:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.4);
}
/* Body with better spacing */
.toast-ai-prompt-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: linear-gradient(135deg, #f8fffe 0%, #ffffff 100%);
}

.toast-ai-prompt-body p {
    margin: 0 0 12px 0;
    font-size: 15px;
    line-height: 1.5;
    color: #2c3e50;
    font-weight: 500;
}

/* Suggestions with better mobile design */
.toast-ai-suggestions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast-ai-suggestion-btn {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #e3f2fd;
    background: linear-gradient(135deg, #ffffff 0%, #f8fffe 100%);
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 14px;
    line-height: 1.4;
    color: #2c3e50;
    -webkit-tap-highlight-color: transparent;
    tap-highlight-color: transparent;
    outline: none;
    min-height: 48px;
    display: flex;
    align-items: center;
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.08);
    font-weight: 500;
}

.toast-ai-suggestion-btn:hover,
.toast-ai-suggestion-btn:focus {
    background: linear-gradient(135deg, #e8f5e8 0%, #f0fff0 100%);
    border-color: #28a745;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.2);
    color: #1e7e34;
}

.toast-ai-suggestion-btn:active {
    transform: translateY(0);
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    border-color: #20c997;
    color: #155724;
}

.toast-ai-suggestion-btn.aibtn-other {
    font-style: italic;
    color: #6c757d;
    border-style: dashed;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border-color: #adb5bd;
    font-weight: 400;
}

.toast-ai-suggestion-btn.aibtn-other:hover,
.toast-ai-suggestion-btn.aibtn-other:focus {
    background: linear-gradient(135deg, #e3f2fd 0%, #f0f8ff 100%);
    border-color: #007bff;
    color: #495057;
    border-style: solid;
}

/* Custom input container - Fixed visibility and mobile-friendly */
.toast-ai-custom-input-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 8px;
    padding: 16px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 8px;
    border: 1px solid #dee2e6;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.toast-ai-custom-input {
    width: 100%;
    min-height: 100px;
    padding: 12px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    resize: vertical;
    font-size: 14px;
    line-height: 1.5;
    font-family: inherit;
    transition: border-color 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
    outline: none;
    box-sizing: border-box;
}

.toast-ai-custom-input:focus {
    border-color: #28a745;
    box-shadow: 0 0 0 2px rgba(40, 167, 69, 0.2);
}

.toast-ai-custom-input::placeholder {
    color: #6c757d;
    opacity: 1;
}

.toast-ai-submit-custom-btn {
    align-self: flex-end;
    padding: 10px 20px;
    border: none;
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    font-weight: 500;
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
    tap-highlight-color: transparent;
    outline: none;
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.3);
}

.toast-ai-submit-custom-btn:hover,
.toast-ai-submit-custom-btn:focus {
    background: linear-gradient(135deg, #218838 0%, #1e7e34 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.4);
}

.toast-ai-submit-custom-btn:active {
    transform: translateY(0);
}

.toast-ai-submit-custom-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Footer */
.toast-ai-prompt-footer {
    padding: 12px 20px;
    background: linear-gradient(135deg, #f8fffe 0%, #f0fff0 100%);
    border-top: 2px solid #e8f5e8;
    font-size: 12px;
    color: #28a745;
    text-align: center;
    font-weight: 500;
}

/* Spinner for loading states - Enhanced */
.toast-ai-spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #28a745;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    animation: aiSpin 1s linear infinite;
    margin: 20px auto;
}

.toast-ai-thinking-p {
    text-align: center;
    font-size: 14px;
    color: #666;
    margin: 10px 0 20px 0;
    font-weight: 500;
}

/* Animations */
@keyframes aiSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes aiModalFadeIn {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* Tablet styles */
@media (min-width: 768px) {
    .toast-ai-assistant-icon {
        top: 12px;
        right: 12px;
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
    
    .toast-ai-assistant-prompt {
        width: 420px;
        max-width: calc(100vw - 64px);
    }
    
    .toast-ai-prompt-body {
        padding: 24px;
    }
    
    .toast-ai-suggestion-btn {
        padding: 16px 18px;
        font-size: 15px;
    }
}

/* Desktop styles */
@media (min-width: 1024px) {
    .toast-ai-assistant-prompt {
        width: 450px;
    }
    
    .toast-ai-prompt-body {
        padding: 28px;
    }
}

/* Mobile-specific fixes for iOS and Android */
@media (max-width: 767px) {
    .toast-ai-assistant-prompt {
        width: calc(100vw - 16px);
        max-height: calc(100vh - 16px);
        border-radius: 8px;
    }
    
    .toast-ai-suggestion-btn {
        min-height: 52px;
        padding: 16px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .toast-ai-custom-input {
        font-size: 16px; /* Prevents zoom on iOS */
        min-height: 120px;
    }
    
    .toast-ai-submit-custom-btn {
        min-height: 48px;
        font-size: 16px;
        width: 100%;
        margin-top: 8px;
    }
}

/* Additional user-friendly enhancements consistent with program export modal */
.toast-ai-assistant-prompt {
    border: 2px solid #28a745;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* Success feedback styling */
.toast-ai-success-message {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    border: 1px solid #28a745;
    color: #155724;
    padding: 12px 16px;
    border-radius: 6px;
    margin: 12px 0;
    font-weight: 500;
}

/* Error feedback styling */
.toast-ai-error-message {
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    border: 1px solid #dc3545;
    color: #721c24;
    padding: 12px 16px;
    border-radius: 6px;
    margin: 12px 0;
    font-weight: 500;
}

/* Focus styles for better accessibility */
.toast-ai-suggestion-btn:focus,
.toast-ai-submit-custom-btn:focus {
    outline: 2px solid #28a745;
    outline-offset: 2px;
}

/* Improved visual hierarchy */
.toast-ai-prompt-body p.ai-intro-text {
    background: linear-gradient(135deg, #e8f5e8 0%, #f0fff0 100%);
    border: 2px solid #28a745;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.15);
    color: #155724;
    font-weight: 600;
}

/* Enhanced tablet styles */
@media (min-width: 768px) {
    .toast-ai-assistant-icon::before {
        font-size: 20px;
    }
    
    .toast-ai-suggestion-btn {
        font-size: 15px;
        padding: 16px 18px;
    }
}

/* Enhanced desktop styles */
@media (min-width: 1024px) {
    .toast-ai-assistant-icon::before {
        font-size: 22px;
    }
    
    .toast-ai-suggestion-btn {
        font-size: 15px;
        padding: 16px 20px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .toast-ai-assistant-icon {
        border: 2px solid currentColor;
    }
    
    .toast-ai-suggestion-btn {
        border-width: 2px;
    }
    
    .toast-ai-close-btn {
        background: rgba(255, 255, 255, 0.9);
        color: #333;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .toast-ai-assistant-icon,
    .toast-ai-suggestion-btn,
    .toast-ai-submit-custom-btn,
    .toast-ai-close-btn {
        transition: none;
    }
    
    .toast-ai-assistant-prompt {
        animation: none;
    }
    
    .toast-ai-spinner {
        animation: none;
        border: 3px solid #28a745;
    }
}
    
    /* Definitive SVG Icon Styles for Custom Undo/Redo Buttons */
.toastui-editor-toolbar-icons.ipmflow-undo-button {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-corner-up-left'%3E%3Cpolyline points='9 14 4 9 9 4'%3E%3C/polyline%3E%3Cpath d='M20 20v-7a4 4 0 0 0-4-4H4'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 16px 16px;
}

.toastui-editor-toolbar-icons.ipmflow-redo-button {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-corner-up-right'%3E%3Cpolyline points='15 14 20 9 15 4'%3E%3C/polyline%3E%3Cpath d='M4 20v-7a4 4 0 0 1 4-4h12'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 16px 16px;
}
.toast-ai-assistant-icon.ai-icon-cooldown {
    opacity: 0.5;
    cursor: not-allowed;
    animation: ai-cooldown-pulse 1.5s infinite;
}

@keyframes ai-cooldown-pulse {
    0% {
        opacity: 0.5;
    }
    50% {
        opacity: 0.8;
    }
    100% {
        opacity: 0.5;
    }
}