/**
 * Inqyra Widget Styles
 * Based on ipChat widget styling
 *
 * @package Inqyra
 */

/* ============================================
   CSS Reset for Widget - Prevent theme interference
   ============================================ */

/* Remove all pseudo-elements from theme */
.inqyra-toggle::before,
.inqyra-toggle::after,
.inqyra-close::before,
.inqyra-close::after,
.inqyra-send::before,
.inqyra-send::after,
.inqyra-container button::before,
.inqyra-container button::after {
    content: none !important;
    display: none !important;
}

/* Reset all elements inside widget container */
.inqyra-widget,
.inqyra-widget * {
    box-sizing: border-box !important;
    line-height: normal;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Reset button styles */
.inqyra-toggle {
    all: unset;
    box-sizing: border-box !important;
    cursor: pointer;
}

.inqyra-close {
    all: unset;
    box-sizing: border-box !important;
    cursor: pointer;
}

/* Reset input/textarea styles */
.inqyra-container textarea {
    all: unset;
    box-sizing: border-box !important;
}

/* Reset heading styles inside widget */
.inqyra-container h3 {
    all: unset;
    display: block;
}

/* ============================================
   Widget Styles
   ============================================ */

/* Widget positioning */
.inqyra-widget {
    position: fixed;
    z-index: 999999;
}

.inqyra-position-bottom-right {
    bottom: 20px;
    right: 20px;
}

.inqyra-position-bottom-left {
    bottom: 20px;
    left: 20px;
}

.inqyra-position-top-right {
    top: 20px;
    right: 20px;
}

.inqyra-position-top-left {
    top: 20px;
    left: 20px;
}

/* Chat Toggle Button */
.inqyra-toggle {
    position: relative !important;
    border: none !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2) !important;
    transition: all 0.3s ease !important;
    width: auto !important;
    min-height: 50px !important;
    padding: 12px 20px !important;
    border-radius: 25px !important;
    gap: 8px !important;
    text-decoration: none !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    outline: none !important;
    -webkit-appearance: none !important;
    appearance: none !important;
}

.inqyra-toggle:hover {
    transform: scale(1.05) !important;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2) !important;
}

.inqyra-toggle:active {
    transform: scale(0.98) !important;
}

.inqyra-toggle-icon {
    display: inline-block;
    vertical-align: middle !important;
    flex-shrink: 0 !important;
    line-height: 0 !important;
}

.inqyra-toggle-icon svg {
    width: 24px !important;
    height: 24px !important;
    vertical-align: middle !important;
}

.inqyra-toggle-text {
    display: inline-block !important;
    vertical-align: middle !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    white-space: nowrap !important;
}

/* Hide toggle button when chat is open */
.inqyra-widget.inqyra-open .inqyra-toggle {
    display: none !important;
}

/* Chat Container */
.inqyra-container {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 520px;
    max-height: calc(100vh - 100px);
    display: none;
    flex-direction: column;
    background-color: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    animation: inqyra-slide-up 0.3s ease;
}

/* Position adjustments for container */
.inqyra-position-bottom-left .inqyra-container {
    right: auto;
    left: 0;
}

.inqyra-position-top-right .inqyra-container,
.inqyra-position-top-left .inqyra-container {
    bottom: auto;
    top: 0;
    animation: inqyra-slide-down 0.3s ease;
}

.inqyra-position-top-left .inqyra-container {
    right: auto;
    left: 0;
}

/* Animations */
@keyframes inqyra-slide-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes inqyra-slide-down {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Chat Header */
.inqyra-header {
    padding: 14px 16px !important;
    color: white !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    flex-shrink: 0;
}

.inqyra-header-icon {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.inqyra-header-info {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.inqyra-header-title {
    margin: 0 !important;
    padding: 0 !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    color: inherit !important;
    line-height: 1.3 !important;
    border: none !important;
    background: none !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.inqyra-header-subtitle {
    margin: 2px 0 0 0 !important;
    padding: 0 !important;
    font-size: 11px !important;
    opacity: 0.85;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.inqyra-close {
    background: none !important;
    border: none !important;
    color: white !important;
    font-size: 20px !important;
    cursor: pointer !important;
    padding: 0 !important;
    margin: 0 0 0 auto !important;
    width: 28px !important;
    height: 28px !important;
    min-width: 28px !important;
    min-height: 28px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 4px !important;
    transition: background-color 0.2s !important;
    box-shadow: none !important;
    text-shadow: none !important;
    line-height: 1 !important;
    flex-shrink: 0;
}

.inqyra-close:hover {
    background-color: rgba(255, 255, 255, 0.1) !important;
}

.inqyra-close svg {
    width: 16px;
    height: 16px;
}

/* Chat Messages */
.inqyra-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    background-color: #f9f9f9;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.inqyra-message {
    display: flex;
    animation: inqyra-message-slide-in 0.3s ease;
}

@keyframes inqyra-message-slide-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.inqyra-message-user {
    justify-content: flex-end;
}

.inqyra-message-assistant {
    justify-content: flex-start;
    align-items: flex-start;
}

.inqyra-message-icon {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    margin-right: 8px;
    margin-top: 2px;
}

.inqyra-message-content {
    max-width: 85%;
    padding: 10px 12px;
    border-radius: 12px;
    word-wrap: break-word;
    line-height: 1.5;
    font-size: 13px;
}

.inqyra-message-assistant .inqyra-message-content {
    background-color: #ffffff;
    color: #1F2937;
    border: 1px solid #e0e0e0;
    border-bottom-left-radius: 4px;
}

.inqyra-message-user .inqyra-message-content {
    max-width: 75%;
    border-bottom-right-radius: 4px;
}

/* Message content formatting */
.inqyra-message-content strong {
    font-weight: 600;
}

.inqyra-message-assistant .inqyra-message-content strong {
    color: #111827;
}

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

.inqyra-message-content a {
    text-decoration: underline;
    transition: color 0.2s;
}

.inqyra-message-assistant .inqyra-message-content a {
    color: #5B7FFF;
}

.inqyra-message-assistant .inqyra-message-content a:hover {
    color: #4A6FE8;
}

.inqyra-message-user .inqyra-message-content a {
    color: white;
}

/* Markdown formatting */
.inqyra-message-content .inqyra-h1 {
    font-size: 1.25em;
    display: block;
    margin: 4px 0;
}

.inqyra-message-content .inqyra-h2 {
    font-size: 1.15em;
    display: block;
    margin: 4px 0;
}

.inqyra-message-content .inqyra-h3 {
    font-size: 1.05em;
    display: block;
    margin: 3px 0;
}

.inqyra-message-content .inqyra-h4 {
    display: block;
    margin: 2px 0;
}

.inqyra-message-content pre {
    background-color: #1F2937;
    color: #E5E7EB;
    padding: 10px 12px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 6px 0;
    font-size: 0.85em;
    line-height: 1.5;
}

.inqyra-message-content code {
    background-color: rgba(0, 0, 0, 0.06);
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 0.9em;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

.inqyra-message-content pre code {
    background: none;
    padding: 0;
    font-size: inherit;
}

.inqyra-message-content ul,
.inqyra-message-content ol {
    margin: 4px 0;
    padding-left: 20px;
}

.inqyra-message-content li {
    margin: 2px 0;
}

.inqyra-message-content blockquote {
    border-left: 3px solid #D1D5DB;
    padding-left: 10px;
    margin: 6px 0;
    color: #6B7280;
}

.inqyra-message-assistant .inqyra-message-content blockquote {
    border-left-color: #9CA3AF;
}

.inqyra-message-content del {
    opacity: 0.6;
}

.inqyra-message-content hr {
    border: none;
    border-top: 1px solid #E5E7EB;
    margin: 8px 0;
}

.inqyra-message-user .inqyra-message-content code {
    background-color: rgba(255, 255, 255, 0.15);
}

/* Typing Indicator */
.inqyra-typing .inqyra-message-content {
    padding: 10px 12px;
    background-color: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
}

.inqyra-typing-dots {
    display: flex;
    gap: 4px;
    align-items: center;
    height: 20px;
}

.inqyra-typing-dots span {
    width: 8px;
    height: 8px;
    background-color: #9CA3AF;
    border-radius: 50%;
    animation: inqyra-typing-bounce 1.4s infinite;
}

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

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

@keyframes inqyra-typing-bounce {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-10px);
    }
}

/* Chat Input */
.inqyra-input-container {
    padding: 10px 12px !important;
    background-color: white !important;
    border-top: 1px solid #e0e0e0 !important;
    display: flex !important;
    gap: 8px !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    flex-shrink: 0;
}

.inqyra-input {
    flex: 1 !important;
    min-width: 0 !important;
    width: auto !important;
    height: auto !important;
    min-height: 36px !important;
    max-height: 120px !important;
    padding: 8px 14px !important;
    margin: 0 !important;
    border: none !important;
    border-radius: 20px !important;
    font-size: 12px !important;
    line-height: 1.4 !important;
    font-family: inherit !important;
    outline: none !important;
    transition: border-color 0.2s !important;
    background-color: #f0f0f0 !important;
    color: #1F2937 !important;
    box-shadow: none !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    resize: none !important;
}

.inqyra-input:focus {
    outline: none !important;
    box-shadow: none !important;
}

.inqyra-input::placeholder {
    color: #aaa !important;
    font-size: 12px !important;
    font-family: inherit !important;
    opacity: 1 !important;
}

.inqyra-send {
    all: unset !important;
    box-sizing: border-box !important;
    flex-shrink: 0 !important;
    min-width: 32px !important;
    height: 32px !important;
    padding: 0 !important;
    margin: 0 !important;
    color: white !important;
    border: none !important;
    border-radius: 50% !important;
    font-size: 12px !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    transition: filter 0.2s, opacity 0.2s !important;
    box-shadow: none !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    line-height: 1 !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 4px !important;
}

/* Send button with text - pill shape */
.inqyra-send:has(.inqyra-send-text) {
    border-radius: 16px !important;
    padding: 6px 12px !important;
    width: auto !important;
    min-width: auto !important;
}

.inqyra-send:hover:not(:disabled) {
    filter: brightness(0.9);
}

.inqyra-send:disabled {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
}

.inqyra-send svg,
.inqyra-send .inqyra-send-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.inqyra-send .inqyra-send-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.inqyra-send-text {
    white-space: nowrap;
}

/* Powered By Footer */
.inqyra-footer {
    padding: 4px 12px;
    text-align: center;
    font-size: 10px;
    color: #999;
    border-top: 1px solid #f0f0f0;
    flex-shrink: 0;
}

.inqyra-footer a {
    color: inherit;
    text-decoration: none;
}

.inqyra-footer a:hover {
    text-decoration: underline;
}

/* Scrollbar Styling */
.inqyra-messages::-webkit-scrollbar {
    width: 6px;
}

.inqyra-messages::-webkit-scrollbar-track {
    background: #F3F4F6;
}

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

.inqyra-messages::-webkit-scrollbar-thumb:hover {
    background: #9CA3AF;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .inqyra-widget.inqyra-open {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
    }

    .inqyra-container {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        height: 100% !important;
        max-height: 100% !important;
        border-radius: 0 !important;
    }
}

/* Print styles - hide widget */
@media print {
    .inqyra-widget {
        display: none !important;
    }
}
