/* ROSA Chatbot Styles */
:root {
    --chatbot-primary: #002147;
    --chatbot-secondary: #800000;
    --chatbot-accent: #FFD700;
    --chatbot-light: #f8f9fa;
    --chatbot-dark: #2c3e50;
}

/* Floating Chat Button Container */
.chatbot-button-container {
    position: fixed;
    bottom: 30px;
    left: auto;
    right: 30px;
    display: flex;
    align-items: center;
    flex-direction: row-reverse;
    gap: 15px;
    z-index: 9998;
    cursor: pointer;
}

/* Floating Chat Button */
.chatbot-button {
    position: relative;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-secondary) 100%);
    background-image: url('img/librarian_avatar.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    box-shadow: 0 4px 20px rgba(0, 33, 71, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0;
    /* Hide any text/icon content */
    transition: all 0.3s ease;
    animation: pulse 2s infinite;
    overflow: hidden;
    flex-shrink: 0;
}

/* Show icon as fallback if image doesn't load */
.chatbot-button i {
    display: none;
    font-size: 28px;
    color: white;
    z-index: 1;
}

/* If image fails, show icon */
.chatbot-button:not([style*="background-image"]) i,
.chatbot-button[style*="background-image: none"] i {
    display: flex;
}

/* Gradient border effect for circular image */
.chatbot-button::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    padding: 4px;
    background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-secondary) 100%);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask-composite: exclude;
    z-index: -1;
}

.chatbot-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(0, 33, 71, 0.6);
}

.chatbot-button.active {
    transform: scale(1.05);
    box-shadow: 0 8px 40px rgba(128, 0, 0, 0.6);
}

@keyframes pulse {

    0%,
    100% {
        box-shadow: 0 4px 20px rgba(0, 33, 71, 0.4);
    }

    50% {
        box-shadow: 0 4px 30px rgba(128, 0, 0, 0.6);
    }
}

/* Chatbot Button Text Container */
.chatbot-button-text {
    background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-secondary) 100%);
    padding: 12px 18px;
    border-radius: 25px;
    box-shadow: 0 4px 15px rgba(0, 33, 71, 0.3);
    min-width: 200px;
    max-width: 280px;
    animation: slideInRight 0.5s ease;
}

.chatbot-greeting {
    font-size: 14px;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 4px;
    letter-spacing: 0.5px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.chatbot-rotating-message {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.95);
    font-weight: 400;
    line-height: 1.4;
    min-height: 16px;
    transition: opacity 0.3s ease;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

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

@keyframes fadeInOut {
    0%, 100% {
        opacity: 0.7;
    }
    50% {
        opacity: 1;
    }
}

.chatbot-button-container:hover .chatbot-button-text {
    box-shadow: 0 6px 20px rgba(0, 33, 71, 0.4);
    transform: translateX(-5px);
}

.chatbot-button-container:hover .chatbot-button {
    transform: scale(1.1);
}

/* Notification Badge */
.chatbot-badge {
    position: absolute;
    top: -5px;
    left: auto;
    right: -5px;
    background: #dc3545;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: bold;
    border: 2px solid white;
}

/* Chat Window */
.chatbot-window {
    position: fixed;
    bottom: 120px;
    left: auto;
    right: 30px;
    width: 380px;
    height: 550px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.3);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 9999;
    animation: slideIn 0.3s ease;
}

.chatbot-window.active {
    display: flex;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Chat Header */
.chatbot-header {
    background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-secondary) 100%);
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 20px 20px 0 0;
}

.chatbot-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chatbot-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--chatbot-primary);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.chatbot-title {
    display: flex;
    flex-direction: column;
}

.chatbot-title h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.chatbot-status {
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 5px;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #28a745;
    border-radius: 50%;
    animation: blink 1.5s infinite;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }
}

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

.chatbot-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

/* Chat Messages */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

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

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

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

.chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Message Bubbles */
.message {
    display: flex;
    gap: 10px;
    animation: messageSlide 0.3s ease;
}

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

.message.bot .message-avatar {
    background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-secondary) 100%);
    color: white;
}

.message.user .message-avatar {
    background: #6c757d;
    color: white;
}

.message-content {
    max-width: 70%;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.message.bot .message-bubble {
    background: white;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.message.user .message-bubble {
    background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-secondary) 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.message-time {
    font-size: 11px;
    color: #999;
    margin-top: 5px;
    padding: 0 5px;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 10px;
    padding: 10px 0;
}

.typing-indicator .message-bubble {
    padding: 12px 16px;
    display: flex;
    gap: 5px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {

    0%,
    60%,
    100% {
        transform: translateY(0);
    }

    30% {
        transform: translateY(-10px);
    }
}

/* Quick Actions */
.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.quick-action-btn {
    background: white;
    border: 2px solid var(--chatbot-primary);
    color: var(--chatbot-primary);
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.quick-action-btn:hover {
    background: var(--chatbot-primary);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 3px 10px rgba(0, 33, 71, 0.3);
}

/* Chat Input */
.chatbot-input-area {
    padding: 15px 20px;
    background: white;
    border-top: 1px solid #e9ecef;
    display: flex;
    gap: 10px;
    align-items: center;
}

.chatbot-input {
    flex: 1;
    border: 2px solid #e9ecef;
    border-radius: 25px;
    padding: 12px 18px;
    font-size: 14px;
    outline: none;
    transition: all 0.3s ease;
}

.chatbot-input:focus {
    border-color: var(--chatbot-primary);
    box-shadow: 0 0 0 3px rgba(0, 33, 71, 0.1);
}

.chatbot-send-btn {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-secondary) 100%);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.3s ease;
}

.chatbot-send-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 3px 15px rgba(0, 33, 71, 0.4);
}

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

/* Welcome Message */
.welcome-message {
    background: linear-gradient(135deg, rgba(0, 33, 71, 0.05) 0%, rgba(128, 0, 0, 0.05) 100%);
    border-left: 4px solid var(--chatbot-primary);
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 10px;
}

.welcome-message h5 {
    margin: 0 0 8px 0;
    color: var(--chatbot-primary);
    font-size: 15px;
    font-weight: 600;
}

.welcome-message p {
    margin: 0;
    font-size: 13px;
    color: #666;
    line-height: 1.5;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .chatbot-button-container {
        bottom: 20px;
        left: auto;
        right: 15px;
        gap: 10px;
        flex-direction: column-reverse;
        align-items: flex-end;
    }
    
    .chatbot-button-text {
        min-width: 150px;
        max-width: 200px;
        padding: 10px 14px;
        order: 2;
    }
    
    .chatbot-greeting {
        font-size: 12px;
    }
    
    .chatbot-rotating-message {
        font-size: 11px;
    }
    
    .chatbot-button {
        width: 60px;
        height: 60px;
        order: 1;
    }
    
    .chatbot-window {
        bottom: 90px;
        left: 10px;
        right: 10px;
        width: calc(100vw - 20px);
        max-width: none;
        height: calc(100vh - 110px);
        max-height: none;
        border-radius: 15px;
    }
    
    .chatbot-header {
        padding: 15px;
        border-radius: 15px 15px 0 0;
    }
    
    .chatbot-header-info {
        gap: 10px;
    }
    
    .chatbot-avatar {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
    
    .chatbot-title h4 {
        font-size: 14px;
    }
    
    .chatbot-status {
        font-size: 11px;
    }
    
    .chatbot-messages {
        padding: 15px;
        gap: 12px;
    }
    
    .message-content {
        max-width: 85%;
    }
    
    .message-bubble {
        padding: 10px 14px;
        font-size: 13px;
    }
    
    .chatbot-input-area {
        padding: 12px 15px;
    }
    
    .chatbot-input {
        padding: 10px 15px;
        font-size: 13px;
    }
    
    .chatbot-send-btn {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    
    .quick-action-btn {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .suggested-response {
        padding: 8px 12px;
        font-size: 12px;
    }
}

/* Small Mobile Devices */
@media (max-width: 480px) {
    .chatbot-button-container {
        bottom: 15px;
        right: 10px;
        gap: 8px;
    }
    
    .chatbot-button {
        width: 55px;
        height: 55px;
    }
    
    .chatbot-button-text {
        min-width: 140px;
        max-width: 180px;
        padding: 8px 12px;
    }
    
    .chatbot-greeting {
        font-size: 11px;
    }
    
    .chatbot-rotating-message {
        font-size: 10px;
    }
    
    .chatbot-window {
        bottom: 80px;
        left: 5px;
        right: 5px;
        width: calc(100vw - 10px);
        height: calc(100vh - 95px);
        border-radius: 12px;
    }
    
    .chatbot-header {
        padding: 12px;
    }
    
    .chatbot-avatar {
        width: 35px;
        height: 35px;
        font-size: 16px;
    }
    
    .chatbot-title h4 {
        font-size: 13px;
    }
    
    .chatbot-messages {
        padding: 12px;
    }
    
    .message-content {
        max-width: 90%;
    }
    
    .message-bubble {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .chatbot-input-area {
        padding: 10px 12px;
        gap: 8px;
    }
    
    .chatbot-input {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .chatbot-send-btn {
        width: 38px;
        height: 38px;
        font-size: 14px;
    }
    
    .quick-actions {
        gap: 6px;
    }
    
    .quick-action-btn {
        padding: 5px 10px;
        font-size: 11px;
    }
    
    .suggested-responses {
        gap: 6px;
    }
    
    .suggested-response {
        padding: 7px 10px;
        font-size: 11px;
    }
}

/* Landscape Mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .chatbot-window {
        height: calc(100vh - 100px);
        max-height: 400px;
    }
}

/* Link Styling in Messages */
.message-bubble a {
    color: inherit;
    text-decoration: underline;
    font-weight: 600;
}

.message.bot .message-bubble a {
    color: var(--chatbot-primary);
}

.message.user .message-bubble a {
    color: white;
}

/* Suggested Responses */
.suggested-responses {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}

.suggested-response {
    background: white;
    border: 2px solid #e9ecef;
    color: var(--chatbot-dark);
    padding: 10px 15px;
    border-radius: 12px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
}

.suggested-response:hover {
    border-color: var(--chatbot-primary);
    background: rgba(0, 33, 71, 0.05);
    transform: translateX(5px);
}

/* Error Message */
.error-message {
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    padding: 12px;
    border-radius: 8px;
    font-size: 13px;
    color: #856404;
}