/* Haidth AI Styles */

/* Container */
#haidth-ai-container {
    position: fixed !important;
    bottom: 20px !important;
    left: 0 !important;
    right: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 999999 !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif !important;
    pointer-events: none !important;
}

/* Search Bar */
#haidth-ai-search-bar {
    display: flex !important;
    align-items: center !important;
    background-color: #ffffff !important;
    border-radius: 30px !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1) !important;
    padding: 8px 16px !important;
    width: 300px !important;
    transition: opacity 0.4s ease, transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), width 0.3s ease, box-shadow 0.3s ease, visibility 0s linear !important;
    transform-origin: center bottom !important;
    will-change: transform, opacity, width !important;
    box-sizing: border-box !important;
    pointer-events: auto !important;
}

#haidth-ai-search-bar.focused {
    width: 500px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

#haidth-ai-search-bar.morphing {
    position: absolute;
    bottom: 15px;
    left: 15px;
    right: 15px;
    width: calc(100% - 30px);
    max-width: none;
    border-radius: 20px;
    z-index: 10001;
}

#haidth-ai-search-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px 0;
    font-size: 16px;
    outline: none;
    color: #333;
    width: 100%;
    margin-left: 0;
}

/* Fix the placeholder alignment */
#haidth-ai-search-input::placeholder {
    opacity: 1;
    padding-left: 0;
}

#haidth-ai-search-button,
#haidth-ai-chat-submit {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #66e24a;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    color: white;
    cursor: pointer;
    outline: none;
    transition: background-color 0.3s ease, transform 0.2s ease;
    padding: 0;
    margin-left: 8px;
    flex-shrink: 0;
}

#haidth-ai-search-button:hover {
    background-color: #4bb12f;
    transform: scale(1.05);
}

#haidth-ai-search-button svg {
    width: 18px;
    height: 18px;
}

/* Chat Panel */
#haidth-ai-chat-panel {
    position: fixed !important;
    right: -400px !important;
    bottom: 80px !important;
    width: 380px !important;
    height: 500px !important;
    background-color: #f5f5f5 !important;
    border-radius: 12px !important;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.1) !important;
    display: flex !important;
    flex-direction: column !important;
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
    overflow: hidden !important;
    z-index: 999999 !important;
    will-change: transform !important;
    pointer-events: auto !important;
    transform: translateX(400px) !important;
}

#haidth-ai-chat-panel.open {
    transform: translateX(-20px) !important;
    right: 0 !important;
}

#haidth-ai-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    background-color: #66e24a;
    color: white;
}

#haidth-ai-chat-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 500;
}

#haidth-ai-close-button {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    margin: 0;
    order: -1;
}

#haidth-ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
}

.haidth-ai-message {
    max-width: 80%;
    margin-bottom: 10px;
    padding: 16px 18px;
    border-radius: 18px;
    line-height: 1.5;
    position: relative;
    opacity: 0;
    transform: translateY(20px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    font-size: 15px;
}

.haidth-ai-user-message {
    align-self: flex-end;
    background-color: #e6f9e6;
    border-bottom-right-radius: 4px;
    animation: userMessageZoom 0.5s forwards cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-origin: bottom right;
    color: #1e5e10;
}

.haidth-ai-ai-message {
    align-self: flex-start;
    background-color: #f1f1f1;
    border-bottom-left-radius: 4px;
    animation: aiMessageFadeIn 0.6s forwards cubic-bezier(0.34, 1.56, 0.64, 1);
    color: #323232;
}

/* Enhance lists in AI responses */
.haidth-ai-ai-message ul,
.haidth-ai-ai-message ol {
    padding-left: 22px;
    margin: 8px 0;
}

.haidth-ai-ai-message ul li,
.haidth-ai-ai-message ol li {
    margin-bottom: 6px;
    position: relative;
}

/* Add custom styling for unordered lists */
.haidth-ai-ai-message ul {
    list-style: none;
    padding-left: 18px;
}

.haidth-ai-ai-message ul li::before {
    content: "•";
    color: #66e24a;
    font-weight: bold;
    display: inline-block;
    width: 1em;
    margin-left: -1em;
    font-size: 18px;
    position: absolute;
    top: -2px;
    left: 0;
}

/* Add custom styling for ordered lists */
.haidth-ai-ai-message ol {
    counter-reset: item;
    list-style: none;
    padding-left: 22px;
}

.haidth-ai-ai-message ol li {
    counter-increment: item;
    position: relative;
}

.haidth-ai-ai-message ol li::before {
    content: counter(item) ".";
    color: #66e24a;
    font-weight: bold;
    position: absolute;
    left: -22px;
    width: 22px;
    text-align: right;
}

/* Enhanced animations */
@keyframes userMessageZoom {
    0% {
        opacity: 0;
        transform: scale(0.7) translateY(40px);
    }
    60% {
        transform: scale(1.05) translateY(-5px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes aiMessageFadeIn {
    0% {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    30% {
        opacity: 0.5;
    }
    70% {
        transform: translateY(-5px) scale(1);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Add a typing animation for AI responses */
@keyframes typingDot {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

.haidth-ai-typing {
    display: inline-flex;
    align-items: center;
    margin-left: 5px;
}

.haidth-ai-typing span {
    width: 6px;
    height: 6px;
    margin: 0 2px;
    background-color: #66e24a;
    border-radius: 50%;
    display: inline-block;
    animation: typingDot 1s infinite;
}

.haidth-ai-typing span:nth-child(1) {
    animation-delay: 0s;
}

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

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

/* Text formatting styles */
.haidth-ai-ai-message p {
    margin: 0 0 12px 0;
}

.haidth-ai-ai-message p:last-child {
    margin-bottom: 0;
}

.haidth-ai-ai-message strong,
.haidth-ai-ai-message b {
    font-weight: 600;
    color: #1a1a1a;
}

.haidth-ai-ai-message em,
.haidth-ai-ai-message i {
    font-style: italic;
    color: #222;
}

/* Special handling for blockquotes */
.haidth-ai-ai-message blockquote {
    border-left: 3px solid #66e24a;
    padding-left: 12px;
    margin: 10px 0 10px 5px;
    color: #555;
    font-style: italic;
}

.haidth-ai-source {
    font-size: 12px;
    margin-top: 5px;
    opacity: 0.7;
}

.haidth-ai-source a {
    color: #66e24a;
    text-decoration: none;
}

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

#haidth-ai-chat-input-container {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    background-color: white;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

#haidth-ai-chat-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 10px 0;
    font-size: 15px;
    outline: none;
}

#haidth-ai-chat-submit:hover {
    background-color: #4bb12f;
}

/* Loading indicator */
.haidth-ai-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px 0;
}

.haidth-ai-loading-dots {
    display: flex;
}

.haidth-ai-loading-dots span {
    width: 8px;
    height: 8px;
    margin: 0 2px;
    background-color: #ccc;
    border-radius: 50%;
    animation: haidthAiLoadingDot 1.4s infinite ease-in-out both;
}

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

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

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

/* Physics-based animations */
@keyframes panelSlideIn {
    0% {
        transform: translateX(400px);
        opacity: 0;
    }
    40% {
        transform: translateX(-15px);
    }
    65% {
        transform: translateX(8px);
    }
    85% {
        transform: translateX(-4px);
    }
    100% {
        transform: translateX(-20px);
        opacity: 1;
    }
}

@keyframes panelSlideOut {
    0% {
        transform: translateX(-20px);
        opacity: 1;
    }
    20% {
        transform: translateX(-10px);
    }
    100% {
        transform: translateX(400px);
        opacity: 0;
    }
}

#haidth-ai-chat-panel.animate-in {
    animation: panelSlideIn 0.85s forwards cubic-bezier(0.22, 0.68, 0.36, 1.15);
    transform: translateX(-20px) !important; /* Ensure final position is consistent */
    right: 0 !important;
}

#haidth-ai-chat-panel.animate-out {
    animation: panelSlideOut 0.6s forwards cubic-bezier(0.34, 0.56, 0.64, 1);
    transform: translateX(400px) !important; /* Ensure final position is consistent */
}

/* Search bar hide/show animations */
#haidth-ai-search-bar.hidden {
    opacity: 0;
    transform: translateY(30px);
    pointer-events: none;
    visibility: hidden;
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0s linear 0.3s;
}

@keyframes searchBarEntrance {
    0% {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    70% {
        transform: translateY(-5px) scale(1.02);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

#haidth-ai-search-bar.animate-entrance {
    animation: searchBarEntrance 0.6s forwards cubic-bezier(0.22, 0.68, 0.36, 1.15);
}

/* Media queries for responsive design */
@media (max-width: 768px) {
    #haidth-ai-search-bar {
        width: 250px;
    }
    
    #haidth-ai-search-bar.focused {
        width: 400px;
    }
    
    #haidth-ai-chat-panel {
        width: 320px;
        height: 450px;
    }
}

@media (max-width: 480px) {
    #haidth-ai-search-bar {
        width: 200px;
    }
    
    #haidth-ai-search-bar.focused {
        width: 300px;
    }
    
    #haidth-ai-chat-panel {
        width: 90%;
        height: 400px;
        right: -100%;
    }
    
    #haidth-ai-chat-panel.open {
        right: 5%;
    }
}

.haidth-ai-admin-tabs .tab-content {
    display: none;
}

.haidth-ai-admin-tabs .tab-content.active {
    display: block;
}

#haidth-ai-search-bar-clone {
    border-radius: 30px;
    background-color: #ffffff;
}

#haidth-ai-chat-input-clone {
    border-radius: 20px;
    background-color: #ffffff;
    will-change: transform, top, left, width, height, border-radius;
}

#haidth-ai-chat-input-clone input {
    background: transparent;
    border: none;
    outline: none;
    font-size: 15px;
    padding: 8px 0;
}

#haidth-ai-chat-input-clone button {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #66e24a;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    color: white;
    cursor: pointer;
    padding: 0;
    margin-left: 8px;
    flex-shrink: 0;
}

/* Text Selection Menu Styles */
.haidth-text-selection-menu {
    position: absolute !important;
    display: flex !important;
    flex-direction: row !important;
    background-color: #ffffff !important;
    border-radius: 12px !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.12) !important;
    padding: 10px !important;
    z-index: 999999 !important;
    transform: translateY(15px) scale(0.95) !important;
    opacity: 0 !important;
    transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
    backdrop-filter: blur(10px) !important;
    border: 1px solid rgba(102, 226, 74, 0.2) !important;
    max-width: 320px !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
}

.haidth-text-selection-menu.haidth-menu-show {
    transform: translateY(0) scale(1) !important;
    opacity: 1 !important;
    animation: pulseGlow 2s infinite !important;
}

@keyframes pulseGlow {
    0% {
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.12);
    }
    50% {
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.12), 0 0 0 5px rgba(102, 226, 74, 0.3);
    }
    100% {
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.12);
    }
}

.haidth-selection-option {
    background: linear-gradient(145deg, #6eea52, #5fd545);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 8px 10px;
    margin: 3px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 60px;
    flex: 0 0 auto;
}

.haidth-selection-option:before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.2) 50%, rgba(255,255,255,0) 100%);
    transition: all 0.6s ease;
}

.haidth-selection-option:hover {
    background: linear-gradient(145deg, #4bb12f, #57cc37);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
}

.haidth-selection-option:hover:before {
    left: 100%;
}

.haidth-selection-option:active {
    transform: translateY(1px);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    background: linear-gradient(145deg, #3c9026, #45a52c);
}

/* Add animated highlight on hover */
.haidth-selection-option::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border-radius: 10px;
    background: linear-gradient(45deg, #66e24a, #45a52c, #66e24a);
    background-size: 200% 200%;
    opacity: 0;
    z-index: -1;
    transition: opacity 0.3s ease;
}

.haidth-selection-option:hover::after {
    opacity: 0.6;
    animation: gradientMove 1.5s ease infinite;
}

@keyframes gradientMove {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

/* Add focus styles for accessibility */
.haidth-selection-option:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(102, 226, 74, 0.4);
}

/* Icons for selection options */
.haidth-selection-option[data-action="summarize"]::before,
.haidth-selection-option[data-action="explain"]::before,
.haidth-selection-option[data-action="analyze"]::before,
.haidth-selection-option[data-action="simplify"]::before {
    content: '';
    position: relative;
    display: inline-block;
    width: 16px;
    height: 16px;
    background-position: center;
    background-repeat: no-repeat;
    background-size: contain;
    margin-right: 6px;
    left: 0;
    top: 0;
    transition: all 0.6s ease;
}

.haidth-selection-option[data-action="summarize"]::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' viewBox='0 0 16 16'%3E%3Cpath d='M2 2h12a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V3a1 1 0 0 1 1-1zm0 4h12a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1zm6 4h6a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H8a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1z'/%3E%3C/svg%3E");
}

.haidth-selection-option[data-action="explain"]::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' viewBox='0 0 16 16'%3E%3Cpath d='M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0-1.5a5.5 5.5 0 1 0 0-11 5.5 5.5 0 0 0 0 11zM8.85 7.15l.7-.7a.5.5 0 0 1 .7.7l-1.4 1.4a.5.5 0 0 1-.7 0l-1.4-1.4a.5.5 0 0 1 .7-.7l.7.7V4.5a.5.5 0 0 1 1 0v2.65z'/%3E%3C/svg%3E");
}

.haidth-selection-option[data-action="analyze"]::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' viewBox='0 0 16 16'%3E%3Cpath d='M2 14a1 1 0 0 1-1-1V3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H2zm0-1h12V3H2v10zm7-8.5a.5.5 0 0 0-1 0v6a.5.5 0 0 0 1 0v-6zm-3 2a.5.5 0 0 0-1 0v4a.5.5 0 0 0 1 0v-4zm6-1a.5.5 0 0 0-1 0v5a.5.5 0 0 0 1 0v-5z'/%3E%3C/svg%3E");
}

.haidth-selection-option[data-action="simplify"]::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' viewBox='0 0 16 16'%3E%3Cpath d='M3 2a1 1 0 0 1 1-1h8a1 1 0 0 1 1 1v1H3V2zm1 3a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1H4zm1 3a.5.5 0 0 1 0-1h6a.5.5 0 0 1 0 1H5zm0 2a.5.5 0 0 1 0-1h6a.5.5 0 0 1 0 1H5zm0 2a.5.5 0 0 1 0-1h6a.5.5 0 0 1 0 1H5z'/%3E%3C/svg%3E");
}

.haidth-open-animation {
    animation: haidthSlideIn 0.4s ease forwards;
}

@keyframes haidthSlideIn {
    0% {
        transform: translateY(20px);
        opacity: 0;
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Enhanced triangle pointer for the selection menu */
.haidth-text-selection-menu::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-top: 10px solid #ffffff;
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.1));
}

/* Style text selection only within Haidth AI components */
#haidth-ai-container ::selection,
#haidth-ai-chat-panel ::selection,
#haidth-ai-search-bar ::selection {
    background-color: rgba(102, 226, 74, 0.3);
    color: #2c7a18;
}

/* Style for highlighted text only within plugin components */
#haidth-ai-container .haidth-highlighted-text,
#haidth-ai-container .highlighted,
#haidth-ai-chat-panel .haidth-highlighted-text,
#haidth-ai-chat-panel .highlighted {
    background-color: rgba(102, 226, 74, 0.15);
    color: #2c7a18;
    border-bottom: 1px dashed #66e24a;
}

/* Style links only within Haidth AI components */
#haidth-ai-container a {
    color: #4bb12f;
    transition: color 0.2s ease;
}

#haidth-ai-container a:hover {
    color: #66e24a;
    text-decoration: underline;
}

/* Style hadith content links only within Haidth AI components */
#haidth-ai-container .entry-content a,
#haidth-ai-container .hadith-content a,
#haidth-ai-container .hadith-text a,
#haidth-ai-chat-messages a {
    color: #4bb12f !important;
}

#haidth-ai-container .entry-content a:hover,
#haidth-ai-container .hadith-content a:hover,
#haidth-ai-container .hadith-text a:hover,
#haidth-ai-chat-messages a:hover {
    color: #66e24a !important;
}

/* Style for selected hadith text */
.selected-hadith-text,
.hadith-highlight {
    background-color: rgba(102, 226, 74, 0.15);
    border-radius: 3px;
    padding: 2px 0;
} 