/* Mathematics Today Custom Styles */

html {
    scroll-behavior: smooth;
}

body {
    background-color: #f8fafc;
    background-image: radial-gradient(#cbd5e1 1px, transparent 1px);
    background-size: 20px 20px;
}

/* Glassmorphism Panel */
.glass-panel {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.8);
}

/* AI Quick Answer Box Styling */
.quick-answer {
    position: relative;
    overflow: hidden;
}
.quick-answer::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 4px; height: 100%;
    background: #4f46e5; /* Indigo 600 */
}

/* Canvas crisp rendering */
canvas {
    image-rendering: -moz-crisp-edges;
    image-rendering: -webkit-crisp-edges;
    image-rendering: crisp-edges;
}

/* ===== AI CHAT WIDGET ===== */
.ai-chat-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.ai-chat-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: white;
    border: none;
    padding: 14px 22px;
    border-radius: 50px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    box-shadow: 0 8px 32px rgba(79, 70, 229, 0.4);
    transition: all 0.3s ease;
}
.ai-chat-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(79, 70, 229, 0.5);
}
.ai-icon { width: 24px; height: 24px; }

@keyframes pulse-ring {
    0% { box-shadow: 0 0 0 0 rgba(79, 70, 229, 0.5); }
    70% { box-shadow: 0 0 0 14px rgba(79, 70, 229, 0); }
    100% { box-shadow: 0 0 0 0 rgba(79, 70, 229, 0); }
}
.pulse-ai { animation: pulse-ring 2.5s infinite; }

.ai-chat-box {
    display: none;
    flex-direction: column;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 520px;
    max-height: calc(100vh - 100px);
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15), 0 0 0 1px rgba(0,0,0,0.05);
    overflow: hidden;
    position: absolute;
    bottom: 0;
    right: 0;
}

.ai-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: white;
}
.ai-chat-header-info { display: flex; flex-direction: column; }
.ai-chat-title { font-weight: 700; font-size: 16px; }
.ai-chat-subtitle { font-size: 12px; opacity: 0.85; display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.ai-chat-online {
    width: 8px; height: 8px;
    background: #34d399;
    border-radius: 50%;
    display: inline-block;
    animation: blink-dot 1.5s infinite;
}
@keyframes blink-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}
.ai-chat-close {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 32px; height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.ai-chat-close:hover { background: rgba(255,255,255,0.35); }

.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f8fafc;
}

.ai-msg {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 16px;
    margin-bottom: 10px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    animation: msg-in 0.3s ease;
}
@keyframes msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.ai-msg-user {
    background: linear-gradient(135deg, #4f46e5, #6366f1);
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}
.ai-msg-bot {
    background: white;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
}

.ai-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}
.ai-quick-btn {
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    color: #4338ca;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}
.ai-quick-btn:hover {
    background: #4f46e5;
    color: white;
    border-color: #4f46e5;
}

.typing-indicator {
    display: flex;
    gap: 5px;
    padding: 12px 16px;
    max-width: 70px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    margin-bottom: 10px;
}
.typing-indicator span {
    width: 8px; height: 8px;
    background: #94a3b8;
    border-radius: 50%;
    animation: typing-bounce 1.4s infinite ease-in-out;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

.ai-chat-input-area {
    display: flex;
    padding: 12px 16px;
    border-top: 1px solid #e2e8f0;
    background: white;
    gap: 8px;
}
.ai-chat-input-area input {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}
.ai-chat-input-area input:focus { border-color: #4f46e5; }
.ai-chat-send {
    background: #4f46e5;
    color: white;
    border: none;
    width: 42px; height: 42px;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.ai-chat-send:hover { background: #4338ca; }
.ai-chat-send:disabled { opacity: 0.5; cursor: not-allowed; }

.ai-chat-footer {
    text-align: center;
    font-size: 11px;
    color: #94a3b8;
    padding: 8px;
    background: #f8fafc;
    border-top: 1px solid #f1f5f9;
}

/* ===== COMMENT SYSTEM ===== */
.comments-section {
    max-width: 800px;
    margin: 3rem auto;
    padding: 0 1rem;
}
.comments-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #e2e8f0;
}
.comments-header h3 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0;
}
.comments-header span {
    font-size: 0.85rem;
    color: #64748b;
    background: #f1f5f9;
    padding: 4px 12px;
    border-radius: 20px;
}

.comment-form {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 2rem;
}
.comment-form input,
.comment-form textarea {
    width: 100%;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 12px 16px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
    margin-bottom: 12px;
    box-sizing: border-box;
    background: white;
}
.comment-form input:focus,
.comment-form textarea:focus { border-color: #4f46e5; }
.comment-form textarea { resize: vertical; min-height: 100px; }

.comment-form button {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: white;
    border: none;
    padding: 12px 28px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.comment-form button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(79, 70, 229, 0.3);
}
.comment-form button:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.comment-alert {
    display: none;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 12px;
}
.comment-alert-error { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.comment-alert-success { background: #f0fdf4; color: #16a34a; border: 1px solid #bbf7d0; }

.comment-item {
    display: flex;
    gap: 14px;
    padding: 16px 0;
    border-bottom: 1px solid #f1f5f9;
    animation: msg-in 0.3s ease;
}
.comment-item:last-child { border-bottom: none; }

.comment-avatar {
    width: 42px; height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    flex-shrink: 0;
}
.comment-body { flex: 1; min-width: 0; }
.comment-meta { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.comment-author { color: #1e293b; font-size: 14px; }
.comment-date { font-size: 12px; color: #94a3b8; }
.comment-text { font-size: 14px; color: #475569; line-height: 1.6; margin: 0; }
.no-comments { text-align: center; color: #94a3b8; font-size: 15px; padding: 2rem 0; }

/* Mobile responsive */
@media (max-width: 480px) {
    .ai-chat-container { bottom: 12px; right: 12px; }
    .ai-chat-box { width: calc(100vw - 24px); height: calc(100vh - 80px); }
    .ai-chat-toggle { padding: 12px 18px; font-size: 14px; }
    .ai-toggle-text { display: none; }
}
