/* ============================================
   K-VISION EXPORT Chatbot System CSS
   Mobile-First Responsive Design
   Design System: #1F3C88, #00A8A8, #F7F9FC
   ============================================ */

/* Chatbot Floating Button */
.chatbot-button {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    border-radius: 50%;
    border: none;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    z-index: 9998;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chatbot-button:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 12px 36px rgba(31, 60, 136, 0.35);
}

.chatbot-button:active {
    transform: scale(0.95);
}

.chatbot-button .icon {
    position: absolute;
    transition: all 0.3s ease;
}

.chatbot-button .icon-chat {
    font-size: 28px;
    color: white;
    opacity: 1;
}

.chatbot-button .icon-close {
    font-size: 24px;
    color: white;
    opacity: 0;
    transform: rotate(90deg);
}

.chatbot-button.active .icon-chat {
    opacity: 0;
    transform: rotate(-90deg);
}

.chatbot-button.active .icon-close {
    opacity: 1;
    transform: rotate(0deg);
}

/* Chatbot Badge (unread indicator) */
.chatbot-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--error-color);
    color: white;
    font-size: 12px;
    font-weight: 600;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Chatbot Panel */
.chatbot-panel {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 400px;
    max-width: calc(100vw - 48px);
    height: 600px;
    max-height: calc(100vh - 150px);
    background: white;
    border-radius: 16px;
    box-shadow: var(--shadow-xl);
    z-index: 9997;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
}

.chatbot-panel.active {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: all;
}

/* Chatbot Header */
.chatbot-header {
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.chatbot-avatar {
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.chatbot-info h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.chatbot-info p {
    margin: 4px 0 0 0;
    font-size: 13px;
    opacity: 0.9;
}

/* Search Bar */
.chatbot-search {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    background: white;
}

.search-wrapper {
    position: relative;
}

.search-wrapper input {
    width: 100%;
    padding: 12px 40px 12px 40px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
}

.search-wrapper input:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(31, 60, 136, 0.1);
}

.search-wrapper .icon-search {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 16px;
}

.search-wrapper .icon-clear {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.search-wrapper input:not(:placeholder-shown) ~ .icon-clear {
    opacity: 1;
}

.search-wrapper .icon-clear:hover {
    color: var(--error-color);
}

/* Category Tabs */
.chatbot-categories {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    background: white;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.chatbot-categories::-webkit-scrollbar {
    height: 0;
}

.category-tabs {
    display: flex;
    gap: 8px;
    white-space: nowrap;
}

.category-tab {
    padding: 8px 16px;
    background: var(--bg-secondary);
    border: none;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.category-tab:hover {
    background: var(--bg-tertiary);
}

.category-tab.active {
    background: var(--primary-color);
    color: white;
}

/* FAQ Content */
.chatbot-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    -webkit-overflow-scrolling: touch;
}

.chatbot-content::-webkit-scrollbar {
    width: 6px;
}

.chatbot-content::-webkit-scrollbar-track {
    background: transparent;
}

.chatbot-content::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

/* FAQ Item */
.faq-item {
    margin-bottom: 12px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    overflow: hidden;
    transition: all 0.2s ease;
}

.faq-item:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.faq-question {
    padding: 16px;
    background: white;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    transition: background 0.2s ease;
}

.faq-question:hover {
    background: var(--bg-secondary);
}

.faq-question-text {
    flex: 1;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.5;
}

.faq-icon {
    color: var(--primary-color);
    font-size: 18px;
    transition: transform 0.3s ease;
    flex-shrink: 0;
}

.faq-item.active .faq-icon {
    transform: rotate(180deg);
}

.faq-answer {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.faq-item.active .faq-answer {
    max-height: 500px;
}

.faq-answer-content {
    padding: 0 16px 16px 16px;
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-secondary);
}

/* Language Label */
.language-label {
    display: inline-block;
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-color);
    margin-bottom: 4px;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-state-icon {
    font-size: 64px;
    color: var(--border-color);
    margin-bottom: 16px;
}

.empty-state h4 {
    font-size: 18px;
    color: var(--text-primary);
    margin: 0 0 8px 0;
}

.empty-state p {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0;
}

/* Pagination */
.chatbot-pagination {
    padding: 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
}

.pagination-info {
    font-size: 13px;
    color: var(--text-secondary);
}

.pagination-buttons {
    display: flex;
    gap: 8px;
}

.pagination-button {
    padding: 8px 16px;
    background: var(--bg-secondary);
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.pagination-button:hover:not(:disabled) {
    background: var(--primary-color);
    color: white;
}

.pagination-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Loading State */
.chatbot-loading {
    text-align: center;
    padding: 40px 20px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Responsive Design */
@media (max-width: 767px) {
    .chatbot-button {
        width: 56px;
        height: 56px;
        bottom: 20px;
        right: 20px;
    }

    .chatbot-button .icon-chat {
        font-size: 24px;
    }

    .chatbot-panel {
        bottom: 90px;
        right: 0;
        left: 0;
        margin: 0 12px;
        width: auto;
        max-width: none;
        height: 70vh;
        border-radius: 16px;
    }

    .chatbot-header {
        padding: 16px;
    }

    .chatbot-avatar {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }

    .chatbot-info h3 {
        font-size: 16px;
    }

    .chatbot-info p {
        font-size: 12px;
    }

    .category-tab {
        font-size: 12px;
        padding: 6px 12px;
    }
}

@media (min-width: 768px) and (max-width: 1023px) {
    .chatbot-panel {
        width: 380px;
    }
}

@media (min-width: 1024px) {
    .chatbot-panel {
        width: 420px;
        height: 650px;
    }
}

/* Accessibility */
.chatbot-button:focus-visible,
.category-tab:focus-visible,
.pagination-button:focus-visible,
.faq-question:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

/* Dark Mode Support (Future) */
@media (prefers-color-scheme: dark) {
    .chatbot-panel {
        background: #1a1a1a;
    }

    .chatbot-search,
    .chatbot-categories,
    .chatbot-pagination {
        background: #1a1a1a;
        border-color: #333;
    }

    .faq-item {
        border-color: #333;
    }

    .faq-question {
        background: #1a1a1a;
    }

    .faq-question:hover {
        background: #222;
    }

    .faq-question-text {
        color: #e0e0e0;
    }

    .faq-answer-content {
        color: #b0b0b0;
    }

    .search-wrapper input {
        background: #222;
        border-color: #333;
        color: #e0e0e0;
    }

    .category-tab {
        background: #222;
        color: #b0b0b0;
    }

    .category-tab:hover {
        background: #2a2a2a;
    }
}

/* Animation Utilities */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.3s ease forwards;
}

/* Tooltip */
.chatbot-tooltip {
    position: absolute;
    bottom: calc(100% + 12px);
    right: 0;
    background: var(--text-primary);
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.chatbot-button:hover .chatbot-tooltip {
    opacity: 1;
}

.chatbot-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    right: 20px;
    border: 6px solid transparent;
    border-top-color: var(--text-primary);
}
