/* Q-Orb Visual Styling */

/* === CSS Variables === */
:root {
    --q-orb-diameter: 220px;
    --q-card-bg: radial-gradient(520px 320px at 50% 32%, rgba(110, 160, 255, 0.18) 0%, rgba(60, 120, 255, 0.10) 28%, rgba(10, 18, 30, 0.85) 58%, rgba(7, 10, 15, 1) 74%, rgba(7, 10, 15, 1) 100%);
    --q-card-border: rgba(255, 255, 255, 0.08);
    --q-card-shadow: 0 26px 48px rgba(3, 6, 12, 0.65);
    --q-card-text: #dfe8ff;
    --q-card-muted: #a9b7d9;
    --q-pill-bg: rgba(255, 255, 255, 0.08);
    --q-pill-border: rgba(255, 255, 255, 0.18);
    --q-pill-hover: rgba(255, 255, 255, 0.16);
}

/* === Base Layout === */
body {
    overflow-x: hidden !important;
}

#q-panel {
    display: flex;
    flex-direction: column;
    background: white;
    border-left: 1px solid #f0f0f0;
    transition: height 0.3s ease, margin-top 0.3s ease;
    position: relative;
    right: auto;
    z-index: 1;
    padding: 0 !important;
    margin: 0 !important;
    align-self: flex-start !important;
}

#analysis-card-stack {
    scrollbar-width: thin;
    scroll-behavior: smooth;
}

#q-orb-container {
    flex: 1;
    display: flex;
    align-items: stretch;
    justify-content: center;
    padding: 0 !important;
    margin: 0 !important;
}

#q-orb {
    display: flex;
    justify-content: center;
    width: 100%;
    color: var(--q-card-text);
}

.practice-content-padding {
    position: relative;
}

.practice-content-padding > .flex {
    align-items: stretch !important;
}

/* === Q Card Shell === */
.q-card-shell {
    position: relative;
    width: 100%;
    border-radius: 20px;
    border: 1px solid var(--q-card-border);
    background: var(--q-card-bg);
    box-shadow: var(--q-card-shadow);
    overflow: hidden;
    padding: 18px 18px 22px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    isolation: isolate;
    backdrop-filter: blur(6px);
    transition: border-color 220ms ease, box-shadow 220ms ease;
}

.q-card-shell::before {
    content: '';
    position: absolute;
    inset: -40% -30% auto -30%;
    height: 70%;
    background: radial-gradient(480px 320px at 50% 20%, rgba(135, 180, 255, 0.28), rgba(30, 60, 120, 0));
    filter: blur(24px);
    opacity: 0.55;
    z-index: -2;
}

.q-card-shell::after {
    content: '';
    position: absolute;
    inset: auto 18% -48px 18%;
    height: 54px;
    border-radius: 9999px;
    background: radial-gradient(70% 70% at 50% 10%, rgba(64, 94, 190, 0.45), rgba(5, 8, 16, 0));
    filter: blur(10px);
    opacity: 0.75;
    z-index: -1;
}

/* === Q Card Wrapper === */
.q-card-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    background: radial-gradient(1200px 800px at 50% 60%, #11182a 0%, #0b0e14 55%, #070a0f 100%);
    color: #dfe8ff;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    padding: 0 !important;
    margin: 0 !important;
}

.q-card {
    width: min(420px, 100%);
    background: radial-gradient(520px 320px at 50% 32%, rgba(110, 160, 255, 0.18) 0%, rgba(60, 120, 255, 0.10) 28%, rgba(10, 18, 30, 0.9) 58%, rgba(7, 10, 15, 1) 74%);
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    overflow: hidden;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    box-sizing: border-box;
    padding-bottom: 188px;
}

.q-card-content {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    text-align: center;
    overflow-wrap: break-word;
    word-break: break-word;
    width: 100%;
    padding: 130px 16px 18px;
    margin-top: 0;
    box-sizing: border-box;
    transition: margin-top 0.3s ease;
}

/* === Orb Stage === */
.q-orb-stage {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    display: grid;
    place-items: center;
    padding: 0;
    margin-top: 10px;
}

.q-orb-orb {
    position: relative;
    width: min(var(--q-orb-diameter), 72%);
    aspect-ratio: 1 / 1;
    display: grid;
    place-items: center;
}

#q-canvas {
    width: 160px;
    height: 160px;
    display: block;
}

/* === Orb Core Styling === */
.q-orb {
    --core-inner: #ffffff;
    --core-outer: #8bd0ff;
    --rim-color: rgba(168, 85, 247, 0.75);
    --halo-color: rgba(168, 85, 247, 0.35);
    --ambient-color: rgba(89, 55, 155, 0.2);
    --lift: translate3d(0, 0, 0);
}

.q-orb-body {
    position: relative;
    width: 100%;
    border-radius: 9999px;
    display: grid;
    place-items: center;
    transform: var(--lift);
    filter: drop-shadow(0 26px 58px rgba(32, 18, 62, 0.55));
    transition: filter 320ms ease, transform 320ms ease;
}

.q-orb-ambient,
.q-orb-halo,
.q-orb-rim,
.q-orb-core {
    position: absolute;
    inset: 0;
    border-radius: 9999px;
    pointer-events: none;
    transition: opacity 320ms ease, background 320ms ease, box-shadow 320ms ease, transform 320ms ease;
}

.q-orb-ambient {
    inset: -32%;
    background: radial-gradient(circle, var(--ambient-color), rgba(7, 6, 16, 0) 70%);
    filter: blur(24px);
    opacity: 0.58;
    z-index: -2;
}

.q-orb-halo {
    inset: -18%;
    background: radial-gradient(circle, var(--halo-color), rgba(12, 12, 24, 0));
    filter: blur(14px);
    opacity: 0.87;
    animation: q-orb-idle-halo 8s ease-in-out infinite;
    z-index: -1;
}

.q-orb-rim {
    inset: 5%;
    border: 1.8px solid rgba(255, 255, 255, 0.32);
    box-shadow: 0 0 28px var(--rim-color), 0 0 80px rgba(122, 81, 194, 0.4);
    opacity: 0.88;
}

.q-orb-core {
    inset: 14%;
    background: radial-gradient(circle at 48% 42%, var(--core-inner) 0%, var(--core-outer) 64%, rgba(26, 71, 142, 0.42) 100%);
    box-shadow: inset 0 0 22px rgba(255, 255, 255, 0.55), 0 0 18px rgba(130, 160, 255, 0.25);
    animation: q-orb-idle-breathe 6s ease-in-out infinite;
}

/* === Orb Hover State === */
.q-orb:hover .q-orb-body,
.q-orb.q-state-listening .q-orb-body {
    --lift: translate3d(0, -8px, 0);
    filter: drop-shadow(0 32px 72px rgba(72, 112, 200, 0.55));
}

/* === Orb States === */
.q-orb.q-state-idle {
    --core-inner: #f6fbff;
    --core-outer: #8bd0ff;
    --rim-color: rgba(168, 120, 255, 0.55);
    --halo-color: rgba(120, 160, 255, 0.42);
    --ambient-color: rgba(68, 90, 180, 0.22);
}

.q-orb.q-state-listening {
    --core-inner: #e8ffff;
    --core-outer: #44ebff;
    --rim-color: rgba(0, 210, 255, 0.75);
    --halo-color: rgba(88, 230, 255, 0.58);
    --ambient-color: rgba(24, 180, 245, 0.28);
}

.q-orb.q-state-listening .q-orb-core {
    animation: q-orb-listening-breathe 3.5s ease-in-out infinite;
}

.q-orb.q-state-processing {
    --core-inner: #f2ecff;
    --core-outer: #b79bff;
    --rim-color: rgba(164, 126, 255, 0.95);
    --halo-color: rgba(168, 120, 255, 0.62);
    --ambient-color: rgba(110, 78, 210, 0.34);
}

.q-orb.q-state-processing .q-orb-halo {
    animation: q-orb-processing-halo 2.8s ease-in-out infinite;
}

.q-orb.q-state-processing .q-orb-rim {
    animation: q-orb-processing-ring 2.2s ease-in-out infinite;
}

.q-orb.q-state-processing .q-orb-core {
    animation: q-orb-processing-core 2.1s ease-in-out infinite;
}

/* === Spoken Text === */
.spoken {
    max-width: 90%;
    text-align: center;
    line-height: 1.5;
    margin-top: 8px;
    word-wrap: break-word;
    white-space: normal;
    transition: opacity 0.4s ease;
    font-size: 1.1em;
    position: relative;
}

.spoken-speaking {
    font-size: 1.2em;
}

.spoken-word {
    opacity: 0;
    display: inline-block;
    transition: opacity 260ms ease;
    margin-right: 0.25em;
}

.spoken-word:last-child {
    margin-right: 0;
}

.spoken-speaking .spoken-word-visible {
    opacity: 1;
}

.spoken-fade {
    opacity: 0;
}

#q-speech {
    position: absolute;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    max-width: 360px;
    text-align: center;
    z-index: 5;
    pointer-events: none;
}

#q-notifications {
    position: relative;
    z-index: 2;
    width: 100%;
    transition: opacity 1.2s ease-out;
}

.q-notify-active {
    opacity: 1;
}

.q-notify-fading {
    opacity: 0;
}

.q-status-message {
    color: var(--q-card-muted);
}

/* === Pills === */
#q-orb .pills {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 10px;
    width: 100%;
    max-width: calc(100% - 24px);
    margin: 0 auto 10px;
    overflow: visible;
    box-sizing: border-box;
}

.q-card-pills {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    padding: 4px 0 8px;
}

#q-orb .pill,
.q-card-pills .pill {
    background: var(--q-pill-bg);
    border: 1px solid var(--q-pill-border);
    color: var(--q-card-text);
    padding: 8px 12px;
    border-radius: 999px;
    font-size: 13px;
    letter-spacing: 0.01em;
    transition: background 200ms ease, border-color 200ms ease, transform 200ms ease;
    cursor: pointer;
    flex: 0 0 auto;
    white-space: nowrap;
    min-width: 88px;
    max-width: 140px;
    text-align: center;
}

.pill:hover,
.pill:focus-visible {
    background: var(--q-pill-hover);
    border-color: rgba(255, 255, 255, 0.28);
    transform: translateY(-1px);
}

.pill:focus-visible {
    outline: 2px solid rgba(135, 180, 255, 0.5);
    outline-offset: 1px;
}

.pill:active {
    transform: translateY(1px);
}

/* === Analysis Card Container === */
#analysis-card-stack {
    flex-grow: 1;
    overflow-y: auto;
    max-height: 60%;
}

#analysisToastContainer {
    width: 100% !important;
    margin-top: 8px !important;
    display: flex !important;
    justify-content: center !important;
    align-items: flex-start !important;
    position: relative !important;
    z-index: 2 !important;
    overflow: visible !important;
}

#analysisToastContainer .global-job-overlay {
    position: relative !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: flex-start !important;
    width: 100% !important;
    min-width: 100% !important;
    height: auto !important;
    inset: unset !important;
    margin: 0 !important;
    padding: 0 12px !important;
    box-sizing: border-box !important;
    pointer-events: none !important;
    overflow: visible !important;
}

#analysisToastContainer .job-cards-container {
    position: relative !important;
    width: 100% !important;
    min-width: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start !important;
    align-items: center !important;
    gap: 12px !important;
    padding: 0 !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    overflow: visible !important;
}

#analysisToastContainer .realtime-job-card,
#analysisToastContainer .job-card {
    position: relative !important;
    width: min(100%, 360px) !important;
    max-width: 360px !important;
    min-width: 260px !important;
    margin: 0 auto !important;
    left: auto !important;
    right: auto !important;
    transform: none !important;
    animation: none !important;
    transition: opacity 0.25s ease, box-shadow 0.25s ease !important;
    pointer-events: auto !important;
}

#analysisToastContainer .realtime-job-card[style*="transform"],
#analysisToastContainer .job-card[style*="transform"] {
    transform: none !important;
}

#analysisToastContainer .realtime-job-card[style*="left"],
#analysisToastContainer .job-card[style*="left"] {
    left: 0 !important;
}

/* === DAVE PATCH — Re-center analysis toast under Q === */
#analysisToastContainer {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: flex-start !important;
    width: 100% !important;
    padding: 0 0 12px !important;
    box-sizing: border-box !important;
    overflow: visible !important;
}

#analysisToastContainer .global-job-overlay {
    position: relative !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: flex-start !important;
    width: 100% !important;
    min-width: 100% !important;
    height: auto !important;
    inset: unset !important;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
    pointer-events: none !important;
    overflow: visible !important;
}

#analysisToastContainer .job-cards-container {
    position: relative !important;
    width: 100% !important;
    min-width: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 0 !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    overflow: visible !important;
}

#analysisToastContainer .realtime-job-card,
#analysisToastContainer .job-card {
    position: relative !important;
    width: 360px !important;
    min-width: 260px !important;
    max-width: 360px !important;
    margin: 0 auto !important;
    left: auto !important;
    right: auto !important;
    top: auto !important;
    transform: none !important;
    animation: none !important;
    transition: opacity 0.25s ease, box-shadow 0.25s ease !important;
    pointer-events: auto !important;
}

#analysisToastContainer .realtime-job-card[style*="transform"],
#analysisToastContainer .job-card[style*="transform"] {
    transform: none !important;
}

#analysisToastContainer .realtime-job-card[style*="width"],
#analysisToastContainer .job-card[style*="width"] {
    width: 360px !important;
    min-width: 260px !important;
    max-width: 360px !important;
}

@media (max-width: 640px) {
    .q-card-content {
        padding: 24px 16px 18px;
        margin-top: 0;
    }

    #q-speech {
        position: static;
        transform: none;
        width: 100%;
        max-width: none;
        margin-bottom: 12px;
        z-index: 2;
        pointer-events: auto;
    }

    #q-notifications {
        z-index: 1;
    }

    #analysisToastContainer .realtime-job-card,
    #analysisToastContainer .job-card {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
    }
}

@media (min-width: 700px) {
    .q-card-content {
        margin-top: -100px;
    }
}

/* === Q Analysis Debrief Card === */
.q-debrief-card {
    width: 360px;
    padding: 14px;
    border-radius: 14px;
    background: radial-gradient(circle at 25% 25%, rgba(168, 85, 247, 0.25), rgba(30, 30, 50, 0.9));
    border: 1px solid rgba(168, 85, 247, 0.4);
    text-align: center;
    color: #f3eaff;
    animation: qGlow 3s ease-in-out infinite alternate;
    box-shadow: 0 0 18px rgba(168, 85, 247, 0.4);
}

.q-debrief-header {
    font-size: 16px;
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 6px;
}

.q-debrief-stats div {
    font-size: 13px;
    color: #d5c8ff;
    margin: 3px 0;
}

.q-debrief-footer {
    font-size: 11px;
    color: #aab0ff;
    margin-top: 6px;
    opacity: 0.8;
}

@keyframes qGlow {
    from {
        box-shadow: 0 0 12px rgba(168, 85, 247, 0.3);
    }
    to {
        box-shadow: 0 0 28px rgba(168, 85, 247, 0.6);
    }
}

/* === Hidden Elements === */
body > .global-job-overlay,
.job-created-notification,
#q-status {
    display: none !important;
}

/* === Tailwind Override === */
.py-6,
.p-5 {
    padding: 0 !important;
}

/* === Animations === */
@keyframes q-orb-idle-breathe {
    0%, 100% {
        transform: scale(0.97);
    }
    45% {
        transform: scale(1.02);
    }
}

@keyframes q-orb-listening-breathe {
    0%, 100% {
        transform: scale(0.96);
    }
    48% {
        transform: scale(1.05);
    }
}

@keyframes q-orb-idle-halo {
    0%, 100% {
        opacity: 0.78;
        transform: scale(0.98);
    }
    50% {
        opacity: 0.92;
        transform: scale(1.04);
    }
}

@keyframes q-orb-processing-core {
    0%, 100% {
        transform: scale(0.94);
        box-shadow: inset 0 0 18px rgba(255, 255, 255, 0.45);
    }
    50% {
        transform: scale(1.05);
        box-shadow: inset 0 0 30px rgba(255, 255, 255, 0.7);
    }
}

@keyframes q-orb-processing-halo {
    0%, 100% {
        opacity: 0.65;
        transform: scale(1);
    }
    45% {
        opacity: 1;
        transform: scale(1.08);
    }
}

@keyframes q-orb-processing-ring {
    0%, 100% {
        box-shadow: 0 0 24px var(--rim-color), 0 0 68px rgba(168, 120, 255, 0.5);
    }
    50% {
        box-shadow: 0 0 34px var(--rim-color), 0 0 80px rgba(186, 136, 255, 0.65);
    }
}

/* === Q Speech & Notifications Regions === */
.q-speech-region,
.q-notifications-region {
  text-align: center;
  overflow: visible;
  opacity: 0;
  margin: 0;
  transition: all 0.25s ease;
}

.q-speech-region {
  font-size: 15px;
  color: #e8e8f8;
  font-weight: 400;
  line-height: 1.4;
}

.q-notifications-region {
  font-size: 13px;
  color: #bfbff5;
}

.q-speech-region:empty,
.q-notifications-region:empty {
  height: 0;
  margin: 0;
  opacity: 0;
}

.q-speech-region:not(:empty),
.q-notifications-region:not(:empty) {
  opacity: 1;
  margin-top: 6px;
}

/* === Responsive === */
@media (min-width: 1440px) {
    .max-w-\[1100px\] {
        max-width: 1280px !important;
    }
}

@media (max-width: 420px) {
    #q-orb .pill {
        flex: 1 1 45%;
    }
}
