/**
 * AIOHM Knowledge Assistant - Chat and Search Styles
 * Version: 1.2.0 (Complete and Final Styles)
 */

/* --- OHM Brand Theme Variables --- */
:root {
    --ohm-primary: #457d58;
    --ohm-dark: #272727;
    --ohm-light-accent: #cbddd1;
    --ohm-muted-accent: #7d9b76;
    --ohm-light-bg: #EBEBEB;
    --ohm-dark-accent: #1f5014;
    --ohm-font-primary: 'Montserrat', 'Montserrat Alternates', sans-serif;
    --ohm-font-secondary: 'PT Sans', sans-serif;
}

/* --- Global Wrappers to fight Elementor and theme conflicts --- */
.aiohm-chat-wrapper, .aiohm-search-wrapper {
    max-width: 800px;
    margin: 0 auto 2em auto;
    clear: both;
}

/* Reset any theme interference */
.aiohm-chat-container * {
    box-sizing: border-box;
}

.aiohm-chat-container input,
.aiohm-chat-container textarea,
.aiohm-chat-container button {
    font-family: inherit !important;
    font-size: inherit !important;
}

/* --- CHAT WIDGET STYLES --- */
.aiohm-chat-container {
    max-width: 100%;
    border: 1px solid var(--ohm-light-bg);
    border-radius: 12px;
    overflow: hidden;
    font-family: var(--ohm-font-secondary);
    display: flex;
    flex-direction: column;
    background: var(--aiohm-secondary-color, #fdfdfd); /* Solid background */
}

.aiohm-chat-header {
    background: var(--aiohm-primary-color, var(--ohm-dark-accent));
    color: var(--aiohm-text-color, #ffffff);
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.aiohm-chat-title {
    font-family: var(--ohm-font-primary);
    font-weight: bold;
}

.aiohm-chat-status {
    display: flex;
    align-items: center;
    gap: 8px;
}

.aiohm-status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #28a745;
    transition: background-color 0.3s ease;
}

.aiohm-status-indicator[data-status="ready"] {
    background-color: #28a745;
    animation: pulse 2s infinite;
}

.aiohm-status-indicator[data-status="thinking"] {
    background-color: #ffc107;
    animation: pulse 1s infinite;
}

.aiohm-status-indicator[data-status="error"] {
    background-color: #dc3545;
    animation: none;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

.aiohm-chat-messages {
    background-color: var(--aiohm-background-color, #f0f4f8);
    flex-grow: 1;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.aiohm-message {
    display: flex;
    gap: 10px;
    max-width: 85%;
    align-items: flex-end;
}

.aiohm-message-bot {
    align-self: flex-start;
}

.aiohm-message-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.aiohm-message-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    flex-shrink: 0;
    overflow: hidden;
}

.aiohm-message-avatar img,
.aiohm-message-avatar svg {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.aiohm-message-bubble { 
    padding: 10px 15px; 
    border-radius: 12px;
    line-height: 1.6;
}

.aiohm-message-bot .aiohm-message-bubble {
    background-color: #fff;
    border: 1px solid var(--ohm-light-bg);
    color: var(--ohm-dark);
    border-bottom-left-radius: 4px;
}

.aiohm-message-user .aiohm-message-bubble {
    background-color: var(--aiohm-primary-color, #457d58);
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* Message content formatting */
.aiohm-message-content {
    word-wrap: break-word;
    white-space: pre-wrap;
}

.aiohm-message-content p {
    margin: 0 0 0.8em 0;
    line-height: 1.5;
}

.aiohm-message-content p:last-child {
    margin-bottom: 0;
}

.aiohm-message-content strong {
    font-weight: bold;
}

.aiohm-message-content em {
    font-style: italic;
}

.aiohm-typing-dots {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 8px 0;
}

.aiohm-typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: currentColor;
    opacity: 0.4;
    animation: typing-pulse 1.4s infinite;
}

.aiohm-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.aiohm-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-pulse {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1.0); opacity: 1; }
}

.aiohm-chat-input-container {
    padding: 10px;
    background-color: #fff;
    border-top: 1px solid var(--ohm-light-bg);
}

.aiohm-chat-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    border: 2px solid var(--ohm-light-bg, #EBEBEB);
    border-radius: 12px;
    padding: 8px 12px;
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.aiohm-chat-input-wrapper:focus-within {
    border-color: var(--aiohm-primary-color, #457d58);
    box-shadow: 0 0 0 3px rgba(69, 125, 88, 0.1);
}

.aiohm-chat-input {
    flex-grow: 1 !important;
    border: none !important;
    padding: 8px 4px !important;
    background: transparent !important;
    outline: none !important;
    box-shadow: none !important;
    resize: none !important;
    font-family: var(--ohm-font-secondary) !important;
    font-size: 1em !important;
    line-height: 1.4 !important;
    min-height: 20px !important;
    max-height: 120px !important;
    color: #333 !important;
    width: auto !important;
}

.aiohm-chat-input::placeholder {
    color: var(--ohm-muted-accent, #7d9b76);
}

.aiohm-chat-send-btn {
    background: var(--aiohm-primary-color, #1f5014) !important;
    border: none !important;
    border-radius: 8px !important;
    color: #fff !important;
    width: 44px !important;
    height: 44px !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
    flex-shrink: 0 !important;
    box-shadow: 0 2px 8px rgba(31, 80, 20, 0.2) !important;
    position: relative !important;
    overflow: hidden !important;
    min-width: 44px !important;
    margin: 0 !important;
    padding: 0 !important;
}

.aiohm-chat-send-btn:hover:not(:disabled) {
    background: var(--aiohm-primary-color, #2a6b1a);
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 4px 12px rgba(31, 80, 20, 0.3);
}

.aiohm-chat-send-btn:active:not(:disabled) {
    transform: translateY(0) scale(0.98);
    box-shadow: 0 2px 8px rgba(31, 80, 20, 0.2);
}

.aiohm-chat-send-btn:disabled {
    background: var(--ohm-muted-accent, #d1d5db);
    cursor: not-allowed;
    opacity: 0.5;
    transform: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Enhanced send button SVG styling */
.aiohm-chat-send-btn svg {
    transition: transform 0.2s ease;
    width: 20px;
    height: 20px;
}

.aiohm-chat-send-btn:hover:not(:disabled) svg {
    transform: translateX(2px);
}

/* Ripple effect on click */
.aiohm-chat-send-btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.3s, height 0.3s;
}

.aiohm-chat-send-btn:active::after {
    width: 50px;
    height: 50px;
}

.aiohm-chat-branding { text-align: center; }
.aiohm-chat-branding, .aiohm-chat-footer-button { transition: background-color 0.2s; }
.aiohm-chat-branding { padding: 8px 15px; background-color: #EBEBEB; font-size: 12px; color: #6c757d; }
.aiohm-chat-branding strong { color: var(--ohm-dark); }
.aiohm-chat-footer-button { display: block; text-decoration: none; font-weight: bold; padding: 12px 15px; color: var(--aiohm-text-color, #ffffff); background-color: var(--aiohm-primary-color, #457d58); }
.aiohm-chat-footer-button:hover { color: var(--aiohm-text-color, #ffffff); filter: brightness(90%); }


/* --- SEARCH COMPONENT STYLES --- */
.aiohm-search-container {
    width: 100%;
    margin: 0 auto;
}

.aiohm-search-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
    width: 100%;
}
.aiohm-search-form {
    flex-grow: 1;
    min-width: 250px;
}
.aiohm-search-input-wrapper {
    height: 50px;
    display: flex;
    width: 100%;
    border: 2px solid var(--ohm-light-bg);
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}
.aiohm-search-input-wrapper input {
    flex-grow: 1;
    border: none;
    padding: 0 16px;
    font-size: 16px;
    outline: none;
    background: transparent;
}
.aiohm-search-input-wrapper button {
    background: var(--ohm-primary);
    border: none;
    color: white;
    padding: 0 20px;
    cursor: pointer;
}
.aiohm-search-filters {
    flex-shrink: 0;
}
.aiohm-search-filters select {
    height: 50px;
    padding: 0 15px;
    border: 2px solid var(--ohm-light-bg);
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
}

.aiohm-search-results {
    margin-top: 20px;
    border-top: 1px solid var(--ohm-light-bg);
    padding-top: 20px;
}
.aiohm-search-result-item {
    background: #fdfdfd;
    border: 1px solid var(--ohm-light-bg);
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 8px;
    transition: box-shadow 0.2s;
}
.aiohm-search-result-item:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
}
.aiohm-search-result-item h3 {
    margin: 0 0 5px 0;
    font-size: 1.1em;
    font-family: var(--ohm-font-primary);
}
.aiohm-search-result-item h3 a {
    text-decoration: none;
    color: var(--ohm-dark-accent);
}
.aiohm-search-result-item p {
    margin: 0 0 10px 0;
    font-size: 0.95em;
    color: #555;
}
.aiohm-result-type {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    background-color: var(--ohm-light-accent);
    color: var(--ohm-dark-accent);
    font-size: 0.8em;
    font-weight: bold;
    text-transform: uppercase;
}