/* AI Bot Global Widget Styles */
#ai-bot-widget {
    position: fixed;
    bottom: 25px;
    right: 25px;
    z-index: 10000;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* AI Bot Button/Icon */
.ai-bot-button {
    width: 70px;
    height: 70px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    border: 3px solid white;
    animation: float 3s ease-in-out infinite;
}

.ai-bot-button:hover {
    transform: scale(1.15) rotate(5deg);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.6);
}

.ai-bot-avatar {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
}

.ai-bot-icon {
    font-size: 28px;
    color: white;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

/* Tooltip */
.ai-bot-tooltip {
    position: absolute;
    bottom: 100%;
    right: 0;
    background: #333;
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 12px;
    white-space: nowrap;
    margin-bottom: 10px;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.ai-bot-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    right: 20px;
    border: 5px solid transparent;
    border-top-color: #333;
}

.ai-bot-button:hover .ai-bot-tooltip {
    opacity: 1;
    transform: translateY(0);
}

/* Pulsing animation */
.ai-bot-pulse {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: rgba(102, 126, 234, 0.4);
    animation: pulse 2s infinite;
    z-index: -1;
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(1.5); opacity: 0; }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

/* AI Bot Popup */
.ai-bot-popup {
    position: absolute;
    bottom: 90px;
    right: 0;
    width: 380px;
    height: 520px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #e1e5e9;
}

.ai-bot-popup.active {
    display: flex;
    animation: slideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideUp {
    from { 
        opacity: 0; 
        transform: translateY(30px) scale(0.9); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0) scale(1); 
    }
}

/* Header */
.ai-bot-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.ai-bot-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-bot-avatar-small {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.ai-bot-title h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.ai-bot-status {
    font-size: 12px;
    opacity: 0.9;
    margin-top: 2px;
}

.ai-bot-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.ai-bot-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Messages */
.ai-bot-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ai-bot-message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 18px;
    position: relative;
    animation: messageSlide 0.3s ease;
}

@keyframes messageSlide {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.ai-message {
    align-self: flex-start;
    background: white;
    border-radius: 18px 18px 18px 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.user-message {
    align-self: flex-end;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 18px 18px 4px 18px;
}

.message-content {
    margin-bottom: 4px;
    line-height: 1.4;
    word-wrap: break-word;
}

.message-time {
    font-size: 11px;
    opacity: 0.6;
    text-align: right;
}

/* Quick Questions */
.ai-bot-quick-questions {
    padding: 12px 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    border-top: 1px solid #e1e5e9;
    background: white;
    flex-shrink: 0;
}

.quick-question {
    background: #f8f9fa;
    border: 1px solid #e1e5e9;
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #495057;
}

.quick-question:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
    transform: translateY(-1px);
}

/* Input Area */
.ai-bot-input-container {
    border-top: 1px solid #e1e5e9;
    background: white;
    flex-shrink: 0;
}

.ai-bot-input {
    padding: 16px 20px;
    display: flex;
    gap: 12px;
    align-items: center;
}

#ai-bot-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e1e5e9;
    border-radius: 25px;
    outline: none;
    font-size: 14px;
    transition: border-color 0.2s;
    background: #f8f9fa;
}

#ai-bot-input:focus {
    border-color: #667eea;
    background: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.ai-bot-send-btn {
    background: #667eea;
    color: white;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.ai-bot-send-btn:hover {
    background: #5a6fd8;
    transform: scale(1.05);
}

.ai-bot-send-btn:active {
    transform: scale(0.95);
}

.ai-bot-disclaimer {
    padding: 8px 20px 16px;
    font-size: 11px;
    color: #6c757d;
    text-align: center;
    border-top: 1px solid #f1f3f4;
}

.ai-bot-disclaimer a {
    color: #667eea;
    text-decoration: none;
}

.ai-bot-disclaimer a:hover {
    text-decoration: underline;
}

/* 🆕 AI Suggestions Panel */
.ai-suggestions-panel {
    background: linear-gradient(135deg, #f8f9ff 0%, #f0f2ff 100%);
    border: 1px solid #e1e5e9;
    border-radius: 12px;
    padding: 16px;
    margin: 12px 0;
    animation: slideInSuggestions 0.4s ease;
}

@keyframes slideInSuggestions {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}

.ai-suggestions-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    color: #667eea;
    font-weight: 600;
    font-size: 14px;
}

.ai-suggestions-grid {
    display: grid;
    gap: 8px;
}

.ai-suggestion-item {
    background: white;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    padding: 10px 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.ai-suggestion-item:hover {
    border-color: #667eea;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.15);
}

.ai-suggestion-icon {
    color: #667eea;
    font-size: 14px;
    flex-shrink: 0;
}

/* 🆕 AI Assistant Features */
.ai-assistant-features {
    background: white;
    border-radius: 12px;
    padding: 16px;
    margin: 12px 0;
    border: 1px solid #e1e5e9;
}

.ai-feature-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.ai-feature-item {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.ai-feature-item:hover {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.ai-feature-icon {
    font-size: 20px;
    margin-bottom: 6px;
    display: block;
}

.ai-feature-text {
    font-size: 12px;
    font-weight: 500;
}

/* 🆕 Smart Form Fields */
.ai-form-suggestions {
    background: #fff9e6;
    border: 1px solid #ffe066;
    border-radius: 8px;
    padding: 12px;
    margin: 8px 0;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.ai-suggestion-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.ai-suggestion-btn {
    background: #ffe066;
    border: 1px solid #ffd43b;
    border-radius: 16px;
    padding: 4px 12px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #495057;
}

.ai-suggestion-btn:hover {
    background: #ffd43b;
    transform: translateY(-1px);
}

/* 🆕 AI-generated Content Preview */
.ai-content-preview {
    background: #e7f5ff;
    border: 1px solid #a5d8ff;
    border-radius: 8px;
    padding: 12px;
    margin: 8px 0;
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(10px); }
    to { opacity: 1; transform: translateX(0); }
}

.preview-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    color: #1971c2;
    font-weight: 600;
    font-size: 13px;
}

.preview-content {
    font-size: 13px;
    line-height: 1.4;
    color: #495057;
}

/* 🆕 AI Analysis Results */
.ai-analysis-result {
    background: linear-gradient(135deg, #e3f2fd 0%, #f3e5f5 100%);
    border: 1px solid #bbdefb;
    border-radius: 8px;
    padding: 12px;
    margin: 8px 0;
    animation: pulseGlow 2s ease-in-out;
}

@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 0 0 rgba(102, 126, 234, 0); }
    50% { box-shadow: 0 0 20px rgba(102, 126, 234, 0.3); }
}

.analysis-score {
    display: inline-block;
    background: #667eea;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    margin-left: 8px;
}

.analysis-suggestions {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #bbdefb;
}

.analysis-suggestion {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #495057;
    margin-bottom: 4px;
}

/* 🆕 Typing Indicator */
.ai-typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border-radius: 18px;
    align-self: flex-start;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    max-width: 120px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #667eea;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* 🆕 AI Message Actions */
.ai-message-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #e1e5e9;
}

.ai-action-btn {
    background: #f8f9fa;
    border: 1px solid #e1e5e9;
    border-radius: 16px;
    padding: 4px 12px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #495057;
    display: flex;
    align-items: center;
    gap: 4px;
}

.ai-action-btn:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

/* 🆕 Context-aware Suggestions */
.context-suggestions {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 8px;
    padding: 12px;
    margin: 8px 0;
}

.context-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    color: #e17055;
    font-weight: 600;
    font-size: 13px;
}

.context-items {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.context-item {
    background: #ffeaa7;
    border: 1px solid #fdcb6e;
    border-radius: 16px;
    padding: 4px 12px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.context-item:hover {
    background: #fdcb6e;
    transform: translateY(-1px);
}

/* 🆕 Popular Searches */
.popular-searches {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 12px;
    margin: 8px 0;
}

.popular-searches-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    color: #495057;
    font-weight: 600;
    font-size: 13px;
}

.search-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.search-tag {
    background: white;
    border: 1px solid #e1e5e9;
    border-radius: 16px;
    padding: 4px 10px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #495057;
}

.search-tag:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

/* 🆕 Exercise Preview */
.exercise-preview {
    background: white;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    padding: 12px;
    margin: 8px 0;
    animation: slideInUp 0.3s ease;
}

@keyframes slideInUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.preview-exercise-name {
    font-weight: 600;
    color: #495057;
    margin-bottom: 6px;
}

.preview-exercise-details {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    font-size: 12px;
    color: #6c757d;
}

.preview-detail {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* 🆕 Loading States */
.ai-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: #6c757d;
    font-size: 14px;
}

.ai-loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 8px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 🆕 Error States */
.ai-error-message {
    background: #ffe6e6;
    border: 1px solid #ffcccc;
    border-radius: 8px;
    padding: 12px;
    margin: 8px 0;
    color: #d63031;
    font-size: 13px;
    animation: shake 0.5s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* 🆕 Success States */
.ai-success-message {
    background: #e6f7e6;
    border: 1px solid #ccffcc;
    border-radius: 8px;
    padding: 12px;
    margin: 8px 0;
    color: #27ae60;
    font-size: 13px;
    animation: bounceIn 0.5s ease;
}

@keyframes bounceIn {
    0% { transform: scale(0.8); opacity: 0; }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); opacity: 1; }
}

/* Responsivitet */
@media (max-width: 768px) {
    #ai-bot-widget {
        bottom: 15px;
        right: 15px;
    }
    
    .ai-bot-button {
        width: 60px;
        height: 60px;
    }
    
    .ai-bot-icon {
        font-size: 24px;
    }
    
    .ai-bot-popup {
        width: calc(100vw - 30px);
        height: 70vh;
        right: 15px;
        bottom: 80px;
    }
    
    .ai-bot-tooltip {
        display: none;
    }
    
    .ai-feature-grid {
        grid-template-columns: 1fr;
    }
    
    .ai-suggestions-grid {
        grid-template-columns: 1fr;
    }
}

/* Scrollbar styling */
.ai-bot-messages::-webkit-scrollbar {
    width: 6px;
}

.ai-bot-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.ai-bot-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.ai-bot-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* 🆕 Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .ai-bot-popup {
        background: #1e1e1e;
        border-color: #333;
    }
    
    .ai-bot-messages {
        background: #2d2d2d;
    }
    
    .ai-message {
        background: #333;
        color: white;
    }
    
    .ai-suggestions-panel {
        background: #2a2a2a;
        border-color: #444;
    }
    
    .ai-suggestion-item {
        background: #333;
        border-color: #444;
        color: white;
    }
    
    #ai-bot-input {
        background: #333;
        border-color: #444;
        color: white;
    }
    
    #ai-bot-input:focus {
        background: #3a3a3a;
        border-color: #667eea;
    }
}

/* 🆕 High Contrast Mode */
@media (prefers-contrast: high) {
    .ai-bot-button {
        border: 2px solid #000;
    }
    
    .ai-bot-popup {
        border: 2px solid #000;
    }
    
    .ai-message {
        border: 1px solid #000;
    }
    
    .user-message {
        border: 1px solid #000;
    }
}

/* 🆕 Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .ai-bot-button,
    .ai-bot-popup,
    .ai-bot-message,
    .ai-suggestions-panel,
    .ai-content-preview,
    .ai-analysis-result,
    .exercise-preview,
    .ai-error-message,
    .ai-success-message {
        animation: none;
        transition: none;
    }
    
    .ai-bot-button:hover {
        transform: none;
    }
    
    .typing-dot {
        animation: none;
    }
}