/* style.css */
.groq-chat-container {
    max-width: 100%;
    width: 100%;
    margin: 20px auto;
    border: 1px solid #82ce5d;
    border-radius: 8px;
    padding: 15px;
    position: relative;
    overflow: visible;
    box-sizing: border-box;
}

.chat-history {
    display: block;
    min-height: 500px;
    height: 60vh;
    overflow-y: auto;
    border: 1px solid #eee;
    margin-bottom: 15px;
    padding: 10px;
}

.chat-message {
    margin: 10px 0;
    padding: 8px;
    border-radius: 5px;
    word-break: break-word;
    text-align: justify;
    animation: messageAppear 0.3s ease;
    clear: both;
}

.message-prefix {
    font-weight: bold;
}

.user-message {
    background-color: #f6f6f6;
    margin-left: auto;
    margin-right: 5%;
    float: left;
    font-size: .9em;
}

.ai-message {
    background-color: #e8ffd3;
    margin-right: auto;
    margin-left: 5%;
    float: right;
    line-height: 1.4em;
    font-size: .9em;
}

.last-ai-message {
    color: #757c72;
    font-style: italic;
    background-color: #f0f6e3 !important;
    border-left: 3px solid #d0ddcc;
}

.last-ai-message:hover {
    color: #2e312d;
    border-left-color: #919a8e;
}

.chat-message::after {
    content: "";
    display: table;
    clear: both;
}

@keyframes messageAppear {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-input {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

#userInput {
    flex-grow: 1;
    padding: 12px;
    height: 42px;
    box-sizing: border-box;
}

#userInput::placeholder {
    font-style: italic;
    transition: opacity 0.4s ease;
}

#userInput:focus::placeholder {
    opacity: 0;
}

#sendButton {
    padding: 0 5px;
    height: 42px;
    background-color: #82ce5d;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
}

#sendButton:hover {
    background-color: #569c49;
    color: white;
}

.history-controls {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: -1px;
    display: none;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border: 1px solid #f2481a;
    border-radius: 8px;
    padding: 10px;
    font-size:.9em;
    font-style: italic;
    white-space: nowrap;
}

.history-controls.visible {
    display: flex;
    opacity: 1;
    left: 50%;
    transform: translateX(-50%);
}

.history-controls.visible > * {
    justify-content: space-between;
    margin: 0 10px;
}

#toggleHistory {
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: #efefef;
    border: 1px solid #e9e9e9;
    border-top-color: #82ce5d;
    border-radius: 0 0 4px 4px;
    height: 30px;
    padding: 0 15px;
    /*display: flex;*/
    display: table;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 3;
    transition: none !important;
    box-shadow: inset 0px 11px 8px -10px #ddd;
}

#toggleHistory.ison {
    background: #f2481a !important;
    border-color: #f2481a !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

#toggleHistory.ison:hover .dashicons:before,
#toggleHistory.ison .dashicons:before {
    color: #fff !important;
}

#toggleHistory .dashicons {
    display: table;
    padding:0 5px;
}

#toggleHistory .dashicons:before {
    font-size: 30px;
    color: #ccc;
    display: table-cell;
    vertical-align: middle;
}

#toggleHistory:not(.ison):hover {
    box-shadow: inset 0px 11px 8px -10px #bbb;
    background: #ddd;
    border: 1px solid #e0e0e0;
    border-top-color: #82ce5d;
}

#toggleHistory:hover .dashicons:before {
    color: #f2481a;
}

.date-clear-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-grow: 1;
}

#historyDate {
    flex-grow: 1;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
}

/* Clear History Button */
#clearHistory {
    background-color: #f2481a;
    border: none;
    border-radius: 4px;
    width: 34px;
    height: 34px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

#clearHistory:hover {
    background-color: #C13914;
}

#clearHistory .dashicons,
#sendButton {
    display: table;
}

#clearHistory .dashicons:before,
#sendButton .dashicons {
    font-size: 30px;
    color: white;
    display: table-cell;
    vertical-align: middle;
}

/* Responsive Design */
@media (max-width: 768px) {
    .groq-chat-container {
        margin: 10px auto;
        padding: 10px;
    }

    .chat-history {
        height: 400px;
        min-height: 400px;
        margin-bottom: 10px;
    }

    .history-controls {
        font-size:1.1em;
        width: 100%;
    }
    
    .history-controls.visible {
        display: block;
    }
    
    .history-controls.visible > * {
        justify-content: none;
        margin: 0;
    }


    .chat-input {
        flex-direction: column;
    }
    
    #userInput {
        width: 100%;
        height: 46px;
        padding: 14px;
    }
    
    #sendButton {
        width: 100%;
        height: 42px;
        padding: 0 5px;
    }
    
    #sendButton .dashicons {
        width: 100%;
        display: block;
        height: auto;
    }
    
    #sendButton .dashicons:before {
        font-size: 40px;
        margin-top: -15px;
    }
    
    #clearHistory {
        width: 100%;
        height: 42px;
        padding: 0 5px;
        margin-top: 10px;
    }
    
    #historyDate {
        margin-top: 10px;
    }
    
    #historyDate, #dateLabel {
        width: 100%;
        text-align: center;
    }
    
}

@media (max-width: 480px) {
    .chat-history {
        height: 300px;
        min-height: 300px;
        padding: 8px;
    }
    
    .date-clear-group {
        flex-wrap: wrap;
    }
    
    #historyDate {
        max-width: 100%;
    }
    
    #sendButton {
        margin-right: 0;
    }
}
