/**
 * Copyright since 2026 Ecom Experts
 */

:root {
    --mag-qa-primary: #2563eb;
    --mag-qa-border: #e5e7eb;
    --mag-qa-bg: #f9fafb;
    --mag-qa-text: #1f2937;
    --mag-qa-side-width: 30%;
}

.mag-qa-container {
    margin: 2rem 0;
    padding: 1.5rem;
    background: white;
    border: 1px solid var(--mag-qa-border);
    border-radius: 12px;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

.mag-qa-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--mag-qa-border);
}

.mag-qa-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--mag-qa-text);
}

.mag-qa-status-pill {
    font-size: 0.75rem;
    padding: 0.25rem 0.75rem;
    background: #ecfdf5;
    color: #059669;
    border-radius: 9999px;
    font-weight: 500;
}

/* Accordion */
.mag-qa-accordion {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.mag-qa-item {
    border: 1px solid var(--mag-qa-border);
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.2s ease, opacity 0.2s ease;
}

.mag-qa-item:hover {
    background-color: #f8fafc;
    border-color: var(--mag-qa-primary);
}

.mag-qa-item:hover {
    border-color: var(--mag-qa-primary);
    background: #f8fafc;
}

.mag-qa-question-row {
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.mag-qa-icon {
    width: 24px;
    height: 24px;
    background: var(--mag-qa-primary);
    color: white;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.8rem;
}

.mag-qa-text {
    flex: 1;
    font-weight: 600;
    color: var(--mag-qa-text);
    font-size: 0.95rem;
}

/* Search Area */
.mag-qa-input-area {
    margin-top: 1.5rem;
}

.mag-qa-input-wrapper {
    display: flex;
    gap: 0.5rem;
}

.mag-qa-input-wrapper input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--mag-qa-border);
    border-radius: 8px;
    outline: none;
}

.mag-qa-input-wrapper button {
    background: var(--mag-qa-primary);
    color: white;
    border: none;
    padding: 0 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
}

/* Popup / Terminal */
#mag-qa-popup {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 400px;
    height: 550px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    z-index: 9999;
    border: 1px solid var(--mag-qa-border);
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#mag-qa-popup.mag-qa-popup-hidden {
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    pointer-events: none;
}

/* Side Mode Base */
#mag-qa-popup.mag-qa-side-mode {
    top: 0;
    bottom: 0;
    height: 100vh;
    width: var(--mag-qa-side-width);
    border-radius: 0;
}

#mag-qa-popup.mag-qa-side-right {
    right: 0;
    left: auto;
    border-left: 1px solid var(--mag-qa-border);
}

#mag-qa-popup.mag-qa-side-left {
    left: 0;
    right: auto;
    border-right: 1px solid var(--mag-qa-border);
}

.mag-qa-popup-header {
    padding: 1rem;
    background: var(--mag-qa-primary);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mag-qa-popup-title {
    font-weight: 700;
    font-size: 1rem;
}

#mag-qa-close-popup {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mag-qa-popup-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: var(--mag-qa-bg);
}

.mag-qa-msg {
    max-width: 85%;
    padding: 0.8rem 1rem;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.4;
}

.msg-user {
    align-self: flex-end;
    background: var(--mag-qa-primary);
    color: white;
}

.msg-ai {
    align-self: flex-start;
    background: white;
    border: 1px solid var(--mag-qa-border);
    color: var(--mag-qa-text);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.mag-qa-buy-btn {
    display: block;
    width: 100%;
    margin-top: 10px;
    background: #22c55e;
    color: white;
    border: none;
    padding: 8px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.mag-qa-popup-footer {
    padding: 1rem;
    background: white;
    border-top: 1px solid var(--mag-qa-border);
}

.mag-qa-popup-input-group {
    display: flex;
    gap: 0.5rem;
}

.mag-qa-popup-input-group input {
    flex: 1;
    border: 1px solid var(--mag-qa-border);
    padding: 0.6rem;
    border-radius: 6px;
    outline: none;
}

.mag-qa-popup-input-group button {
    background: var(--mag-qa-primary);
    color: white;
    border: none;
    padding: 0.6rem 1rem;
    border-radius: 6px;
    cursor: pointer;
}

/* Mobile Optimization & Font Fixes */
@media screen and (max-width: 768px) {
    .mag-qa-container {
        padding: 1rem;
        font-size: 14px !important;
    }

    .mag-qa-title {
        font-size: 16px !important;
        /* Force px to avoid huge rem scaling */
    }

    .mag-qa-text {
        font-size: 14px !important;
    }

    .mag-qa-answer-content {
        font-size: 14px !important;
        line-height: 1.5;
    }

    .mag-qa-status-pill {
        font-size: 11px !important;
    }

    .mag-qa-input-wrapper input,
    .mag-qa-popup-input-group input,
    .mag-qa-msg {
        font-size: 14px !important;
    }

    /* Popup on Mobile: Adaptive Size */
    #mag-qa-popup {
        width: 94% !important;
        left: 3% !important;
        right: 3% !important;
        bottom: 10px !important;
        height: 70vh !important;
        border-radius: 12px !important;
    }

    /* Reset Side Mode on Mobile to behave like a bottom sheet or full modal */
    #mag-qa-popup.mag-qa-side-mode {
        width: 100% !important;
        height: 100% !important;
        top: 0 !important;
        left: 0 !important;
        border-radius: 0 !important;
    }

    .mag-qa-popup-header {
        padding: 0.8rem;
    }
}