 /* Enhanced Draggable Pedagogy Chat Window Styles */

/* Base pedagogy chat window styles */
.pedagogy-chat {
    position: fixed;
    top: calc(50vh - 300px);
    left: calc(50vw - 200px);
    width: 400px;
    height: 600px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    display: none;
    flex-direction: column;
    overflow: hidden;
    transition: none;
    border: 2px solid #e0e0e0;
    z-index: 10000;
}

/* When dragging, add visual feedback */
.pedagogy-chat.dragging {
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.4);
    z-index: 10001;
}

.pedagogy-chat.active {
    display: flex;
}

/* Resize handle */
.resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    cursor: nw-resize;
    border-radius: 0 0 12px 0;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.resize-handle:hover {
    opacity: 1;
}

.resize-handle::before {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-bottom: 8px solid rgba(255, 255, 255, 0.8);
}

.pedagogy-chat.resizing {
    user-select: none;
}

/* Draggable window specific styles */
.draggable-modal {
    /* Inherits all styles from .scenario-chat-modal */
}

.draggable-modal .chat-modal-content {
    /* Remove this wrapper - content is now direct child */
    display: contents;
}

/* Dragging states */
.draggable-modal.dragging {
    cursor: grabbing;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.4);
    z-index: 10001;
}

.dragging-chat {
    cursor: grabbing;
    user-select: none;
}

/* Header styles */
.draggable-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: grab;
    border-radius: 12px 12px 0 0;
    min-height: 50px;
}

.draggable-header:active {
    cursor: grabbing;
}

.chat-title {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.chat-title h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.chat-icon {
    font-size: 18px;
}

.drag-hint {
    font-size: 12px;
    opacity: 0.8;
    margin-left: 8px;
}

/* Control buttons */
.chat-controls {
    display: flex;
    gap: 4px;
}

.chat-controls button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.2s ease;
}

.chat-controls button:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.chat-position {
    font-size: 16px;
}

.chat-resize {
    font-size: 14px;
}

.chat-minimize {
    font-size: 18px;
    font-weight: bold;
}

.chat-close {
    font-size: 20px;
    font-weight: bold;
}

/* Body styles */
.chat-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
}

/* Message styles */
.chat-message {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    animation: fadeInUp 0.3s ease;
}

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

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.assistant-message .message-avatar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.user-message .message-avatar {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.message-content {
    flex: 1;
    min-width: 0;
}

.message-body {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    padding: 12px 16px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 4px;
    border: 1px solid #e2e8f0;
    color: #374151;
}

.user-message .message-body {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: white !important;
    border: 1px solid #5a67d8 !important;
}

.assistant-message .message-body {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%) !important;
    border: 1px solid #0ea5e9 !important;
    color: #0c4a6e !important;
}

/* Additional specific selectors for pedagogy messages */
.pedagogy-chat .user-message .message-body {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: white !important;
    border: 1px solid #5a67d8 !important;
}

.pedagogy-chat .assistant-message .message-body {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%) !important;
    border: 1px solid #0ea5e9 !important;
    color: #0c4a6e !important;
}

/* Ensure pedagogy-specific message types also get proper styling */
.pedagogy-chat .pedagogy-intro-message .message-body,
.pedagogy-chat .pedagogy-response .message-body {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%) !important;
    border: 1px solid #0ea5e9 !important;
    color: #0c4a6e !important;
}

.message-timestamp {
    font-size: 11px;
    color: #666;
    padding: 0 4px;
}

/* Input area */
.chat-input-area {
    border-top: 1px solid #e0e0e0;
    background: white;
    padding: 16px;
}

.chat-input-container {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

#chat-input {
    flex: 1;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 8px 12px;
    resize: none;
    font-family: inherit;
    font-size: 14px;
    transition: border-color 0.2s ease;
}

#chat-input:focus {
    outline: none;
    border-color: #667eea;
}

.chat-send-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.chat-send-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chat-input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
}

.char-counter {
    font-size: 12px;
    color: #666;
}

.chat-actions {
    display: flex;
    gap: 8px;
}

.chat-action-btn {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    color: #666;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chat-action-btn:hover {
    background: #e9ecef;
    border-color: #ced4da;
}

/* Status bar */
.chat-status {
    background: #f8f9fa;
    border-top: 1px solid #e0e0e0;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #666;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 3px;
    background: #28a745;
}

.status-indicator.processing {
    background: #ffc107;
    animation: pulse 1s infinite;
}

.status-indicator.error {
    background: #dc3545;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Minimized state */
.pedagogy-chat.minimized {
    height: 60px;
    width: 300px;
    bottom: 20px;
    right: 20px;
    top: auto;
    left: auto;
}

.pedagogy-chat.minimized .chat-body,
.pedagogy-chat.minimized .chat-status {
    display: none;
}

.pedagogy-chat.minimized .draggable-header {
    border-radius: 12px;
}

/* Toast notifications */
.chat-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #333;
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 10002;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease;
}

.chat-toast.show {
    opacity: 1;
    transform: translateX(0);
}

.chat-toast-success {
    background: #28a745;
}

.chat-toast-error {
    background: #dc3545;
}

.chat-toast-info {
    background: #17a2b8;
}

/* Message type specific styles */
.pedagogy-intro-message {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 16px;
}

.pedagogy-intro-message h4 {
    margin: 0 0 12px 0;
    color: white;
}

.pedagogy-notice {
    background: rgba(255, 255, 255, 0.1);
    padding: 12px;
    border-radius: 8px;
    margin: 12px 0;
}

.pedagogy-response {
    background: #f8f9fa;
    border-left: 4px solid #667eea;
    padding: 16px;
    border-radius: 8px;
}

.error-message {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
    padding: 16px;
    border-radius: 8px;
}

.error-message h4 {
    color: #721c24;
    margin: 0 0 8px 0;
}

/* Responsive design */
@media (max-width: 768px) {
    .draggable-modal .chat-modal-content {
        width: 90vw;
        height: 80vh;
        max-width: 400px;
        max-height: 600px;
    }
    
    .drag-hint {
        display: none;
    }
    
    .chat-title h3 {
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .draggable-modal .chat-modal-content {
        width: 95vw;
        height: 85vh;
    }
    
    .chat-controls button {
        width: 24px;
        height: 24px;
        font-size: 12px;
    }
    
    .chat-messages {
        padding: 12px;
    }
    
    .chat-input-area {
        padding: 12px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .draggable-header {
        background: #000;
        border: 2px solid #fff;
    }
    
    .chat-modal-content {
        border: 3px solid #000;
    }
    
    .message-body {
        border: 1px solid #000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .chat-modal-content,
    .chat-controls button,
    .chat-toast,
    .chat-message {
        transition: none;
        animation: none;
    }
}

/* Rich Text Formatting Styles */

/* Typography enhancements */
.message-body h3,
.message-body h4,
.message-body h5 {
    margin: 0.8em 0 0.5em 0;
    font-weight: 600;
    line-height: 1.3;
}

.message-body h3 {
    font-size: 1.2em;
    color: #2563eb;
    border-bottom: 2px solid #e5e7eb;
    padding-bottom: 0.3em;
}

.message-body h4 {
    font-size: 1.1em;
    color: #1d4ed8;
}

.message-body h5 {
    font-size: 1em;
    color: #1e40af;
}

/* Text formatting */
.message-body strong {
    font-weight: 600;
    color: #1f2937;
}

.message-body em {
    font-style: italic;
    color: #374151;
}

/* Code formatting */
.message-body .inline-code {
    background: #f3f4f6;
    color: #dc2626;
    padding: 0.2em 0.4em;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9em;
    border: 1px solid #e5e7eb;
}

.message-body .code-block {
    background: #1f2937;
    color: #f9fafb;
    padding: 1em;
    border-radius: 8px;
    margin: 0.8em 0;
    overflow-x: auto;
    border: 1px solid #374151;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.message-body .code-block code {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9em;
    line-height: 1.4;
    color: inherit;
    background: none;
    padding: 0;
    border: none;
}

/* Lists */
.message-body ul,
.message-body ol {
    margin: 0.8em 0;
    padding-left: 1.5em;
}

.message-body li {
    margin: 0.3em 0;
    line-height: 1.5;
}

.message-body ul li {
    list-style-type: disc;
}

.message-body ol li {
    list-style-type: decimal;
}

/* Nested lists */
.message-body ul ul,
.message-body ol ol,
.message-body ul ol,
.message-body ol ul {
    margin: 0.2em 0;
}

.message-body ul ul li {
    list-style-type: circle;
}

.message-body ul ul ul li {
    list-style-type: square;
}

/* Tables */
.message-body .chat-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.8em 0;
    background: white;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.message-body .chat-table td {
    padding: 0.6em 0.8em;
    border: 1px solid #e5e7eb;
    vertical-align: top;
}

.message-body .chat-table tr:nth-child(even) {
    background: #f9fafb;
}

.message-body .chat-table tr:hover {
    background: #f3f4f6;
}

/* Blockquotes */
.message-body blockquote {
    margin: 0.8em 0;
    padding: 0.8em 1em;
    background: #f8fafc;
    border-left: 4px solid #3b82f6;
    border-radius: 0 6px 6px 0;
    font-style: italic;
    color: #475569;
}

/* Mathematics Display */
.message-body .math-inline {
    display: inline;
    margin: 0 0.2em;
}

.message-body .math-display {
    display: block;
    margin: 1em 0;
    text-align: center;
    padding: 0.8em;
    background: #fefefe;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    overflow-x: auto;
}

/* MathJax styling */
.message-body .MathJax {
    font-size: 1em !important;
}

.message-body .MathJax_Display {
    margin: 0.8em 0 !important;
}

/* Enhanced content sections */
.message-body .intro-message,
.message-body .scenario-presentation,
.message-body .question-message,
.message-body .response-acknowledgment,
.message-body .rationale-presentation,
.message-body .seed-questions-presentation,
.message-body .expectations-presentation,
.message-body .misconceptions-presentation,
.message-body .conclusion-presentation {
    margin: 0.5em 0;
}

.message-body .config-summary,
.message-body .scenario-summary,
.message-body .progress-summary {
    background: #f8fafc;
    padding: 0.8em;
    border-radius: 6px;
    margin: 0.8em 0;
    border: 1px solid #e2e8f0;
}

.message-body .config-item,
.message-body .scenario-item {
    margin: 0.3em 0;
    padding: 0.2em 0;
}

.message-body .scenario-type-description,
.message-body .question-prompt {
    background: #eff6ff;
    padding: 0.8em;
    border-radius: 6px;
    margin: 0.8em 0;
    border-left: 4px solid #3b82f6;
    font-style: italic;
}

/* Seed questions styling */
.message-body .seed-questions-list {
    margin: 0.8em 0;
}

.message-body .seed-question-item {
    display: flex;
    gap: 0.5em;
    margin: 0.5em 0;
    padding: 0.6em;
    background: #f8fafc;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    transition: background-color 0.2s ease;
}

.message-body .seed-question-item:hover {
    background: #f1f5f9;
}

.message-body .question-number {
    font-weight: 600;
    color: #3b82f6;
    min-width: 1.5em;
}

.message-body .question-text {
    flex: 1;
    line-height: 1.4;
}

/* Expectations and misconceptions */
.message-body .expectations-list,
.message-body .misconceptions-list {
    margin: 0.8em 0;
}

.message-body .expectation-item {
    margin: 0.4em 0;
    padding: 0.5em;
    background: #f0fdf4;
    border-radius: 4px;
    border-left: 3px solid #22c55e;
}

.message-body .misconception-item {
    margin: 0.4em 0;
    padding: 0.5em;
    background: #fef2f2;
    border-radius: 4px;
    border-left: 3px solid #ef4444;
}

/* Learning summary and next steps */
.message-body .learning-summary,
.message-body .next-steps {
    background: #f8fafc;
    padding: 1em;
    border-radius: 8px;
    margin: 1em 0;
    border: 1px solid #e2e8f0;
}

.message-body .learning-summary h5,
.message-body .next-steps h5 {
    margin: 0 0 0.5em 0;
    color: #1e40af;
    font-size: 1em;
}

/* Action buttons in chat */
.message-body .chat-actions-final {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5em;
    margin: 1em 0 0 0;
    justify-content: center;
}

.message-body .action-btn {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: white;
    border: none;
    padding: 0.6em 1em;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 500;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-block;
}

.message-body .action-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(59, 130, 246, 0.3);
}

/* Character conversation specific styles */
.message-body .character-intro-message,
.message-body .ai-character-notice {
    background: #fef3c7;
    padding: 0.8em;
    border-radius: 6px;
    margin: 0.8em 0;
    border-left: 4px solid #f59e0b;
}

.message-body .scenario-context,
.message-body .your-role-context,
.message-body .conversation-guidance {
    background: #f0f9ff;
    padding: 0.8em;
    border-radius: 6px;
    margin: 0.8em 0;
    border: 1px solid #bae6fd;
}

/* Character message styling */
.character-message .message-avatar {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    flex-direction: column;
    font-size: 10px;
    padding: 2px;
}

.character-avatar .character-icon {
    font-size: 14px;
}

.character-avatar .character-name {
    font-size: 8px;
    font-weight: 600;
    text-align: center;
    line-height: 1;
    margin-top: 1px;
}

.character-message .message-body {
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%) !important;
    border: 1px solid #10b981 !important;
    color: #064e3b !important;
}

/* Error and loading states */
.message-body .error-message {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
    padding: 1em;
    border-radius: 8px;
    margin: 0.8em 0;
}

.message-body .loading-message {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    color: #0c4a6e;
    padding: 1em;
    border-radius: 8px;
    margin: 0.8em 0;
    text-align: center;
}

.message-body .loading-indicator {
    margin: 0.5em 0;
}

.message-body .loading-dots {
    animation: loadingDots 1.5s infinite;
    font-size: 1.2em;
}

@keyframes loadingDots {
    0%, 20% { opacity: 0; }
    50% { opacity: 1; }
    80%, 100% { opacity: 0; }
}

/* Responsive typography */
@media (max-width: 768px) {
    .message-body {
        font-size: 14px;
        line-height: 1.5;
    }
    
    .message-body h3 {
        font-size: 1.1em;
    }
    
    .message-body h4 {
        font-size: 1em;
    }
    
    .message-body .code-block {
        font-size: 0.8em;
        padding: 0.8em;
    }
    
    .message-body .chat-table {
        font-size: 0.9em;
    }
    
    .message-body .chat-table td {
        padding: 0.4em 0.6em;
    }
    
    .message-body .chat-actions-final {
        flex-direction: column;
    }
    
    .message-body .action-btn {
        width: 100%;
        text-align: center;
    }
}

/* Print styles */
@media print {
    .message-body .action-btn,
    .message-body .chat-actions-final {
        display: none;
    }
    
    .message-body {
        background: white !important;
        border: 1px solid #000 !important;
        color: #000 !important;
    }
    
    .message-body .code-block {
        background: #f5f5f5 !important;
        color: #000 !important;
        border: 1px solid #000 !important;
    }
}

/* Dark mode support (if implemented) */
@media (prefers-color-scheme: dark) {
    .message-body .inline-code {
        background: #374151;
        color: #fbbf24;
        border-color: #4b5563;
    }
    
    .message-body .code-block {
        background: #111827;
        color: #f3f4f6;
        border-color: #374151;
    }
    
    .message-body .chat-table {
        background: #1f2937;
        color: #f3f4f6;
    }
    
    .message-body .chat-table td {
        border-color: #374151;
    }
    
    .message-body .chat-table tr:nth-child(even) {
        background: #374151;
    }
    
    .message-body blockquote {
        background: #374151;
        color: #d1d5db;
        border-left-color: #60a5fa;
    }
    
    .message-body .math-display {
        background: #1f2937;
        border-color: #374151;
        color: #f3f4f6;
    }
}

/* Accessibility improvements */
.message-body .inline-code,
.message-body .code-block {
    font-feature-settings: "liga" 0; /* Disable ligatures for better readability */
}

.message-body .action-btn:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.message-body .seed-question-item:focus-within {
    outline: 2px solid #3b82f6;
    outline-offset: 1px;
}

/* High contrast mode enhancements */
@media (prefers-contrast: high) {
    .message-body .inline-code {
        background: #000;
        color: #fff;
        border: 2px solid #fff;
    }
    
    .message-body .code-block {
        background: #000;
        color: #fff;
        border: 2px solid #fff;
    }
    
    .message-body .chat-table {
        border: 2px solid #000;
    }
    
    .message-body .chat-table td {
        border: 1px solid #000;
    }
    
    .message-body blockquote {
        background: #fff;
        color: #000;
        border-left: 4px solid #000;
    }
}

/* Mathematics Input Pad Styles */
.input-controls {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.math-toggle-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 18px;
}

.math-toggle-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.math-toggle-btn.active {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.math-input-pad {
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    margin-top: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: all 0.3s ease;
}

.math-input-pad.hidden {
    display: none;
}

.math-pad-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.math-pad-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.math-pad-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.2s ease;
}

.math-pad-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.math-preview-container {
    padding: 12px 16px;
    background: #f8fafc;
    border-bottom: 1px solid #e5e7eb;
}

.math-preview-container label {
    font-size: 12px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 4px;
    display: block;
}

.math-preview {
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 8px 12px;
    min-height: 40px;
    font-family: 'Times New Roman', serif;
    font-size: 16px;
    display: flex;
    align-items: center;
    color: #1f2937;
}

.math-categories {
    display: flex;
    background: #f3f4f6;
    border-bottom: 1px solid #e5e7eb;
    overflow-x: auto;
}

.math-category-btn {
    background: none;
    border: none;
    padding: 8px 16px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #6b7280;
    white-space: nowrap;
    transition: all 0.2s ease;
    border-bottom: 2px solid transparent;
}

.math-category-btn:hover {
    background: #e5e7eb;
    color: #374151;
}

.math-category-btn.active {
    background: white;
    color: #667eea;
    border-bottom-color: #667eea;
}

.math-symbols-container {
    padding: 16px;
    max-height: 200px;
    overflow-y: auto;
}

.math-symbols-group {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    gap: 8px;
}

.math-symbols-group.hidden {
    display: none;
}

.math-symbol-btn {
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 8px;
    cursor: pointer;
    font-size: 16px;
    font-family: 'Times New Roman', serif;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    color: #1f2937;
}

.math-symbol-btn:hover {
    background: #f3f4f6;
    border-color: #667eea;
    transform: scale(1.05);
}

.math-symbol-btn:active {
    background: #667eea;
    color: white;
    transform: scale(0.95);
}

.math-pad-actions {
    padding: 12px 16px;
    background: #f8fafc;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.math-action-btn {
    background: #667eea;
    border: none;
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.math-action-btn:hover {
    background: #5a67d8;
    transform: translateY(-1px);
}

.math-action-btn:active {
    transform: translateY(0);
}

.math-action-btn#math-clear {
    background: #ef4444;
}

.math-action-btn#math-clear:hover {
    background: #dc2626;
}

.math-action-btn#math-undo {
    background: #f59e0b;
}

.math-action-btn#math-undo:hover {
    background: #d97706;
}

.math-action-btn#math-insert {
    background: #10b981;
}

.math-action-btn#math-insert:hover {
    background: #059669;
}

/* Custom scrollbar for math symbols */
.math-symbols-container::-webkit-scrollbar {
    width: 6px;
}

.math-symbols-container::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}

.math-symbols-container::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.math-symbols-container::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Responsive math pad */
@media (max-width: 768px) {
    .math-symbols-group {
        grid-template-columns: repeat(auto-fill, minmax(45px, 1fr));
        gap: 6px;
    }
    
    .math-symbol-btn {
        padding: 6px;
        font-size: 14px;
        min-height: 36px;
    }
    
    .math-categories {
        font-size: 12px;
    }
    
    .math-category-btn {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .math-pad-actions {
        padding: 8px 12px;
    }
    
    .math-action-btn {
        font-size: 11px;
        padding: 5px 10px;
    }
}

/* Math preview with MathJax support */
.math-preview .MathJax {
    font-size: 1.2em !important;
}

.math-preview .MathJax_Display {
    margin: 0 !important;
}

/* Animation for math pad */
.math-input-pad {
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Math input state indicators */
.math-toggle-btn .math-icon {
    transition: transform 0.2s ease;
}

.math-toggle-btn.active .math-icon {
    transform: rotate(180deg);
}

/* Accessibility improvements for math pad */
.math-symbol-btn:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

.math-category-btn:focus {
    outline: 2px solid #667eea;
    outline-offset: -2px;
}

.math-action-btn:focus {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

/* High contrast mode for math pad */
@media (prefers-contrast: high) {
    .math-input-pad {
        border: 3px solid #000;
    }
    
    .math-symbol-btn {
        border: 2px solid #000;
        background: #fff;
        color: #000;
    }
    
    .math-symbol-btn:hover {
        background: #000;
        color: #fff;
    }
    
    .math-preview {
        border: 2px solid #000;
        background: #fff;
        color: #000;
    }
}
