/* Chat Widget Styles */
.chat-widget {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 9999;
    font-family: 'Vazirmatn', 'Inter', 'Poppins', 'Roboto', sans-serif;
}

[dir="rtl"] .chat-widget {
    left: auto;
    right: 20px;
}

.chat-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(30, 58, 138, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: relative;
}

.chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(30, 58, 138, 0.5);
}

.chat-button i {
    font-size: 24px;
    color: white;
}

.chat-button .badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
}

[dir="rtl"] .chat-button .badge {
    right: auto;
    left: -5px;
}

.chat-container {
    position: fixed;
    bottom: 90px;
    left: 20px;
    width: 380px;
    height: 600px;
    max-height: 80vh;
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 9998;
}

[dir="rtl"] .chat-container {
    left: auto;
    right: 20px;
}

.chat-container.active {
    display: flex;
    animation: slideUp 0.3s ease;
}

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

.chat-header {
    background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 20px 20px 0 0;
}

.chat-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: white;
}

.chat-header .close-btn,
.chat-header .header-btn {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.chat-header .close-btn:hover,
.chat-header .header-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f9fafb;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.chat-message {
    display: flex;
    gap: 10px;
    animation: fadeIn 0.3s ease;
}

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

.chat-message.user {
    flex-direction: row-reverse;
}

[dir="rtl"] .chat-message.user {
    flex-direction: row;
}

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

.chat-message.user .avatar {
    background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
    color: white;
}

.chat-message.assistant .avatar {
    background: #e5e7eb;
    color: #1e3a8a;
}

.chat-message .content {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    line-height: 1.5;
}

.chat-message.user .content {
    background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

[dir="rtl"] .chat-message.user .content {
    border-bottom-right-radius: 18px;
    border-bottom-left-radius: 4px;
}

.chat-message.assistant .content {
    background: white;
    color: #1f2937;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
}

[dir="rtl"] .chat-message.assistant .content {
    border-bottom-left-radius: 18px;
    border-bottom-right-radius: 4px;
}

.chat-input-container {
    padding: 15px 20px;
    background: white;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 10px;
    align-items: center;
}

.chat-input-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.chat-input {
    width: 100%;
    padding: 10px 16px 10px 50px;
    border: 2px solid #e5e7eb;
    border-radius: 25px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 120px;
    transition: border-color 0.2s;
    line-height: 1.5;
    box-sizing: border-box;
    overflow-y: auto;
    min-height: 40px;
}

[dir="rtl"] .chat-input {
    padding: 10px 50px 10px 16px;
    text-align: right;
    direction: rtl;
}

.chat-input:focus {
    outline: none;
    border-color: #3b82f6;
}

.chat-send-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    left: 6px;
    background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    margin: 0;
    padding: 0;
    z-index: 10;
    pointer-events: auto;
}

[dir="rtl"] .chat-send-btn {
    left: auto;
    right: 6px;
    transform: translateY(-50%) scaleX(-1);
}

.chat-send-btn i {
    font-size: 14px;
}

.chat-send-btn:hover {
    transform: scale(1.1);
}

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

.chat-loading {
    display: flex;
    gap: 5px;
    padding: 12px 16px;
}

.chat-loading span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #9ca3af;
    animation: bounce 1.4s infinite ease-in-out both;
}

.chat-loading span:nth-child(1) {
    animation-delay: -0.32s;
}

.chat-loading span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

.chat-empty {
    text-align: center;
    color: #9ca3af;
    padding: 40px 20px;
    font-size: 14px;
}

/* Fullscreen Mode */
.chat-container.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    bottom: 0 !important;
}

[dir="rtl"] .chat-container.fullscreen {
    left: 0;
    right: 0;
}

/* College Card Styles in Chat */
.college-card-chat {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 10px;
    margin: 8px 0;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.college-card-chat:hover {
    border-color: #3b82f6;
    box-shadow: 0 2px 6px rgba(59, 130, 246, 0.2);
    transform: translateY(-1px);
}

.college-card-image {
    width: 80px;
    height: 80px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
    background: #f3f4f6;
}

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

.college-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    padding-bottom: 6px;
    border-bottom: 1px solid #e5e7eb;
}

.college-card-header h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #1e3a8a;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.college-card-header i {
    color: #3b82f6;
    font-size: 12px;
    margin-right: 4px;
    flex-shrink: 0;
}

[dir="rtl"] .college-card-header i {
    transform: scaleX(-1);
    margin-right: 0;
    margin-left: 4px;
}

.college-card-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 6px;
}

.college-card-info {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #4b5563;
    line-height: 1.4;
}

.college-card-info i {
    color: #3b82f6;
    width: 14px;
    font-size: 11px;
    flex-shrink: 0;
}

.college-card-footer {
    display: flex;
    justify-content: flex-end;
    padding-top: 6px;
    border-top: 1px solid #e5e7eb;
}

.college-card-footer span {
    color: #3b82f6;
    font-size: 12px;
    font-weight: 500;
}

/* Chat Link Styles */
.chat-link {
    color: #3b82f6;
    text-decoration: underline;
    transition: color 0.2s;
}

.chat-link:hover {
    color: #1e3a8a;
}

/* Markdown Styles in Chat */
.chat-message .content strong {
    font-weight: 700;
    color: #1e3a8a;
}

.chat-message .content em {
    font-style: italic;
    color: #4b5563;
}

.chat-message .content h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 12px 0 8px 0;
    color: #1e3a8a;
}

.chat-message .content h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 10px 0 6px 0;
    color: #1e3a8a;
}

.chat-message .content h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 8px 0 4px 0;
    color: #1e3a8a;
}

.chat-message .content ul {
    margin: 8px 0;
    padding-right: 20px;
    list-style-type: disc;
}

.chat-message .content li {
    margin: 4px 0;
    line-height: 1.6;
}

/* University Link Card Loading */
.university-link-card {
    margin: 8px 0;
}

.university-link-loading {
    padding: 10px;
    text-align: center;
    color: #9ca3af;
    font-size: 12px;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .chat-container {
        width: calc(100vw - 40px);
        height: calc(100vh - 100px);
        left: 20px;
        right: 20px;
        bottom: 90px;
    }

    [dir="rtl"] .chat-container {
        left: 20px;
        right: 20px;
    }
    
    .chat-container.fullscreen {
        width: 100vw;
        height: 100vh;
        left: 0;
        right: 0;
    }
}

/* Scrollbar Styling */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

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

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

