/* =========================
   Modern Search Agent Theme
   ========================= */

:root {
    --sa-bg: #f8fafc;
    --sa-surface: rgba(255, 255, 255, 0.92);
    --sa-surface-strong: #ffffff;
    --sa-border: rgba(226, 232, 240, 0.95);
    --sa-border-strong: #dbe3ee;
    --sa-text: #0f172a;
    --sa-text-soft: #475569;
    --sa-text-muted: #64748b;
    --sa-primary: #2563eb;
    --sa-primary-hover: #1d4ed8;
    --sa-primary-soft: #dbeafe;
    --sa-success-soft: #ecfeff;
    --sa-shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.05);
    --sa-shadow-md: 0 6px 18px rgba(15, 23, 42, 0.08);
    --sa-shadow-lg: 0 14px 34px rgba(15, 23, 42, 0.12);
    --sa-radius-sm: 12px;
    --sa-radius-md: 16px;
    --sa-radius-lg: 20px;
    --sa-transition: 180ms ease;
}

/* Optional page feel */
body {
    background:
        radial-gradient(circle at top left, rgba(219, 234, 254, 0.65), transparent 35%),
        linear-gradient(180deg, #f8fbff 0%, #f8fafc 100%);
    color: var(--sa-text);
}

/* Optional: polish the overall incoming message bubble
   If this affects other parts too much, remove this section */
.chat.incoming p,
.chat.incoming .message-content,
.chat.incoming .text {
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid var(--sa-border);
    border-radius: 22px;
    padding: 16px 18px;
    box-shadow: var(--sa-shadow-sm);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* Main wrapper for Search Agent result */
.search-agent-result {
    display: block;
    color: var(--sa-text);
    line-height: 1.7;
}

/* Each book item */
.search-agent-book {
    display: block;
    margin: 14px 0 18px;
    padding: 18px 18px 16px;
    background: var(--sa-surface);
    border: 1px solid var(--sa-border);
    border-radius: var(--sa-radius-lg);
    box-shadow: var(--sa-shadow-sm);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition:
        transform var(--sa-transition),
        box-shadow var(--sa-transition),
        border-color var(--sa-transition),
        background var(--sa-transition);
    position: relative;
    overflow: hidden;
}

/* Soft top glow line */
.search-agent-book::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, #60a5fa, #2563eb, #3b82f6);
    opacity: 0.9;
}

/* Hover effect */
.search-agent-book:hover {
    transform: translateY(-2px);
    box-shadow: var(--sa-shadow-md);
    border-color: #c7d7ee;
    background: rgba(255, 255, 255, 0.98);
}

/* Book title */
.search-agent-book-title {
    display: block;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.5;
    color: var(--sa-text);
    letter-spacing: 0.01em;
    margin-bottom: 10px;
    word-break: break-word;
}

/* Metadata lines */
.search-agent-book-line {
    display: block;
    font-size: 0.92rem;
    line-height: 1.75;
    color: var(--sa-text-soft);
    margin: 3px 0;
    word-break: break-word;
}

/* Labels like Author / Type */
.search-agent-book-label {
    font-weight: 650;
    color: var(--sa-text);
    margin-right: 4px;
}

/* Call-to-action link/button */
#chatbot_embedd .search-agent-book-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    padding: 10px 14px;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--sa-primary), #3b82f6);
    color: #ffffff !important;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.85rem;
    letter-spacing: 0.01em;
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.22);
    transition:
        transform var(--sa-transition),
        box-shadow var(--sa-transition),
        opacity var(--sa-transition),
        background var(--sa-transition);
}

/* Optional arrow icon using CSS only */
.search-agent-book-link::after {
    content: "↗";
    font-size: 0.9rem;
    line-height: 1;
    opacity: 0.95;
}

.search-agent-book-link:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 24px rgba(37, 99, 235, 0.28);
    background: linear-gradient(135deg, var(--sa-primary-hover), #2563eb);
    opacity: 0.98;
}

.search-agent-book-link:active {
    transform: translateY(0);
}

/* Bottom line / summary box */
.search-agent-bottom {
    display: block;
    margin-top: 18px;
    padding: 16px 18px;
    border: 1px solid var(--sa-border);
    border-radius: var(--sa-radius-lg);
    background:
        linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    color: #334155;
    font-size: 0.92rem;
    line-height: 1.8;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.search-agent-bottom a {
    color: var(--sa-primary);
    font-weight: 600;
    text-decoration: none;
}

.search-agent-bottom a:hover {
    text-decoration: underline;
}

/* Optional source box styling */
.source-box {
    margin-top: 14px;
    padding: 14px 16px;
    border-radius: var(--sa-radius-md);
    border: 1px solid var(--sa-border);
    background: rgba(255, 255, 255, 0.85);
    color: var(--sa-text-soft);
    box-shadow: var(--sa-shadow-sm);
}

.source-box a {
    color: var(--sa-primary);
    text-decoration: none;
    font-weight: 500;
}

.source-box a:hover {
    text-decoration: underline;
}

.source-label {
    display: inline-block;
    margin-bottom: 6px;
    color: var(--sa-text);
    font-weight: 700;
}

/* Optional: smoother list spacing if many books appear */
.search-agent-result > .search-agent-book:first-child {
    margin-top: 8px;
}

.search-agent-result > .search-agent-book:last-of-type {
    margin-bottom: 10px;
}

/* Optional scrollbar styling for desktop webkit browsers */
.chatbox::-webkit-scrollbar {
    width: 10px;
}

.chatbox::-webkit-scrollbar-track {
    background: transparent;
}

.chatbox::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.35);
    border-radius: 999px;
}

.chatbox::-webkit-scrollbar-thumb:hover {
    background: rgba(100, 116, 139, 0.48);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .search-agent-book {
        padding: 16px 15px 14px;
        border-radius: 16px;
    }

    .search-agent-book-title {
        font-size: 0.98rem;
    }

    .search-agent-book-line {
        font-size: 0.9rem;
    }

    .search-agent-book-link {
        width: 100%;
        justify-content: center;
        border-radius: 14px;
    }

    .search-agent-bottom,
    .source-box {
        border-radius: 16px;
    }
}

/* Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .search-agent-book,
    .search-agent-book-link,
    .chat.incoming p,
    .chat.incoming .message-content,
    .chat.incoming .text {
        transition: none !important;
    }

    .search-agent-book:hover,
    .search-agent-book-link:hover {
        transform: none !important;
    }
}

/* Container Card */
.feedback-box-container {
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 16px;
    margin-top: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    max-width: 800px;
    font-family: sans-serif;
}

/* Textarea Styling */
.feedback-textarea {
    width: 100%;
    min-height: 80px;
    padding: 12px;
    border: 1px solid #d1d1d1;
    border-radius: 8px;
    
    /* Changed from vertical to both */
    resize: both; 
    
    font-size: 14px;
    outline: none;
    transition: all 0.2s ease;
    box-sizing: border-box; 
    background: #f9f9f9;

    /* Recommended: Safety boundaries for width resizing */
    min-width: 490px;
    max-width: 100%;
}

.feedback-textarea:focus {
    border-color: #007bff;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.feedback-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    width: 100%;
}

.email-contact-container {
    display: flex;
    align-items: center;
    /* Increased max-width to accommodate both input and button on one line */
    max-width: 300px; 
}

.email-input {
    display: inline-block;
    width: 200px;
    height: 28px;       /* Standard single-line height */
    opacity: 1;
    padding: 4px 8px;
    margin-right: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    outline: none;
    box-sizing: border-box;
    
    /* Force it to look and act like a single line initially */
    white-space: nowrap; 
    overflow: hidden;    
    resize: both;        /* Natively works perfectly on textareas */

    /* Safety boundaries */
    min-width: 100px;
    max-width: 100%;
    min-height: 28px;
}

.email-label-btn {
    display: flex;
    align-items: center;
    background: transparent;
    border: none;
    color: #666;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
    gap: 5px; /* Adds space between text and icon */
}

/* Ensure SVG alignment */
.email-label-btn svg {
    flex-shrink: 0;
}

.submit-feedback-btn {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s, background 0.2s;
    margin-left: 20px; /* Backup spacing */
}


/* Status Messages */
.thank-you-message {
    padding: 12px 0;
    color: #28a745;
    font-weight: 600;
    font-size: 14px;
}

/* Small animation if user clicks empty */
.error-shake {
    border-color: #dc3545 !important;
    animation: shake 0.3s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

/* The class applied by JavaScript */
.error-shake-email {
    animation: shakeEffect 0.5s ease-in-out;
    border: 1px solid red !important; /* Optional: Highlights the error area in red */
}

/* The actual physical movement framework */
@keyframes shakeEffect {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-6px); }
    40%, 80% { transform: translateX(6px); }
}

.bottom-button-container {
    width: 100%;
    display: flex;
    justify-content: center; 
    padding: 20px 0;         
    margin-top: 10px;       
}

#chatbot_embedd .view-all-button {
    display: inline-block;
    padding: 12px 30px;
    background-color: #007bff; 

    color: #ffffff !important;
    text-decoration: none;
    font-size: 16px;
    font-weight: 600;

    border-radius: 25px;       
    transition: all 0.3s ease; 
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.view-all-button:hover {
    background-color: #0056b3;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
    color: #ffffff !important;
}

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

.search-agent-book, .search-agent-bottom, .message-line {
    animation: fadeInUp 0.4s ease forwards;
}

.streaming-line {
    display: inline-block;
    width: 100%;
    opacity: 0;
    transform: translateY(2px);
    animation: softReveal 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.soft-reveal {
    opacity: 0;
    transform: translateY(3px);
    animation: softReveal 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

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

.source-box,
.satisfaction-row {
	extend: .soft-reveal;
}

.source-box.soft-reveal,
.feedback-buttons.soft-reveal {
    animation-delay: 0.2s;
}

/* ==========================================================================
   Sequential Module Display Animations
   ========================================================================== */

/* Target the primary parent containers and the layout divider line */
.multi-agent-container, 
.agent-section,
.agent-divider {
    /* Triggers the keyframe animation upon DOM injection */
    animation: stackFadeIn 0.5s cubic-bezier(0.25, 1, 0.5, 1) forwards;
    
    /* Prevents layout flash before animation starts */
    will-change: transform, opacity;
}

/* Smooth fade and slide up effect */
@keyframes stackFadeIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.custom-feedback {
  display: inline-block;
  cursor: pointer;
  margin: 10px;
  font-size: 10px;
  color: black; /* Establishes baseline black color */
  transition: all .2s ease-in-out; /* Moved here to ensure smooth shrink reset on hover exit */
}

.custom-feedback .btn-text {
    font-size: 13px; /* Adjust scale to match your design height */
    font-weight: bold;
}

.whatsapp-Btn {
	display: flex;
	align-items: normal;
  margin: 10px;
    font-size: 13px; /* Adjust scale to match your design height */
    font-weight: bold;
}
.whatsapp-Btn a {
	text-decoration-line: none !important;
	display: inline-block;
	margin-top: 2px;
	line-height:1;
}
img.whatsapp_icon {
	display: inline; 
	vertical-align: bottom;
	width: 25px;
}
.custom-feedback:hover, .whatsapp-Btn:hover {
  color: #2EBDD1;
  transform: scale(1.1);
}

.active {
  color: #2EBDD1 !important; /* Locks the blue color when clicked */
}

/* Custom Modal Layout Presentation Definitions */
.custom-modal {
    display: none; 
    position: fixed; 
    z-index: 99999; 
    left: 0;
    top: 0;
    width: 100%; 
    height: 100%; 
    overflow: auto; 
    background-color: rgba(0, 0, 0, 0.4);
}

.modal-content {
    background-color: #ffffff;
    margin: 15% auto; 
    padding: 20px;
    border-radius: 8px;
    width: 80%; 
    max-width: 420px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    font-family: Arial, sans-serif;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e5e5e5;
    padding-bottom: 8px;
}

.modal-header h3 {
    margin: 0;
    color: #003366; /* HKUST Blue */
    font-size: 18px;
}

.modal-close {
    color: #999999;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.modal-close:hover {
    color: #333333;
}

.modal-body {
    padding-top: 12px;
    color: #444444;
    font-size: 14px;
    line-height: 1.5;
}

