.ai-assistant-box {
    width: 100%;
    max-width: 1100px;
    margin-left: auto;
    margin-right: auto;
    margin-top: 24px;
    padding: 20px;
    background: #ffffff;
    border: 1px solid #d9e2f1;
    border-radius: 14px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.04);
}

.ai-assistant-box h3 {
    margin-top: 0;
    margin-bottom: 6px;
    color: #16325c;
}

.ai-assistant-box p {
    margin-bottom: 14px;
    color: #4b5b76;
}

.problem-ai-box {
    padding: 14px 16px;
}

.problem-ai-box.collapsed {
    padding-bottom: 12px;
}

.problem-ai-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.problem-ai-header h3 {
    margin: 0 0 4px;
}

.problem-ai-header p {
    margin: 0;
}

.problem-ai-toggle {
    border: 1px solid #bcd0f7;
    border-radius: 10px;
    background: #eff6ff;
    color: #1d4ed8;
    cursor: pointer;
    font-weight: 700;
    padding: 8px 12px;
    white-space: nowrap;
}

.problem-ai-toggle:hover {
    background: #dbeafe;
}

.problem-ai-body {
    margin-top: 12px;
}

.ai-chat-response {
    max-height: 420px;
    overflow-y: auto;
    padding: 12px;
    margin-bottom: 14px;
    background: #f8fbff;
    border: 1px solid #dbe7f5;
    border-radius: 12px;
}

.ai-chat-turn {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid #e1e9f2;
}

.ai-chat-turn:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.ai-chat-message {
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid transparent;
}

.ai-chat-message + .ai-chat-message {
    margin-top: 8px;
}

.ai-chat-message.user {
    background: #eef4ff;
    border-color: #cdddff;
}

.ai-chat-message.assistant {
    background: #f6fff8;
    border-color: #cfe9d6;
}

.ai-chat-message.thinking {
    background: #fffbe8;
    border-color: #f3df9b;
}

.ai-chat-message.error {
    background: #fff3f3;
    border-color: #f0b9b9;
}

.ai-chat-label {
    font-weight: 700;
    margin-bottom: 6px;
    color: #22324d;
}

.ai-chat-text {
    white-space: pre-line;
    line-height: 1.5;
    color: #1f2d3d;
}

.ai-source-label {
    display: inline-flex;
    margin-bottom: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    background: #dcfce7;
    color: #166534;
    font-size: 13px;
    font-weight: 800;
}

.ai-answer-heading {
    margin: 8px 0 4px;
    color: #0f172a;
    font-size: 18px;
}

.ai-answer-section {
    display: block;
    margin: 6px 0 2px;
    color: #1d4ed8;
}

.ai-answer-step {
    margin: 2px 0 2px 10px;
}

.ai-answer-divider {
    margin: 10px 0;
    border: none;
    border-top: 1px solid #dbe7f5;
}

.ai-chat-input {
    width: 100%;
    min-height: 110px;
    padding: 12px 14px;
    border: 1px solid #cfd9e6;
    border-radius: 10px;
    resize: vertical;
    font: inherit;
    line-height: 1.5;
    box-sizing: border-box;
    margin-bottom: 12px;
}

.ai-chat-input:focus {
    outline: none;
    border-color: #4c84ff;
    box-shadow: 0 0 0 3px rgba(76, 132, 255, 0.15);
}

.ai-chat-send-btn {
    background: #2f6fed;
    color: #ffffff;
    border: none;
    padding: 10px 18px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    font-size: 15px;
    transition: background 0.2s ease;
}

.ai-chat-send-btn:hover {
    background: #1f5ad0;
}

.ai-chat-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.problem-ai-box .ai-chat-input {
    min-height: 72px;
    margin-bottom: 10px;
}

.problem-ai-actions {
    flex-wrap: wrap;
}

.ai-file-compact-label {
    border: 1px solid #bcd0f7;
    border-radius: 10px;
    background: #ffffff;
    color: #2f6fed;
    cursor: pointer;
    font-weight: 600;
    padding: 10px 14px;
}

.ai-file-compact-label:hover {
    background: #f3f7ff;
    border-color: #2f6fed;
}

.problem-ai-box .ai-file-input {
    display: none;
}

.ai-chat-clear-btn {
    background: #ffffff;
    color: #2f6fed;
    border: 1px solid #bcd0f7;
    padding: 10px 18px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    font-size: 15px;
    transition: all 0.2s ease;
}

.ai-chat-clear-btn:hover {
    background: #f3f7ff;
    border-color: #2f6fed;
}
/* Teaching assistant floating widget */
#ai-teaching-widget {
    position: fixed;
    top: 100px;
    right: 24px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

#ai-teaching-trigger {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #70b1c9;
    color: #ffffff;
    border: none;
    border-radius: 999px;
    padding: 12px 18px;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    box-shadow: 0 10px 24px rgba(47, 111, 237, 0.22);
    transition: background 0.2s ease, transform 0.2s ease;
}

#ai-teaching-trigger:hover {
    background: #1f5ad0;
    transform: translateY(-1px);
}

.ai-teaching-icon {
    font-size: 16px;
    line-height: 1;
}

.ai-teaching-text {
    white-space: nowrap;
}

#ai-teaching-panel {
    width: 340px;
    margin-top: 12px;
    background: #ffffff;
    border: 1px solid #d9e2f1;
    border-radius: 16px;
    box-shadow: 0 16px 40px rgba(17, 38, 79, 0.16);
    overflow: hidden;
}

.ai-teaching-hidden {
    display: none;
}

.ai-teaching-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    background: #f8fbff;
    border-bottom: 1px solid #dbe7f5;
}

.ai-teaching-title {
    display: flex;
    flex-direction: column;
    gap: 2px;
    color: #16325c;
}

.ai-teaching-title span {
    font-size: 13px;
    color: #5c798f;
}

.ai-teaching-header-actions {
    display: flex;
    align-items: center;
}

.ai-teaching-icon-btn {
    background: transparent;
    border: none;
    color: #4b5b76;
    font-size: 18px;
    cursor: pointer;
    padding: 2px 6px;
    line-height: 1;
}

.ai-teaching-icon-btn:hover {
    color: #165c48;
}

.ai-teaching-body {
    padding: 16px;
}

.ai-teaching-message {
    margin: 0 0 14px 0;
    color: #4b5b76;
    line-height: 1.5;
}

.ai-teaching-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

@media (max-width: 900px) {
    #ai-teaching-widget {
        top: auto;
        bottom: 20px;
        right: 16px;
    }

    #ai-teaching-panel {
        width: min(92vw, 340px);
    }

    .ai-teaching-text {
        display: none;
    }
}
.ai-file-upload-section {
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: #f8f9fa;
    border-radius: 8px;
}

.ai-file-label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #333;
}

.ai-file-input {
    display: block;
    width: 100%;
    padding: 0.5rem;
    border: 2px dashed #ddd;
    border-radius: 4px;
    cursor: pointer;
}

.ai-file-hint {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.85rem;
    color: #666;
}

.ai-file-preview {
    display: none;
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: #e8f5e9;
    border-left: 3px solid #4caf50;
    border-radius: 4px;
    font-size: 0.9rem;
    color: #2e7d32;
}

.ai-file-preview-row {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    max-width: 100%;
}

.ai-file-preview-text {
    min-width: 0;
}

.ai-file-tag {
    display: inline-block;
    margin-top: 0.25rem;
    padding: 0.25rem 0.5rem;
    background: #e3f2fd;
    border-radius: 4px;
    font-size: 0.85rem;
    color: #1976d2;
}
.ai-file-remove-btn {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #fee2e2;
    color: #b91c1c;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    border: none;
    flex-shrink: 0;
}

.ai-file-remove-btn:hover {
    background: #fecaca;
    color: #7f1d1d;
}
