
/* --- Live Chat Specific Styles --- */
#liveChatBtn {
    position: fixed;
    bottom: 20px;
    right: 30px;
    background-color: var(--accent-color-green); /* Professional green */
    color: white;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: none; /* Initially hidden, shown by JS on scroll */
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    cursor: pointer;
    z-index: 1045;
    border: none;
    transition: background-color 0.3s, transform 0.2s ease-out, opacity 0.3s;
}
#liveChatBtn:hover {
    background-color: #388E3C; /* Darker green */
    transform: scale(1.1);
}
#liveChatBtn .fa-comments {
    line-height: 1;
}
#liveChatBtn .badge-notification {
    position: absolute;
    top: -5px;
    right: -5px;
    padding: 0.3em 0.6em;
    font-size: 0.75rem;
    font-weight: bold;
    line-height: 1;
    background-color: #dc3545;
    color: white;
    border-radius: 50%;
    border: 2px solid white;
    min-width: 20px;
    text-align: center;
}


/* Chat Modal Container - General Structure for User Chat & Purchase Modal */
.chat-modal-container, #purchaseModal .modal-dialog .modal-content {
    display: flex;
    flex-direction: column;
    background: var(--card-bg-light);
    border: 1px solid var(--border-color-light);
    border-radius: 10px; /* Consistent border radius */
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    overflow: hidden; /* Crucial for internal scrolling */
    box-sizing: border-box;
}

/* Specific for user's floating chat modal */
.chat-modal-container {
    position: fixed;
    bottom: 20px;
    right: 30px;
    width: 370px;
    height: 480px; /* Default height */
    max-height: calc(100vh - 90px); /* Max height relative to viewport, leaves space for chat button */
    z-index: 1050;
    display: none; /* Controlled by JS */
}
.chat-modal-container.show {
    display: flex !important;
}

/* Purchase Modal Adjustments */
#purchaseModal .modal-dialog {
    max-width: 500px; /* Standard modal width */
    margin: 1.75rem auto;
}

#purchaseModal .modal-content {
    height: auto; /* Let content determine height initially */
    max-height: 85vh; /* Max height for the modal */
    display: flex;
    flex-direction: column;
}

#purchaseModal .modal-header {
    background-color: var(--primary-color);
    color: var(--text-light);
    padding: 0.75rem 1.25rem; /* Slightly reduced padding */
    flex-shrink: 0;
}
#purchaseModal .modal-header .modal-title {
    font-size: 1.1rem;
    font-weight: 500;
}
#purchaseModal .modal-header .close {
    color: var(--text-light);
    opacity: 0.9;
    text-shadow: none;
}

#purchaseModal .modal-body {
    padding: 1rem 1.25rem;
    overflow-y: auto; /* Make only the body scroll if content exceeds max-height */
    flex-grow: 1;
    background-color: #f9f9f9;
}

#purchaseModal .modal-body p, #purchaseModal .modal-body label {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}
#purchaseModal .modal-body strong {
    color: var(--primary-color);
}
#purchaseModal .modal-body hr {
    margin-top: 0.75rem;
    margin-bottom: 0.75rem;
}
#purchaseModal .form-group {
    margin-bottom: 0.75rem;
}
#purchaseModal .form-control-sm {
    font-size: 0.85rem;
    padding: .25rem .5rem;
    height: calc(1.5em + .5rem + 2px);
}
#purchaseModal .form-check-label {
    font-size: 0.875rem;
}
#purchaseModal .form-text {
    font-size: 0.75rem;
}

/* Payment Instructions Styling within Modal */
.payment-instructions-container {
    background-color: #f0f0f0; /* Light grey background for instructions */
    padding: 0.75rem;
    border-radius: 5px;
    margin-top: 0.5rem;
    margin-bottom: 1rem;
    border: 1px solid #e0e0e0;
    font-size: 0.85rem; /* Slightly smaller font for instructions */
    max-height: 200px; /* Max height for instructions area */
    overflow-y: auto; /* Scroll if instructions are long */
}
.payment-instructions-container ol {
    padding-left: 1.2rem; /* Indent list */
    margin-bottom: 0;
}
.payment-instructions-container ol li {
    margin-bottom: 0.3rem;
}

#otherCountryInstructions {
    background-color: var(--popup-info-bg, #e7f3fe);
    border-color: var(--popup-info-border, #b8daff);
    color: var(--popup-info-text, #0c5460);
}
#otherCountryInstructions a {
    color: var(--primary-color);
    font-weight: 500;
}

#purchaseModal .modal-footer {
    padding: 0.75rem 1.25rem;
    flex-shrink: 0;
    background-color: #f8f9fa;
    border-top: 1px solid var(--border-color-light);
}


/* Chat Modal Header (User Chat) */
.chat-modal-header {
    background-color: var(--primary-color);
    color: var(--text-light);
    padding: 12px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #ddd;
    flex-shrink: 0;
    box-sizing: border-box;
}
.chat-modal-header h5 {
    margin: 0;
    font-size: 1.0rem;
    font-weight: 500;
}
.chat-modal-close-btn {
    background: none;
    border: none;
    color: var(--text-light);
    font-size: 1.6rem;
    line-height: 1;
    opacity: 0.8;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
}
.chat-modal-close-btn:hover {
    opacity: 1;
}

/* Chat Modal Body (Parent for Log and Input Area) - User Chat */
.chat-modal-body {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-sizing: border-box;
    background-color: #f9f9f9;
}

/* Initial View Styling inside Chat Modal Body - User Chat */
#chatInitialView, #chatLoginPromptView {
    padding: 20px 15px;
    text-align: center;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
}
#chatInitialView p, #chatLoginPromptView p {
    margin-bottom: 1rem;
    font-size: 0.9rem;
}
#chatInitialView .form-group, #chatLoginPromptView .form-group {
    margin-bottom: 1rem;
    text-align: left;
    width: 100%;
    max-width: 300px;
}
#chatInitialView label, #chatLoginPromptView label {
    font-weight: 500;
    font-size: 0.9rem;
    margin-bottom: 0.3rem;
    display: block;
}
#chatInitialView .chat-message-input-field,
#chatLoginPromptView .chat-message-input-field {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ccc;
    border-radius: 20px;
    font-size: 0.9rem;
    box-sizing: border-box;
    margin-bottom: 0.5rem;
}
#chatInitialView .chat-message-input-field:focus,
#chatLoginPromptView .chat-message-input-field:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.1rem rgba(var(--primary-color-rgb), 0.25);
}

#chatInitialView .chat-send-btn,
#chatLoginPromptView .chat-send-btn {
    padding: 10px 15px;
    background: var(--accent-color-green);
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.95rem;
    width: 100%;
    max-width: 300px;
}
#chatInitialView .chat-send-btn:hover,
#chatLoginPromptView .chat-send-btn:hover {
    background: #388E3C;
}
#chatInitialView .login-prompt-link,
#chatLoginPromptView .login-prompt-link {
    color: var(--primary-color);
    text-decoration: underline;
    font-weight: 500;
}

/* Active Chat View - User Chat */
#chatActiveView {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Chat Log Container (Scrollable Area for Messages) - User Chat & Admin */
.chat-log-container {
    flex-grow: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    background-color: #ffffff;
}

/* Chat Input Area (Fixed at the bottom) - User Chat & Admin */
.chat-input-area {
    padding: 10px 12px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 8px;
    background: #f9f9f9;
    flex-shrink: 0;
    box-sizing: border-box;
    align-items: center;
}
.chat-message-input-field { /* Targets input[type=text] in chat */
    flex-grow: 1;
    padding: 10px 15px;
    border: 1px solid #ccc;
    border-radius: 20px;
    font-size: 0.9rem;
    box-sizing: border-box;
    line-height: 1.4;
}
.chat-message-input-field:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.1rem rgba(var(--primary-color-rgb), 0.25);
}

.chat-send-btn { /* Targets the send button in chat */
    padding: 10px 15px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.chat-send-btn:hover {
    background: #10185E; /* Darker primary */
}
.chat-send-btn .fas {
    margin-left: 5px;
}

/* Individual Message Styling - User Chat & Admin */
.chat-message {
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    max-width: 80%;
    box-sizing: border-box;
    clear: both;
}
.chat-message p.chat-message-text {
    display: inline-block;
    padding: 8px 14px;
    border-radius: 18px;
    margin-bottom: 3px;
    word-wrap: break-word;
    font-size: 0.88rem;
    line-height: 1.45;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}
.chat-message-sender {
    font-weight: bold;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 2px;
    padding-left: 12px;
    padding-right: 12px;
}

.chat-message-user {
    align-items: flex-end;
    align-self: flex-end;
}
.chat-message-user p.chat-message-text {
    background-color: var(--primary-color);
    color: var(--text-light);
    border-bottom-right-radius: 5px;
}
.chat-message-user .chat-message-sender { text-align: right; }

.chat-message-other {
    align-items: flex-start;
    align-self: flex-start;
}
.chat-message-other p.chat-message-text {
    background-color: #e9ecef;
    color: var(--text-dark);
    border-bottom-left-radius: 5px;
}
.chat-message-other .chat-message-sender { text-align: left; }

.chat-message-system {
    align-self: center;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 8px;
    margin-bottom: 12px;
    width: 100%;
}
.chat-message-system p.chat-message-text {
    background-color: transparent;
    padding: 2px 5px;
    border-radius: 0;
    box-shadow: none;
    font-style: italic;
}

.chat-message-time {
    font-size: 0.65rem;
    color: #999;
    margin-top: 1px;
    padding: 0 12px;
}
.chat-message-user .chat-message-time { align-self: flex-end; }
.chat-message-other .chat-message-time { align-self: flex-start; }

/* Responsive adjustments for user chat modal */
@media (max-width: 575.98px) {
    .chat-modal-container {
        width: calc(100% - 20px);
        height: 70vh;
        max-height: 450px;
        bottom: 10px;
        right: 10px;
        left: auto;
        border-radius: 8px;
    }
    #purchaseModal .modal-dialog {
        margin: 10px;
        width: calc(100% - 20px);
    }
    #purchaseModal .modal-content {
        max-height: 90vh;
    }

    .chat-modal-header h5 { font-size: 0.9rem; }
    .chat-message p.chat-message-text { font-size: 0.85rem; padding: 7px 12px; }
    .chat-message-input-field, .chat-send-btn { font-size: 0.85rem; padding: 9px 12px; }
}


/* Admin Chat Interface (within admin dashboard) */
.chat-modal-like-admin { /* This is the #adminChatInterface */
    height: 480px;
    max-height: calc(100vh - 280px); /* Adjust based on surrounding admin elements */
    display: flex;
    flex-direction: column;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    overflow: hidden;
    box-sizing: border-box;
    background-color: var(--card-bg-light);
}
.chat-modal-like-admin .chat-modal-header { /* Re-use chat-modal-header style */
     border-top-left-radius: 7px;
     border-top-right-radius: 7px;
}
.chat-modal-like-admin .chat-modal-body { /* Re-use chat-modal-body style */
    background-color: #f9f9f9;
}
.chat-modal-like-admin .chat-log-container { /* Re-use chat-log-container style */
    background-color: #ffffff;
}
.chat-modal-like-admin .chat-input-area { /* Re-use chat-input-area style */
    background: #f9f9f9;
}

#adminNoChatSelectedMessage {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: var(--text-muted);
    background-color: var(--card-bg-light);
    border-radius: 8px;
}
/* Ensure admin chat close button is distinct */
#adminCloseCurrentChatInterfaceBtn {
    background: none;
    border: none;
    color: var(--text-light);
    font-size: 1.4rem;
    line-height: 1;
    opacity: 0.8;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    margin-left: auto;
}
#adminCloseCurrentChatInterfaceBtn:hover {
    opacity: 1;
}

/* Sidebar Toggle Icon */
button[data-toggle="offcanvas"] {
    border: 1px solid var(--primary-color) !important;
    color: var(--primary-color) !important;
    padding: 0.375rem 0.75rem;
}
button[data-toggle="offcanvas"]:hover {
    background-color: var(--primary-color) !important;
    color: white !important;
}
button[data-toggle="offcanvas"] .fa-bars {
    font-size: 1.1rem;
}
