/**
 * Toqan AI Agent - Frontend Styles
 *
 * @package Toqan_AI_Agent
 */

:root {
    --toqan-primary-color: #0073aa;
    --toqan-secondary-color: #ffffff;
    --toqan-text-color: #333333;
    --toqan-border-color: #dddddd;
    --toqan-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    --toqan-radius: 12px;
}

/* Floating Button */
.toqan-floating-button {
    position: fixed;
    z-index: 999999;
    transition: transform 0.3s ease;
}

.toqan-floating-button:hover {
    transform: scale(1.05);
}

.toqan-position-bottom-right {
    bottom: 20px;
    right: 20px;
}

.toqan-position-bottom-left {
    bottom: 20px;
    left: 20px;
}

.toqan-chat-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 15px 20px;
    background-color: var(--toqan-primary-color);
    color: var(--toqan-secondary-color);
    border: none;
    border-radius: 50px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--toqan-shadow);
    transition: all 0.3s ease;
    position: relative;
}

.toqan-chat-btn.toqan-icon-only {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    padding: 0;
    gap: 0;
}

.toqan-chat-btn svg {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
}

.toqan-chat-btn.toqan-icon-only svg {
    width: 28px;
    height: 28px;
}

.toqan-chat-btn:hover {
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.2);
}

.toqan-unread-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #ff4444;
    color: white;
    border-radius: 50%;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: bold;
    min-width: 20px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(255, 68, 68, 0.4);
    display: none;
}

.toqan-unread-badge.toqan-pulse {
    animation: badgePulse 2s infinite;
}

@keyframes badgePulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 2px 8px rgba(255, 68, 68, 0.4);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 4px 12px rgba(255, 68, 68, 0.6);
    }
}

/* Modal */
.toqan-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000000;
}

.toqan-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: backdrop-filter 0.3s ease;
}

.toqan-modal-overlay.toqan-no-blur {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

.toqan-modal-container {
    position: absolute;
    right: 20px;
    bottom: 20px;
    width: 420px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 40px);
    z-index: 1;
}

/* Chat Widget */
.toqan-chat-widget {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: white;
    border-radius: var(--toqan-radius);
    box-shadow: var(--toqan-shadow);
    overflow: hidden;
    position: relative;
}

.toqan-embedded {
    max-width: 800px;
    margin: 40px auto;
    height: 600px;
    border: 1px solid var(--toqan-border-color);
}

/* Chat Header */
.toqan-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    background: var(--toqan-primary-color);
    color: var(--toqan-secondary-color);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.toqan-chat-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.toqan-chat-actions {
    display: flex;
    gap: 10px;
}

.toqan-minimize-btn,
.toqan-close-btn {
    background: transparent;
    border: none;
    color: var(--toqan-secondary-color);
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.toqan-minimize-btn:hover,
.toqan-close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Chat Body */
.toqan-chat-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.toqan-conversation-prompt {
    padding: 20px;
    background: #f8f9fa;
    border-bottom: 1px solid var(--toqan-border-color);
    text-align: center;
}

.toqan-conversation-prompt p {
    margin: 0 0 15px 0;
    color: var(--toqan-text-color);
}

.toqan-prompt-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.toqan-messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    scroll-behavior: smooth;
}

.toqan-messages-container::-webkit-scrollbar {
    width: 6px;
}

.toqan-messages-container::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.toqan-messages-container::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.toqan-messages-container::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* Messages */
.toqan-message {
    margin-bottom: 15px;
    display: flex;
    animation: messageSlideIn 0.3s ease;
}

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

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

.toqan-agent-message {
    justify-content: flex-start;
}

.toqan-message-content {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    line-height: 1.4;
}

.toqan-user-message .toqan-message-content {
    background: var(--toqan-primary-color);
    color: var(--toqan-secondary-color);
    border-bottom-right-radius: 4px;
}

.toqan-agent-message .toqan-message-content {
    background: #f0f0f0;
    color: var(--toqan-text-color);
    border-bottom-left-radius: 4px;
}

.toqan-error-message .toqan-message-content {
    background: #ffebee;
    color: #c62828;
    border-left: 3px solid #c62828;
}

.toqan-success-message .toqan-message-content {
    background: #e8f5e9;
    color: #2e7d32;
    border-left: 3px solid #2e7d32;
}

.toqan-message-content .dashicons {
    margin-right: 5px;
    vertical-align: middle;
}

/* Typing Indicator */
.toqan-typing-indicator {
    margin-bottom: 15px;
}

.toqan-typing-dots {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}

.toqan-typing-dots span {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite;
}

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

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

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

/* Welcome Message */
.toqan-welcome-message {
    text-align: left;
    padding: 40px 20px;
    color: #999;
}

/* Chat Footer */
.toqan-chat-footer {
    padding: 15px;
    background: white;
    border-top: 1px solid var(--toqan-border-color);
}

.toqan-uploaded-files {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.toqan-uploaded-file,
.toqan-file-uploading {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #f0f0f0;
    border-radius: 20px;
    font-size: 13px;
}

.toqan-file-icon {
    color: var(--toqan-primary-color);
}

.toqan-file-size {
    color: #999;
    font-size: 11px;
}

.toqan-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid var(--toqan-primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.toqan-input-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f5f5f5;
    border-radius: 25px;
    padding: 8px 8px 8px 15px;
}

.toqan-attach-btn {
    background: transparent;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    transition: color 0.2s;
    position: relative;
}

.toqan-attach-btn:hover {
    color: var(--toqan-primary-color);
}

.toqan-attach-btn::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    margin-bottom: 5px;
    z-index: 1000;
}

.toqan-attach-btn:hover::after {
    opacity: 1;
}

.toqan-message-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 14px;
    outline: none;
    min-height: 20px;
    resize: none;
}

.toqan-message-input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.toqan-send-btn {
    background: var(--toqan-primary-color);
    color: var(--toqan-secondary-color);
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s;
}

.toqan-send-btn:hover {
    transform: scale(1.1);
}

.toqan-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Login Notice */
.toqan-login-notice {
    text-align: center;
    padding: 20px;
}

.toqan-login-notice p {
    margin: 0;
    color: #666;
}

.toqan-login-notice a {
    color: var(--toqan-primary-color);
    text-decoration: none;
    font-weight: 600;
}

.toqan-login-notice a:hover {
    text-decoration: underline;
}

/* Buttons */
.toqan-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.toqan-btn-primary {
    background: var(--toqan-primary-color);
    color: var(--toqan-secondary-color);
}

.toqan-btn-primary:hover {
    opacity: 0.9;
}

.toqan-btn-secondary {
    background: #f0f0f0;
    color: var(--toqan-text-color);
}

.toqan-btn-secondary:hover {
    background: #e0e0e0;
}

/* Responsive Design */
@media (max-width: 768px) {
    .toqan-modal-container {
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .toqan-chat-widget {
        border-radius: 0;
    }

    .toqan-embedded {
        margin: 20px auto;
        height: 500px;
    }

    .toqan-floating-button {
        bottom: 15px;
        right: 15px;
    }

    .toqan-position-bottom-left {
        left: 15px;
    }

    .toqan-chat-btn {
        padding: 12px 16px;
        font-size: 14px;
    }

    .toqan-btn-text {
        display: none;
    }

    .toqan-message-content {
        max-width: 90%;
    }
}

/* User Conversations Dashboard */
.toqan-user-conversations {
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px;
}

.toqan-no-conversations {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.toqan-conversations-list {
    display: grid;
    gap: 20px;
}

.toqan-conversation-item {
    background: white;
    border: 1px solid var(--toqan-border-color);
    border-radius: var(--toqan-radius);
    padding: 20px;
    transition: box-shadow 0.2s;
}

.toqan-conversation-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.toqan-conversation-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.toqan-conversation-title {
    margin: 0;
    font-size: 18px;
}

.toqan-conversation-title a {
    color: var(--toqan-text-color);
    text-decoration: none;
}

.toqan-conversation-title a:hover {
    color: var(--toqan-primary-color);
}

.toqan-conversation-date {
    color: #999;
    font-size: 13px;
}

.toqan-conversation-preview {
    margin: 10px 0;
    color: #666;
    font-size: 14px;
}

.toqan-conversation-meta {
    display: flex;
    gap: 15px;
    font-size: 13px;
    color: #999;
    margin-bottom: 15px;
}

.toqan-conversation-status {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.toqan-status-active {
    background: #e8f5e9;
    color: #2e7d32;
}

.toqan-status-archived {
    background: #f5f5f5;
    color: #999;
}

.toqan-conversation-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.toqan-btn-danger {
    background: #ffebee;
    color: #c62828;
}

.toqan-btn-danger:hover {
    background: #ffcdd2;
}

/* Pagination */
.toqan-pagination {
    margin-top: 30px;
    text-align: center;
}

.toqan-pagination .page-numbers {
    display: inline-block;
    padding: 8px 12px;
    margin: 0 4px;
    background: white;
    border: 1px solid var(--toqan-border-color);
    border-radius: 4px;
    color: var(--toqan-text-color);
    text-decoration: none;
    transition: all 0.2s;
}

.toqan-pagination .page-numbers:hover,
.toqan-pagination .page-numbers.current {
    background: var(--toqan-primary-color);
    color: var(--toqan-secondary-color);
    border-color: var(--toqan-primary-color);
}

/* Accessibility */
.toqan-chat-widget *:focus {
    outline: 2px solid var(--toqan-primary-color);
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    .toqan-floating-button,
    .toqan-modal {
        display: none !important;
    }
}


/* Markdown Content Styling */
.toqan-markdown-content {
    line-height: 1.6;
}

.toqan-markdown-content p {
    margin: 0 0 0.5em 0;
}

.toqan-markdown-content p:last-child {
    margin-bottom: 0;
}

.toqan-markdown-content strong {
    font-weight: 600;
    color: inherit;
}

.toqan-markdown-content em {
    font-style: italic;
}

.toqan-markdown-content ul,
.toqan-markdown-content ol {
    margin: 0.5em 0;
    padding-left: 1.5em;
}

.toqan-markdown-content li {
    margin: 0.25em 0;
}

.toqan-markdown-content h1,
.toqan-markdown-content h2,
.toqan-markdown-content h3,
.toqan-markdown-content h4 {
    margin: 0.75em 0 0.5em 0;
    font-weight: 600;
    line-height: 1.3;
}

.toqan-markdown-content h1 { font-size: 1.5em; }
.toqan-markdown-content h2 { font-size: 1.3em; }
.toqan-markdown-content h3 { font-size: 1.1em; }
.toqan-markdown-content h4 { font-size: 1em; }

.toqan-markdown-content a {
    color: #0073aa;
    text-decoration: underline;
}

.toqan-markdown-content a:hover {
    color: #005177;
}

.toqan-markdown-content blockquote {
    border-left: 3px solid #ddd;
    margin: 0.5em 0;
    padding-left: 1em;
    color: #666;
}

.toqan-markdown-content code {
    background: #f5f5f5;
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.toqan-markdown-content pre {
    background: #f5f5f5;
    padding: 0.75em;
    border-radius: 4px;
    overflow-x: auto;
    margin: 0.5em 0;
}

.toqan-markdown-content pre code {
    background: none;
    padding: 0;
}

/* Conversation History Panel */
.toqan-history-panel {
    position: absolute;
    left: -320px;
    top: 0;
    bottom: 0;
    width: 300px;
    background: white;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    transition: left 0.3s ease;
    z-index: 10;
    display: flex;
    flex-direction: column;
}

.toqan-history-panel.toqan-open {
    left: 0;
}

.toqan-history-header {
    padding: 15px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid var(--toqan-border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.toqan-history-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--toqan-text-color);
}

.toqan-history-close {
    background: transparent;
    border: none;
    font-size: 24px;
    line-height: 1;
    color: #666;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toqan-history-close:hover {
    color: #333;
}

.toqan-history-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.toqan-history-loading,
.toqan-history-empty {
    text-align: center;
    padding: 40px 20px;
    color: #999;
}

.toqan-history-loading p,
.toqan-history-empty p {
    margin: 0;
}

.toqan-history-item {
    padding: 12px;
    margin-bottom: 8px;
    background: #f8f9fa;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.toqan-history-item:hover {
    background: #e9ecef;
    border-color: var(--toqan-primary-color);
}

.toqan-history-item.toqan-active {
    background: var(--toqan-primary-color);
    color: white;
}

.toqan-history-item-preview {
    font-size: 13px;
    margin: 0 0 5px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.toqan-history-item.toqan-active .toqan-history-item-preview {
    color: white;
}

.toqan-history-item-meta {
    font-size: 11px;
    color: #999;
    display: flex;
    justify-content: space-between;
}

.toqan-history-item.toqan-active .toqan-history-item-meta {
    color: rgba(255, 255, 255, 0.8);
}

/* History and New Conversation Buttons in Header */
.toqan-history-btn,
.toqan-new-conversation-btn {
    background: transparent;
    border: none;
    color: var(--toqan-secondary-color);
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.toqan-history-btn:hover,
.toqan-new-conversation-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}
