/* Conversational Search Frontend Styles */

/* Reset and base styles */
.cs-popup-overlay *,
.cs-floating-trigger * {
    box-sizing: border-box;
}

/* Popup overlay */
.cs-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.cs-popup-overlay.cs-popup-open {
    display: flex !important;
    opacity: 1;
    visibility: visible;
}

/* Popup positioning variants */
.cs-popup-center {
    align-items: center;
    justify-content: center;
}

.cs-popup-bottom-right {
    align-items: flex-end;
    justify-content: flex-end;
    padding: 20px;
}

.cs-popup-bottom-left {
    align-items: flex-end;
    justify-content: flex-start;
    padding: 20px;
}

.cs-popup-top-right {
    align-items: flex-start;
    justify-content: flex-end;
    padding: 20px;
}

.cs-popup-top-left {
    align-items: flex-start;
    justify-content: flex-start;
    padding: 20px;
}

/* Popup container */
.cs-popup-container {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    max-width: 960px;
    width: 90%;
    max-height: 600px;
    height: 80vh;
    display: flex;
    flex-direction: column;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    animation: cs-popup-slide-in 0.3s ease-out;
    touch-action: manipulation;
    transition: max-height 0.3s ease-out;
}

@keyframes cs-popup-slide-in {
    from {
        transform: scale(0.9) translateY(20px);
        opacity: 0;
    }
    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

/* Popup header */
.cs-popup-header {
    background: #AD0765;
    color: white;
    padding: 16px 20px;
    border-radius: 12px 12px 0 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.cs-popup-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.cs-popup-controls {
    display: flex;
    gap: 8px;
}

/* Popup body */
.cs-popup-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

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

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

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

.cs-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Messages */
.cs-message {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
}

.cs-message-user {
    align-items: flex-end;
}

.cs-message-assistant {
    align-items: flex-start;
}

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

.cs-message-user .cs-message-content {
    background: #ECF8FF;
    color: #404040;
    border: 1px solid #42C7FF;
    text-align: left;
}

.cs-message-assistant .cs-message-content {
    background: #FFEDF4;
    color: #AD0765;
    border: 1px solid #FFA1B7;
    text-align: left;
}

.cs-welcome-message .cs-message-content {
    background: #FFEDF4;
    color: #AD0765;
    border: 1px solid #FFA1B7;
    text-align: left;
}

/* Message links */
.cs-message-content a {
    color: inherit;
    text-decoration: underline;
    opacity: 0.9;
}

.cs-message-content a:hover {
    opacity: 1;
}

.cs-message-user .cs-message-content a {
    color: rgba(255, 255, 255, 0.9);
}

/* Message timestamp */
.cs-message-time {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
    padding: 0 4px;
}

/* Typing indicator */
.cs-typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    color: #666;
    font-size: 13px;
}

.cs-typing-dots {
    display: flex;
    gap: 3px;
}

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

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

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

/* Popup footer */
.cs-popup-footer {
    border-top: 1px solid #e0e0e0;
    padding: 16px 20px;
    flex-shrink: 0;
}

.cs-chat-form {
    margin-bottom: 12px;
}

.cs-input-group {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.cs-chat-input {
    flex: 1;
    min-height: 37px;
    max-height: 100px;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 18px;
    resize: none;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.4;
    outline: none;
    transition: border-color 0.2s ease;
}

.cs-chat-input:focus {
    border-color: #AD0765;
}

.cs-chat-input:disabled {
    background: #f5f5f5;
    color: #999;
}

/* Buttons */
.cs-btn {
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

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

.cs-btn-new-chat {
    background: white;
    color: #D0539A;
    border-radius: 9px;
    padding: 4px 12px;
    font-size: 12px;
}

.cs-btn-new-chat:hover {
    color: #AD0765;
}

.cs-btn-send {
    background: #AD0765;
    color: white;
    padding: 8px 16px;
    border-radius: 18px;
    min-width: 60px;
    flex-direction: row-reverse;
}

.cs-btn-send:not(:disabled):hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(173, 7, 101, 0.3);
}

.cs-btn-icon {
    background: transparent;
    color: rgba(255, 255, 255, 0.8);
    padding: 4px;
    border-radius: 4px;
    width: 28px;
    height: 28px;
}

.cs-btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.cs-btn-text {
    background: transparent;
    color: #ffffff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
}

.cs-btn-text:hover {
    background: rgba(173, 7, 101, 0.1);
}

/* Footer actions */
.cs-footer-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
}

.cs-powered-by {
    color: #D0539A;
}

/* Trigger buttons */
.cs-trigger-button, .cs-trigger-btn {
    background: white;
    color: #404040;
    border: 2px solid #404040;
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.cs-trigger-button:hover, .cs-trigger-btn:hover {
    background: #FFEDF4;
    color: #AD0765;
    border-color: #AD0765;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(173, 7, 101, 0.2);
}

.cs-trigger-link {
    color: #AD0765;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.cs-trigger-link:hover {
    color: #33021E;
    text-decoration: underline;
}

/* Floating trigger */
.cs-floating-trigger {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999998;
}

.cs-btn-floating {
    background: #AD0765;
    color: white;
    border: none;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(173, 7, 101, 0.3);
    transition: all 0.3s ease;
}

.cs-btn-floating:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(173, 7, 101, 0.4);
}

/* Auto trigger wrapper */
.cs-auto-trigger {
    margin: 20px 0;
    text-align: center;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .cs-popup-container {
        width: 95%;
        height: auto;
        max-height: calc(100vh - 20px);
        border-radius: 8px;
    }
    
    /* Optimize height when keyboard is open */
    .cs-popup-overlay.cs-keyboard-open .cs-popup-container {
        max-height: calc(100vh - 20px);
    }
    
    .cs-popup-header {
        padding: 12px 16px;
        border-radius: 8px 8px 0 0;
    }
    
    .cs-popup-title {
        font-size: 15px;
    }
    
    .cs-chat-messages {
        padding: 16px;
    }
    
    .cs-popup-footer {
        padding: 12px 16px;
    }
    
    .cs-message-content {
        max-width: 90%;
        padding: 10px 14px;
    }
    
    .cs-chat-input {
        font-size: 16px;
        transform: scale(0.875);
        transform-origin: left center;
    }
    
    .cs-floating-trigger {
        bottom: 15px;
        right: 15px;
    }
    
    .cs-btn-floating {
        width: 50px;
        height: 50px;
        font-size: 18px;
    }
}

@media (max-width: 480px) {
    .cs-popup-overlay.cs-popup-bottom-right,
    .cs-popup-overlay.cs-popup-bottom-left,
    .cs-popup-overlay.cs-popup-top-right,
    .cs-popup-overlay.cs-popup-top-left {
        padding: 10px;
    }
    
    .cs-popup-container {
        max-height: calc(100vh - 20px);
    }
    
    /* Optimize height when keyboard is open on small screens */
    .cs-popup-overlay.cs-keyboard-open .cs-popup-container {
        max-height: calc(100vh - 20px);
    }
    
    .cs-input-group {
        gap: 6px;
    }
    
    .cs-chat-input {
        padding: 6px 10px;
        font-size: 16px;
        transform: scale(0.8125);
        transform-origin: left center;
    }
    
    .cs-btn-send {
        padding: 6px 12px;
        min-width: 50px;
        font-size: 13px;
    }
}

/* Dark theme support */
@media (prefers-color-scheme: dark) {
    .cs-popup-container {
        background: #2d2d2d;
        color: #ffffff;
    }
    
    .cs-message-assistant .cs-message-content {
        background: #3a3a3a;
        color: #ffffff;
        border-color: #555;
    }
    
    .cs-popup-footer {
        border-top-color: #555;
    }
    
    .cs-chat-input {
        background: #3a3a3a;
        color: #ffffff;
        border-color: #555;
    }
    
    .cs-chat-input:focus {
        border-color: #AD0765;
    }
    
    .cs-powered-by {
        color: #999;
    }
}

/* Search results display */
.cs-search-results {
    margin-top: 16px;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    background: #f9f9f9;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.cs-search-results-header {
    background: #FFEDF4;
    padding: 10px 14px;
    border-bottom: 1px solid #FFA1B7;
    font-size: 12px;
    font-weight: 600;
    color: #AD0765;
}

.cs-search-results-title {
    display: flex;
    align-items: center;
    gap: 6px;
}

.cs-search-results-list {
    padding: 0;
}

.cs-search-result-item {
    display: flex;
    padding: 12px 14px;
    border-bottom: 1px solid #e8e8e8;
    transition: background-color 0.2s ease;
}

.cs-search-result-item:last-child {
    border-bottom: none;
}

.cs-search-result-item:hover {
    background: #FFEDF4;
}

.cs-result-number {
    width: 20px;
    height: 20px;
    background: #AD0765;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 600;
    flex-shrink: 0;
    margin-right: 12px;
    margin-top: 2px;
}

.cs-result-content {
    flex: 1;
    min-width: 0;
    text-align: left;
}

.cs-result-title {
    margin-bottom: 4px;
}

.cs-result-title a {
    color: #AD0765;
    text-decoration: none;
    font-weight: 500;
    font-size: 13px;
    line-height: 1.3;
    display: block;
    text-align: left;
}

.cs-result-title a:hover {
    color: #33021E;
    text-decoration: underline;
}

.cs-result-excerpt {
    font-size: 11px;
    line-height: 1.4;
    color: #666;
    margin-top: 4px;
}

/* Dark theme support for search results */
@media (prefers-color-scheme: dark) {
    .cs-search-results {
        background: #2a2a2a;
        border-color: #555;
    }
    
    .cs-search-results-header {
        background: #333;
        border-color: #555;
        color: #ccc;
    }
    
    .cs-search-result-item {
        border-color: #444;
    }
    
    .cs-search-result-item:hover {
        background: #333;
    }
    
    .cs-result-title a {
        color: #FFA1B7;
    }
    
    .cs-result-title a:hover {
        color: #F971A7;
    }
    
    .cs-result-excerpt {
        color: #bbb;
    }
}

/* Animation for new messages */
.cs-message {
    animation: cs-message-slide-in 0.3s ease-out;
}

@keyframes cs-message-slide-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Loading state */
.cs-popup-container.cs-loading .cs-chat-input {
    background: #f5f5f5;
    color: #999;
}

/* Error state */
.cs-message-error .cs-message-content {
    background: #ffebee;
    color: #c62828;
    border: 1px solid #ffcdd2;
}

/* Success highlights in messages */
.cs-message-content code {
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 4px;
    border-radius: 3px;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 0.9em;
}

.cs-message-content pre {
    background: rgba(0, 0, 0, 0.05);
    padding: 8px;
    border-radius: 4px;
    overflow-x: auto;
    margin: 8px 0;
}

.cs-message-content strong {
    font-weight: 600;
}

/* Example Prompts Styling */
.cs-example-prompts {
    margin: 12px 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    animation: cs-prompts-fade-in 0.3s ease-out;
    align-items: flex-start;
}

@keyframes cs-prompts-fade-in {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.cs-example-prompt {
    background: #f8f9fa;
    color: #AD0765;
    border: 1px solid #FFA1B7;
    border-radius: 16px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: normal;
    word-wrap: break-word;
    word-break: break-word;
    display: inline-block;
    text-align: left;
    line-height: 1.3;
    min-height: 32px;
    max-width: 300px;
    width: auto;
}

.cs-example-prompt:hover {
    background: #FFEDF4;
    border-color: #AD0765;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(173, 7, 101, 0.15);
}

.cs-example-prompt:active {
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(173, 7, 101, 0.2);
}

/* Initial prompts styling */
.cs-initial-prompts {
    margin-top: 16px;
    margin-bottom: 8px;
}

.cs-initial-prompts .cs-example-prompt {
    background: #FFEDF4;
    border-color: #FFA1B7;
    color: #AD0765;
}

.cs-initial-prompts .cs-example-prompt:hover {
    background: #FFD6E3;
    border-color: #AD0765;
}

/* Follow-up prompts styling */
.cs-follow-up-prompts {
    margin-top: 8px;
    margin-bottom: 8px;
}

.cs-follow-up-prompts .cs-example-prompt {
    background: #f0f8ff;
    border-color: #42C7FF;
    color: #0066cc;
    font-size: 12px;
    padding: 6px 12px;
}

.cs-follow-up-prompts .cs-example-prompt:hover {
    background: #e6f3ff;
    border-color: #0066cc;
    color: #004499;
}

/* Mobile responsiveness for example prompts */
@media (max-width: 768px) {
    .cs-example-prompts {
        gap: 6px;
        margin: 10px 0;
        flex-direction: column;
        align-items: flex-start;
    }
    
    .cs-example-prompt {
        font-size: 12px;
        padding: 6px 12px;
        max-width: 100%;
        width: 100%;
        min-height: 28px;
    }
    
    .cs-follow-up-prompts .cs-example-prompt {
        font-size: 11px;
        padding: 5px 10px;
        max-width: 100%;
        width: 100%;
    }
}

@media (max-width: 480px) {
    .cs-example-prompts {
        gap: 4px;
    }
    
    .cs-example-prompt {
        font-size: 11px;
        padding: 5px 10px;
        max-width: 100%;
        width: 100%;
        min-height: 26px;
    }
    
    .cs-follow-up-prompts .cs-example-prompt {
        font-size: 10px;
        padding: 4px 8px;
        max-width: 100%;
        width: 100%;
    }
}

/* Dark theme support for example prompts */
@media (prefers-color-scheme: dark) {
    .cs-example-prompt {
        background: #3a3a3a;
        color: #FFA1B7;
        border-color: #555;
    }
    
    .cs-example-prompt:hover {
        background: #4a4a4a;
        border-color: #FFA1B7;
    }
    
    .cs-initial-prompts .cs-example-prompt {
        background: #4a3a3a;
        border-color: #666;
        color: #FFA1B7;
    }
    
    .cs-initial-prompts .cs-example-prompt:hover {
        background: #5a4a4a;
        border-color: #FFA1B7;
    }
    
    .cs-follow-up-prompts .cs-example-prompt {
        background: #3a4a5a;
        border-color: #42C7FF;
        color: #66B3FF;
    }
    
    .cs-follow-up-prompts .cs-example-prompt:hover {
        background: #4a5a6a;
        border-color: #66B3FF;
        color: #4D9FFF;
    }
}

