/* public/assets/css/fab-chat.css - High Specificity Version */

#app .fabs {
    position: fixed;
    bottom: 1em;
    right: 1em;
    z-index: 1011;
}

#app .btnSendMessage {
    width: 100%;
    height: 30px;
    background-color: var(--v-theme-primary);
    color: white;
    border: none;
    box-shadow: 0 3px 5px rgba(0,0,0,0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: background-color 0.3s ease;
}

#app .fabs button .material-icons {
    font-size: 28px;
}

.v-application .fabs section,
.v-application .fabs footer {
    background: #1f1f1f!important;
}

.v-application.v-theme--light .fabs section,
.v-application.v-theme--light .fabs footer {
    background: #ffffff!important;
}

#app .btnSendMessage:hover {
    background-color: var(--v-theme-primary-darken-1);
}
#app .btnSendMessage:focus {
    outline: none;
}

#app .fabs .chat_body_section {
    min-height: 250px;
}

#app .chat-window {
    background-color: white; /* Fallback */
    background-color: var(--v-theme-surface);
    position: fixed;
    right: 1.5em;
    bottom: 6.5em;
    width: 400px;
    max-width: 90vw;
    font-family: 'Roboto', sans-serif;
    box-shadow: 0 5px 20px rgba(0,0,0,0.2);
    border-radius: 15px;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transform-origin: bottom right;
    transition: all .25s ease-in-out;
    display: flex;
    flex-direction: column;
}

#app .chat-window.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

#app .chat-window.is-maximized {
    top: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    border-radius: 0;
    margin: 0;
}

#app .chat_header {
    padding: 12px 15px;
    display: flex;
    align-items: center;
    color: white;
    flex-shrink: 0;
}

#app .header_img img {
    border-radius: 50%;
    width: 40px;
    height: 40px;
    border: 2px solid rgba(255, 255, 255, 0.5);
}

#app .chat_option_text { margin-left: 15px; }
#app .chat_option_text .agent { font-size: 12px; font-weight: 300; }
#app .chat_option_text .online { opacity: 0.8; font-size: 11px; font-weight: 300; }
#app .chat_header_buttons { margin-left: auto; display: flex; align-items: center; }

#app .chat_body_section {
    color: var(--v-theme-on-surface);
    flex-grow: 1;
    overflow-y: auto;
    padding: 15px;
    display: none;
    min-height: 0;
}
#app .chat_body_section.active { display: block; }

#app .chat_converse {
    display: flex;
    flex-direction: column;
}
#app .message-container {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#app .chat_form_section {
    padding: 15px 15px 5px 15px !important;
}
#app .chat_form_section > .v-input,
#app .chat_form_section > .v-textarea {
    margin-bottom: 0px !important;
}

#app .chat_msg_item {
    padding: 8px 12px;
    max-width: 80%;
    word-wrap: break-word;
    border-radius: 12px;
    line-height: 1.5;
    animation: zoomIn .3s ease-out;
    font-size: 13px;
    display: inline-block;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    white-space: pre-wrap;
    overflow-wrap: break-word;
    position: relative;
}

#app .chat_msg_item.chat_msg_item_admin {
    align-self: flex-start;
    background-color: rgba(var(--v-theme-on-surface-rgb), 0.07);
    border-bottom-left-radius: 4px;
}
#app .chat_msg_item.chat_msg_item_user {
    align-self: flex-end;
    background-color: var(--v-theme-primary);
    color: var(--v-theme-on-primary, white);
    border-bottom-right-radius: 4px;
}
#app .chat_msg_item.is-loading { display: flex; align-items: center; gap: 8px; }

#app .fab_field {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    padding: 8px;
    background-color: var(--v-theme-surface);
    border-top: 1px solid rgba(var(--v-theme-on-surface-rgb), 0.12);
}
#app .fab_field textarea {
    flex-grow: 1;
    border: none;
    outline: none;
    padding: 8px;
    font-size: 14px;
    resize: none;
    background: transparent;
    color: var(--v-theme-on-surface);
    max-height: 100px;
    overflow-y: auto;
}

@keyframes zoomIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

#app .chat_body_section::-webkit-scrollbar { width: 6px; }
#app .chat_body_section::-webkit-scrollbar-track { background: transparent; }
#app .chat_body_section::-webkit-scrollbar-thumb { border-radius: 10px; background: rgba(0, 0, 0, 0.2); }

/* Add necessary styles for new chat features */
.fab_field {
    position: relative;
    display: flex;
    align-items: flex-end; /* Align items to bottom for textarea growth */
}

.fab_field textarea {
    flex: 1;
    border: none;
    outline: none;
    padding: 12px 10px;
    resize: none;
    overflow-y: auto;
    max-height: 100px; /* Limit height */
    min-height: 44px; /* Default height */
    line-height: 1.4;
    background-color: transparent;
}

.image-preview-container {
    position: absolute;
    bottom: 100%; /* Position above the footer */
    left: 0;
    right: 0;
    /* Use CSS variables from Vuetify */
    background-color: rgb(var(--v-theme-surface));
    padding: 8px;
    border-top: 1px solid rgba(var(--v-border-color), var(--v-border-opacity));
    border-radius: 8px 8px 0 0;
}

.image-preview-wrapper {
    position: relative;
    display: inline-block;
}

.image-preview {
    max-height: 100px;
    max-width: 100%;
    border-radius: 4px;
    display: block;
}

.remove-image-btn {
    position: absolute !important;
    top: -10px;
    right: -10px;
    background-color: rgba(0, 0, 0, 0.6);
    color: white !important;
}

.chat-message-image {
    max-width: 100%;
    border-radius: 8px;
    margin-top: 8px;
    cursor: pointer;
    transition: opacity 0.3s;
}
.chat-message-image:hover {
    opacity: 0.8;
}


.chat_msg_item {
    position: relative; /* Necessary for absolute positioning */
    padding-right: 30px; /* Add space for the button */
}

/* Position the copy button */
.chat_msg_item .copy-btn {
    position: absolute;
    top: 2px;
    right: -15px;
    left: auto;
    display: none; /* Hidden by default */
    z-index: 10;
    color: rgba(var(--v-theme-on-surface), 0.6); /* Use Vuetify theme color */
}

/* Show on hover */
.chat_msg_item:hover .copy-btn {
    display: block;
}

/* Adjust position for user messages */
.chat_msg_item_user {
     padding-right: 8px; /* Reset user padding */
     padding-left: 30px; /* Add space on the left for user */
}
.chat_msg_item_user .copy-btn {
    right: auto; /* Unset right */
    left: 10px;   /* Position on the left */
}

.fabs .header_img::after {
    content: "Plus";
    position: absolute;
    bottom: -5px;
    left: 0;
    font-size: 10px;
    display: block;
    background: linear-gradient(to bottom right, red, yellow);
    padding: 0px 8px;
    border-radius: 10px;
    font-weight: 700;
    color: white;
    text-shadow: 2px 2px 4px #000000;
}

.fabs .header_img {
    position: relative;
}
