#chatgpt-chatbox {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 350px;
    background: white;
    padding: 10px;
    border-radius: 5px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    z-index: 999999;
    transition: all 0.3s ease;
    display: flex !important;
    flex-direction: column;
    height: 500px;
    max-height: 80vh;
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateY(0) !important;
    pointer-events: auto !important;
}

/* Hidden state must override #chatgpt-chatbox (use same ID + class for specificity) */
#chatgpt-chatbox.chatbot-chatbox-hidden,
.chatbot-chatbox-hidden {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    transform: translateY(20px) !important;
}

.chatgpt-toggle-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 999998;
    display: flex !important;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s;
    background-color: #2271b1;
}

.chatgpt-toggle-button:hover {
    transform: scale(1.1);
}

.chatgpt-toggle-button svg {
    width: 24px;
    height: 24px;
    fill: white;
}

.chatgpt-toggle-button .close-icon {
    display: none;
}

.chatgpt-toggle-active {
    transform: scale(0.9);
}

#chatgpt-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex !important;
    flex-direction: column;
    gap: 10px;
    background: #f8f9fa;
    height: calc(100% - 120px);
}

#chatgpt-input-container {
    display: flex;
    gap: 10px;
    padding: 10px;
    border-top: 1px solid #eee;
    background: white;
}

#chatgpt-input {
    flex: 1;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

#chatgpt-send {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

#chatgpt-send:hover {
    transform: scale(1.1);
}

.chatgpt-header {
    position: relative;
    display: flex;
    align-items: center;
    padding: 10px;
    background-color: #232cbe;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.chatgpt-logo {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    margin-right: 10px;
}

.chatgpt-header-title {
    flex: 1;
    font-size: 16px;
    font-weight: bold;
    color: #ffffff;
}

.chatgpt-header-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chatgpt-sound-button {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: #ffffff;
    transition: color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chatgpt-sound-button:hover {
    color: #2271b1;
}

.chatgpt-sound-button.muted {
    opacity: 0.5;
}

.chatgpt-sound-button.muted:hover {
    opacity: 0.7;
}

#chatgpt-close {
    background: none;
    border: none;
    color: #ffffff;
    font-size: 18px;
    padding: 8px;
    cursor: pointer;
    transition: color 0.2s;
}

#chatgpt-close:hover {
    color: #2271b1;
}

#chatgpt-expand {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: #ffffff;
    transition: color 0.2s;
}

#chatgpt-expand:hover {
    color: #2271b1;
}

#chatgpt-expand .collapse-icon {
    display: none;
}

#chatgpt-expand svg,
#chatgpt-close svg,
.chatgpt-sound-button svg {
    width: 18px;
    height: 18px;
    vertical-align: middle;
}

/* Message Elements Styling */
.chatgpt-options-container,
.chatgpt-buttons-container,
.chatgpt-radio-container,
.chatgpt-checkboxes-container,
.chatgpt-boolean-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 10px 0;
    width: 100%;
    max-width: 100%;
}

/* Paragraph spacing */
.chatgpt-paragraph {
    margin: 0 0 8px 0;
    line-height: 1.5;
}

.chatgpt-paragraph:last-child {
    margin-bottom: 0;
}

/* Clickable Response Styling */
.chatgpt-clickable-response {
    display: inline-block;
    padding: 2px 4px;
    margin: 2px 0;
    border-radius: 4px;
    cursor: pointer;
    color: #0073aa;
    transition: all 0.2s ease;
}

.chatgpt-clickable-response:hover {
    background-color: #f0f7ff;
    text-decoration: underline;
}

.chatgpt-clickable-response.selected {
    background-color: #e6f2ff;
    color: #005177;
}

.chatgpt-option,
.chatgpt-button {
    padding: 8px 16px;
    border: 1px solid #ddd;
    border-radius: 20px;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    text-align: left;
    color: #333;
}

.chatgpt-option:hover,
.chatgpt-button:hover {
    background: #f5f5f5;
    border-color: #bbb;
}

.chatgpt-option.selected,
.chatgpt-button.selected {
    background: #e6f2ff;
    border-color: #0073aa;
    color: #0073aa;
}

.chatgpt-option.disabled,
.chatgpt-button.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chatgpt-option.disabled:not(.selected):hover,
.chatgpt-button.disabled:not(.selected):hover {
    background: white;
    border-color: #ddd;
}

.chatgpt-link {
    color: #0073aa;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.3s ease;
}

.chatgpt-link:hover {
    border-bottom-color: #0073aa;
}

/* Message spacing */
.chatgpt-message-wrapper {
    position: relative;
    margin: 12px 0;
    padding-top: 15px;
    max-width: 85%;
    animation: fadeIn 0.3s ease-out;
    display: flex;
    flex-direction: column;
}

/* Message paragraph spacing */
.chatgpt-message p {
    margin: 0 0 8px 0;
}

.chatgpt-message p:last-child {
    margin-bottom: 0;
}

/* Handle long words and URLs */
.chatgpt-message a {
    word-break: break-all;
}

/* Improve readability for code blocks */
.chatgpt-message pre,
.chatgpt-message code {
    white-space: pre-wrap;
    word-wrap: break-word;
    background: rgba(0, 0, 0, 0.05);
    padding: 8px;
    border-radius: 4px;
    margin: 8px 0;
    font-family: monospace;
    font-size: 13px;
    overflow-x: auto;
}

.chatgpt-user-message pre,
.chatgpt-user-message code {
    background: rgba(255, 255, 255, 0.1);
}

.chatgpt-message {
    padding: 12px 16px;
    border-radius: 15px;
    line-height: 1.6;
    font-size: 14px;
    word-wrap: break-word;
    word-break: break-word;
    margin: 0;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    position: relative;
    max-width: 100%;
}

.chatgpt-user-message {
    margin-left: auto;
    background: #1e3d59;
    color: #333;
    border-bottom-right-radius: 5px;
}

.chatgpt-bot-message {
    margin-right: auto;
    background: white;
    color: #333;
    border-bottom-left-radius: 5px;
}

.chatgpt-message-time {
    font-size: 11px;
    color: #666;
    margin-top: 4px;
    padding: 0 5px;
    opacity: 0.8;
}

.chatgpt-user-message + .chatgpt-message-time {
    text-align: right;
    margin-left: auto;
}

.chatgpt-bot-message + .chatgpt-message-time {
    text-align: left;
    margin-right: auto;
}

/* Message text styling */
.chatgpt-text-wrapper {
    margin: 0;
    margin-top: -15px;
    margin-bottom: -15px !important;
    white-space: pre-wrap;
    word-wrap: break-word;
    word-break: break-word;
    hyphens: auto;
}

.chatgpt-line {
    margin: 0;
    padding: 4px 0;
    line-height: 1.6;
    max-width: 100%;
}

.chatgpt-empty-line {
    height: 0.7em;
}

/* Mobile responsiveness */
@media screen and (max-width: 480px) {
    .chatgpt-message-wrapper {
        max-width: 90%;
    }

    .chatgpt-message {
        padding: 10px 14px;
        font-size: 15px;
    }

    .chatgpt-message-time {
        font-size: 10px;
    }
}

/* Ensure links are visible in both message types */
.chatgpt-user-message a {
    color: #ffffff;
    text-decoration: underline;
    opacity: 0.9;
}

.chatgpt-user-message a:hover {
    opacity: 1;
}

.chatgpt-bot-message a {
    color: #2271b1;
    text-decoration: none;
}

.chatgpt-bot-message a:hover {
    text-decoration: underline;
}

/* Common styles for interactive containers */
.chatgpt-radio-wrapper,
.chatgpt-checkbox-wrapper,
.chatgpt-boolean-wrapper {
    display: flex;
    align-items: center;
    padding: 8px;
    background: #f8f9fa;
    border: 1px solid #e1e4e8;
    border-radius: 6px;
    margin: 4px 0;
    transition: all 0.2s ease;
}

.chatgpt-radio-wrapper:hover,
.chatgpt-checkbox-wrapper:hover,
.chatgpt-boolean-wrapper:hover {
    background: #f0f4f8;
    border-color: #0073aa;
}

/* Radio and Checkbox inputs */
.chatgpt-radio,
.chatgpt-checkbox {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid #cbd5e0;
    margin: 0 8px 0 0;
    position: relative;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.chatgpt-radio {
    border-radius: 50%;
}

.chatgpt-checkbox {
    border-radius: 4px;
}

.chatgpt-radio:checked,
.chatgpt-checkbox:checked {
    border-color: #0073aa;
    background-color: #0073aa;
}

.chatgpt-radio:checked::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    background: white;
    border-radius: 50%;
}

.chatgpt-checkbox:checked::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 12px;
}

/* Labels */
.chatgpt-radio-wrapper label,
.chatgpt-checkbox-wrapper label,
.chatgpt-boolean-wrapper label {
    flex: 1;
    font-size: 14px;
    cursor: pointer;
    user-select: none;
    margin: 0;
    padding: 0 4px;
}

/* Dropdown styling */
.chatgpt-dropdown-container {
    background: white;
    border: 1px solid #e1e4e8;
    border-radius: 8px;
    padding: 8px;
    margin: 8px 0;
    width: 100%;
}

.chatgpt-dropdown {
    width: 100%;
    padding: 8px 32px 8px 12px;
    border: 1px solid #e1e4e8;
    border-radius: 6px;
    background: white;
    font-size: 14px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 16px;
    margin-bottom: 8px;
}

.chatgpt-dropdown:hover {
    border-color: #0073aa;
}

.chatgpt-dropdown:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.2);
}

/* Submit button styling */
.chatgpt-submit-selection {
    width: 100%;
    padding: 8px 12px;
    margin-top: 8px;
    background: #0073aa;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease;
}

.chatgpt-submit-selection:hover:not(:disabled) {
    background: #005a87;
}

.chatgpt-submit-selection:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Boolean specific styling */
.chatgpt-boolean-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chatgpt-boolean-wrapper {
    flex-direction: row;
    justify-content: flex-start;
}

/* Disabled state styling */
.chatgpt-radio:disabled,
.chatgpt-checkbox:disabled,
.chatgpt-dropdown:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background-color: #f5f5f5;
}

.chatgpt-radio-wrapper.disabled,
.chatgpt-checkbox-wrapper.disabled,
.chatgpt-boolean-wrapper.disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background-color: #f5f5f5;
}

/* Fix line break display */
br {
    display: block;
    margin: 8px 0;
    content: "";
    line-height: 1.5;
}

/* Message time styling */
.chatgpt-message-time {
    font-size: 12px;
    color: #666;
    margin-top: 4px;
    text-align: right;
}

.chatgpt-text-wrapper {
    margin-bottom: 8px;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.chatgpt-line {
    margin: 0;
    padding: 2px 0;
    line-height: 1.4;
}

.chatgpt-asterisk {
    color: #ff0000;
    font-weight: bold;
}

/* Sound button styling */
.chatgpt-sound-button {
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    background: transparent;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    outline: none;
}

.chatgpt-sound-button:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

.chatgpt-sound-button.muted {
    opacity: 0.5;
}

.chatgpt-sound-button.muted:hover {
    opacity: 0.7;
}

/* Remove any conflicting white-space properties */
.chatgpt-message * {
    white-space: pre-line;
}

.chatgpt-message-wrapper {
    margin: 4px 0;
}

/* Interactive Elements Container Styling */
.chatgpt-dropdown-container,
.chatgpt-radio-container,
.chatgpt-checkboxes-container {
    background: white;
    border: 1px solid #e1e4e8;
    border-radius: 8px;
    padding: 8px;
    margin: 8px 0;
    width: 100%;
}

/* Text content spacing */
.chatgpt-text-content {
    margin-bottom: 8px;
}

/* Style the expanded state */
.chatgpt-expanded {
    width: 70vw !important;
    height: 70vh !important;
    max-width: 1200px !important;
    max-height: 800px !important;
    position: fixed !important;
    transform: translate(-50%, -50%) !important;
    bottom: auto !important;
    right: auto !important;
    margin: 0 !important;
}

.chatgpt-expanded .chatgpt-messages {
    height: calc(90vh - 160px) !important;
    max-height: calc(800px - 160px) !important;
}

@media (max-width: 768px) {
    .chatgpt-expanded {
        width: 100vw !important;
        height: 100vh !important;
        max-width: none !important;
        max-height: none !important;
        border-radius: 0 !important;
    }

    .chatgpt-expanded .chatgpt-messages {
        height: calc(100vh - 160px) !important;
        max-height: none !important;
    }
}

.chatbot-input-disabled {
    background-color: #f0f0f1 !important;
    cursor: not-allowed !important;
    color: #666 !important;
    border-color: #ddd !important;
}

.chatbot-button-disabled {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
    pointer-events: none !important;
    background-color: #f0f0f1 !important;
}

#chatgpt-input-container.chatbot-disabled {
    background-color: #f8f9fa !important;
    border-top-color: #ddd !important;
}

#chatgpt-input-container.chatbot-disabled::before {
    content: 'Chat session ended';
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    background: #f0f0f1;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    color: #666;
    border: 1px solid #ddd;
}

/* Transition for expand/collapse */
.chatgpt-chatbox {
    transition: all 0.3s ease-in-out;
}

.chatbot-session-info {
    padding: 5px 10px;
    font-size: 11px;
    color: #666;
    background: rgba(0,0,0,0.05);
    border-bottom: 1px solid rgba(0,0,0,0.1);
    transition: opacity 0.3s ease, height 0.3s ease;
    overflow: hidden;
}

.chatbot-session-info.hidden {
    display: none;
    height: 0;
    padding: 0;
    border: none;
}
