/* Web/css/style.css - Additions for Live Chat */

/* Floating chat button */
.chat-toggle-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: var(--gradient-primary); /* Uses your gradient */
    color: var(--text-primary);
    border: none;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    font-size: 1.8rem;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 5px 15px rgba(0,0,0,0.4);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    z-index: 1000; /* Ensures it is above other elements */
}

.chat-toggle-btn:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.6);
}

/* Main chat widget container */
.chat-widget-container {
    position: fixed;
    bottom: 100px; /* Above the floating button */
    right: 30px;
    width: 380px; /* Widget width */
    height: 550px; /* Widget height */
    background-color: var(--bg-dark-secondary);
    border-radius: 15px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden; /* For rounded corners to work well */
    z-index: 999;
    transform-origin: bottom right; /* For scaling animations if added */
    transition: transform 0.3s ease-out, opacity 0.3s ease-out;
}

.chat-widget-container.hidden {
    transform: scale(0.8);
    opacity: 0;
    pointer-events: none; /* Disables interactions when hidden */
}

/* Widget header */
.chat-widget-header {
    background: var(--gradient-primary);
    color: var(--text-primary);
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 1.1rem;
    border-top-left-radius: 15px;
    border-top-right-radius: 15px;
}

.chat-widget-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--text-primary); /* To make text white on gradient */
}

.chat-header-btn {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1.2rem;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.chat-header-btn:hover {
    transform: scale(1.1);
}

/* Main widget body (conversations sidebar and chat area) */
.chat-widget-body {
    display: flex;
    flex-grow: 1;
    background-color: var(--bg-dark-primary); /* Darker background */
}

/* Conversations sidebar within widget */
.chat-sidebar {
    width: 140px; /* Fixed width for conversations sidebar */
    background-color: var(--bg-dark-primary);
    border-right: 1px solid #2a2a2e;
    padding: 15px 10px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    font-size: 0.85rem;
    flex-shrink: 0; /* Prevents shrinking */
}

.chat-sidebar h2 {
    font-size: 1.05rem;
    color: var(--accent-primary);
    margin-bottom: 15px;
    padding-bottom: 5px;
    border-bottom: 1px solid #2a2a2e;
    text-align: center;
}

.new-conversation-btn-widget {
    background-color: var(--accent-secondary);
    color: var(--text-primary);
    padding: 8px 10px;
    border-radius: 8px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    margin-bottom: 15px;
    transition: background-color 0.2s ease, transform 0.2s ease;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
}

.new-conversation-btn-widget:hover {
    background-color: #d15fa8;
    transform: translateY(-1px);
}

.conversation-list-widget {
    flex-grow: 1;
    list-style: none;
    padding: 0;
    margin: 0;
}

.conversation-item-widget {
    display: flex;
    align-items: center;
    padding: 10px;
    margin-bottom: 8px;
    background-color: #0d0d11;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    border: 1px solid #2a2a2e;
}

.conversation-item-widget:hover {
    background-color: rgba(232, 67, 147, 0.08); /* Subtle background on hover */
}

.conversation-item-widget.active {
    background: var(--gradient-primary);
    color: var(--text-primary);
    box-shadow: 0 1px 5px rgba(0,0,0,0.2);
    font-weight: 600;
}

.conversation-item-widget.active .conversation-status-widget {
    color: var(--text-primary); /* So status also changes when active */
}

.conversation-avatar-widget {
    width: 30px;
    height: 30px;
    background-color: var(--accent-secondary);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-right: 10px;
    flex-shrink: 0;
}
.conversation-avatar-widget i {
    color: var(--text-primary); /* White icon */
}

.conversation-info-widget {
    flex-grow: 1;
    overflow: hidden; /* For ellipsis */
}

.conversation-info-widget h3 {
    font-size: 0.9rem;
    margin: 0;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-info-widget p {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-status-widget {
    font-size: 0.7rem;
    padding: 3px 6px;
    border-radius: 4px;
    margin-left: 8px;
    flex-shrink: 0;
    white-space: nowrap;
}

.conversation-status-widget.open {
    background-color: rgba(40, 167, 69, 0.2); /* Subtle green */
    color: var(--success-color);
}
.conversation-status-widget.closed {
    background-color: rgba(220, 53, 69, 0.2); /* Subtle red */
    color: var(--error-color);
}
.conversation-status-widget.pending {
    background-color: rgba(255, 193, 7, 0.2); /* Subtle yellow */
    color: var(--warning-color);
}

/* Main chat area (messages and input) */
.chat-main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    padding: 15px;
    background-color: var(--bg-dark-secondary); /* Background for message area */
}

.chat-main-header {
    padding-bottom: 15px;
    margin-bottom: 15px;
    border-bottom: 1px solid #2a2a2e;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-main-header h3 {
    font-size: 1.1rem;
    color: var(--accent-primary);
    margin: 0;
    flex-grow: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-main-header .chat-status-indicator {
    font-size: 0.8rem;
    padding: 3px 8px;
    border-radius: 5px;
    margin-left: 10px;
    flex-shrink: 0;
}
.chat-main-header .close-conversation-btn {
    margin-left: 10px;
    color: var(--text-secondary); /* Close conversation icon color */
}
.chat-main-header .close-conversation-btn:hover {
    color: var(--error-color); /* Red on hover */
}


.chat-messages-widget {
    flex-grow: 1;
    overflow-y: auto;
    padding: 10px;
    background-color: var(--bg-dark-primary);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px; /* Space between message bubbles */
    margin-bottom: 15px;
    border: 1px solid #2a2a2e;
}

/* Message bubble styles */
.message-bubble-widget {
    max-width: 80%;
    padding: 10px 15px;
    border-radius: 15px;
    word-wrap: break-word;
    font-size: 0.9rem;
    position: relative;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.message-bubble-widget.user {
    background-color: var(--accent-primary); /* Main color for user messages */
    color: white;
    align-self: flex-end; /* Align right */
    border-bottom-right-radius: 5px; /* Small adjustment in bottom-right corner */
}

.message-bubble-widget.admin {
    background-color: var(--bg-light); /* Lighter shade for agent/admin */
    color: var(--text-primary);
    align-self: flex-start; /* Align left */
    border-bottom-left-radius: 5px; /* Small adjustment in bottom-left corner */
}

.message-time-widget {
    font-size: 0.65rem;
    color: rgba(255,255,255,0.7); /* Opacity for time */
    position: absolute;
    bottom: 5px;
}
.message-bubble-widget.user .message-time-widget {
    right: 15px; /* Aligned right in user messages */
}
.message-bubble-widget.admin .message-time-widget {
    left: 15px; /* Aligned left in admin messages */
}

/* Message input area */
.chat-input-area-widget {
    display: flex;
    gap: 10px;
    padding-top: 10px;
    border-top: 1px solid #2a2a2e;
}

.chat-input-area-widget textarea {
    flex-grow: 1;
    padding: 10px 12px;
    border: 1px solid #333;
    border-radius: 8px;
    background-color: #0d0d11;
    color: var(--text-primary);
    font-size: 0.95rem;
    resize: none;
    min-height: 40px;
    max-height: 120px;
    transition: border-color 0.2s ease;
}

.chat-input-area-widget textarea:focus {
    border-color: var(--accent-primary);
    outline: none;
}

.chat-input-area-widget button {
    background: var(--gradient-primary);
    color: var(--text-primary);
    border: none;
    border-radius: 8px;
    padding: 10px 15px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 5px;
}

.chat-input-area-widget button:hover {
    transform: translateY(-1px);
    background: linear-gradient(90deg, #ff84b4 0%, #eb58a3 100%);
}
.chat-input-area-widget button i {
    font-size: 1rem;
}

/* Media Queries for widget responsiveness */
@media (max-width: 640px) {
    .chat-toggle-btn {
        width: 50px;
        height: 50px;
        font-size: 1.5rem;
        bottom: 20px;
        right: 20px;
    }

    .chat-widget-container {
        width: calc(100% - 40px); /* Occupies almost full width */
        height: calc(100% - 80px); /* And almost full height */
        bottom: 10px;
        right: 10px;
        border-radius: 10px;
    }

    .chat-widget-header {
        padding: 12px 15px;
        font-size: 1rem;
    }

    .chat-widget-header h3 {
        font-size: 1rem;
    }

    .chat-sidebar {
        width: 100%;
        height: 180px; /* Fixed height on mobile if collapsed */
        border-right: none;
        border-bottom: 1px solid #2a2a2e;
        padding: 10px;
    }
    .chat-sidebar h2 {
        font-size: 1.2rem;
        margin-bottom: 10px;
    }
    .new-conversation-btn-widget {
        font-size: 0.8rem;
        padding: 6px 8px;
    }
    .conversation-item-widget {
        padding: 8px;
        margin-bottom: 5px;
    }
    .conversation-info-widget h3 {
        font-size: 0.8rem;
    }
    .conversation-info-widget p {
        font-size: 0.7rem;
    }
    .conversation-status-widget {
        font-size: 0.65rem;
        padding: 2px 4px;
    }
    .conversation-avatar-widget {
        width: 25px;
        height: 25px;
        font-size: 0.8rem;
        margin-right: 8px;
    }


    .chat-main {
        padding: 10px;
    }
    .chat-main-header {
        padding-bottom: 10px;
        margin-bottom: 10px;
    }
    .chat-main-header h3 {
        font-size: 1rem;
    }
    .chat-messages-widget {
        padding: 8px;
        margin-bottom: 10px;
    }
    .message-bubble-widget {
        max-width: 90%;
        padding: 8px 12px;
        font-size: 0.85rem;
    }
    .message-time-widget {
        font-size: 0.6rem;
    }
    .chat-input-area-widget textarea {
        min-height: 35px;
        font-size: 0.9rem;
    }
    .chat-input-area-widget button {
        padding: 8px 12px;
        font-size: 0.85rem;
    }
}
