/* ===================================
   Chatbot Styles
   =================================== */

/* Chat Button */
.chat-button {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--color-accent);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(255, 107, 53, 0.4);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 28px rgba(255, 107, 53, 0.5);
}

.chat-button-text {
    font-family: var(--font-family);
    font-size: 20px;
    font-weight: 700;
    color: white;
    text-transform: lowercase;
}

/* Chat Window */
.chat-window {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 380px;
    height: 600px;
    background-color: var(--color-header-dark);
    border-radius: 12px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.3);
    z-index: 999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: opacity var(--transition-base), transform var(--transition-base), visibility var(--transition-base);
}

.chat-window.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

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

.chat-header-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-header-icon {
    width: 32px;
    height: 32px;
    background-color: var(--color-accent);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-header-icon svg {
    width: 18px;
    height: 18px;
    color: white;
}

.chat-header h3 {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: white;
    margin: 0;
}

.chat-header-status {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 2px;
}

/* Header Action Buttons */
.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.chat-header-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition-fast);
}

.chat-header-btn:hover {
    color: white;
}

.chat-header-btn svg {
    width: 20px;
    height: 20px;
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

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

.chat-messages::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Message Bubbles */
.chat-message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: var(--font-size-sm);
    line-height: 1.5;
    animation: messageSlide 0.3s ease;
}

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

.chat-message.bot {
    align-self: flex-start;
    background-color: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.9);
    border-bottom-left-radius: 4px;
}

.chat-message.user {
    align-self: flex-end;
    background-color: var(--color-accent);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message.system {
    align-self: center;
    background-color: transparent;
    color: rgba(255, 255, 255, 0.5);
    font-size: 12px;
    padding: 8px 12px;
    text-align: center;
}

/* Streaming Cursor */
.chat-message.streaming::after {
    content: '\258B';
    animation: blink 1s steps(1) infinite;
    margin-left: 2px;
    opacity: 0.7;
}

@keyframes blink {
    0%, 50% { opacity: 0.7; }
    51%, 100% { opacity: 0; }
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background-color: rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    max-width: 60px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background-color: rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    animation: typingBounce 1.4s ease-in-out infinite;
}

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

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

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

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

/* Loading State */
.chat-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: rgba(255, 255, 255, 0.7);
    text-align: center;
    padding: 20px;
}

.chat-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

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

.chat-loading-text {
    font-size: var(--font-size-sm);
    margin-bottom: 8px;
}

.chat-loading-progress {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
}

/* Chat Input */
.chat-input-container {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background-color: rgba(255, 255, 255, 0.03);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-input {
    flex: 1;
    background-color: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 12px 16px;
    color: white;
    font-family: inherit;
    font-size: var(--font-size-sm);
    resize: none;
    outline: none;
    transition: border-color var(--transition-fast), background-color var(--transition-fast);
}

.chat-input:focus {
    border-color: var(--color-accent);
    background-color: rgba(255, 255, 255, 0.1);
}

.chat-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.chat-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chat-send-btn {
    width: 44px;
    height: 44px;
    background-color: var(--color-accent);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color var(--transition-fast), transform var(--transition-fast);
}

.chat-send-btn:hover:not(:disabled) {
    background-color: #e55a2b;
    transform: scale(1.05);
}

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

.chat-send-btn svg {
    width: 20px;
    height: 20px;
    color: white;
}

/* Welcome Message */
.chat-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: rgba(255, 255, 255, 0.7);
    text-align: center;
    padding: 20px;
}

.chat-welcome h4 {
    font-size: var(--font-size-lg);
    color: white;
    margin-bottom: 8px;
}

.chat-welcome p {
    font-size: var(--font-size-sm);
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 20px;
}

.chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.chat-suggestion {
    background-color: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 8px 16px;
    font-family: var(--font-family);
    font-size: 12px;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    transition: background-color var(--transition-fast), border-color var(--transition-fast);
}

.chat-suggestion:hover {
    background-color: rgba(255, 107, 53, 0.2);
    border-color: var(--color-accent);
    color: white;
}

/* Download Confirmation */
.chat-download-note {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 20px;
}

/* Cache Status Indicator */
.cache-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 12px;
    margin-bottom: 16px;
}

.cache-status svg {
    flex-shrink: 0;
}

.cache-status.cached {
    background-color: rgba(76, 175, 80, 0.2);
    color: #81c784;
}

.cache-status.not-cached {
    background-color: rgba(255, 107, 53, 0.2);
    color: var(--color-accent);
}

.chat-start-btn {
    background-color: var(--color-accent);
    border: none;
    border-radius: 8px;
    padding: 12px 32px;
    font-family: var(--font-family);
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: white;
    cursor: pointer;
    transition: background-color var(--transition-fast), transform var(--transition-fast);
}

.chat-start-btn:hover {
    background-color: #e55a2b;
    transform: scale(1.05);
}

/* Error State */
.chat-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px;
    background-color: rgba(255, 59, 48, 0.1);
    border-radius: 8px;
    margin: 8px;
}

.chat-error-text {
    color: #ff6b6b;
    font-size: var(--font-size-sm);
    margin-bottom: 12px;
    text-align: center;
}

.chat-retry-btn {
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    padding: 8px 16px;
    color: white;
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
    transition: background-color var(--transition-fast);
}

.chat-retry-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

/* Responsive */
@media (max-width: 480px) {
    .chat-button {
        bottom: 16px;
        right: 16px;
        width: 56px;
        height: 56px;
    }

    .chat-window {
        bottom: 88px;  /* Position above the button (16px + 56px + 16px gap) */
        right: 8px;
        left: 8px;
        width: auto;   /* Use left/right margins instead of 100% */
        height: calc(100vh - 176px);  /* Account for header (80px) + bottom (88px) + 8px buffer */
        max-height: calc(100vh - 176px);
        border-radius: 12px;
    }

    .chat-window.active {
        transform: translateY(0) scale(1);
    }
}

@media (max-width: 768px) and (min-width: 481px) {
    .chat-window {
        width: 340px;
        height: 480px;
        right: 16px;
        bottom: 88px;
    }
}
