/* Session closure message styling */
.message-text.session-closure {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
    color: white;
    border-radius: 12px;
    padding: 16px;
    border: none;
    box-shadow: 0 4px 12px rgba(238, 90, 36, 0.3);
    font-weight: 500;
}

.message-text.session-closure a {
    color: #fff;
    text-decoration: underline;
    font-weight: 600;
}

.message-text.session-closure a:hover {
    color: #f1f2f6;
}

/* P&F Assistant Chatbot Styles */
.pafd-chatbot-container {
    max-width: 600px;
    margin: 20px auto;
    border: 1px solid #ddd;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.pafd-chatbot-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
    text-align: center;
    font-weight: 600;
    font-size: 18px;
}

.pafd-chatbot-messages {
    height: 400px;
    overflow-y: auto;
    padding: 20px;
    background-color: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.pafd-message {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    line-height: 1.4;
    position: relative;
}

.pafd-message.user {
    background-color: #007cba;
    color: white;
    align-self: flex-end;
    margin-left: auto;
}

.pafd-message.bot {
    background-color: white;
    color: #333;
    align-self: flex-start;
    border: 1px solid #e1e5e9;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.pafd-message.bot::before {
    content: '🤖';
    position: absolute;
    left: -25px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 16px;
}

.pafd-feedback-buttons {
    margin-top: 8px;
    display: flex;
    gap: 8px;
}

.pafd-feedback-btn {
    background: none;
    border: 1px solid #ddd;
    border-radius: 15px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
}

.pafd-feedback-btn:hover {
    background-color: #f0f0f0;
}

.pafd-feedback-btn.liked {
    background-color: #4CAF50;
    color: white;
    border-color: #4CAF50;
}

.pafd-feedback-btn.disliked {
    background-color: #f44336;
    color: white;
    border-color: #f44336;
}

.pafd-chatbot-input-area {
    padding: 15px 20px;
    background-color: white;
    border-top: 1px solid #e1e5e9;
    display: flex;
    gap: 10px;
    align-items: center;
}

.pafd-chatbot-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 25px;
    outline: none;
    font-size: 14px;
    transition: border-color 0.2s ease;
}

.pafd-chatbot-input:focus {
    border-color: #007cba;
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.1);
}

.pafd-send-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
    font-size: 16px;
}

.pafd-send-btn:hover {
    transform: scale(1.05);
}

.pafd-send-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.pafd-typing-indicator {
    display: none;
    align-items: center;
    gap: 8px;
    color: #666;
    font-style: italic;
    padding: 10px 16px;
}

.pafd-typing-dots {
    display: flex;
    gap: 4px;
}

.pafd-typing-dots span {
    width: 6px;
    height: 6px;
    background-color: #666;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.pafd-typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.pafd-typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.pafd-reset-btn {
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
    margin-left: 10px;
    transition: background-color 0.2s ease;
}

.pafd-reset-btn:hover {
    background: #5a6268;
}

/* Responsive Design */
@media (max-width: 768px) {
    .pafd-chatbot-container {
        margin: 10px auto;
        border-radius: 8px;
        max-width: calc(100vw - 20px);
        width: calc(100vw - 20px);
        box-sizing: border-box;
        position: relative;
        left: 0;
        right: 0;
    }
    
    .pafd-chatbot-messages {
        height: 300px;
        padding: 15px;
    }
    
    .pafd-message {
        max-width: 95%;
        font-size: 14px;
        padding: 10px 14px;
    }
    
    .pafd-chatbot-input-area {
        padding: 12px 15px;
    }
    
    .pafd-chatbot-input {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .pafd-send-btn {
        width: 40px;
        height: 40px;
        font-size: 14px;
    }
    
    .pafd-disclaimer-bar {
        padding: 6px 15px;
        font-size: 10px;
    }
}

@media (max-width: 480px) {
    .pafd-chatbot-container {
        margin: 5px auto;
        border-radius: 6px;
        max-width: calc(100vw - 10px);
        width: calc(100vw - 10px);
        box-sizing: border-box;
        position: relative;
        left: 0;
        right: 0;
    }
    
    .pafd-chatbot-header {
        padding: 12px 15px;
        font-size: 16px;
    }
    
    .pafd-chatbot-messages {
        height: 250px;
        padding: 12px;
    }
    
    .pafd-message {
        font-size: 13px;
        padding: 8px 12px;
    }
    
    .pafd-chatbot-input-area {
        padding: 10px 12px;
    }
    
    .pafd-disclaimer-bar {
        padding: 5px 12px;
        font-size: 9px;
    }
}

/* Scrollbar Styling */
.pafd-chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

.pafd-chatbot-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.pafd-chatbot-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.pafd-chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Floating Chatbot Styles */
#pafd-floating-chatbot {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    pointer-events: none;
}

#pafd-floating-chatbot * {
    pointer-events: auto;
}

.pafd-chat-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 50px;
    padding: 15px 20px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    font-size: 16px;
    font-weight: 600;
    min-width: 60px;
    justify-content: center;
}

.pafd-chat-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.pafd-chat-icon {
    font-size: 20px;
    line-height: 1;
}

.pafd-chat-text {
    font-size: 14px;
    white-space: nowrap;
}

.pafd-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    height: 500px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #e1e5e9;
    box-sizing: border-box;
}

.pafd-chat-window.pafd-chat-open {
    display: flex;
}

.pafd-chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 16px;
}

.pafd-chat-title {
    flex: 1;
}

.pafd-chat-controls {
    display: flex;
    gap: 5px;
}

.pafd-control-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    border-radius: 4px;
    width: 24px;
    height: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    line-height: 1;
    transition: background-color 0.2s ease;
}

.pafd-control-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.pafd-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background-color: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.pafd-chat-input-area {
    padding: 15px 20px;
    background-color: white;
    border-top: 1px solid #e1e5e9;
    display: flex;
    gap: 10px;
    align-items: center;
}

.pafd-chat-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 20px;
    outline: none;
    font-size: 14px;
    transition: border-color 0.2s ease;
}

.pafd-chat-input:focus {
    border-color: #007cba;
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.1);
}

/* Mobile Responsive - Bottom Sheet Design */
@media (max-width: 768px) {
    #pafd-floating-chatbot {
        bottom: 20px;
        right: 20px;
    }
    
    .pafd-chat-button {
        padding: 14px 18px;
        font-size: 14px;
        border-radius: 30px;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    }
    
    .pafd-chat-text {
        display: none;
    }
    
    .pafd-chat-window {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        width: 100% !important;
        height: 85vh !important;
        max-height: none !important;
        max-width: none !important;
        border-radius: 20px 20px 0 0 !important;
        box-sizing: border-box;
        z-index: 1000000;
        transform: translateY(100%) !important;
        transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) !important;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    }
    
    .pafd-chat-window.pafd-chat-open {
        transform: translateY(0) !important;
    }
    
    .pafd-chat-header {
        padding: 20px 20px 15px 20px;
        border-bottom: 1px solid #e1e5e9;
        position: relative;
    }
    
    .pafd-chat-header::before {
        content: '';
        position: absolute;
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 4px;
        background: #ccc;
        border-radius: 2px;
    }
    
    .pafd-chat-messages {
        padding: 20px;
        height: calc(100% - 160px) !important;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .pafd-chat-input-area {
        padding: 15px 20px 20px 20px;
        background: white;
        border-top: 1px solid #e1e5e9;
    }
    
    .pafd-chat-input {
        font-size: 16px;
        padding: 12px 16px;
        border-radius: 25px;
    }
    
    .pafd-send-btn {
        width: 44px;
        height: 44px;
    }
    
    .pafd-disclaimer-bar {
        padding: 8px 20px 12px 20px;
        font-size: 11px;
        background: #f8f9fa;
        border-top: 1px solid #e1e5e9;
    }
}

@media (max-width: 480px) {
    #pafd-floating-chatbot {
        bottom: 15px;
        right: 15px;
    }
    
    .pafd-chat-button {
        padding: 12px 16px;
        font-size: 13px;
    }
    
    .pafd-chat-window {
        height: 90vh !important;
        border-radius: 16px 16px 0 0 !important;
    }
    
    .pafd-chat-header {
        padding: 16px 16px 12px 16px;
        font-size: 16px;
    }
    
    .pafd-chat-messages {
        padding: 16px;
        height: calc(100% - 150px) !important;
    }
    
    .pafd-message {
        font-size: 14px;
        padding: 10px 14px;
    }
    
    .pafd-chat-input-area {
        padding: 12px 16px 16px 16px;
    }
    
    .pafd-disclaimer-bar {
        padding: 6px 16px 10px 16px;
        font-size: 10px;
    }
}

/* Animation for chat window */
.pafd-chat-window {
    transition: all 0.3s ease;
}

/* Desktop animation */
@media (min-width: 769px) {
    .pafd-chat-window {
        animation: slideUp 0.3s ease-out;
    }
    
    @keyframes slideUp {
        from {
            opacity: 0;
            transform: translateY(20px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
}

/* Mobile bottom sheet animation */
@media (max-width: 768px) {
    .pafd-chat-window {
        animation: none;
        transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    }
    
    /* Slide up from bottom animation is handled by transform in CSS */
}

/* Notification badge (for future use) */
.pafd-chat-button::after {
    content: '';
    position: absolute;
    top: -2px;
    right: -2px;
    width: 12px;
    height: 12px;
    background: #ff4444;
    border-radius: 50%;
    display: none;
}

.pafd-chat-button.has-notification::after {
    display: block;
}

/* Disclaimer Styles */
.pafd-disclaimer-bar {
    font-size: 11px;
    padding: 8px 15px;
    text-align: center;
    border-top: 1px solid #e1e5e9;
    background-color: #f8f9fa;
    color: #666;
}

.pafd-disclaimer-link {
    color: #007cba;
    text-decoration: underline;
    cursor: pointer;
    transition: color 0.2s ease;
}

.pafd-disclaimer-link:hover {
    color: #005a87;
}

.pafd-disclaimer-modal {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.pafd-disclaimer-modal.show {
    display: flex;
}

.pafd-disclaimer-content {
    background: white;
    padding: 25px;
    border-radius: 8px;
    max-width: 500px;
    width: 100%;
    max-height: 80%;
    overflow-y: auto;
    position: relative;
    font-size: 13px;
    line-height: 1.5;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.pafd-disclaimer-close {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    transition: color 0.2s ease;
    line-height: 1;
}

.pafd-disclaimer-close:hover {
    color: #333;
}

.pafd-disclaimer-content h3 {
    margin: 0 0 15px 0;
    font-size: 16px;
    color: #333;
    font-weight: 600;
}

.pafd-disclaimer-content p {
    margin: 0 0 12px 0;
    color: #555;
}

.pafd-disclaimer-content a {
    color: #007cba;
    text-decoration: underline;
    transition: color 0.2s ease;
}

.pafd-disclaimer-content a:hover {
    color: #005a87;
}

/* Mobile disclaimer modal */
@media (max-width: 768px) {
    .pafd-disclaimer-modal {
        padding: 15px;
    }
    
    .pafd-disclaimer-content {
        padding: 20px;
        max-height: 70vh;
        font-size: 12px;
    }
    
    .pafd-disclaimer-content h3 {
        font-size: 15px;
        margin-bottom: 12px;
    }
    
    .pafd-disclaimer-close {
        top: 8px;
        right: 12px;
        font-size: 22px;
    }
}

@media (max-width: 480px) {
    .pafd-disclaimer-modal {
        padding: 10px;
    }
    
    .pafd-disclaimer-content {
        padding: 18px;
        max-height: 75vh;
        font-size: 11px;
    }
    
    .pafd-disclaimer-content h3 {
        font-size: 14px;
        margin-bottom: 10px;
    }
}
/* Additional Mobile Fixes */
@media screen and (max-width: 768px) {
    /* Mobile backdrop overlay */
    .pafd-chat-window.pafd-chat-open::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: -1;
        opacity: 0;
        animation: fadeInBackdrop 0.3s ease-out forwards;
    }
    
    @keyframes fadeInBackdrop {
        to {
            opacity: 1;
        }
    }
    
    /* Prevent body scroll when chat is open */
    body.pafd-chat-open {
        overflow: hidden;
        position: fixed;
        width: 100%;
    }
    
    /* Handle safe area for devices with notches */
    .pafd-chat-window {
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    /* Smooth scrolling for chat messages */
    .pafd-chat-messages {
        scroll-behavior: smooth;
    }
}

@media screen and (max-width: 480px) {
    /* Extra small screens */
    #pafd-floating-chatbot {
        max-width: calc(100vw - 30px);
    }
    
    .pafd-chat-button {
        min-width: 50px;
    }
    
    .pafd-chat-icon {
        font-size: 18px;
    }
}

/* Landscape orientation fixes for mobile */
@media screen and (max-height: 500px) and (orientation: landscape) {
    .pafd-chat-window {
        height: 95vh !important;
        border-radius: 12px 12px 0 0 !important;
    }
    
    .pafd-chat-messages {
        height: calc(100% - 140px) !important;
    }
    
    .pafd-chat-header {
        padding: 12px 20px 8px 20px;
    }
}

/* Prevent chatbot from causing horizontal scroll */
.pafd-chatbot-container,
#pafd-floating-chatbot,
.pafd-chat-window {
    max-width: 100vw;
    box-sizing: border-box;
}

/* iOS specific fixes */
@supports (-webkit-touch-callout: none) {
    .pafd-chat-input {
        font-size: 16px !important; /* Prevents zoom on iOS */
    }
    
    .pafd-chat-messages {
        -webkit-overflow-scrolling: touch;
    }
}