/* AIOX Processor — Floating Badge.
 *
 * Position/shape/size come from `aiox-badge--pos-*`, `aiox-badge--shape-*`,
 * and `aiox-badge--size-*` modifier classes added in PHP. Colours come from
 * CSS variables injected via wp_add_inline_style().
 */

:root {
    --aiox-badge-bg: #667eea;
    --aiox-badge-fg: #ffffff;
}

/* ===== Container (fixed-position floating widget) ===== */
.aiox-badge {
    position: fixed;
    z-index: 99998;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    color: var(--aiox-badge-fg);
    line-height: 1.4;
}

.aiox-badge--pos-bottom-right { right: 24px; bottom: 24px; }
.aiox-badge--pos-bottom-left  { left:  24px; bottom: 24px; }
.aiox-badge--pos-top-right    { right: 24px; top:    24px; }
.aiox-badge--pos-top-left     { left:  24px; top:    24px; }

/* ===== Trigger ===== */
.aiox-badge__trigger {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    background: var(--aiox-badge-bg);
    color: var(--aiox-badge-fg);
    border: 0;
    padding: 10px 14px;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.25);
    transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
    font: inherit !important;
    line-height: 1.15;
    text-align: left;
}
.aiox-badge__trigger:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.3);
    filter: brightness(1.05);
}
.aiox-badge__trigger-title    { font-size: 14px; font-weight: 700; }
.aiox-badge__trigger-subtitle { font-size: 11px; opacity: 0.85; font-weight: 500; margin-top: 2px; }

/* Shape modifiers */
.aiox-badge--shape-square  .aiox-badge__trigger { border-radius: 0; }
.aiox-badge--shape-rounded .aiox-badge__trigger { border-radius: 10px; }
.aiox-badge--shape-pill    .aiox-badge__trigger { border-radius: 50px; }
.aiox-badge--shape-circle  .aiox-badge__trigger {
    border-radius: 50%;
    width: 72px;
    height: 72px;
    padding: 0;
    align-items: center;
    justify-content: center;
}
.aiox-badge--shape-circle .aiox-badge__trigger-title    { font-size: 12px; }
.aiox-badge--shape-circle .aiox-badge__trigger-subtitle { font-size: 9px; margin-top: 1px; }

/* Size modifiers */
.aiox-badge--size-small  .aiox-badge__trigger { padding: 8px 12px; }
.aiox-badge--size-small  .aiox-badge__trigger-title    { font-size: 12px; }
.aiox-badge--size-small  .aiox-badge__trigger-subtitle { font-size: 10px; }
.aiox-badge--size-small.aiox-badge--shape-circle .aiox-badge__trigger { width: 56px; height: 56px; }

.aiox-badge--size-large  .aiox-badge__trigger { padding: 14px 18px; }
.aiox-badge--size-large  .aiox-badge__trigger-title    { font-size: 16px; }
.aiox-badge--size-large  .aiox-badge__trigger-subtitle { font-size: 12px; }
.aiox-badge--size-large.aiox-badge--shape-circle .aiox-badge__trigger { width: 88px; height: 88px; }

/* ===== Panel =====
 * Hidden by default. A `.is-open` class on the container reveals it.
 * (Using a class instead of the `hidden` attribute because `display: flex`
 * on this rule would otherwise override the attribute's UA default.)
 */
.aiox-badge__panel {
    display: none;
    position: absolute;
    width: 360px;
    max-width: calc(100vw - 48px);
    max-height: 70vh;
    overflow: hidden;
    background: #ffffff;
    color: #0f172a;
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.22);
    border: 1px solid rgba(15, 23, 42, 0.08);
    flex-direction: column;
}
.aiox-badge.is-open .aiox-badge__panel {
    display: flex;
    animation: aiox-badge-slide 0.25s ease both;
}
.aiox-badge--pos-bottom-right .aiox-badge__panel { right: 0;  bottom: calc(100% + 12px); }
.aiox-badge--pos-bottom-left  .aiox-badge__panel { left:  0;  bottom: calc(100% + 12px); }
.aiox-badge--pos-top-right    .aiox-badge__panel { right: 0;  top:    calc(100% + 12px); }
.aiox-badge--pos-top-left     .aiox-badge__panel { left:  0;  top:    calc(100% + 12px); }

@keyframes aiox-badge-slide {
    from { transform: translateY(8px); opacity: 0; }
    to   { transform: translateY(0);   opacity: 1; }
}

/* Panel — Header (gradient strip with title + close) */
.aiox-badge__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
}
.aiox-badge__panel-title {
    margin: 0;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.aiox-badge__close {
    background: rgba(255, 255, 255, 0.18);
    border: 0;
    color: #ffffff;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease;
}
.aiox-badge__close:hover { background: rgba(255, 255, 255, 0.32); }

/* Panel — Body (scrollable) */
.aiox-badge__body {
    overflow-y: auto;
    padding: 14px 16px;
    flex: 1 1 auto;
    color: #334155;
    font-size: 13px;
}
.aiox-badge__body::-webkit-scrollbar         { width: 6px; }
.aiox-badge__body::-webkit-scrollbar-track   { background: transparent; }
.aiox-badge__body::-webkit-scrollbar-thumb   { background: #cbd5e1; border-radius: 3px; }

/* Optimisation banner */
.aiox-badge__optim {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.12), rgba(118, 75, 162, 0.12));
    color: #5a4ad1;
    font-size: 11px;
    font-weight: 700;
    margin-bottom: 12px;
}
.aiox-badge__optim-icon { font-size: 13px; }

/* Sections */
.aiox-badge__section { margin-top: 14px; }
.aiox-badge__section:first-of-type { margin-top: 0; }
.aiox-badge__section-title {
    margin: 0 0 6px 0;
    font-size: 11px;
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.aiox-badge__summary {
    margin: 0;
    color: #1e293b;
    line-height: 1.55;
}

/* Topics chips */
.aiox-badge__topics {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.aiox-badge__topic {
    display: inline-block;
    padding: 3px 10px;
    background: #f1f5f9;
    color: #1e293b;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
}

/* Key points bullet list */
.aiox-badge__bullets {
    list-style: disc;
    padding-left: 20px;
    margin: 0;
    color: #1e293b;
}
.aiox-badge__bullets li { margin: 0 0 4px 0; font-size: 13px; line-height: 1.5; }
.aiox-badge__bullets li:last-child { margin-bottom: 0; }

/* Content analysis grid */
.aiox-badge__analysis {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 4px 12px;
    margin: 0;
}
.aiox-badge__analysis dt { color: #64748b; font-size: 12px; }
.aiox-badge__analysis dd { color: #1e293b; font-size: 12px; margin: 0; font-weight: 500; }

/* Q&A */
.aiox-badge__qa-list { display: flex; flex-direction: column; gap: 12px; }
.aiox-badge__qa-item {
    padding: 10px 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
}
.aiox-badge__qa-question {
    font-weight: 700;
    font-size: 13px;
    color: #0f172a;
    margin-bottom: 4px;
}
.aiox-badge__qa-answer {
    font-size: 13px;
    color: #334155;
    line-height: 1.55;
}
.aiox-badge__qa-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
    font-size: 11px;
    color: #64748b;
}
.aiox-badge__confidence {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    font-weight: 700;
    letter-spacing: 0.02em;
}
.aiox-badge__conf-icon { display: inline-block; }
.aiox-badge__confidence--high    { background: #dcfce7; color: #166534; }
.aiox-badge__confidence--medium  { background: #fef3c7; color: #92400e; }
.aiox-badge__confidence--low     { background: #fee2e2; color: #991b1b; }
.aiox-badge__confidence--unknown { background: #f1f5f9; color: #475569; }

/* Footer */
.aiox-badge__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    font-size: 11px;
}
.aiox-badge__footer-tag {
    background: #ccfbf1;
    color: #115e59;
    padding: 3px 10px;
    border-radius: 999px;
    font-weight: 700;
}
.aiox-badge__footer-link {
    color: #5a4ad1;
    text-decoration: none;
    font-weight: 600;
}
.aiox-badge__footer-link:hover { text-decoration: underline; }

/* Tiny screens */
@media (max-width: 480px) {
    .aiox-badge__panel { width: 300px; }
}
