/* WIA AI Modal for Plagiarism Checker */

/* Ask AI 버튼 (우측 하단 플로팅) */
.wia-ai-btn {
    position: fixed;
    bottom: 100px;
    right: 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 15px 25px;
    border-radius: 30px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s;
}

.wia-ai-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.wia-ai-btn i {
    font-size: 18px;
}

/* AI 모달 오버레이 */
.wia-ai-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 10000;
    backdrop-filter: blur(5px);
}

.wia-ai-modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* 모달 컨텐츠 */
.wia-ai-modal .ai-modal-content {
    background: #fff;
    border-radius: 20px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* 모달 헤더 */
.wia-ai-modal .ai-modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.wia-ai-modal .ai-modal-title {
    font-size: 22px;
    font-weight: bold;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.wia-ai-modal .ai-close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.3s;
}

.wia-ai-modal .ai-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* AI 탭 선택 */
.ai-selector {
    display: flex;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

.ai-tab {
    flex: 1;
    padding: 15px;
    text-align: center;
    cursor: pointer;
    border: none;
    background: none;
    font-size: 15px;
    font-weight: 500;
    transition: all 0.3s;
    border-bottom: 3px solid transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.ai-tab.active {
    background: white;
    border-bottom-color: #667eea;
    color: #667eea;
}

.ai-tab:hover:not(.active) {
    background: #e9ecef;
}

.ai-tab i {
    font-size: 18px;
}

.ai-tab .badge {
    background: #28a745;
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
}

/* API 키 설정 */
.api-setup {
    padding: 15px 20px;
    border-bottom: 1px solid #dee2e6;
    background: #f8f9fa;
}

.api-input-group {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.api-input {
    flex: 1;
    min-width: 200px;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
}

.api-input:focus {
    outline: none;
    border-color: #667eea;
}

.api-save-btn {
    background: #28a745;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.3s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.api-save-btn:hover {
    background: #218838;
}

.api-link {
    color: #667eea;
    text-decoration: none;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.api-link:hover {
    text-decoration: underline;
}

.api-status {
    margin-top: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    display: none;
}

.api-status.success {
    display: block;
    background: #d4edda;
    color: #155724;
}

.api-status.error {
    display: block;
    background: #f8d7da;
    color: #721c24;
}

/* 컨텍스트 표시 */
.check-context {
    padding: 10px 20px;
    background: #e3f2fd;
    border-bottom: 1px solid #bbdefb;
    font-size: 13px;
    color: #1565c0;
    display: none;
}

.check-context.show {
    display: block;
}

.check-context strong {
    color: #0d47a1;
}

/* 채팅 영역 */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 350px;
    max-height: 50vh;
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: white;
}

/* 메시지 스타일 */
.ai-message {
    margin-bottom: 15px;
    display: flex;
}

.ai-message.user {
    justify-content: flex-end;
}

.ai-message.assistant {
    justify-content: flex-start;
}

.ai-message-content {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.6;
}

.ai-message.user .ai-message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 6px;
}

.ai-message.assistant .ai-message-content {
    background: #f1f3f5;
    color: #333;
    border-bottom-left-radius: 6px;
}

.ai-message-content code {
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
}

.ai-message.assistant .ai-message-content code {
    background: #e9ecef;
}

/* 웰컴 메시지 */
.welcome-message {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.welcome-message i {
    font-size: 48px;
    color: #667eea;
    margin-bottom: 15px;
}

.welcome-message h4 {
    margin: 0 0 10px;
    color: #333;
}

.welcome-message p {
    margin: 0;
    font-size: 14px;
}

/* 입력 영역 */
.message-input-area {
    padding: 15px 20px;
    border-top: 1px solid #dee2e6;
    background: #f8f9fa;
}

.message-input-group {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.ai-message-input {
    flex: 1;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 14px;
    resize: none;
    max-height: 100px;
    outline: none;
    font-family: inherit;
}

.ai-message-input:focus {
    border-color: #667eea;
}

.ai-send-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ai-send-btn:hover {
    transform: scale(1.05);
}

.ai-send-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

/* 로딩 상태 */
.ai-message.loading .ai-message-content {
    display: flex;
    align-items: center;
    gap: 8px;
}

.typing-indicator {
    display: flex;
    gap: 4px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #667eea;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-5px); }
}

/* 반응형 */
@media (max-width: 768px) {
    .wia-ai-btn {
        bottom: 80px;
        right: 15px;
        padding: 12px 18px;
        font-size: 14px;
    }

    .wia-ai-btn span {
        display: none;
    }

    .wia-ai-modal .ai-modal-content {
        width: 95%;
        max-height: 95vh;
        border-radius: 15px;
    }

    .ai-tab {
        padding: 12px 8px;
        font-size: 13px;
    }

    .ai-tab span {
        display: none;
    }

    .api-input-group {
        flex-direction: column;
        align-items: stretch;
    }

    .api-input {
        min-width: auto;
    }

    .ai-message-content {
        max-width: 85%;
    }
}

/* =============================================================================
   AI 도구 버튼
============================================================================= */
.ai-tools {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
}

.ai-tools-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary-color, #667eea);
}

.ai-tools-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.ai-tool-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: white;
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-color, #1e293b);
    cursor: pointer;
    transition: all 0.2s ease;
}

.ai-tool-btn:hover {
    background: var(--primary-color, #667eea);
    color: white;
    border-color: var(--primary-color, #667eea);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.ai-tool-btn:active {
    transform: translateY(0);
}

.ai-tool-btn i {
    font-size: 0.85rem;
}

/* 각 도구별 호버 색상 */
.ai-tool-btn[data-tool="rewrite"]:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.ai-tool-btn[data-tool="citation"]:hover {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.ai-tool-btn[data-tool="improve"]:hover {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.ai-tool-btn[data-tool="translate"]:hover {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
}

.ai-tool-btn[data-tool="summarize"]:hover {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
}

.ai-tool-btn[data-tool="similar"]:hover {
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
    color: #333;
}

/* 반응형 */
@media (max-width: 576px) {
    .ai-tools-buttons {
        gap: 6px;
    }
    
    .ai-tool-btn {
        padding: 6px 10px;
        font-size: 0.75rem;
    }
}
