.ai-chatbox-container {
    display: flex;
    gap: 10px;
    max-width: 100%;
    height: 800px; /* default fixed height */
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;

    flex-direction: row;
}

/* Chatbox */
.ai-chatbox {
    flex: 2;
    display: flex;
    flex-direction: column;
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
    overflow: hidden;
}

/* Header */
.ai-chatbox .chat-header {
    background: #0073aa;
    color: white;
    padding: 10px 14px;
    font-weight: bold;
    font-size: 15px;

    display: flex;
    justify-content: space-between;
    /*align-items: center;*/
    /*background: #007bff;*/
    /*color: #fff;*/
    padding: 5px 9px;
    font-weight: bold;
    border-radius: 6px 6px 0 0;
}

.ai-chatbox .chat-settings {
    /*background: #fff;*/
    /*color: #007bff;*/
    border: none;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
}


.ai-chatbox .new-session-btn {
    background: #fff;
    color: #007bff;
    border: none;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
}

.ai-chatbox .new-session-btn:hover {
    background: #f1f1f1;
}

/* Messages area */
.ai-chatbox .chat-messages {
    flex: 1;
    padding: 12px;
    overflow-y: auto;
    background: #f9f9f9;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ai-chatbox .chat-message {
    display: flex;
    flex-direction: column;
    margin-bottom: 10px;
}

.ai-chatbox .chat-message.user {
    align-self: flex-end;
    justify-content: flex-end;
}

.ai-chatbox .chat-message.ai {
    align-self: flex-start;
    justify-content: flex-start;
}

.ai-chatbox .chat-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    /*max-width: 70%;*/
    word-wrap: break-word;
}

.ai-chatbox .chat-message.user .chat-bubble {
    background: #4a90e2;
    color: white;
    align-self: flex-end;
}

.ai-chatbox .chat-message.ai .chat-bubble {
    background: #f1f1f1;
    color: #333;
    align-self: flex-start;
}

/* Timestamp */
.ai-chatbox .timestamp {
    font-size: 0.75rem;
    color: #888;
    margin-top: 3px;
    align-self: flex-start;
}

.ai-chatbox .chat-message.user .timestamp {
    align-self: flex-end;
}

/* Recording indicator */
.recording-message-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    background: #eaeaea;
    color: #333;
    border-radius: 16px;
    padding: 6px 10px;
    font-size: 12px;
    max-width: fit-content;
    animation: fadeIn 0.2s ease-in-out;
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    background: #eaeaea;
    color: #333;
    border-radius: 16px;
    padding: 6px 10px;
    font-size: 12px;
    max-width: fit-content;
    animation: fadeIn 0.2s ease-in-out;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    background: #555;
    border-radius: 50%;
    display: inline-block;
    animation: bounce 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) {
    animation-delay: 0s;
}
.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}
.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Input area */
.ai-chatbox .chat-input {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px;
    border-top: 1px solid #ddd;
}

.ai-chatbox .chat-input input {
    flex: 1;
    padding: 5px;
    border: 1px solid #ccc;
    border-radius: 6px;
    outline: none;
    font-size: 14px;
}

.ai-chatbox .chat-input input.msg {
    flex: 1;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
}

.ai-chatbox .chat-input button {
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 6px;
    padding: 5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, border-color 0.2s;
}

.ai-chatbox .chat-input button:hover {
    background: #f5f5f5;
    border-color: #999;
}

.ai-chatbox .chat-input button:disabled {
    background: #999;
    cursor: not-allowed;
}

.ai-chatbox .chat-input button.mic {
    background: #ff5e57;
}

.ai-chatbox .chat-input button.mic:hover {
    background: #e14b44;
}

/* Mic recording active state */
.ai-chatbox .chat-input button.mic.active {
    background: #e14b44;
    box-shadow: 0 0 0 0 rgba(225, 75, 68, 0.7);
    animation: pulse 1.5s infinite;
}

.ai-chatbox .chat-input .recording-indicator {
    display: none;
    font-size: 13px;
    color: #e14b44;
    font-weight: 500;
}

.ai-chatbox .chat-input .recording-indicator.active {
    display: inline-block;
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 50%, 100% { opacity: 1; }
    25%, 75% { opacity: 0; }
}

.ai-chatbox .chat-input button svg {
    pointer-events: none;
    width: 20px;
    height: 20px;
    color: #333;
}

/* Default mic button */
.ai-chatbox .chat-input button.mic svg {
    color: #333;
}

/* Recording state */
.ai-chatbox .chat-input button.mic.recording {
    background: #ffe5e5;
    border-color: #e74c3c;
}

.ai-chatbox .chat-input button.mic.recording svg {
    color: #e74c3c;
    animation: pulse 1s infinite;
}

.recording-indicator {
    display: none;
    font-size: 12px;
    color: #e74c3c;
    margin-left: 5px;
}

/* Simple pulse animation */
@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.6; }
    100% { transform: scale(1); opacity: 1; }
}


/* Quiz Panel */
.ai-quiz-panel {
    flex: 1;
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
    padding: 12px;
    overflow-y: auto;
}

.ai-quiz-panel .quiz-header {
    font-weight: bold;
    font-size: 15px;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid #ddd;
}

/*.ai-quiz-panel .quiz-item {*/
/*    background: #f4f8fb;*/
/*    border: 1px solid #dde7ef;*/
/*    border-radius: 8px;*/
/*    padding: 5px 7px;*/
/*    margin-bottom: 5px;*/
/*    font-size: 14px;*/
/*}*/

.quiz-item {
    border: 1px solid #ddd;
    border-radius: 6px;
    margin-bottom: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s ease;
}

.quiz-question {
    padding: 10px;
    background: #f7f7f7;
    font-weight: bold;
    font-size: xx-small;
}

.quiz-answer {
    padding: 10px;
    background: #fff;
    display: none;
}

.quiz-item:not(.collapsed) .quiz-answer {
    display: block;
}

.sessions-panel {
    flex: 1;
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
    padding: 9px;
    overflow-y: auto;
    order: 2;
}

.sessions-panel ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sessions-panel li {
    padding: 6px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
}

.sessions-panel .sessions-header {
    font-weight: bold;
    font-size: 15px;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid #ddd;
}

.sessions-panel li:hover {
    background: #f1f1f1;
}

/* Mobile view adjustments */
@media (max-width: 768px) {
    .ai-chatbox-container {
        flex-direction: column;
    }

    .ai-quiz-panel {
        order: 1;  /* quiz first */
    }

    .sessions-panel {
        order: 2;  /* quiz first */
    }
}