/* Kelluva hakuavustaja. */
/* ==========================================================================
   TEKIJÄTORI CHAT - Floating Chat Widget
   ========================================================================== */

/* CSS variables scoped to chat widget only - prevents conflicts with other site components */
.tekijatori-chat-widget {
    --tt-primary: #FFAC00;
    --tt-primary-dark: #E69B00;
    --tt-primary-light: #FFD166;
    --tt-dark: #1a1a1a;
    --tt-gray-900: #212121;
    --tt-gray-800: #333333;
    --tt-gray-600: #666666;
    --tt-gray-400: #999999;
    --tt-gray-200: #e5e5e5;
    --tt-gray-100: #f5f5f5;
    --tt-white: #ffffff;
    --tt-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    --tt-shadow-lg: 0 25px 60px rgba(0, 0, 0, 0.25);
    --tt-radius: 20px;
    --tt-radius-sm: 12px;
    --tt-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Widget Container */
.tekijatori-chat-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Toggle Button (Chat Bubble) */
.tekijatori-chat-toggle {
    position: relative;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--tt-primary) 0%, var(--tt-primary-dark) 100%);
    border: none;
    cursor: pointer;
    box-shadow: var(--tt-shadow);
    transition: var(--tt-transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.tekijatori-chat-toggle:hover {
    transform: scale(1.08);
    box-shadow: var(--tt-shadow-lg);
}

.tekijatori-chat-toggle:active {
    transform: scale(0.95);
}

.tekijatori-chat-toggle-icon {
    color: var(--tt-white);
    display: flex;
    align-items: center;
    justify-content: center;
}

.tekijatori-chat-toggle-icon .icon-close {
    display: none;
}

.tekijatori-chat-widget.is-open .tekijatori-chat-toggle-icon .icon-search {
    display: none;
}

.tekijatori-chat-widget.is-open .tekijatori-chat-toggle-icon .icon-close {
    display: block;
}

/* Pulse Animation */
.tekijatori-chat-toggle-pulse {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--tt-primary);
    animation: tt-pulse 2s ease-out infinite;
    pointer-events: none;
}

.tekijatori-chat-widget.is-open .tekijatori-chat-toggle-pulse {
    display: none;
}

@keyframes tt-pulse {
    0% { transform: scale(1); opacity: 0.5; }
    100% { transform: scale(1.5); opacity: 0; }
}

/* Chat Panel */
.tekijatori-chat-panel {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 140px);
    background: var(--tt-white);
    border-radius: var(--tt-radius);
    box-shadow: var(--tt-shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: var(--tt-transition);
    transform-origin: bottom right;
}

.tekijatori-chat-widget.is-open .tekijatori-chat-panel {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Header */
.tekijatori-chat-panel .tekijatori-chat-header {
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    padding: 16px 20px !important;
    background: linear-gradient(135deg, var(--tt-primary) 0%, var(--tt-primary-dark) 100%) !important;
    color: var(--tt-dark) !important;
    border: none !important;
    margin: 0 !important;
}

.tekijatori-chat-header .tekijatori-chat-avatar {
    width: 44px !important;
    height: 44px !important;
    border-radius: 50% !important;
    background: var(--tt-white) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: var(--tt-dark) !important;
    flex-shrink: 0 !important;
}

.tekijatori-chat-header .tekijatori-chat-avatar svg {
    width: 24px !important;
    height: 24px !important;
    stroke: var(--tt-dark) !important;
}

.tekijatori-chat-header .tekijatori-chat-title {
    flex: 1 !important;
    min-width: 0 !important;
}

.tekijatori-chat-header .tekijatori-chat-title strong {
    display: block !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    color: var(--tt-dark) !important;
}

.tekijatori-chat-header .tekijatori-chat-close {
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    min-height: 36px !important;
    border-radius: 50% !important;
    background: rgba(0, 0, 0, 0.15) !important;
    border: none !important;
    color: var(--tt-dark) !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: var(--tt-transition) !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    text-decoration: none !important;
}

.tekijatori-chat-header .tekijatori-chat-close:hover {
    background: rgba(0, 0, 0, 0.25) !important;
    color: var(--tt-dark) !important;
}

.tekijatori-chat-header .tekijatori-chat-close svg {
    width: 20px !important;
    height: 20px !important;
    stroke: var(--tt-dark) !important;
}

/* Messages Area */
.tekijatori-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 200px;
    max-height: 350px;
    background: var(--tt-gray-100);
}

/* Message Bubbles */
.tekijatori-chat-msg {
    display: flex;
    animation: tt-msgIn 0.3s ease;
}

@keyframes tt-msgIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.tekijatori-chat-msg-bot {
    justify-content: flex-start;
}

.tekijatori-chat-msg-user {
    justify-content: flex-end;
}

.tekijatori-chat-msg .msg-content {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.tekijatori-chat-msg-bot .msg-content {
    background: var(--tt-white);
    color: var(--tt-gray-800);
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.tekijatori-chat-msg-user .msg-content {
    background: var(--tt-primary);
    color: var(--tt-dark);
    border-bottom-right-radius: 4px;
}

.tekijatori-chat-msg-loading .msg-content {
    color: var(--tt-gray-600);
    font-style: italic;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--tt-gray-400);
    animation: tt-typing 1.4s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes tt-typing {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* Input Area */
.tekijatori-chat-input-area {
    padding: 16px 20px;
    background: var(--tt-white);
    border-top: 1px solid var(--tt-gray-200);
}

.tekijatori-chat-form {
    margin: 0;
}

.input-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--tt-gray-100);
    border-radius: var(--tt-radius-sm);
    padding: 4px 4px 4px 16px;
    border: 2px solid transparent;
    transition: var(--tt-transition);
}

.input-wrapper:focus-within {
    border-color: var(--tt-primary);
    background: var(--tt-white);
}

#tekijatori-chat-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 14px;
    color: var(--tt-gray-900);
    outline: none;
    padding: 10px 0;
}

#tekijatori-chat-input::placeholder {
    color: var(--tt-gray-400);
}

.tekijatori-chat-form #tekijatori-chat-submit {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
    border-radius: 10px !important;
    background: var(--tt-primary) !important;
    border: none !important;
    color: var(--tt-dark) !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: var(--tt-transition) !important;
    flex-shrink: 0 !important;
    padding: 0 !important;
}

.tekijatori-chat-form #tekijatori-chat-submit:hover {
    background: var(--tt-primary-dark) !important;
}

.tekijatori-chat-form #tekijatori-chat-submit:disabled {
    background: var(--tt-gray-400) !important;
    cursor: not-allowed !important;
}

.tekijatori-chat-form #tekijatori-chat-submit svg {
    width: 20px !important;
    height: 20px !important;
    display: block !important;
    stroke: var(--tt-dark) !important;
    fill: none !important;
}

.tekijatori-chat-form #tekijatori-chat-submit .send-icon {
    display: block !important;
}

.tekijatori-chat-form #tekijatori-chat-submit .loading-icon {
    display: none !important;
    animation: tt-spin 1s linear infinite !important;
}

.tekijatori-chat-form #tekijatori-chat-submit.is-loading .send-icon {
    display: none !important;
}

.tekijatori-chat-form #tekijatori-chat-submit.is-loading .loading-icon {
    display: block !important;
}

@keyframes tt-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Redirect Notice */
.tekijatori-chat-redirect {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: linear-gradient(135deg, var(--tt-primary-light) 0%, var(--tt-primary) 100%);
    border-radius: 12px;
    margin-top: 8px;
    color: var(--tt-dark);
    font-size: 13px;
    font-weight: 500;
}

.tekijatori-chat-redirect svg {
    animation: tt-spin 1s linear infinite;
    flex-shrink: 0;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .tekijatori-chat-widget {
        bottom: 16px;
        right: 16px;
    }
    
    /* Piilota widget kokonaan mobiilissa tekijät-sivulla */
    .tekijatori-chat-widget.is-tekijat-page {
        display: none !important;
    }
    
    .tekijatori-chat-toggle {
        width: 56px;
        height: 56px;
    }
    
    .tekijatori-chat-panel {
        width: calc(100vw - 32px);
        right: 0;
        bottom: 72px;
        max-height: calc(100vh - 100px);
    }
    
    .tekijatori-chat-messages {
        max-height: 280px;
    }
}

/* Scrollbar Styling */
.tekijatori-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.tekijatori-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.tekijatori-chat-messages::-webkit-scrollbar-thumb {
    background: var(--tt-gray-300);
    border-radius: 3px;
}

.tekijatori-chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--tt-gray-400);
}
