/* BOSSco Widget Frame Styles */

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --bg: #ffffff;
    --bg-secondary: #f8fafc;
    --text: #1e293b;
    --text-secondary: #475569;     /* AAA 7.5:1 on white */
    --border: #e2e8f0;
    --shadow: rgba(0, 0, 0, 0.08);
    --radius: 12px;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --user-bubble-bg: var(--primary);
    --user-bubble-text: #ffffff;
    --assistant-bubble-bg: var(--bg-secondary);
    --assistant-bubble-text: var(--text);
}

/* Dark theme */
.theme-dark {
    --primary: #3b82f6;
    --primary-hover: #60a5fa;
    --bg: #1e293b;
    --bg-secondary: #0f172a;
    --text: #f1f5f9;
    --text-secondary: #b8c5d3;     /* AAA 8.5:1 on #1e293b */
    --border: #334155;
    --shadow: rgba(0, 0, 0, 0.3);
}

html, body {
    height: 100%;
    overflow: hidden;
    font-family: var(--font);
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

/* Screen reader only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* Layout */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Header */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--primary);
    color: #fff;
    flex-shrink: 0;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.chat-logo {
    height: 28px;
    width: auto;
    max-width: 120px;
    object-fit: contain;
    flex-shrink: 0;
}

.chat-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.close-btn {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: background 0.15s;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.close-btn:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.welcome-message {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 16px;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.5;
}

.message {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: var(--radius);
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: none;
    display: flex;
    flex-direction: column;
}

.message-sender {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.03em;
    margin-bottom: 2px;
    opacity: 0.7;
}

.message-content {
    display: block;
    hyphens: none;
    overflow-wrap: break-word;
    word-break: break-word;
}

.message-user {
    align-self: flex-end;
    background: var(--user-bubble-bg);
    color: var(--user-bubble-text);
    border-bottom-right-radius: 4px;
}

.message-assistant {
    align-self: flex-start;
    background: var(--assistant-bubble-bg);
    color: var(--assistant-bubble-text);
    border-bottom-left-radius: 4px;
}

.message-typing {
    align-self: flex-start;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-style: italic;
}

/* Input */
.chat-input-area {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    background: var(--bg);
    flex-shrink: 0;
}

.chat-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

.chat-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 24px;
    font-family: var(--font);
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    outline: none;
    transition: border-color 0.15s;
    min-height: 44px;
}

.chat-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 15%, transparent);
}

.chat-input::placeholder {
    color: var(--text-secondary);
}

.send-btn {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    flex-shrink: 0;
}

.send-btn:hover {
    background: var(--primary-hover);
}

.send-btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Powered by */
.powered-by {
    text-align: center;
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 8px;
}

.powered-by strong {
    color: var(--primary);
}

/* Scrollbar */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Preview badge */
.preview-badge {
    position: absolute;
    top: 52px;
    right: 8px;
    background: #f59e0b;
    color: #451a03;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    padding: 2px 8px;
    border-radius: 4px;
    z-index: 10;
    pointer-events: none;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
    }
}
