/* Smart Content Assistant Chatbot Styles */
:root {
    --sca-primary-color: #007cba;
    --sca-secondary-color: #f0f0f0;
    --sca-text-color: #333;
    --sca-border-radius: 12px;
    --sca-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    --sca-transition: all 0.3s ease;
}

.sca-chatbot {
    position: fixed;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.4;
}

/* Position variants */
.sca-chatbot.bottom-right {
    bottom: 20px;
    right: 20px;
}

.sca-chatbot.bottom-left {
    bottom: 20px;
    left: 20px;
}

.sca-chatbot.top-right {
    top: 20px;
    right: 20px;
}

.sca-chatbot.top-left {
    top: 20px;
    left: 20px;
}

.sca-chatbot.center-right {
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
}

.sca-chatbot.center-left {
    top: 50%;
    left: 20px;
    transform: translateY(-50%);
}

/* Chat toggle button */
.sca-chat-toggle {
    width: 60px;
    height: 60px;
    background: var(--sca-primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--sca-shadow);
    transition: var(--sca-transition);
    color: white;
    position: relative;
    overflow: hidden;
}

.sca-chat-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.2);
}

.sca-chat-toggle.active {
    background: #dc3545;
}

.sca-chat-toggle svg {
    transition: var(--sca-transition);
}

.sca-chat-toggle.active svg {
    transform: rotate(180deg);
}

/* Notification badge */
.sca-notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #dc3545;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: bold;
    animation: pulse 2s infinite;
}

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

/* Chat window */
.sca-chat-window {
    position: absolute;
    width: 350px;
    height: 500px;
    background: white;
    border-radius: var(--sca-border-radius);
    box-shadow: var(--sca-shadow);
    display: none;
    flex-direction: column;
    overflow: hidden;
    transition: var(--sca-transition);
}

.sca-chat-window.show {
    display: flex;
    animation: slideUp 0.3s ease-out;
}

/* Position adjustments for chat window */
.sca-chatbot.bottom-right .sca-chat-window,
.sca-chatbot.center-right .sca-chat-window {
    bottom: 70px;
    right: 0;
}

.sca-chatbot.bottom-left .sca-chat-window,
.sca-chatbot.center-left .sca-chat-window {
    bottom: 70px;
    left: 0;
}

.sca-chatbot.top-right .sca-chat-window {
    top: 70px;
    right: 0;
}

.sca-chatbot.top-left .sca-chat-window {
    top: 70px;
    left: 0;
}

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

/* Chat header */
.sca-chat-header {
    background: var(--sca-primary-color);
    color: white;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sca-bot-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sca-bot-avatar {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sca-bot-name {
    font-weight: 600;
    font-size: 16px;
}

.sca-bot-status {
    font-size: 12px;
    opacity: 0.8;
}

.sca-chat-close {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: var(--sca-transition);
}

.sca-chat-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Language selector */
.sca-language-selector {
    display: flex;
    gap: 5px;
    margin-left: auto;
    margin-right: 10px;
}

.sca-lang-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    transition: var(--sca-transition);
}

.sca-lang-btn:hover,
.sca-lang-btn.active {
    background: rgba(255, 255, 255, 0.3);
}

/* Topic suggestions */
.sca-topic-suggestions {
    padding: 15px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.sca-topic-title {
    font-size: 12px;
    font-weight: 600;
    color: #6c757d;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sca-topic-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.sca-topic-chip {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 16px;
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
    transition: var(--sca-transition);
    color: var(--sca-text-color);
}

.sca-topic-chip:hover {
    background: var(--sca-primary-color);
    color: white;
    border-color: var(--sca-primary-color);
}

/* Messages container */
.sca-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

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

.sca-chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.sca-chat-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 2px;
}

/* Message styles */
.sca-message {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    max-width: 85%;
    animation: fadeIn 0.3s ease-out;
}

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

.sca-user-message {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.sca-bot-message {
    align-self: flex-start;
}

.sca-message-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 12px;
    font-weight: 600;
}

.sca-bot-message .sca-message-avatar {
    background: var(--sca-primary-color);
    color: white;
}

.sca-user-message .sca-message-avatar {
    background: #6c757d;
    color: white;
}

.sca-message-content {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 10px 14px;
    position: relative;
    word-wrap: break-word;
}

.sca-bot-message .sca-message-content {
    border-bottom-left-radius: 4px;
}

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

.sca-message-time {
    font-size: 11px;
    color: #6c757d;
    margin-top: 4px;
    text-align: right;
}

.sca-user-message .sca-message-time {
    text-align: left;
    color: rgba(255, 255, 255, 0.7);
}

/* Search results */
.sca-search-results {
    margin-top: 10px;
}

.sca-result-item {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 8px;
    transition: var(--sca-transition);
}

.sca-result-item:hover {
    background: #e9ecef;
}

.sca-result-title {
    font-weight: 600;
    color: var(--sca-primary-color);
    text-decoration: none;
    font-size: 13px;
    display: block;
    margin-bottom: 4px;
}

.sca-result-excerpt {
    font-size: 12px;
    color: #6c757d;
    line-height: 1.3;
}

.sca-result-type {
    font-size: 10px;
    background: var(--sca-primary-color);
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
    display: inline-block;
    margin-top: 4px;
    text-transform: uppercase;
}

/* Input container */
.sca-chat-input-container {
    padding: 15px;
    border-top: 1px solid #e9ecef;
    display: flex;
    gap: 10px;
    align-items: center;
    background: white;
}

.sca-chat-input {
    flex: 1;
    border: 1px solid #dee2e6;
    border-radius: 20px;
    padding: 10px 15px;
    font-size: 14px;
    outline: none;
    transition: var(--sca-transition);
}

.sca-chat-input:focus {
    border-color: var(--sca-primary-color);
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.1);
}

.sca-chat-send {
    background: var(--sca-primary-color);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--sca-transition);
    color: white;
}

.sca-chat-send:hover {
    background: #005a87;
    transform: scale(1.05);
}

.sca-chat-send:disabled {
    background: #6c757d;
    cursor: not-allowed;
    transform: none;
}

/* Typing indicator */
.sca-typing-indicator {
    padding: 10px 15px;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
}

.sca-typing-dots {
    display: flex;
    gap: 4px;
    align-items: center;
}

.sca-typing-dots::before {
    content: 'Kirjoittaa';
    font-size: 12px;
    color: #6c757d;
    margin-right: 8px;
}

.sca-typing-dots span {
    width: 6px;
    height: 6px;
    background: #6c757d;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.sca-typing-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

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

@keyframes typing {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Contact suggestion */
.sca-contact-suggestion {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 8px;
    padding: 10px;
    margin-top: 10px;
    text-align: center;
}

.sca-contact-btn {
    background: var(--sca-primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 12px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    margin-top: 8px;
    transition: var(--sca-transition);
}

.sca-contact-btn:hover {
    background: #005a87;
    text-decoration: none;
    color: white;
}

/* Responsive design */
@media (max-width: 768px) {
    .sca-chat-window {
        width: calc(100vw - 40px);
        height: calc(100vh - 100px);
        max-width: 400px;
        max-height: 600px;
        min-width: 320px;
    }
    
    .sca-chatbot.bottom-right .sca-chat-window,
    .sca-chatbot.bottom-left .sca-chat-window {
        bottom: 70px;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
    }
    
    .sca-chatbot.top-right .sca-chat-window,
    .sca-chatbot.top-left .sca-chat-window {
        top: 70px;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
    }
    
    .sca-chatbot.center-right .sca-chat-window,
    .sca-chatbot.center-left .sca-chat-window {
        top: 50%;
        left: 50%;
        right: auto;
        transform: translate(-50%, -50%);
    }
}

@media (max-width: 480px) {
    .sca-chat-window {
        width: calc(100vw - 20px) !important;
        height: calc(100vh - 80px) !important;
        border-radius: 8px !important;
        min-width: 300px !important;
        max-width: none !important;
        max-height: none !important;
    }
    
    .sca-chatbot {
        bottom: 10px !important;
        right: 10px !important;
        left: auto !important;
        top: auto !important;
        transform: none !important;
    }
    
    .sca-chat-window {
        bottom: 70px !important;
        left: 10px !important;
        right: 10px !important;
        transform: none !important;
    }
    
    .sca-topic-chips {
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .sca-topic-chip {
        font-size: 11px;
        padding: 4px 8px;
        margin: 2px;
    }
    
    .sca-chat-input {
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .sca-chat-messages {
        padding: 10px;
    }
    
    .sca-message {
        max-width: 90%;
    }
}

/* Extra small screens */
@media (max-width: 320px) {
    .sca-chat-window {
        width: calc(100vw - 10px) !important;
        left: 5px !important;
        right: 5px !important;
        min-width: 280px !important;
    }
    
    .sca-chat-header {
        padding: 10px 15px;
    }
    
    .sca-bot-name {
        font-size: 14px;
    }
    
    .sca-topic-chip {
        font-size: 10px;
        padding: 3px 6px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .sca-chat-window {
        background: #2d3748;
        color: #e2e8f0;
    }
    
    .sca-message-content {
        background: #4a5568;
        border-color: #4a5568;
        color: #e2e8f0;
    }
    
    .sca-user-message .sca-message-content {
        background: var(--sca-primary-color);
        color: white;
    }
    
    .sca-chat-input {
        background: #4a5568;
        border-color: #4a5568;
        color: #e2e8f0;
    }
    
    .sca-topic-suggestions {
        background: #1a202c;
        border-color: #4a5568;
    }
    
    .sca-topic-chip {
        background: #4a5568;
        border-color: #4a5568;
        color: #e2e8f0;
    }
    
    .sca-result-item {
        background: #4a5568;
        border-color: #4a5568;
    }
}

/* Accessibility */
.sca-chatbot [role="button"] {
    cursor: pointer;
}

.sca-chatbot button:focus,
.sca-chatbot input:focus {
    outline: 2px solid var(--sca-primary-color);
    outline-offset: 2px;
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .sca-chat-toggle {
        border: 2px solid #000;
    }
    
    .sca-chat-window {
        border: 2px solid #000;
    }
    
    .sca-message-content {
        border: 2px solid #000;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .sca-chatbot * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}