/* 
==============================================
CHC Chat Widget Styles - Single Source of Truth
==============================================
*/

/* --- Main Widget Positioning & Container --- */
#chc-chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999999;
    transform: translateY(10px);
}

#chc-chat-container {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 360px;
    max-height: 520px;
    background-color: #1A1A1A;
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    z-index: 999998;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: opacity 0.3s ease, transform 0.3s ease;
    transform: translateY(10px);
}

#chc-chat-container.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

#chc-chat-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(5px);
    z-index: 999997;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

#chc-chat-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* --- Chat Button --- */
#chc-chat-button {
    background-color: #00FF9C;
    color: #121212;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 3px 10px rgba(0, 255, 156, 0.2);
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
}

#chc-chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 5px 15px rgba(0, 255, 156, 0.4);
}

/* --- Header --- */
.chc-chat-header {
    min-height: 56px;
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
    background-color: transparent;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.chc-header-title {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #FFFFFF;
    font-weight: bold;
}

.chc-header-title .chc-header-text {
    margin: 0;
}

.chc-header-status {
    background-color: rgba(0, 255, 156, 0.15);
    color: #00FF9C;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.chc-header-status .chc-status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: #00FF9C;
    border-radius: 50%;
}

.chc-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chc-header-actions button {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    padding: 5px;
}

.chc-header-actions button:hover {
    color: #FFFFFF;
}

/* --- Name Input Form --- */
.chc-chat-registration-form {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px 30px;
    text-align: center;
}

.chc-chat-registration-form h3 {
    font-size: 24px;
    font-weight: bold;
    color: #FFFFFF;
    margin: 0 0 8px 0;
    line-height: 1.2;
}

.chc-chat-registration-form h3 span {
    font-weight: normal;
    color: rgba(255, 255, 255, 0.7);
    display: block;
    font-size: 18px;
    margin-bottom: 4px;
}

.chc-chat-registration-form p {
    color: rgba(255, 255, 255, 0.6);
    margin: 0 0 24px 0;
}

.chc-chat-registration-form .chc-input-wrapper {
    position: relative;
    width: 100%;
}

.chc-chat-registration-form .chc-input-icon {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255, 255, 255, 0.4);
    pointer-events: none;
}

#chc-name-input {
    width: 100%;
    padding: 12px 20px 12px 50px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 99px;
    font-size: 16px;
    margin-bottom: 15px;
    background: rgba(255, 255, 255, 0.05);
    color: #FFFFFF;
    transition: all 0.3s ease;
}

#chc-name-input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.1);
    border-color: #00FF9C;
    box-shadow: 0 0 15px rgba(0, 255, 156, 0.3);
}

#chc-name-submit {
    width: 100%;
    padding: 12px;
    background: #FF007A;
    color: white;
    border: none;
    border-radius: 99px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(255, 0, 122, 0.3);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

#chc-name-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(255, 0, 122, 0.4);
}

/* --- Chat Interface --- */
#chc-chat-interface {
    flex: 1;
    display: none;
    flex-direction: column;
    overflow: hidden;
}
#chc-chat-interface.active { display: flex; }

#chc-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chc-input-container {
    padding: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background-color: #1A1A1A;
}

.chc-input-container form {
    display: flex;
    gap: 10px;
    align-items: center;
}

#chc-message-input {
    flex: 1;
    border-radius: 20px;
    padding: 10px 18px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.05);
    color: #FFFFFF;
    resize: none;
    height: 44px;
    line-height: 18px;
    font-family: inherit;
    padding-top: 10px;
    padding-bottom: 10px;
}

#chc-message-input:focus {
    outline: none;
    border-color: #00FF9C;
    background: rgba(255, 255, 255, 0.1);
}

#chc-send-button {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #00FF9C;
    color: #121212;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
}

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

.chc-security-notice {
    color: rgba(255, 255, 255, 0.5);
    font-size: 11px;
    text-align: center;
    margin-top: 8px;
}

/* --- Message Bubbles --- */
.chc-message {
    max-width: 85%;
    padding: 10px 15px;
    border-radius: 18px;
    line-height: 1.4;
    word-wrap: break-word;
}
.chc-message.user {
    align-self: flex-end;
    background: #FF007A;
    color: white;
    border-bottom-right-radius: 4px;
}
.chc-message.admin {
    align-self: flex-start;
    background: #333333;
    color: white;
    border-bottom-left-radius: 4px;
}
.chc-message.system {
    align-self: center;
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
    text-align: center;
}

/* Failsafe for old, incorrectly flagged system messages */
.chc-message:not(.chc-message-user):has(.chc-message-content:first-child:last-child:contains("This chat has been closed")) {
    align-self: center;
    text-align: center;
    background: rgba(255, 255, 255, 0.1);
}

/* --- Responsive for Mobile --- */
@media screen and (max-width: 480px) {
    #chc-chat-container {
        width: 100%;
        height: 100vh;
        max-height: 100%;
        bottom: 0;
        right: 0;
        top: 0;
        left: 0;
        border-radius: 0;
        box-shadow: none;
        background-color: #000;
    }
    .chc-message { max-width: 90%; }
}

/* Reserve space for chat widget to prevent page jump */
body::after {
    content: "";
    display: block;
    height: 80px;
    width: 100%;
    position: fixed;
    bottom: 0;
    left: 0;
    z-index: -1;
    opacity: 0;
    pointer-events: none;
}

/* Critical inline styles that override any other styles */
body { font-family: Arial, sans-serif; }

/* Make the security notice more readable */
.chc-security-notice {
    color: rgba(255, 255, 255, 0.7) !important; 
    font-size: 12px !important;
    text-align: center !important;
    margin-top: 8px !important;
}

/* Improved contrast for input areas */
.chc-message-input, #chc-name-input {
    width: 100%;
    padding: 12px 20px !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    border-radius: 99px !important;
    font-size: 16px !important;
    background: rgba(255, 255, 255, 0.05) !important;
    color: #FFFFFF !important;
    box-shadow: none !important;
    transition: all 0.3s ease;
}

#chc-name-input:focus, .chc-message-input:focus {
    outline: none !important;
    background: rgba(255, 255, 255, 0.1) !important;
    border-color: #00FF9C !important;
    box-shadow: 0 0 15px rgba(0, 255, 156, 0.3) !important;
}

/* Increased contrast for chat header */
.chc-chat-header {
    background-color: transparent !important;
    color: #FFFFFF !important; 
    border-bottom: 1px solid rgba(0, 255, 156, 0.3) !important;
}

.chc-header-status, .chc-header-text {
    color: #FFFFFF !important; 
    font-weight: bold !important;
}

.chc-header-status .chc-status-dot {
    background-color: #00FF9C !important;
}

#chc-chat-overlay.active {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
}

/* Name input form styles */
#chc-name-form-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    background-color: transparent;
}

#chc-name-form h3 {
    font-size: 24px;
    font-weight: bold;
    color: #FFFFFF;
    margin-bottom: 8px;
    line-height: 1.2;
}

#chc-name-form h3 span {
    font-weight: normal;
    color: rgba(255, 255, 255, 0.7);
    display: block;
    font-size: 18px;
    margin-bottom: 4px;
}

#chc-name-form {
    width: 100%;
    max-width: 300px;
    text-align: center;
}

#chc-name-submit {
    width: 100%;
    padding: 12px;
    background: #FF007A;
    color: white;
    border: none;
    border-radius: 99px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 0 20px rgba(255, 0, 122, 0.4);
}

#chc-name-submit:hover {
    background: #FF007A;
    filter: brightness(1.2);
}

/* Message styling fixes */
.chc-message {
    display: block !important;
    margin-bottom: 15px !important;
    max-width: 85% !important;
    position: relative !important;
    clear: both !important;
    word-wrap: break-word !important;
    box-sizing: border-box !important;
}

.chc-message.user {
    float: right !important;
    align-self: flex-end !important;
    background: #FF007A !important; 
    color: white !important;
    border-radius: 18px 18px 4px 18px !important;
    padding: 12px 16px !important;
    margin-left: auto !important;
    margin-right: 0 !important;
}

.chc-message.admin {
    float: left !important;
    align-self: flex-start !important;
    background: #333333 !important;
    color: white !important;
    border-radius: 18px 18px 18px 4px !important;
    padding: 12px 16px !important;
    margin-right: auto !important;
    margin-left: 0 !important;
}

.chc-message.system {
    align-self: center !important;
    float: none !important;
    background: rgba(42, 47, 69, 0.8) !important;
    color: rgba(255, 255, 255, 0.95) !important;
    border-radius: 12px !important;
    padding: 10px 14px !important;
    margin: 10px auto !important;
    max-width: 90% !important;
    text-align: center !important;
}

.chc-message-content {
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    white-space: pre-wrap !important;
    font-size: 14px !important;
    line-height: 1.4 !important;
    color: inherit !important;
}

.chc-message-time {
    font-size: 11px !important;
    opacity: 0.9 !important; 
    margin-top: 4px !important;
    text-align: right !important;
}

.chc-message.user .chc-message-time {
    opacity: 1 !important;
}

/* Input styling */
.chc-message-input {
    resize: none !important;
    min-height: 40px !important;
    max-height: 80px !important;
    overflow-y: auto !important;
}

/* Message structure fixes */
#chc-messages:after {
    content: '';
    display: table;
    clear: both;
}

/* Clean hover effect */
.chc-chat-button:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 255, 156, 0.3), 0 8px 20px rgba(0, 0, 0, 0.15);
}

.chc-send-button {
    background: #00FF9C !important;
    color: #121212 !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* --- Responsive for Mobile (Forced Override) --- */
@media screen and (max-width: 480px) {
    #chc-chat-widget {
        transform: none !important;
        z-index: 1000000 !important;
    }

    #chc-chat-container.active {
        width: 100vw !important;
        height: 100vh !important;
        max-height: 100vh !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        transform: none !important;
        background-color: #000 !important;
    }
}

body.chc-chat-active {
    overflow: hidden;
} 