/* AI analysis pages — loader, result panel, markdown prose */

.ai-page-stack {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.ai-loader-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    min-height: min(50vh, 420px);
    padding: 2rem 1.5rem;
    margin: 0 auto;
    max-width: 640px;
    text-align: center;
    background: rgba(24, 28, 36, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

/* Nawsome loader: outer shell fully transparent; dark caption sits behind SVG */
.ai-nawsome-loader.ai-loader-panel {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    padding: 1rem 0.75rem;
}

.ai-nawsome-loader .ai-loader-stack {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.25rem;
    min-height: min(50vh, 420px);
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    padding: 1rem 0.5rem;
}

/* Caption row: fully transparent — no fill, border, or shadow */
.ai-nawsome-loader .ai-loader-backplate {
    width: min(100%, 26rem);
    padding: 0 0.5rem;
    text-align: center;
    background: transparent;
    border: none;
    box-shadow: none;
    pointer-events: none;
}

.ai-nawsome-loader .ai-loader-backplate .ai-spin-title {
    margin: 0;
}

.ai-nawsome-loader .ai-spin-title--below-loader {
    animation: none;
    text-shadow:
        0 0 1px rgba(0, 0, 0, 0.9),
        0 2px 14px rgba(0, 0, 0, 0.75),
        0 0 20px rgba(0, 0, 0, 0.5);
}

.ai-nawsome-loader .ai-loader-svg-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
}

.ai-loader-container {
    opacity: 1;
}

.ai-loader-image {
    display: block;
    max-width: min(100%, 320px);
    height: auto;
    border-radius: 12px;
    margin: 0 auto;
}

.ai-loader-image--wide {
    max-width: min(100%, 360px);
}

.ai-spin-title {
    margin: 0;
    color: #fff;
    font-size: clamp(1.15rem, 3vw, 1.65rem);
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.35;
    animation: ai-blink 1.4s infinite ease-in-out;
}

.ai-spin-subtitle {
    margin: 0;
    color: rgba(232, 236, 241, 0.88);
    font-size: 0.95rem;
    line-height: 1.5;
    max-width: 42rem;
}

.ai-spin-subtitle--openrtb,
.ai-spin-subtitle--single {
    margin-left: 0;
    margin-top: 0;
}

/* Glass panel for streamed / injected analysis */
.ai-result-view {
    background: rgba(15, 17, 23, 0.72);
    border: 1px solid rgba(38, 43, 54, 0.95);
    padding: clamp(1.25rem, 3vw, 2rem);
    border-radius: 16px;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

.ai-result-view:empty {
    display: none;
}

.ai-error-text {
    color: #f87171;
    font-weight: 700;
    margin: 0;
    padding: 0.75rem 1rem;
    background: rgba(248, 113, 113, 0.1);
    border-radius: 10px;
    border: 1px solid rgba(248, 113, 113, 0.25);
}

/* Markdown / rich text inside result (use on wrapper or nested .ai-doc) */
.ai-doc {
    color: #e8ecf1;
    line-height: 1.65;
}

.ai-doc a {
    color: #93c5fd;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.ai-doc a:hover {
    color: #bfdbfe;
}

.ai-doc pre {
    overflow-x: auto;
    padding: 1rem 1.1rem;
    margin: 1rem 0;
    font-size: 0.8125rem;
    line-height: 1.5;
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
}

.ai-doc code {
    font-family: ui-monospace, "Cascadia Code", monospace;
}

.ai-doc :not(pre) > code {
    background: rgba(248, 113, 113, 0.12);
    color: #fecaca;
    padding: 0.15em 0.4em;
    border-radius: 6px;
    font-size: 0.9em;
}

.ai-doc blockquote {
    margin: 1rem 0;
    padding: 0.65rem 1rem;
    border-left: 4px solid #60a5fa;
    background: rgba(96, 165, 250, 0.08);
    color: rgba(232, 236, 241, 0.95);
}

.ai-doc hr {
    border: none;
    height: 1px;
    margin: 1.5rem 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.12),
        transparent
    );
}

.ai-doc table {
    border-collapse: collapse;
    width: 100%;
    margin: 1rem 0;
    font-size: 0.9rem;
}

.ai-doc table td,
.ai-doc table th {
    border: 1px solid rgba(255, 255, 255, 0.12);
    padding: 10px 14px;
}

.ai-doc table th {
    background: rgba(248, 250, 252, 0.12);
    color: #f1f5f9;
    font-weight: 600;
}

.ai-doc table td p {
    margin: 0;
}

.ai-doc table code {
    background: rgba(0, 0, 0, 0.35);
    color: #fecaca;
}

.ai-doc h1,
.ai-doc h2,
.ai-doc h3 {
    color: #60a5fa;
    margin-top: 1.35rem;
    margin-bottom: 0.5rem;
    font-weight: 700;
    line-height: 1.3;
}

.ai-doc h1:first-child,
.ai-doc h2:first-child,
.ai-doc h3:first-child {
    margin-top: 0;
}

.ai-doc p {
    line-height: 1.65;
    margin-bottom: 0.85rem;
}

.ai-doc ul {
    padding-left: 1.35rem;
    margin-bottom: 1rem;
}

.ai-doc li {
    margin-bottom: 0.4rem;
    list-style-type: disc;
}

.ai-doc strong {
    color: #4ade80;
}

@keyframes ai-blink {
    0% {
        opacity: 1;
    }
    50% {
        opacity: 0.55;
    }
    100% {
        opacity: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ai-spin-title {
        animation: none;
    }

    .ai-nawsome-loader #out2,
    .ai-nawsome-loader #out3,
    .ai-nawsome-loader #inner3,
    .ai-nawsome-loader #inner1,
    .ai-nawsome-loader #center1 {
        animation: none !important;
    }

    .ai-nawsome-loader .svg-frame svg {
        transition: none;
    }
}

/* --- Nawsome loader — https://uiverse.io/Nawsome/cowardly-squid-50 (scoped) --- */
.pf-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.ai-nawsome-loader .svg-frame {
    position: relative;
    width: 300px;
    height: 300px;
    transform-style: preserve-3d;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto;
    flex-shrink: 0;
}

.ai-nawsome-loader .svg-frame svg {
    position: absolute;
    transition: 0.5s;
    z-index: calc(1 - (0.2 * var(--j)));
    transform-origin: center;
    width: 344px;
    height: 344px;
}

.ai-nawsome-loader #out1 path {
    fill: none;
}

.ai-nawsome-loader #out3 {
    fill: none;
}

.ai-nawsome-loader .svg-frame:hover svg {
    transform: rotate(-80deg) skew(30deg) translateX(calc(45px * var(--i)))
        translateY(calc(-35px * var(--i)));
}

.ai-nawsome-loader .svg-frame svg #center {
    transition: 0.5s;
    transform-origin: center;
}

.ai-nawsome-loader .svg-frame:hover svg #center {
    transform: rotate(-30deg) translateX(45px) translateY(-3px);
}

.ai-nawsome-loader #out2 {
    animation: ai-nl-rotate16 7s ease-in-out infinite alternate;
    transform-origin: center;
}

.ai-nawsome-loader #out3 {
    animation: ai-nl-rotate16 3s ease-in-out infinite alternate;
    transform-origin: center;
    stroke: #ff0;
}

.ai-nawsome-loader #inner3,
.ai-nawsome-loader #inner1 {
    animation: ai-nl-rotate16 4s ease-in-out infinite alternate;
    transform-origin: center;
}

.ai-nawsome-loader #center1 {
    fill: #ff0;
    animation: ai-nl-rotate16 2s ease-in-out infinite alternate;
    transform-origin: center;
}

@keyframes ai-nl-rotate16 {
    to {
        transform: rotate(360deg);
    }
}
