/* ===================================================
   NURU INTELLIGENCE OS — WIDGET STYLES v4.0
   Dark terminal aesthetic. Not a chatbot.
   An intake intelligence system.
   =================================================== */

/* ===== CONTAINER ===== */
.nuru-chat-widget {
    background: #0d1220;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #1a2235;
    display: flex;
    flex-direction: column;
    height: 560px;
    width: 100%;
    position: relative;
    box-shadow:
        0 32px 80px rgba(0, 0, 0, 0.6),
        0 0 0 1px rgba(0, 212, 170, 0.04),
        inset 0 1px 0 rgba(255, 255, 255, 0.03);
    font-family: 'Instrument Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

.nuru-chat-widget::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(0, 212, 170, 0.6) 30%,
        rgba(0, 212, 170, 0.9) 50%,
        rgba(0, 212, 170, 0.6) 70%,
        transparent 100%
    );
    z-index: 10;
    animation: scanGlow 4s ease-in-out infinite;
}

@keyframes scanGlow {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* ===== HEADER ===== */
.chat-widget-header {
    background: #111827;
    padding: 0.875rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid #1a2235;
    flex-shrink: 0;
    position: relative;
}

.chat-widget-header::before {
    content: '';
    display: flex;
    width: 44px;
    height: 10px;
    background:
        radial-gradient(circle at 5px 50%, #ff5f57 5px, transparent 5px),
        radial-gradient(circle at 22px 50%, #febc2e 5px, transparent 5px),
        radial-gradient(circle at 39px 50%, #28c840 5px, transparent 5px);
    flex-shrink: 0;
    opacity: 0.7;
}

.status-indicator {
    width: 6px;
    height: 6px;
    background: #00d4aa;
    border-radius: 50%;
    box-shadow: 0 0 4px #00d4aa, 0 0 10px rgba(0, 212, 170, 0.4);
    animation: statusPulse 2.5s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes statusPulse {
    0%, 100% {
        box-shadow: 0 0 4px #00d4aa, 0 0 8px rgba(0, 212, 170, 0.3);
        opacity: 1;
    }
    50% {
        box-shadow: 0 0 8px #00d4aa, 0 0 20px rgba(0, 212, 170, 0.5);
        opacity: 0.8;
    }
}

.widget-title {
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    color: rgba(139, 150, 176, 0.6);
    font-weight: 500;
    font-size: 0.78rem;
    letter-spacing: 0.06em;
    flex: 1;
}

.widget-badge {
    margin-left: auto;
    background: rgba(0, 212, 170, 0.08);
    color: #00d4aa;
    border: 1px solid rgba(0, 212, 170, 0.2);
    border-radius: 4px;
    padding: 0.15rem 0.6rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    text-shadow: 0 0 8px rgba(0, 212, 170, 0.5);
}

/* ===== MESSAGES ===== */
.chat-widget-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
    background: #0d1220;
    scroll-behavior: smooth;
}

.chat-widget-messages::-webkit-scrollbar { width: 3px; }
.chat-widget-messages::-webkit-scrollbar-track { background: transparent; }
.chat-widget-messages::-webkit-scrollbar-thumb {
    background: #1a2235;
    border-radius: 2px;
}
.chat-widget-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 212, 170, 0.3);
}

/* ===== INDIVIDUAL MESSAGES ===== */
.widget-message {
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
    animation: slideIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(8px) scale(0.99); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.widget-message.user { flex-direction: row-reverse; }

.message-entered {
    animation: slideIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ===== AVATAR ===== */
.message-avatar {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
    background: #111827;
    border: 1px solid #1a2235;
}

.widget-message.ai .message-avatar {
    background: rgba(0, 212, 170, 0.06);
    border-color: rgba(0, 212, 170, 0.15);
    font-size: 0.75rem;
    color: #00d4aa;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
}

.widget-message.user .message-avatar {
    background: rgba(240, 165, 0, 0.06);
    border-color: rgba(240, 165, 0, 0.15);
}

/* ===== BUBBLES ===== */
.message-bubble {
    background: #111827;
    border: 1px solid #1a2235;
    border-radius: 10px;
    border-top-left-radius: 3px;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    line-height: 1.65;
    color: #c8d0e0;
    max-width: 100%;
    flex: 1;
    word-wrap: break-word;
    position: relative;
    transition: border-color 0.2s ease;
}

.widget-message.ai .message-bubble:hover {
    border-color: rgba(0, 212, 170, 0.12);
}

.widget-message.user .message-bubble {
    background: rgba(0, 212, 170, 0.07);
    color: #e8edf8;
    border-color: rgba(0, 212, 170, 0.18);
    border-radius: 10px;
    border-top-right-radius: 3px;
}

/* ===== TYPING INDICATOR ===== */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0.75rem 1rem;
    background: #111827;
    border: 1px solid #1a2235;
    border-radius: 10px;
    border-top-left-radius: 3px;
    width: fit-content;
}

.typing-indicator span {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #00d4aa;
    animation: typingBounce 1.2s infinite ease-in-out;
    opacity: 0.4;
}

.typing-indicator span:nth-child(1) { animation-delay: 0s; }
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% {
        transform: translateY(-5px);
        opacity: 1;
        box-shadow: 0 0 6px rgba(0, 212, 170, 0.6);
    }
}

.thinking-bubble {
    background: #111827;
    border: 1px solid #1a2235;
    border-radius: 10px;
    border-top-left-radius: 3px;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

.thinking-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    color: rgba(0, 212, 170, 0.4);
    white-space: nowrap;
    letter-spacing: 0.04em;
}

.thinking-dots {
    display: flex;
    gap: 4px;
    align-items: center;
}

.thinking-dots span {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #00d4aa;
    animation: typingBounce 1.2s infinite ease-in-out;
    opacity: 0.4;
}

.thinking-dots span:nth-child(1) { animation-delay: 0s; }
.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

.thinking-avatar { animation: avatarPulse 1.2s infinite ease-in-out; }

@keyframes avatarPulse {
    0%, 100% { transform: scale(1); }
    50%       { transform: scale(1.08); opacity: 0.8; }
}

/* ===== QUICK-PICK BUTTONS ===== */
#quickPickContainer {
    padding: 0 1.25rem 0.875rem;
    background: #0d1220;
    flex-shrink: 0;
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: max-height 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
}

#quickPickContainer.visible {
    max-height: 180px;
    opacity: 1;
}

#quickPickContainer.dismissed {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
}

.quick-pick-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(200, 208, 224, 0.45);
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.quick-pick-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

.quick-pick-btn {
    background: rgba(0, 212, 170, 0.08);
    border: 1px solid rgba(0, 212, 170, 0.3);
    border-radius: 4px;
    padding: 0.375rem 0.875rem;
    font-size: 0.775rem;
    font-family: 'Instrument Sans', sans-serif;
    color: #00d4aa;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.18s ease;
    white-space: nowrap;
    opacity: 0;
    transform: translateY(4px);
    animation: quickPickAppear 0.3s ease forwards;
    letter-spacing: 0.01em;
}

@keyframes quickPickAppear {
    to { opacity: 1; transform: translateY(0); }
}

.quick-pick-btn:hover {
    background: rgba(0, 212, 170, 0.07);
    border-color: rgba(0, 212, 170, 0.28);
    color: #00d4aa;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 212, 170, 0.1);
}

.quick-pick-btn:active {
    transform: translateY(0);
    box-shadow: none;
}

/* ===== INPUT AREA ===== */
.chat-widget-input {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 1.125rem;
    border-top: 1px solid #1a2235;
    background: #111827;
    flex-shrink: 0;
}

#nuruInput {
    flex: 1;
    background: #111827;
    border: 1px solid rgba(0, 212, 170, 0.2);
    border-radius: 6px;
    padding: 0.6rem 0.875rem;
    font-size: 0.875rem;
    font-family: 'Instrument Sans', sans-serif;
    color: #f0f4ff;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#nuruInput::placeholder {
    color: rgba(139, 150, 176, 0.3);
    font-style: normal;
}

#nuruInput:focus {
    border-color: rgba(0, 212, 170, 0.3);
    box-shadow: 0 0 0 3px rgba(0, 212, 170, 0.06);
}

/* ===== SEND BUTTON ===== */
.send-btn {
    width: 34px;
    height: 34px;
    border-radius: 6px;
    background: #00d4aa;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
    color: #080c14;
}

.send-btn:hover {
    background: #00b891;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(0, 212, 170, 0.3);
}

.send-btn:active {
    transform: translateY(0);
    box-shadow: none;
}

.send-btn svg {
    color: #080c14;
    stroke: #080c14;
}

/* ===== MARKDOWN RENDERING ===== */
.nuru-rendered .nuru-h3 {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.825rem;
    font-weight: 700;
    color: #00d4aa;
    margin: 0.625rem 0 0.25rem;
    display: block;
    letter-spacing: 0.02em;
}

.nuru-rendered .nuru-h4 {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.775rem;
    font-weight: 600;
    color: rgba(0, 212, 170, 0.7);
    margin: 0.5rem 0 0.2rem;
    display: block;
}

.nuru-rendered .nuru-list {
    margin: 0.5rem 0;
    padding-left: 1.125rem;
    list-style: none;
}

.nuru-rendered .nuru-list li {
    margin-bottom: 0.25rem;
    font-size: 0.85rem;
    line-height: 1.55;
    color: #8b96b0;
    position: relative;
    padding-left: 0.75rem;
}

.nuru-rendered .nuru-list li::before {
    content: '→';
    position: absolute;
    left: -0.25rem;
    color: rgba(0, 212, 170, 0.4);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
}

.nuru-rendered .nuru-divider {
    border: none;
    border-top: 1px solid #1a2235;
    margin: 0.75rem 0;
}

.nuru-rendered strong {
    font-weight: 600;
    color: #e8edf8;
}

.nuru-rendered .nuru-p {
    margin-bottom: 0.5rem;
    line-height: 1.65;
}

.nuru-rendered .nuru-p:last-child {
    margin-bottom: 0;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 968px) {
    .nuru-chat-widget { height: 480px; }
}

@media (max-width: 640px) {
    .nuru-chat-widget {
        height: 440px;
        border-radius: 10px;
    }
    .quick-pick-btn { font-size: 0.735rem; padding: 0.3rem 0.7rem; }
    #quickPickContainer.visible { max-height: 200px; }
    .message-bubble { max-width: 88%; font-size: 0.85rem; }
}

/* ===================================================
   WASTE MAP CARD — v1.0
   Inline diagnostic card rendered when backend
   returns waste_map field at peak insight moment.
   Appears in chat before Nuru's follow-up text.
   Design: #080c14 base, teal diagnosis, amber cost.
   =================================================== */

.waste-map-message {
    align-items: flex-start;
}

.waste-map-card {
    background: #080c14;
    border: 1px solid rgba(0, 212, 170, 0.3);
    border-radius: 10px;
    padding: 20px;
    max-width: 480px;
    font-family: 'Instrument Sans', Arial, sans-serif;
    box-shadow:
        0 0 24px rgba(0, 212, 170, 0.08),
        inset 0 1px 0 rgba(0, 212, 170, 0.05);
    animation: slideIn 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.waste-map-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(0, 212, 170, 0.15);
}

.waste-map-label {
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.15em;
    color: #00d4aa;
    text-transform: uppercase;
}

.waste-map-confidence {
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.waste-map-pattern {
    margin-bottom: 14px;
}

.waste-pattern-name {
    display: inline-block;
    background: rgba(0, 212, 170, 0.1);
    color: #00d4aa;
    font-size: 12px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 4px;
    letter-spacing: 0.04em;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.waste-pattern-def {
    color: #c8d0e0;
    font-size: 13px;
    line-height: 1.6;
    margin: 0;
}

.waste-map-quote {
    background: rgba(240, 165, 0, 0.05);
    border-left: 2px solid rgba(240, 165, 0, 0.5);
    padding: 10px 14px;
    margin-bottom: 14px;
    border-radius: 0 6px 6px 0;
}

.waste-quote-marker {
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-size: 9px;
    font-weight: 600;
    color: rgba(240, 165, 0, 0.6);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    display: block;
    margin-bottom: 6px;
}

.waste-map-quote blockquote {
    margin: 0;
    color: #cbd5e1;
    font-size: 13px;
    font-style: italic;
    line-height: 1.55;
}

.waste-map-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 10px;
}

.waste-map-cell {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 6px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.waste-cell-label {
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-size: 9px;
    font-weight: 600;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.waste-cell-value {
    color: #c8d0e0;
    font-size: 12px;
    line-height: 1.45;
}

.waste-cell-value.cost {
    color: #f0a500;
    font-weight: 700;
    font-size: 13px;
    font-family: 'JetBrains Mono', 'Courier New', monospace;
}

.waste-map-unknown {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.waste-unknown-text {
    color: #64748b;
    font-size: 12px;
    line-height: 1.5;
    font-style: italic;
}

@media (max-width: 480px) {
    .waste-map-grid { grid-template-columns: 1fr; }
    .waste-map-card { padding: 14px; max-width: 100%; }
}

/* ===================================================
   PREMIUM WIDGET UPGRADES — v5.0
   Typewriter cursor, intel bar, status cycler,
   char counter, avatar glow ring
   =================================================== */

/* Typewriter cursor */
.tw-cursor {
    display: inline-block;
    color: #00d4aa;
    font-weight: 300;
    animation: cursorBlink 0.8s step-end infinite;
    margin-left: 1px;
    font-size: 0.85em;
}
@keyframes cursorBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* ===== HEADER STATUS CYCLER ===== */
.nuru-header-id {
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-size: 0.72rem;
    font-weight: 700;
    color: #00d4aa;
    letter-spacing: 0.08em;
    flex: 1;
}

.nuru-status-wrap {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-left: auto;
}

.nuru-status-dot {
    width: 5px;
    height: 5px;
    background: #00d4aa;
    border-radius: 50%;
    flex-shrink: 0;
    animation: statusPulse 2.5s ease-in-out infinite;
}

#nuru-status-text {
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-size: 0.62rem;
    font-weight: 600;
    color: rgba(0, 212, 170, 0.55);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    transition: opacity 0.18s ease;
    white-space: nowrap;
}

/* ===== INTELLIGENCE BAR ===== */
.intel-bar {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 0.5rem 1.25rem;
    background: rgba(0, 212, 170, 0.03);
    border-top: 1px solid rgba(0, 212, 170, 0.07);
    border-bottom: 1px solid rgba(0, 212, 170, 0.07);
    flex-shrink: 0;
    overflow: hidden;
}

.intel-slot {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    padding: 0 0.75rem;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.intel-slot:first-child { padding-left: 0; }
.intel-slot:last-child { border-right: none; padding-right: 0; }

.intel-slot-label {
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-size: 8px;
    font-weight: 700;
    color: #334155;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.intel-slot-value {
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-size: 9.5px;
    font-weight: 600;
    color: #475569;
    letter-spacing: 0.06em;
    transition: color 0.4s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.intel-slot-value.intel-hit {
    color: #00d4aa;
    text-shadow: 0 0 8px rgba(0, 212, 170, 0.4);
    animation: intelFlash 0.5s ease;
}

@keyframes intelFlash {
    0% { opacity: 0.2; transform: translateY(3px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* ===== CHAR COUNTER ===== */
.nuru-input-wrap {
    position: relative;
    flex: 1;
}

#nuruCharCount {
    position: absolute;
    bottom: -18px;
    right: 2px;
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-size: 9px;
    color: #334155;
    letter-spacing: 0.06em;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

#nuruCharCount.visible { opacity: 1; }

/* ===== AVATAR GLOW (during typing only) ===== */
.message-avatar.avatar-glow {
    box-shadow: 0 0 0 2px rgba(0, 212, 170, 0.15), 0 0 12px rgba(0, 212, 170, 0.2);
    animation: avatarGlowPulse 1s ease-in-out infinite;
}

@keyframes avatarGlowPulse {
    0%, 100% { box-shadow: 0 0 0 2px rgba(0, 212, 170, 0.1), 0 0 8px rgba(0, 212, 170, 0.15); }
    50% { box-shadow: 0 0 0 3px rgba(0, 212, 170, 0.25), 0 0 18px rgba(0, 212, 170, 0.3); }
}