/* =================================================================
   AI CHAT WIDGET STYLES - GEHTSOFT BRAND
   =================================================================
   Standalone CSS for embeddable AI chat assistant widget
   Following Gehtsoft Brand Guidelines v-01 | JUNE 2025
   ================================================================= */

/* Chat FAB Button */
.chat-fab {
    position: fixed;
    bottom: 32px;
    right: 32px;
    height: 48px;
    padding: 0 16px 0 12px;
    border-radius: 24px;
    background: linear-gradient(135deg, #8de37b 0%, #5aa0d8 50%, #17479d 100%);
    border: none;
    box-shadow: 0 4px 16px rgba(90, 160, 216, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
    z-index: 10000;
}

.chat-fab:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(90, 160, 216, 0.6);
}

.chat-fab:active {
    transform: translateY(0);
}

.chat-fab svg {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

.chat-fab-text {
    color: white;
    font-size: 13px;
    font-weight: 500;
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    white-space: nowrap;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Chat Widget Overlay */
.chat-widget-overlay {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 400px;
    height: 600px;
    z-index: 10001;
    display: none;
    animation: slideIn 0.3s ease;
    min-width: 320px;
    max-width: 800px;
}

.chat-widget-overlay.active {
    display: flex;
}

/* Resize Handle */
.chat-widget-overlay::after {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 5px;
    height: 60px;
    background: rgba(102, 126, 234, 0.3);
    cursor: ew-resize;
    border-radius: 0 3px 3px 0;
    transition: background 0.2s;
}

.chat-widget-overlay:hover::after {
    background: rgba(102, 126, 234, 0.5);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Chat Panel Container */
.chat-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    width: 100%;
}

/* Chat Header */
.chat-header {
    padding: 16px;
    border-bottom: 1px solid #363b44;
    background: #000000;
    color: white;
    cursor: move;
    user-select: none;
    position: relative;
    overflow: hidden;
}

.chat-header::before {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 80px;
    background: linear-gradient(to bottom, #8de37b 0%, #5aa0d8 50%, #17479d 100%);
    -webkit-mask-image: repeating-linear-gradient(to right, black 0px, black 2px, transparent 2px, transparent 5px);
    mask-image: repeating-linear-gradient(to right, black 0px, black 2px, transparent 2px, transparent 5px);
    opacity: 0.8;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header h3 {
    margin: 0;
    font-size: 18px;
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-weight: 500;
    position: relative;
    z-index: 1;
}

.header-actions {
    display: flex;
    gap: 8px;
}

.btn-clear {
    margin-right: 32px;
}

.btn-clear, .btn-close {
    background: rgba(90, 160, 216, 0.2);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    transition: background 0.2s;
    position: relative;
    z-index: 1;
}

.btn-clear:hover, .btn-close:hover {
    background: rgba(90, 160, 216, 0.4);
}

/* Field Indicator */
.field-indicator {
    background: #e8f4fd;
    border-bottom: 1px solid #5aa0d8;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    animation: slideDown 0.2s ease;
}

@keyframes slideDown {
    from {
        max-height: 0;
        opacity: 0;
        padding-top: 0;
        padding-bottom: 0;
    }
    to {
        max-height: 50px;
        opacity: 1;
        padding-top: 10px;
        padding-bottom: 10px;
    }
}

.field-indicator-content {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.field-icon {
    font-size: 18px;
}

.field-text {
    font-size: 14px;
    color: #333;
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.field-label {
    color: #17479d;
    font-weight: 600;
}

.field-clear-btn {
    background: transparent;
    border: none;
    color: #666;
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 3px;
    transition: background 0.2s, color 0.2s;
}

.field-clear-btn:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #333;
}

/* Selected Element Highlight */
.chat-widget-selected {
    box-shadow: 0 0 0 2px rgba(90, 160, 216, 0.6),
                0 0 12px rgba(90, 160, 216, 0.4),
                0 0 20px rgba(141, 227, 123, 0.2) !important;
    cursor: pointer !important;
    transition: box-shadow 0.2s ease !important;
    position: relative !important;
}

/* Chat Messages Area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #ffffff;
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Message Bubbles */
.message {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 12px;
    word-wrap: break-word;
}

.message.user {
    align-self: flex-end;
    background: #5aa0d8;
    color: white;
}

.message.assistant {
    align-self: flex-start;
    background: #f5f5f5;
    color: #000000;
    border: 1px solid #e0e0e0;
}

.message.error {
    align-self: center;
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    max-width: 90%;
}

.message-content {
    line-height: 1.5;
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
}

/* Markdown Styles */
.message-content h1 {
    font-size: 1.5em;
    font-weight: 700;
    margin: 12px 0 8px 0;
    line-height: 1.3;
}

.message-content h2 {
    font-size: 1.3em;
    font-weight: 700;
    margin: 10px 0 6px 0;
    line-height: 1.3;
}

.message-content h3 {
    font-size: 1.1em;
    font-weight: 700;
    margin: 8px 0 4px 0;
    line-height: 1.3;
}

.message-content strong {
    font-weight: 700;
}

.message-content em {
    font-style: italic;
}

.message-content del {
    text-decoration: line-through;
    opacity: 0.7;
}

.message-content code {
    background: rgba(0, 0, 0, 0.08);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9em;
}

.message.user .message-content code {
    background: rgba(255, 255, 255, 0.2);
}

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

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

.message-content ul,
.message-content ol {
    margin: 8px 0;
    padding-left: 24px;
}

.message-content ol {
    list-style-type: decimal;
}

.message-content ul {
    list-style-type: disc;
}

.message-content li {
    margin: 4px 0;
    line-height: 1.6;
}

.message-content blockquote {
    border-left: 3px solid rgba(0, 0, 0, 0.2);
    padding-left: 12px;
    margin: 8px 0;
    color: rgba(0, 0, 0, 0.7);
    font-style: italic;
}

.message.user .message-content blockquote {
    border-left-color: rgba(255, 255, 255, 0.4);
    color: rgba(255, 255, 255, 0.9);
}

.message-content hr {
    border: none;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    margin: 12px 0;
}

.message-content a {
    color: #5aa0d8;
    text-decoration: underline;
}

.message-content a:hover {
    color: #17479d;
}

.message.user .message-content a {
    color: #8de37b;
}

.message.user .message-content a:hover {
    color: #ffffff;
}

/* Loading Animation */
.loading-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.loading-text {
    font-size: 14px;
    color: #666;
    font-style: italic;
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 0.5;
    }
    50% {
        opacity: 1;
    }
}

.loading-dots {
    display: flex;
    gap: 4px;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #5aa0d8;
    animation: bounce 1.4s infinite ease-in-out both;
}

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

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

@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

/* Chat Input Area */
.chat-input {
    display: flex;
    gap: 8px;
    padding: 16px;
    border-top: 1px solid #e0e0e0;
    background: white;
    position: relative;
}

.chat-input input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    outline: none;
    font-family: inherit;
}

.chat-input input:focus {
    border-color: #1976d2;
}

.chat-input input:disabled {
    background: #f5f5f5;
    cursor: not-allowed;
}

.btn-send {
    background: linear-gradient(135deg, #5aa0d8 0%, #17479d 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-send:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(23, 71, 157, 0.3);
}

.btn-send:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Autocomplete Dropdown */
.autocomplete-dropdown {
    position: absolute;
    bottom: 100%;
    left: 16px;
    right: 16px;
    max-height: 250px;
    overflow-y: auto;
    background: white;
    border: 1px solid #5aa0d8;
    border-radius: 6px;
    box-shadow: 0 -4px 12px rgba(90, 160, 216, 0.15);
    display: none;
    z-index: 1000;
    margin-bottom: 8px;
}

.autocomplete-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.15s ease;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover {
    background: #e8f4fd;
}

.autocomplete-item.selected {
    background: linear-gradient(90deg,
        rgba(141, 227, 123, 0.15) 0%,
        rgba(90, 160, 216, 0.15) 50%,
        rgba(23, 71, 157, 0.1) 100%);
    border-left: 3px solid #5aa0d8;
}

.autocomplete-question {
    font-size: 14px;
    color: #333;
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-weight: 500;
    line-height: 1.4;
    display: flex;
    align-items: center;
    gap: 8px;
}

.match-badge {
    display: inline-block;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
    margin-left: auto;
    white-space: nowrap;
}

.match-badge-answer {
    background: linear-gradient(90deg, rgba(141, 227, 123, 0.2), rgba(90, 160, 216, 0.2));
    color: #17479d;
}

.autocomplete-item.matched-in-answer {
    border-left: 3px solid #8de37b;
    background: rgba(141, 227, 123, 0.05);
}

/* Responsive Design */
@media (max-width: 768px) {
    .chat-widget-overlay {
        top: 10px;
        right: 10px;
        bottom: 10px;
        left: 10px;
        width: auto;
    }

    .chat-fab {
        bottom: 16px;
        right: 16px;
        height: 44px;
        padding: 0 14px 0 10px;
    }

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

    .chat-fab-text {
        font-size: 12px;
    }
}
