/**
 * HBChat Widget CSS
 *
 * @package HBChat
 * @since 1.0.0
 */

.hbchat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    /* Ensure widget stays on top of all other content */
    isolation: isolate;
}

.hbchat-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--hbchat-button-bg);
    color: var(--hbchat-button-text);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-size: 24px;
    transition: transform 0.2s ease;
}

.hbchat-button svg {
    width: 24px;
    height: 24px;
    fill: var(--hbchat-button-icon-color, var(--hbchat-button-text));
}

.hbchat-button:hover {
    transform: scale(1.05);
    background-color: var(--hbchat-button-hover-bg);
}

.hbchat-window {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 300px;
    height: 400px;
    background: var(--hbchat-window-bg);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 999999;
}

.hbchat-header {
    background-color: var(--hbchat-header-bg);
    color: var(--hbchat-header-text);
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.hbchat-header h3 {
    margin: 0 !important;
    font-size: 16px !important;
    font-weight: 600 !important;
}

#hbchat-bot-name {
    color: var(--hbchat-header-text) !important;
}

.hbchat-close {
    background: none;
    border: none;
    color: var(--hbchat-header-text);
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hbchat-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    overflow-x: hidden;
    background-color: var(--hbchat-messages-bg);
    max-height: calc(400px - 120px); /* 400px window height minus header and input height */
    scroll-behavior: smooth;
    /* Custom scrollbar styling */
    scrollbar-width: thin;
    scrollbar-color: var(--hbchat-scrollbar-thumb) var(--hbchat-scrollbar-track);
}

/* Webkit scrollbar styling for better UX */
.hbchat-messages::-webkit-scrollbar {
    width: 6px;
}

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

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

.hbchat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--hbchat-scrollbar-thumb-hover);
}

.hbchat-message {
    margin-bottom: 12px;
    padding: 8px 12px;
    border-radius: 12px;
    max-width: 80%;
    word-wrap: break-word;
    font-size: 14px;
    line-height: 1.4;
}

.hbchat-message.user {
    background-color: var(--hbchat-user-message-bg);
    color: var(--hbchat-user-message-text);
    margin-left: auto;
    text-align: right;
}

.hbchat-message.bot {
    background-color: var(--hbchat-bot-message-bg);
    color: var(--hbchat-bot-message-text);
    border: 1px solid var(--hbchat-bot-message-border);
}

/* Typing indicator animation */
.hbchat-typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    background-color: var(--hbchat-bot-message-bg);
    border: 1px solid var(--hbchat-bot-message-border);
    border-radius: 12px;
    max-width: 80%;
    margin-bottom: 12px;
}

.hbchat-typing-dot {
    width: 6px;
    height: 6px;
    background-color: #999;
    border-radius: 50%;
    animation: hbchat-typing 1.4s infinite ease-in-out;
}

.hbchat-typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.hbchat-typing-dot:nth-child(2) {
    animation-delay: -0.16s;
}

.hbchat-typing-dot:nth-child(3) {
    animation-delay: 0s;
}

@keyframes hbchat-typing {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Link styling in chat messages */
.hbchat-message a {
    color: var(--hbchat-button-bg, #007cba);
    text-decoration: underline;
    font-weight: 500;
}

.hbchat-message a:hover {
    color: var(--hbchat-button-hover-bg, #005a87);
    text-decoration: none;
}

.hbchat-input-container {
    padding: 15px;
    background: var(--hbchat-window-bg);
    border-top: 1px solid var(--hbchat-bot-message-border);
    display: flex;
    gap: 8px;
}

.hbchat-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--hbchat-input-border);
    border-radius: 20px;
    font-size: 14px;
    outline: none;
    color: var(--hbchat-input-text);
}

.hbchat-input:focus {
    border-color: var(--hbchat-input-focus-border);
}

.hbchat-send {
    background-color: var(--hbchat-send-button-bg);
    color: var(--hbchat-send-button-text);
    border: none;
    padding: 8px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.hbchat-send svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.hbchat-send:hover {
    background-color: var(--hbchat-send-button-hover-bg);
    transform: scale(1.05);
}

/* Responsive design */
@media (max-width: 768px) {
    .hbchat-widget {
        bottom: 10px;
        right: 10px;
    }
    
    .hbchat-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        bottom: 80px;
        right: 10px;
        left: 10px;
        max-width: 350px;
        margin: 0 auto;
    }
    
    .hbchat-messages {
        max-height: calc(100vh - 200px);
    }
}

@media (max-width: 480px) {
    .hbchat-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 80px);
        bottom: 70px;
    }
    
    .hbchat-messages {
        max-height: calc(100vh - 180px);
    }
}

/* Action Buttons Styles */
.hbchat-actions {
    margin: 15px 0;
    padding: 0;
}

.hbchat-actions-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 5px;
    margin: 0;
}

.hbchat-action-button {
    background-color: var(--hbchat-send-button-bg);
    color: var(--hbchat-send-button-text);
    border: none;
    padding: 5px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    text-align: left;
    transition: all 0.2s ease;
    word-wrap: break-word;
    min-height: 30px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
}

.hbchat-action-button .hbchat-arrow-icon {
    width: 12px;
    height: 12px;
    fill: currentColor;
    flex-shrink: 0;
}

.hbchat-action-button .hbchat-arrow-icon svg {
    width: 100%;
    height: 100%;
    fill: currentColor;
}

.hbchat-action-button:hover {
    background-color: var(--hbchat-send-button-hover-bg);
    transform: translateY(-1px);
}

.hbchat-action-button:active {
    transform: translateY(0);
}

/* Action Form Styles */
.hbchat-action-form {
    background: var(--hbchat-bot-message-bg);
    border: 1px solid var(--hbchat-bot-message-border);
    border-radius: 12px;
    margin: 15px 0;
    overflow: hidden;
}

.hbchat-form-header {
    background: var(--hbchat-header-bg);
    color: var(--hbchat-header-text);
    padding: 12px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.hbchat-form-header h4 {
    margin: 0;
    font-size: 14px !important;
    font-weight: 600 !important;
    color: var(--hbchat-header-text) !important;
}

.hbchat-form-close {
    background: none;
    border: none;
    color: var(--hbchat-header-text);
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hbchat-form-fields {
    padding: 15px;
}

.hbchat-form-field {
    margin-bottom: 15px;
}

.hbchat-form-field:last-child {
    margin-bottom: 0;
}

.hbchat-form-field label {
    display: block;
    margin-bottom: 5px;
    font-size: 13px;
    font-weight: 500;
    color: var(--hbchat-bot-message-text);
}

.hbchat-form-field input,
.hbchat-form-field textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--hbchat-input-border);
    border-radius: 6px;
    font-size: 14px;
    color: var(--hbchat-input-text);
    background: var(--hbchat-window-bg);
    outline: none;
    box-sizing: border-box;
}

.hbchat-form-field input:focus,
.hbchat-form-field textarea:focus {
    border-color: var(--hbchat-input-focus-border);
}

.hbchat-form-field textarea {
    resize: vertical;
    min-height: 60px;
}

.hbchat-form-actions {
    padding: 12px 15px;
    background: var(--hbchat-messages-bg);
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.hbchat-form-submit,
.hbchat-form-cancel {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.hbchat-form-submit {
    background-color: var(--hbchat-send-button-bg);
    color: var(--hbchat-send-button-text);
}

.hbchat-form-submit:hover {
    background-color: var(--hbchat-send-button-hover-bg);
}

.hbchat-form-submit.loading {
    background-color: var(--hbchat-send-button-bg);
    opacity: 0.7;
    cursor: not-allowed;
    pointer-events: none;
}

.hbchat-form-submit.loading .hbchat-form-submit-text {
    display: none;
}

.hbchat-form-submit.loading .hbchat-form-submit-spinner {
    display: inline-block;
}

.hbchat-form-submit-spinner {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: hbchat-form-spin 1s linear infinite;
}

@keyframes hbchat-form-spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

.hbchat-form-cancel {
    background-color: transparent;
    color: var(--hbchat-bot-message-text);
    border: 1px solid var(--hbchat-input-border);
}

.hbchat-form-cancel:hover {
    background-color: var(--hbchat-input-border);
}

.hbchat-form-cancel:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Mobile responsive for actions */
@media (max-width: 768px) {
    .hbchat-actions-grid {
        grid-template-columns: 1fr;
        gap: 6px;
    }
    
    .hbchat-action-button {
        font-size: 14px;
        padding: 12px;
        min-height: 44px;
    }
    
    .hbchat-form-fields {
        padding: 12px;
    }
    
    .hbchat-form-actions {
        padding: 10px 12px;
        flex-direction: column;
    }
    
    .hbchat-form-submit,
    .hbchat-form-cancel {
        width: 100%;
        padding: 10px;
    }
}
