/**
 * SignalPilot Documentation Chatbot Styles
 * Modern, Material Design-inspired chat interface
 */

/* Container & Positioning */
.sp-chatbot-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Toggle Button */
.sp-chatbot-toggle {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #29B6F6 0%, #0288D1 100%);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(41, 182, 246, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.sp-chatbot-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(41, 182, 246, 0.6);
}

.sp-chatbot-toggle:active {
    transform: scale(0.95);
}

.sp-chatbot-icon,
.sp-chatbot-close-icon {
    width: 32px; /* Bigger icon for better visibility */
    height: 32px;
    transition: all 0.3s ease;
}

.sp-chatbot-closed .sp-chatbot-close-icon {
    opacity: 0;
    transform: rotate(-90deg) scale(0);
    position: absolute;
}

.sp-chatbot-closed .sp-chatbot-icon {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

.sp-chatbot-open .sp-chatbot-icon {
    opacity: 0;
    transform: rotate(90deg) scale(0);
    position: absolute;
}

.sp-chatbot-open .sp-chatbot-close-icon {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

/* Badge for unread messages */
.sp-chatbot-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4757;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    border: 2px solid white;
}

/* Chat Window */
.sp-chatbot-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 400px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 120px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: scale(0.9) translateY(20px);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sp-chatbot-open .sp-chatbot-window {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: all;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .sp-chatbot-window {
        background: #1e1e2e;
        color: #e0e0e0;
    }
}

/* Header */
.sp-chatbot-header {
    background: linear-gradient(135deg, #29B6F6 0%, #0288D1 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.sp-chatbot-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

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

.sp-chatbot-avatar svg {
    width: 24px;
    height: 24px;
}

.sp-chatbot-title h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.sp-chatbot-status {
    margin: 2px 0 0;
    font-size: 14px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
}

.sp-chatbot-status::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    display: inline-block;
    animation: pulse 2s ease-in-out infinite;
}

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

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

.sp-chatbot-action-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.sp-chatbot-action-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.sp-chatbot-action-btn svg {
    width: 18px;
    height: 18px;
}

/* Messages Container */
.sp-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

/* Custom scrollbar */
.sp-chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

.sp-chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

.sp-chatbot-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.sp-chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

@media (prefers-color-scheme: dark) {
    .sp-chatbot-messages::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.2);
    }

    .sp-chatbot-messages::-webkit-scrollbar-thumb:hover {
        background: rgba(255, 255, 255, 0.3);
    }
}

/* Messages */
.sp-chatbot-message {
    display: flex;
    gap: 10px;
    animation: messageSlideIn 0.3s ease;
}

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

.sp-chatbot-user-message {
    justify-content: flex-end;
}

.sp-chatbot-message-avatar {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #29B6F6 0%, #0288D1 100%);
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.sp-chatbot-message-avatar svg {
    width: 18px;
    height: 18px;
}

.sp-chatbot-message-content {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.6;
    font-size: 16px;
}

.sp-chatbot-bot-message .sp-chatbot-message-content {
    background: #f3f4f6;
    border-bottom-left-radius: 4px;
}

.sp-chatbot-user-message .sp-chatbot-message-content {
    background: linear-gradient(135deg, #29B6F6 0%, #0288D1 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

@media (prefers-color-scheme: dark) {
    .sp-chatbot-bot-message .sp-chatbot-message-content {
        background: #2a2a3e;
        color: #e0e0e0;
    }
}

.sp-chatbot-message-content p {
    margin: 0 0 8px;
}

.sp-chatbot-message-content p:last-child {
    margin-bottom: 0;
}

.sp-chatbot-message-content ul {
    margin: 8px 0;
    padding-left: 20px;
}

.sp-chatbot-message-content li {
    margin: 4px 0;
}

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

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

.sp-chatbot-message-content a {
    color: #29B6F6;
    text-decoration: underline;
}

.sp-chatbot-user-message .sp-chatbot-message-content a {
    color: white;
}

/* Error message */
.sp-chatbot-error .sp-chatbot-message-content {
    background: #fee;
    border-left: 3px solid #f44;
    color: #c33;
}

@media (prefers-color-scheme: dark) {
    .sp-chatbot-error .sp-chatbot-message-content {
        background: #3a2222;
        color: #ff6b6b;
    }
}

/* Typing Indicator */
.sp-chatbot-typing-indicator {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}

.sp-chatbot-typing-indicator span {
    width: 8px;
    height: 8px;
    background: #29B6F6;
    border-radius: 50%;
    animation: typing 1.4s ease-in-out infinite;
}

.sp-chatbot-typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.sp-chatbot-typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Quick Actions */
.sp-chatbot-quick-actions {
    padding: 0 20px 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.sp-chatbot-quick-btn {
    background: white;
    border: 1px solid #e5e7eb;
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #374151;
}

.sp-chatbot-quick-btn:hover {
    background: #f9fafb;
    border-color: #29B6F6;
    color: #29B6F6;
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(41, 182, 246, 0.2);
}

@media (prefers-color-scheme: dark) {
    .sp-chatbot-quick-btn {
        background: #2a2a3e;
        border-color: #3a3a4e;
        color: #e0e0e0;
    }

    .sp-chatbot-quick-btn:hover {
        background: #3a3a4e;
        border-color: #29B6F6;
    }
}

/* Input Container */
.sp-chatbot-input-container {
    border-top: 1px solid #e5e7eb;
    background: white;
    flex-shrink: 0;
}

@media (prefers-color-scheme: dark) {
    .sp-chatbot-input-container {
        background: #2a2a3e;
        border-top-color: #3a3a4e;
    }
}

.sp-chatbot-input-wrapper {
    display: flex;
    align-items: flex-end;
    padding: 16px;
    gap: 10px;
}

.sp-chatbot-input {
    flex: 1;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 16px;
    font-family: inherit;
    resize: none;
    min-height: 44px;
    max-height: 120px;
    transition: border-color 0.2s ease;
}

.sp-chatbot-input:focus {
    outline: none;
    border-color: #29B6F6;
}

@media (prefers-color-scheme: dark) {
    .sp-chatbot-input {
        background: #1e1e2e;
        border-color: #3a3a4e;
        color: #e0e0e0;
    }

    .sp-chatbot-input:focus {
        border-color: #29B6F6;
    }
}

.sp-chatbot-send-btn {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #29B6F6 0%, #0288D1 100%);
    border: none;
    border-radius: 12px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.sp-chatbot-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(41, 182, 246, 0.4);
}

.sp-chatbot-send-btn:active {
    transform: scale(0.95);
}

.sp-chatbot-send-btn svg {
    width: 20px;
    height: 20px;
}

.sp-chatbot-footer-text {
    padding: 0 16px 12px;
    font-size: 13px;
    color: #9ca3af;
    text-align: center;
}

/* Settings Panel */
.sp-chatbot-settings-panel {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: white;
    z-index: 10;
    display: flex;
    flex-direction: column;
}

@media (prefers-color-scheme: dark) {
    .sp-chatbot-settings-panel {
        background: #1e1e2e;
    }
}

.sp-chatbot-settings-header {
    background: linear-gradient(135deg, #29B6F6 0%, #0288D1 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sp-chatbot-settings-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.sp-chatbot-close-settings {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
    transition: background 0.2s ease;
}

.sp-chatbot-close-settings:hover {
    background: rgba(255, 255, 255, 0.3);
}

.sp-chatbot-settings-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.sp-chatbot-setting-group {
    margin-bottom: 20px;
}

.sp-chatbot-setting-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 14px;
    color: #374151;
}

@media (prefers-color-scheme: dark) {
    .sp-chatbot-setting-group label {
        color: #e0e0e0;
    }
}

.sp-chatbot-setting-group input,
.sp-chatbot-setting-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
}

.sp-chatbot-setting-group input:focus,
.sp-chatbot-setting-group select:focus {
    outline: none;
    border-color: #29B6F6;
}

@media (prefers-color-scheme: dark) {
    .sp-chatbot-setting-group input,
    .sp-chatbot-setting-group select {
        background: #2a2a3e;
        border-color: #3a3a4e;
        color: #e0e0e0;
    }
}

.sp-chatbot-setting-group small {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: #6b7280;
}

.sp-chatbot-save-settings {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #29B6F6 0%, #0288D1 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sp-chatbot-save-settings:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(41, 182, 246, 0.4);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .sp-chatbot-container {
        bottom: 16px;
        right: 16px;
    }

    .sp-chatbot-window {
        width: 320px;
        max-width: calc(100vw - 32px);
        height: 420px;
        max-height: 55vh;
        bottom: 76px;
        right: 0;
    }

    /* Force mobile chatbot text size */
    .sp-chatbot-message-content,
    .sp-chatbot-message-content *,
    .sp-chatbot-bot-message .sp-chatbot-message-content,
    .sp-chatbot-bot-message .sp-chatbot-message-content * {
        font-size: 14px !important;
    }

    .sp-chatbot-message-content {
        max-width: 85% !important;
        padding: 8px 10px !important;
        line-height: 1.4 !important;
    }

    .sp-chatbot-message-content p {
        margin: 0 0 6px !important;
    }

    .sp-chatbot-message-content p:last-child {
        margin-bottom: 0 !important;
    }

    .sp-chatbot-header {
        padding: 10px 14px;
    }

    .sp-chatbot-title h3 {
        font-size: 11px;
    }

    .sp-chatbot-status {
        font-size: 9px;
    }

    .sp-chatbot-messages {
        padding: 14px 10px;
    }

    .sp-chatbot-input-wrapper {
        padding: 10px;
    }

    .sp-chatbot-input {
        font-size: 16px;
        padding: 8px 10px;
    }

    .sp-chatbot-quick-btn {
        font-size: 9px;
        padding: 5px 8px;
    }

    .sp-chatbot-toggle {
        width: 56px;
        height: 56px;
    }
}

/* Landscape mobile optimizations */
@media (max-width: 896px) and (orientation: landscape) {
    .sp-chatbot-window {
        width: 340px;
        max-width: 45vw;
        height: 360px;
        max-height: 75vh;
    }

    .sp-chatbot-messages {
        padding: 12px;
    }

    .sp-chatbot-header {
        padding: 8px 12px;
    }

    .sp-chatbot-input-wrapper {
        padding: 8px;
    }
}

/* Accessibility */
.sp-chatbot-toggle:focus,
.sp-chatbot-send-btn:focus,
.sp-chatbot-action-btn:focus,
.sp-chatbot-quick-btn:focus {
    outline: 2px solid #29B6F6;
    outline-offset: 2px;
}

/* Print */
@media print {
    .sp-chatbot-container {
        display: none;
    }
}
