/**
 * Chat Widget Styles
 * Provides styling for the AI support chat widget.
 * 
 * @author Stefan Schumann
 */

/* CSS Custom Properties */
:root {
    --chat-primary-color: #0f4b6c;
    --chat-button-size: 60px;
    --chat-widget-width: 380px;
    --chat-widget-height: 550px;
    --chat-widget-mobile-height: 100%;
    --chat-border-radius: 16px;
    --chat-shadow: 0 5px 40px rgba(0, 0, 0, 0.16);
    --chat-z-index: 99999;
}

/* Floating Chat Button */
.chat-widget-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: var(--chat-button-size);
    height: var(--chat-button-size);
    border-radius: 50%;
    background: var(--chat-primary-color);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: var(--chat-shadow);
    z-index: var(--chat-z-index);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.chat-widget-button:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 50px rgba(0, 0, 0, 0.2);
}

.chat-widget-button:active {
    transform: scale(0.95);
}

.chat-widget-button.position-left {
    right: auto;
    left: 20px;
}

.chat-widget-button svg {
    width: 28px;
    height: 28px;
}

.chat-widget-button.active {
    background: #dc3545;
}

/* Tooltip */
.chat-widget-tooltip {
    position: fixed;
    bottom: 90px;
    right: 20px;
    background: white;
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: var(--chat-shadow);
    z-index: calc(var(--chat-z-index) - 1);
    max-width: 250px;
    font-size: 14px;
    line-height: 1.4;
    color: #333;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease;
    cursor: pointer;
}

.chat-widget-tooltip::after {
    content: '';
    position: absolute;
    bottom: -8px;
    right: 25px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid white;
}

.chat-widget-tooltip.position-left {
    right: auto;
    left: 20px;
}

.chat-widget-tooltip.position-left::after {
    right: auto;
    left: 25px;
}

.chat-widget-tooltip.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.chat-widget-tooltip:hover {
    background: #f8f9fa;
}

/* Chat Container */
.chat-widget-container {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: var(--chat-widget-width);
    height: var(--chat-widget-height);
    max-height: calc(100vh - 120px);
    background: white;
    border-radius: var(--chat-border-radius);
    box-shadow: var(--chat-shadow);
    z-index: var(--chat-z-index);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease;
}

.chat-widget-container.position-left {
    right: auto;
    left: 20px;
}

.chat-widget-container.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.chat-widget-container.minimized {
    height: 56px;
    overflow: hidden;
}

.chat-widget-container.minimized .chat-widget-body,
.chat-widget-container.minimized .chat-widget-context {
    display: none;
}

/* Chat Header */
.chat-widget-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--chat-primary-color);
    color: white;
    flex-shrink: 0;
}

.chat-widget-header-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 15px;
}

.chat-widget-header-actions {
    display: flex;
    gap: 8px;
}

.chat-widget-header-actions button {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.chat-widget-header-actions button:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Context Bar */
.chat-widget-context {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 14px;
    background: #f0f7fa;
    border-bottom: 1px solid #e0e8ec;
    font-size: 12px;
    color: #4a5568;
    flex-shrink: 0;
}

.chat-widget-context-icon {
    flex-shrink: 0;
    color: var(--chat-primary-color);
    margin-top: 1px;
}

.chat-widget-context-text {
    line-height: 1.4;
}

.chat-widget-context-text strong {
    color: #2d3748;
}

.chat-widget-context-text .article-number {
    color: #718096;
    font-size: 11px;
}

/* Chat Body */
.chat-widget-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* Loading State */
.chat-widget-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 16px;
    color: #6c757d;
    font-size: 14px;
}

.chat-widget-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e9ecef;
    border-top-color: var(--chat-primary-color);
    border-radius: 50%;
    animation: chat-spin 0.8s linear infinite;
}

@keyframes chat-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Error State */
.chat-widget-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 12px;
    color: #dc3545;
    text-align: center;
    padding: 20px;
}

.chat-widget-error p {
    margin: 0;
    color: #6c757d;
}

/* Iframe */
.chat-widget-iframe {
    width: 100%;
    height: 100%;
    border: none;
    flex: 1;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .chat-widget-container {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: var(--chat-widget-mobile-height);
        max-height: 100vh;
        border-radius: 0;
    }

    .chat-widget-container.position-left {
        left: 0;
        right: 0;
    }

    .chat-widget-button {
        bottom: 15px;
        right: 15px;
        width: 56px;
        height: 56px;
    }

    .chat-widget-button.position-left {
        right: auto;
        left: 15px;
    }

    .chat-widget-button svg {
        width: 24px;
        height: 24px;
    }

    .chat-widget-tooltip {
        bottom: 80px;
        right: 15px;
        max-width: 200px;
        font-size: 13px;
    }

    .chat-widget-tooltip.position-left {
        right: auto;
        left: 15px;
    }

    :root {
        --chat-widget-height: 100%;
    }
}

/* Print - hide widget */
@media print {
    .chat-widget-button,
    .chat-widget-tooltip,
    .chat-widget-container {
        display: none !important;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .chat-widget-button,
    .chat-widget-tooltip,
    .chat-widget-container {
        transition: none;
    }

    .chat-widget-spinner {
        animation: none;
    }
}
