/**
 * PraiseCue AI Chat Widget Styles
 * Shared styles for website and desktop app
 */

/* CSS Variables */
:root {
    /* Color variables */
    --chat-primary: #4A90E2;
    --chat-primary-hover: #357ABD;
    --chat-success: #4CAF50;
    --chat-warning: #FF9800;
    --chat-error: #F44336;
    --chat-bg: #FFFFFF;
    --chat-bg-secondary: #F5F7FA;
    --chat-border: #E1E4E8;
    --chat-text: #24292E;
    --chat-text-secondary: #586069;
    --chat-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    --chat-radius: 8px;

    /* Positioning variables */
    --chat-btn-size: 60px;
    --chat-btn-bottom: 20px;
    --chat-btn-right: 20px;
    --chat-modal-width: 400px;
    --chat-modal-height: 600px;
    --chat-modal-bottom: 90px;
    --chat-modal-right: 20px;
    --chat-z-index-btn: 9999;
    --chat-z-index-modal: 10000;
}

/* Dark mode disabled - always use light theme to match website */
@media (prefers-color-scheme: dark) {
    :root {
        /* Override with light theme colors */
        --chat-bg: #FFFFFF;
        --chat-bg-secondary: #F5F7FA;
        --chat-border: #E1E4E8;
        --chat-text: #2d3748;
        --chat-text-secondary: #586069;
    }
}

/* Reset - Scoped to chat widget elements only */
.chat-modal *,
.chat-float-btn * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Note: Body styles removed as they should only apply in desktop app mode (separate window) */

/* Floating Chat Button (website only) */
.chat-float-btn {
    position: fixed !important;
    bottom: var(--chat-btn-bottom) !important;
    right: var(--chat-btn-right) !important;
    left: auto !important;
    top: auto !important;
    width: var(--chat-btn-size);
    height: var(--chat-btn-size);
    background: linear-gradient(135deg, #4A90E2, #357ABD);
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.3),
                0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: var(--chat-z-index-btn) !important;
    color: white;
}

.chat-float-btn:hover {
    background: linear-gradient(135deg, #357ABD, #2868A6);
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(74, 144, 226, 0.4),
                0 4px 8px rgba(0, 0, 0, 0.15);
}

.chat-float-btn:active {
    transform: scale(0.95);
}

.chat-float-btn.hidden {
    display: none;
}

/* Chat Modal */
.chat-modal {
    position: fixed !important;
    bottom: var(--chat-modal-bottom) !important;
    right: var(--chat-modal-right) !important;
    left: auto !important;
    top: auto !important;
    width: var(--chat-modal-width);
    max-width: calc(100vw - 40px);
    height: var(--chat-modal-height);
    max-height: calc(100vh - 120px);
    background: #FFFFFF;
    border-radius: var(--chat-radius);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12),
                0 2px 8px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    z-index: var(--chat-z-index-modal) !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: slideInFromBottom 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: 'Georgia', serif;
}

.chat-modal.hidden {
    display: none;
}

@keyframes slideInFromBottom {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Desktop app: fullscreen modal (NO shadows or borders) */
.chat-modal.desktop-mode {
    position: relative;
    top: auto;
    left: auto;
    transform: none;
    bottom: auto;
    right: auto;
    width: 100%;
    height: 100%;
    box-shadow: none;
    border: none;
    border-radius: 0;
}

/* Chat Container */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Chat Header */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--chat-primary);
    color: white;
    border-radius: var(--chat-radius) var(--chat-radius) 0 0;
}

/* Desktop mode: Override header background (we have separate titlebar) */
.chat-modal.desktop-mode .chat-header {
    background: #f8f9fa;
    color: var(--chat-text);
    padding: 8px 16px;
    border-radius: 0;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-icon {
    flex-shrink: 0;
    color: white;
}

.header-text h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

.header-subtitle {
    font-size: 12px;
    opacity: 0.9;
    margin: 0;
}

.close-btn {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Loading State */
.chat-loading {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

.chat-loading.hidden {
    display: none;
}

.loading-content {
    text-align: center;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--chat-border);
    border-top-color: var(--chat-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 8px;
}

.loading-subtext {
    font-size: 13px;
    color: var(--chat-text-secondary);
    margin-bottom: 20px;
}

.loading-progress {
    display: flex;
    align-items: center;
    gap: 12px;
}

.progress-bar {
    flex: 1;
    height: 6px;
    background: var(--chat-bg-secondary);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--chat-primary);
    width: 0%;
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 12px;
    font-weight: 500;
    min-width: 40px;
    text-align: right;
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
    padding: 20px;
    background: var(--chat-bg-secondary);
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--chat-border);
    border-radius: 3px;
}

/* Message */
.message {
    margin-bottom: 16px;
    animation: messageSlideIn 0.3s ease;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* User Message */
.user-message {
    display: flex;
    justify-content: flex-end;
    align-self: flex-end;
}

.user-message .message-content {
    background: var(--chat-primary);
    color: white;
    padding: 10px 14px;
    border-radius: var(--chat-radius);
    max-width: 80%;
}

/* AI Message */
.ai-message {
    display: flex;
    gap: 10px;
    align-self: flex-start;
}

.message-avatar {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    background: var(--chat-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.ai-message .message-content {
    flex: 1;
    background: #FFFFFF;
    color: #2d3748;
    padding: 12px 16px;
    border-radius: var(--chat-radius);
    border: 1px solid var(--chat-border);
}

/* AI Response Styles */
.ai-response {
    font-size: 14px;
    line-height: 1.6;
}

.ai-response p {
    margin: 0 0 12px 0;
}

.ai-response p:last-child {
    margin-bottom: 0;
}

.ai-response ul, .ai-response ol {
    margin: 8px 0;
    padding-left: 20px;
}

.ai-response li {
    margin-bottom: 4px;
}

.ai-response code {
    background: var(--chat-bg-secondary);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 13px;
}

.ai-response a {
    color: var(--chat-primary);
    text-decoration: none;
}

.ai-response a:hover {
    text-decoration: underline;
}

/* Confidence Badges */
.confidence-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 12px;
}

.confidence-badge.high {
    background: rgba(76, 175, 80, 0.1);
    color: var(--chat-success);
}

.confidence-badge.medium {
    background: rgba(255, 152, 0, 0.1);
    color: var(--chat-warning);
}

.confidence-badge.low {
    background: rgba(244, 67, 54, 0.1);
    color: var(--chat-error);
}

/* Disclaimer */
.disclaimer {
    background: rgba(255, 152, 0, 0.1);
    border-left: 3px solid var(--chat-warning);
    padding: 10px 12px;
    margin: 12px 0;
    font-size: 13px;
}

/* Response Footer */
.response-footer {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--chat-border);
}

.response-actions {
    margin-bottom: 10px;
}

.btn-link {
    display: inline-block;
    color: var(--chat-primary);
    text-decoration: none;
    font-size: 13px;
    padding: 6px 12px;
    border-radius: 4px;
    background: rgba(74, 144, 226, 0.1);
    transition: background 0.2s;
}

.btn-link:hover {
    background: rgba(74, 144, 226, 0.2);
}

/* Feedback */
.feedback {
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.feedback-btn {
    background: transparent;
    border: 1px solid var(--chat-border);
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.feedback-btn:hover {
    background: var(--chat-bg-secondary);
    border-color: var(--chat-primary);
}

.feedback-btn.selected {
    background: var(--chat-primary);
    color: white;
    border-color: var(--chat-primary);
}

/* Quick Questions */
.quick-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.quick-question {
    background: #FFFFFF;
    border: 1px solid #E1E4E8;
    color: #2d3748;
    padding: 12px 16px;
    border-radius: 6px;
    text-align: left;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.quick-question:hover {
    background: #4A90E2;
    color: #FFFFFF;
    border-color: #4A90E2;
}

/* Topics List */
.topics-list {
    column-count: 2;
    column-gap: 16px;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: var(--chat-bg-secondary);
    font-size: 13px;
    color: #2d3748;
}

.typing-indicator.hidden {
    display: none;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: #4A90E2;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* Chat Input */
.chat-input-container {
    padding: 16px 20px;
    background: var(--chat-bg);
    border-top: 1px solid var(--chat-border);
}

.chat-input-wrapper {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.chat-input {
    flex: 1;
    border: 1px solid var(--chat-border);
    border-radius: 6px;
    padding: 10px 12px;
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: 14px;
    resize: none;
    max-height: 120px;
    background: #FFFFFF;
    color: #2d3748;
}

.chat-input::placeholder {
    color: #9CA3AF;
}

.chat-input:focus {
    outline: none;
    border-color: var(--chat-primary);
}

.send-btn {
    background: var(--chat-primary);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.send-btn:hover:not(:disabled) {
    background: var(--chat-primary-hover);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.input-footer {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 11px;
    color: var(--chat-text-secondary);
}

/* Chat Footer */
.chat-footer {
    padding: 12px 20px;
    background: var(--chat-bg-secondary);
    border-top: 1px solid var(--chat-border);
    font-size: 12px;
    color: var(--chat-text-secondary);
}

.chat-footer a {
    color: var(--chat-primary);
    text-decoration: none;
}

.chat-footer a:hover {
    text-decoration: underline;
}

/* Responsive Design */
@media (max-width: 480px) {
    .chat-float-btn {
        width: 56px;
        height: 56px;
        bottom: 16px !important;
        right: 16px !important;
    }

    .chat-modal {
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100%;
        bottom: 0 !important;
        right: 0 !important;
        left: 0 !important;
        top: 0 !important;
        border-radius: 0;
    }

    .chat-header {
        border-radius: 0;
    }

    .topics-list {
        column-count: 1;
    }
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.mt-2 {
    margin-top: 8px;
}

.mb-2 {
    margin-bottom: 8px;
}
