:root {
    --primary-color: #007bff;
    --primary-hover: #0056b3;
    --background-color: #f4f7f6;
    --container-bg: #ffffff;
    --border-color: #e0e0e0;
    --bot-message-bg: #e2e6ea;
    --user-message-bg: var(--primary-color);
    /* Agent (live human) message styling - warm brown/orange */
    --agent-message-bg: #fff4e6; /* light orange-cream */
    --agent-text-color: #7c2d12; /* deep brown */
    --bot-text-color: #333;
    --user-text-color: white;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--background-color);
    margin: 0;
    padding: 0;
}

/* Main Website Content - embeds company-cite.html */
.main-content {
    padding: 0;
    margin: 0;
    width: 100%;
    min-height: 100vh;
}

.company-website-iframe {
    display: block;
    width: 100%;
    min-height: 100vh;
    border: none;
    vertical-align: top;
}

/* Floating Widget Button */
.chat-widget-button {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    background-color: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    z-index: 1000;
    transition: transform 0.2s ease-in-out;
}

.chat-widget-button:hover {
    transform: scale(1.1);
}

/* Chat Container */
.chat-container {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 380px;
    height: 500px; /* Fixed height */
    background-color: var(--container-bg);
    border-radius: 12px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    padding: 20px;
    box-sizing: border-box;
    z-index: 999;
    transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out, visibility 0.3s;
    transform: scale(0.95);
    opacity: 0;
    visibility: hidden;
}

.chat-container.chat-container-open {
    visibility: visible;
    transform: scale(1);
    opacity: 1;
    pointer-events: auto;
}

.chat-container.chat-container-closed {
    visibility: hidden;
    transform: scale(0.95);
    opacity: 0;
    pointer-events: none; /* don't block the floating button when closed */
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.agent-status {
    margin-top: 4px;
}

.agent-status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(0, 123, 255, 0.08);
    color: #555;
    font-size: 0.78em;
    font-weight: 500;
}

.agent-status-icon {
    font-size: 0.9em;
    color: var(--primary-color);
}

.status-dot {
    display: none; /* Simplified: hide blinking status dot */
}

@keyframes status-pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    70% {
        transform: scale(1.4);
        opacity: 0;
    }
    100% {
        transform: scale(1.4);
        opacity: 0;
    }
}

.agent-status-label {
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 0.7em;
    color: #6b7280;
}

.agent-status-name {
    font-weight: 600;
    color: var(--primary-color);
}

.chat-header h3 {
    font-size: 1.2em;
    color: #333;
    margin: 0;
}

.close-button {
    background: none;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    color: #666;
}

.chat-history {
    flex-grow: 1;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 10px;
    background-color: #fbfbfb;
    display: flex;
    flex-direction: column;
    gap: 10px;
    height: 350px; /* Fixed height for chat history */
}

/* Message Bubbles */
.message {
    padding: 10px 15px;
    border-radius: 18px;
    max-width: 80%;
    word-wrap: break-word;
    font-size: 0.9em;
    line-height: 1.4;
}

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

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

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

/* Assistant message wrapper: message + feedback */
.assistant-message-wrapper {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    max-width: 80%;
}

.assistant-message-wrapper .message {
    margin: 0;
}

/* Was this helpful? feedback (Home Depot style) */
.message-feedback {
    font-size: 0.8em;
    color: #6b7280;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding-left: 8px; /* nudge right from bubble left edge */
}

.message-feedback .feedback-prompt {
    margin-right: 4px;
}

.message-feedback .feedback-buttons {
    display: inline-flex;
    gap: 4px;
}

.message-feedback .feedback-btn {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    padding: 5px 16px;
    min-width: 2.5em;
    cursor: pointer;
    font-size: 1em;
    transition: background-color 0.15s, border-color 0.15s;
}

.message-feedback .feedback-btn:hover {
    background: #f4f7f6;
    border-color: #ccc;
}

.message-feedback .feedback-btn-yes:hover {
    background: #dcfce7;
    border-color: #22c55e;
}

.message-feedback .feedback-btn-no:hover {
    background: #fee2e2;
    border-color: #ef4444;
}

.message-feedback .feedback-btn:active {
    background: #e8ecef;
}

.message-feedback .feedback-comment-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    margin-top: 2px;
}

.message-feedback .feedback-comment-input {
    flex: 1;
    min-width: 0;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.9em;
    outline: none;
}

.message-feedback .feedback-comment-input:focus {
    border-color: var(--primary-color);
}

.message-feedback .feedback-comment-submit {
    padding: 6px 12px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.85em;
    cursor: pointer;
    white-space: nowrap;
}

.message-feedback .feedback-comment-submit:hover {
    background: var(--primary-hover);
}

.message-feedback .feedback-thanks {
    color: #059669;
    font-weight: 500;
}

/* Chat Input Area */
.chat-input-area {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

#user-input {
    flex-grow: 1;
    padding: 10px 15px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 0.9em;
    outline: none;
    transition: border-color 0.2s;
}

#user-input:focus {
    border-color: var(--primary-color);
}

#send-button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 20px;
    padding: 10px 20px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background-color 0.2s;
}

#send-button:hover {
    background-color: var(--primary-hover);
}

#send-button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

.loading-indicator {
    text-align: center;
    margin-top: 10px;
    color: #666;
    font-style: italic;
    font-size: 0.85em;
}

/* Responsive adjustments */
@media (max-width: 500px) {
    .chat-container {
        width: 90%;
        bottom: 20px;
        right: 5%;
        max-height: 70vh;
    }
    .chat-widget-button {
        bottom: 20px;
        right: 20px;
    }
}