@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ================== CHATBOT CONTAINER ================== */
#chatbot-container {
    position: relative;
    z-index: 10000;
}

/* Prevent backdrop-filter inheritance for all chatbot elements */
#chatbot-container,
#chatbot-container *,
#jee-chatbot,
#jee-chatbot *,
.chatbot-window,
.chatbot-window *,
.chatbot-header,
.chatbot-header *,
#chatbot-messages,
#chatbot-messages *,
.chatbot-input,
.chatbot-input *,
.message,
.message * {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

/* ================== CHATBOT ICON ================== */
#chatbot-icon {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(16, 185, 129, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10001;
    font-size: 0;
    overflow: hidden;
    border: 3px solid rgba(255, 255, 255, 0.2);
}

#chatbot-icon::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.3) 0%, transparent 70%);
    transform: translate(-50%, -50%) scale(0);
    transition: transform 0.3s ease;
}

#chatbot-icon:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 12px 32px rgba(16, 185, 129, 0.6);
}

#chatbot-icon:hover::before {
    transform: translate(-50%, -50%) scale(1);
}

#chatbot-icon:active {
    transform: scale(0.95);
}

#chatbot-icon img {
    width: 32px;
    height: 32px;
    filter: brightness(0) invert(1);
    position: relative;
    z-index: 1;
}

/* Pulsing animation for attention */
#chatbot-icon.pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 8px 24px rgba(16, 185, 129, 0.4);
    }
    50% {
        box-shadow: 0 8px 24px rgba(16, 185, 129, 0.8), 0 0 0 10px rgba(16, 185, 129, 0.1);
    }
}

/* ================== CHATBOT WINDOW ================== */
#chatbot-window {
    position: fixed;
    bottom: 9rem;
    right: 2rem;
    width: min(95vw, 420px);
    height: min(80vh, 600px);
    background: #ffffff;
    border-radius: 24px;
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.15),
        0 0 0 1px rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    z-index: 10000;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

#chatbot-window:not([hidden]) {
    opacity: 1;
    transform: translateY(0) scale(1);
}

#chatbot-window[hidden] {
    display: none;
}

/* ================== CHATBOT HEADER ================== */
.chatbot-header {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top-left-radius: 24px;
    border-top-right-radius: 24px;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
    min-height: 60px;
}

.chatbot-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, rgba(255, 255, 255, 0.1) 0%, transparent 100%);
    pointer-events: none;
}

.chatbot-header h3 {
    font-weight: 700;
    font-size: 1.2rem;
    margin: 0;
    color: white !important;
    background: none !important;
    -webkit-text-fill-color: white !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    position: relative;
    z-index: 1;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#close-chatbot {
    cursor: pointer;
    font-size: 24px;
    font-weight: 300;
    background: rgba(255, 255, 255, 0.15) !important;
    border: none;
    color: white !important;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    position: relative;
    z-index: 1;
    flex-shrink: 0;
    line-height: 1;
}

#close-chatbot:hover {
    background: rgba(255, 255, 255, 0.25) !important;
    transform: scale(1.1);
}

#close-chatbot:active {
    transform: scale(0.9);
}

/* ================== CHATBOT MESSAGES ================== */
#chatbot-messages {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: linear-gradient(to bottom, #f8fafc 0%, #f1f5f9 100%);
    scrollbar-width: thin;
    scrollbar-color: rgba(16, 185, 129, 0.3) transparent;
    min-height: 0;
}

#chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

#chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

#chatbot-messages::-webkit-scrollbar-thumb {
    background: rgba(16, 185, 129, 0.3);
    border-radius: 10px;
}

#chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(16, 185, 129, 0.5);
}

/* ================== MESSAGE STYLES ================== */
.message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    line-height: 1.5;
    font-size: 14px;
    position: relative;
    animation: slideIn 0.3s ease-out;
}

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

.message.user {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.message.bot {
    background: white;
    color: #1f2937;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.message.typing {
    font-style: italic;
    opacity: 0.8;
    background: #e5e7eb;
    color: #6b7280;
    animation: pulse 1.5s infinite;
}

.typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.typing-indicator::after {
    content: '';
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: currentColor;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-indicator::before {
    content: '';
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: currentColor;
    animation: typing 1.4s infinite ease-in-out -0.2s;
    margin-right: 2px;
}

@keyframes typing {
    0%, 80%, 100% {
        opacity: 0.3;
        transform: scale(0.8);
    }
    40% {
        opacity: 1;
        transform: scale(1);
    }
}

/* ================== SPECIAL CONTENT STYLING ================== */
.answer-heading {
    font-weight: 700;
    color: #059669;
    font-size: 16px;
    margin: 16px 0 12px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid rgba(5, 150, 105, 0.2);
    text-align: center;
}

.answer-content {
    background: #f0fdf4;
    border: 1px solid rgba(5, 150, 105, 0.2);
    padding: 16px;
    border-radius: 12px;
    line-height: 1.6;
    font-size: 14px;
    color: #1f2937;
    margin: 8px 0;
}

.key-tip {
    color: #dc2626;
    font-weight: 600;
    margin: 12px 0;
    padding: 12px 16px;
    border-left: 4px solid #dc2626;
    background: linear-gradient(to right, #fef2f2, #fef7f7);
    border-radius: 0 8px 8px 0;
    font-size: 13px;
    box-shadow: 0 2px 4px rgba(220, 38, 38, 0.1);
}

/* ================== CHATBOT INPUT ================== */
.chatbot-input {
    padding: 20px 24px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    display: flex;
    gap: 12px;
    background: white;
    align-items: flex-end;
    flex-shrink: 0;
}

#chatbot-input {
    flex: 1;
    border: 2px solid #e5e7eb;
    border-radius: 24px;
    padding: 12px 20px;
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    outline: none;
    transition: all 0.2s ease;
    resize: none;
    min-height: 20px;
    max-height: 100px;
    background: #f9fafb;
}

#chatbot-input:focus {
    border-color: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
    background: white;
}

#chatbot-input::placeholder {
    color: #9ca3af;
    font-weight: 400;
}

#send-message {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
    flex-shrink: 0;
}

#send-message:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4);
}

#send-message:active {
    transform: scale(0.95);
}

#send-message:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ================== RESPONSIVE DESIGN ================== */
@media (max-width: 768px) {
    #chatbot-icon {
        bottom: 1.5rem;
        right: 1.5rem;
        width: 56px;
        height: 56px;
    }

    #chatbot-icon img {
        width: 28px;
        height: 28px;
    }

    #chatbot-window {
        bottom: 7rem;
        right: 1rem;
        left: 1rem;
        width: auto;
        height: min(85vh, 500px);
        border-radius: 20px;
    }

    .chatbot-header {
        padding: 20px 24px;
        border-radius: 20px 20px 0 0;
        min-height: 65px;
    }

    .chatbot-header h3 {
        font-size: 1.1rem;
    }

    #close-chatbot {
        width: 32px;
        height: 32px;
        font-size: 20px;
    }

    #chatbot-messages {
        padding: 20px;
        gap: 12px;
    }

    .message {
        max-width: 90%;
        font-size: 13px;
        padding: 10px 14px;
    }

    .chatbot-input {
        padding: 16px 20px;
    }

    #chatbot-input {
        padding: 10px 16px;
        font-size: 14px;
    }

    #send-message {
        width: 40px;
        height: 40px;
    }
}

@media (max-width: 480px) {
    #chatbot-window {
        height: min(90vh, 450px);
        border-radius: 16px;
    }

    .chatbot-header {
        padding: 14px 16px;
        border-radius: 16px 16px 0 0;
        min-height: 52px;
    }

    .chatbot-header h3 {
        font-size: 1rem;
    }

    #close-chatbot {
        width: 28px;
        height: 28px;
        font-size: 18px;
    }

    #chatbot-messages {
        padding: 16px;
    }

    .answer-heading {
        font-size: 14px;
    }

    .key-tip {
        font-size: 12px;
        padding: 10px 12px;
    }
}

/* ================== ACCESSIBILITY ================== */
@media (prefers-reduced-motion: reduce) {
    #chatbot-icon,
    #chatbot-window,
    .message,
    #send-message,
    #close-chatbot {
        animation: none;
        transition: none;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .message.bot {
        border: 2px solid #000;
    }
    
    #chatbot-input {
        border: 2px solid #000;
    }
}

/* ================== MERMAID DIAGRAM STYLES ================== */
.mermaid-diagram {
    margin: 12px 0;
    padding: 16px;
    background: #f8fafc;
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: 12px;
    text-align: center;
    overflow-x: auto;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.mermaid-diagram svg {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    background: white;
    padding: 8px;
}

.mermaid-error {
    color: #dc2626;
    font-style: italic;
    padding: 12px;
    background: #fef2f2;
    border: 1px solid #fca5a5;
    border-radius: 8px;
    font-size: 13px;
}

.mermaid-loading {
    color: #6b7280;
    font-style: italic;
    padding: 12px;
    text-align: center;
    animation: pulse 1.5s infinite;
}

/* Mermaid diagram specific styling for small chatbot window */
.mermaid-diagram .node rect {
    stroke: #10b981 !important;
    stroke-width: 2px !important;
}

.mermaid-diagram .node .label {
    font-family: 'Inter', sans-serif !important;
    font-size: 12px !important;
    font-weight: 500 !important;
}

.mermaid-diagram .edgePath path {
    stroke: #059669 !important;
    stroke-width: 2px !important;
}

.mermaid-diagram .arrowheadPath {
    fill: #059669 !important;
    stroke: #059669 !important;
}

/* Responsive adjustments for mobile */
@media (max-width: 480px) {
    .mermaid-diagram {
        padding: 12px;
        margin: 8px 0;
    }
    
    .mermaid-diagram svg {
        padding: 4px;
    }
    
    .mermaid-diagram .node .label {
        font-size: 10px !important;
    }
}



/* Chatbot Category Styles */
/* ================== CATEGORY SELECTOR ================== */
.category-selector {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
    backdrop-filter: blur(4px);
    border-radius: inherit;
}

.category-content {
    background: white;
    padding: 20px;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    max-width: 320px;
    width: 90%;
    max-height: 80%;
    overflow-y: auto;
}

.category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid #f3f4f6;
}

.category-header h4 {
    margin: 0;
    color: #1f2937;
    font-size: 16px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
}

#close-categories {
    background: #f3f4f6 !important;
    border: none !important;
    width: 28px !important;
    height: 28px !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    color: #6b7280 !important;
    font-size: 16px !important;
    line-height: 1 !important;
    transition: all 0.2s ease !important;
    flex-shrink: 0;
    padding: 0 !important;
}

#close-categories:hover {
    background: #e5e7eb !important;
    color: #374151 !important;
    transform: scale(1.1);
}

.category-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.category-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    background: #f9fafb;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    font-family: 'Inter', sans-serif;
    width: 100%;
}

.category-btn:hover {
    background: #f0fdf4;
    border-color: #10b981;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.15);
}

.category-icon {
    font-size: 20px;
    flex-shrink: 0;
    width: 24px;
    text-align: center;
}

.category-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.category-text strong {
    color: #1f2937;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 1px;
}

.category-text small {
    color: #6b7280;
    font-size: 11px;
    font-weight: 400;
    line-height: 1.3;
}

/* Mobile responsiveness */
@media (max-width: 480px) {
    .category-content {
        padding: 16px;
        max-width: 280px;
    }
    
    .category-header h4 {
        font-size: 14px;
    }
    
    .category-btn {
        padding: 12px;
        gap: 10px;
    }
    
    .category-text strong {
        font-size: 12px;
    }
    
    .category-text small {
        font-size: 10px;
    }
}