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

/* Main chat container */
.chat-card {
    width: 480px;
    max-width: 100%;
    border: none;
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(59, 130, 246, 0.15);
    overflow: hidden;
    background: white;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Header styling */
.chat-card .adiv {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    border-radius: 20px 20px 0 0;
    font-size: 16px;
    font-weight: 600;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    padding: 0 20px;
    box-shadow: 0 2px 10px rgba(59, 130, 246, 0.2);
}

.chat-card .adiv span {
    flex: 1;
    text-align: center;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.chat-card .adiv i {
    cursor: pointer;
    transition: opacity 0.2s ease;
    padding: 8px;
    border-radius: 50%;
}

.chat-card .adiv i:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Chat messages container */
.chat-messages {
    overflow-y: auto;
    height: 400px;
    max-height: 400px;
    padding: 16px;
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    scrollbar-width: thin;
    scrollbar-color: #3b82f6 transparent;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #3b82f6;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #1d4ed8;
}

/* Message bubbles */
.chat-messages .d-flex {
    margin-bottom: 16px;
    align-items: flex-end;
}

/* AI Assistant messages */
.chat-messages .d-flex:has(img[src*="female"]) .chat {
    background: white;
    color: #1e293b;
    border: 1px solid #e1e7ef;
    border-radius: 18px 18px 18px 4px;
    padding: 12px 16px;
    font-size: 14px;
    line-height: 1.5;
    max-width: 320px;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.1);
    position: relative;
}

.chat-messages .d-flex:has(img[src*="female"]) .chat::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: -6px;
    width: 12px;
    height: 12px;
    background: white;
    border: 1px solid #e1e7ef;
    border-top: none;
    border-right: none;
    transform: rotate(-45deg);
}

/* User messages */
.chat-messages .d-flex:has(img[src*="male"]) {
    flex-direction: row-reverse;
}

.chat-messages .d-flex:has(img[src*="male"]) .bg-white {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%) !important;
    color: white;
    border-radius: 18px 18px 4px 18px;
    padding: 12px 16px;
    font-size: 14px;
    line-height: 1.5;
    max-width: 320px;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
    margin-left: auto;
    margin-right: 8px;
    position: relative;
}

.chat-messages .d-flex:has(img[src*="male"]) .bg-white::before {
    content: '';
    position: absolute;
    bottom: 0;
    right: -6px;
    width: 12px;
    height: 12px;
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    transform: rotate(45deg);
}

/* Avatar styling */
.chat-messages img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    margin: 0 8px;
    flex-shrink: 0;
}

/* Typing indicator */
.typing-indicator-box {
    display: flex;
    align-items: flex-end;
    padding: 0 16px;
    margin-bottom: 16px;
}

.typing-indicator {
    background: white;
    border: 1px solid #e1e7ef;
    border-radius: 18px 18px 18px 4px;
    padding: 12px 16px;
    margin-left: 8px;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.1);
    position: relative;
}

.typing-indicator::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: -6px;
    width: 12px;
    height: 12px;
    background: white;
    border: 1px solid #e1e7ef;
    border-top: none;
    border-right: none;
    transform: rotate(-45deg);
}

.typing-indicator .dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #3b82f6;
    margin: 0 2px;
    animation: typing 1.4s infinite ease-in-out;
}

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

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Input area */
.chat-card .form-group {
    padding: 16px 20px 20px;
    background: white;
    border-top: 1px solid #e1e7ef;
}

.chat-card .form-control {
    border: 2px solid #e1e7ef;
    border-radius: 24px;
    padding: 12px 20px;
    font-size: 14px;
    line-height: 1.5;
    transition: all 0.2s ease;
    background: #f8fafc;
    resize: none;
    flex: 1;
}

.chat-card .form-control:focus {
    outline: none;
    border-color: #3b82f6;
    background: white;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.chat-card .form-control::placeholder {
    color: #94a3b8;
    font-size: 14px;
}

.chat-card .send-btn {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    margin-left: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
}

.chat-card .send-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.5);
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
}

.chat-card .send-btn:active {
    transform: translateY(0);
}

.chat-card .send-btn svg {
    fill: white;
    width: 18px;
    height: 18px;
}

/* Course promotion cards */
.chat-messages .card {
    border: 1px solid #e1e7ef;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.1);
    margin: 16px 0;
    max-width: 360px;
    background: white;
}

.chat-messages .card img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    border: none;
    border-radius: 0;
    margin: 0;
    box-shadow: none;
}

.chat-messages .card-body {
    padding: 16px;
}

.chat-messages .card-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #1f2937;
}

.chat-messages .card-text {
    font-size: 14px;
    line-height: 1.5;
    color: #6b7280;
    margin-bottom: 8px;
}

.chat-messages .button {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    display: inline-block;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(59, 130, 246, 0.3);
}

.chat-messages .button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
    text-decoration: none;
    color: white;
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
}

/* Responsive design */
@media (max-width: 576px) {
    .chat-card {
        width: 100%;
        max-width: 100%;
        border-radius: 12px;
        position: relative;
        margin-bottom: 20px;
    }
    
    .chat-card .adiv {
        border-radius: 12px 12px 0 0;
        font-size: 14px;
        height: 50px;
        padding: 0 16px;
    }
    
    .chat-messages {
        height: 300px;
        max-height: 300px;
        padding: 12px;
    }
    
    .chat-card .form-group {
        padding: 12px 16px 16px;
    }
    
    .chat-card .form-control {
        padding: 10px 16px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .chat-card .send-btn {
        width: 40px;
        height: 40px;
        margin-left: 8px;
    }
    
    .chat-card .send-btn svg {
        width: 16px;
        height: 16px;
    }
    
    /* Make messages more compact on mobile */
    .chat-messages .d-flex {
        margin-bottom: 12px;
    }
    
    .chat-messages .chat,
    .chat-messages .bg-white {
        max-width: 260px;
        font-size: 13px;
        padding: 10px 14px;
    }
    
    .chat-messages img {
        width: 28px;
        height: 28px;
        margin: 0 6px;
    }
    
    /* Course promotion cards on mobile */
    .chat-messages .card {
        max-width: 280px;
    }
    
    .chat-messages .card img {
        height: 100px;
    }
    
    .chat-messages .card-body {
        padding: 12px;
    }
    
    .chat-messages .card-title {
        font-size: 14px;
    }
    
    .chat-messages .card-text {
        font-size: 13px;
    }
}

/* Extra small screens */
@media (max-width: 375px) {
    .chat-messages {
        height: 250px;
        max-height: 250px;
    }
    
    .chat-messages .chat,
    .chat-messages .bg-white {
        max-width: 220px;
    }
    
    .chat-messages .card {
        max-width: 240px;
    }
}

/* Animation for new messages */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-messages .d-flex {
    animation: fadeInUp 0.3s ease;
}
