/* JAD Robot AI — professional metallic assistant UI */
.jad-ai-wrap {
    --jad-metal: #94a3b8;
    --jad-chrome: #e2e8f0;
    --jad-cyan: #22d3ee;
    --jad-indigo: #6366f1;
    --jad-panel: #0c1018;
    --jad-surface: #141a24;
    font-family: 'Inter', system-ui, sans-serif;
}

/* WhatsApp stacked just below JAD Robot (overrides global-theme + style.css) */
body.gt-theme-active .whatsapp-float,
.whatsapp-float {
    bottom: 24px !important;
    right: 20px !important;
    z-index: 99980;
}

/* ── Launcher: floating robot ── */
.jad-ai-launcher {
    position: fixed;
    bottom: 108px;
    right: 20px;
    z-index: 99990;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 0;
    transition: transform 0.35s cubic-bezier(0.34, 1.4, 0.64, 1);
}

.jad-ai-launcher:hover {
    transform: translateY(-4px) scale(1.03);
}

.jad-ai-launcher.is-open .jad-ai-launcher-body {
    transform: scale(0.92);
    opacity: 0.85;
}

.jad-ai-launcher-ring {
    position: absolute;
    top: 2px;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: 2px solid rgba(34, 211, 238, 0.25);
    animation: jadRingPulse 2.5s ease-out infinite;
    pointer-events: none;
}

.jad-ai-launcher-body {
    position: relative;
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 50% 30%, #1e293b 0%, #0f172a 70%);
    border-radius: 18px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    box-shadow:
        0 4px 24px rgba(0, 0, 0, 0.45),
        0 0 32px rgba(34, 211, 238, 0.12),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
    transition: transform 0.3s, opacity 0.3s;
    animation: jadRobotBob 3.5s ease-in-out infinite;
}

.jad-ai-launcher-label {
    font-size: 0.62rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--jad-chrome);
    background: rgba(12, 16, 24, 0.92);
    padding: 3px 10px;
    border-radius: 999px;
    border: 1px solid rgba(34, 211, 238, 0.2);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.jad-ai-launcher-online {
    position: absolute;
    top: 6px;
    right: 2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #22c55e;
    border: 2px solid #0f172a;
    box-shadow: 0 0 10px #22c55e;
    z-index: 2;
}

/* Robot SVG animations */
.jad-robot-svg--live .jad-robot-antenna {
    animation: jadAntennaBlink 1.8s ease infinite;
}

.jad-robot-svg--live .jad-robot-eye {
    animation: jadEyeGlow 2.4s ease-in-out infinite;
}

.jad-robot-svg--thinking .jad-robot-eye {
    animation: jadEyeThink 0.5s ease infinite alternate;
}

.jad-robot-svg--thinking .jad-robot-mouth-bar {
    animation: jadMouthPulse 0.35s ease infinite alternate;
}

.jad-robot-mouth-bar {
    opacity: 0.7;
}

/* ── Chat panel ── */
.jad-ai-panel {
    position: fixed;
    bottom: 178px;
    right: 20px;
    z-index: 99989;
    width: min(420px, calc(100vw - 28px));
    height: min(580px, calc(100vh - 190px));
    transform-origin: bottom right;
    transition: opacity 0.32s, transform 0.38s cubic-bezier(0.22, 1.1, 0.36, 1), visibility 0.32s;
}

.jad-ai-panel[hidden] {
    opacity: 0;
    visibility: hidden;
    transform: scale(0.88) translateY(24px);
    pointer-events: none;
}

.jad-ai-panel:not([hidden]) {
    opacity: 1;
    visibility: visible;
    transform: scale(1) translateY(0);
}

.jad-ai-panel-frame {
    height: 100%;
    display: flex;
    flex-direction: column;
    border-radius: 22px;
    overflow: hidden;
    background: var(--jad-panel);
    border: 1px solid rgba(148, 163, 184, 0.22);
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.04) inset,
        0 28px 90px rgba(0, 0, 0, 0.55),
        0 0 80px rgba(34, 211, 238, 0.06);
}

/* Metallic top bar */
.jad-ai-panel-frame::before {
    content: '';
    display: block;
    height: 4px;
    background: linear-gradient(90deg, transparent, var(--jad-cyan), var(--jad-indigo), var(--jad-cyan), transparent);
    flex-shrink: 0;
}

.jad-ai-header {
    position: relative;
    padding: 14px 16px;
    background: linear-gradient(180deg, #161d28 0%, #10151e 100%);
    border-bottom: 1px solid rgba(148, 163, 184, 0.15);
    overflow: hidden;
}

.jad-ai-scanlines {
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(34, 211, 238, 0.02) 2px,
        rgba(34, 211, 238, 0.02) 4px
    );
    pointer-events: none;
}

.jad-ai-header-inner {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
}

.jad-ai-avatar-wrap {
    position: relative;
    flex-shrink: 0;
}

.jad-ai-avatar {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 40% 30%, #334155, #0f172a);
    border-radius: 16px;
    border: 1px solid rgba(148, 163, 184, 0.3);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.jad-ai-avatar-glow {
    position: absolute;
    inset: -4px;
    border-radius: 20px;
    background: radial-gradient(circle, rgba(34, 211, 238, 0.2), transparent 70%);
    pointer-events: none;
    animation: jadAvatarGlow 3s ease infinite;
}

.jad-ai-title {
    flex: 1;
    min-width: 0;
}

.jad-ai-title h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: 0.03em;
    color: var(--jad-chrome);
    text-transform: uppercase;
}

.jad-ai-subtitle {
    margin: 1px 0 4px;
    font-size: 0.68rem;
    color: #64748b;
    letter-spacing: 0.04em;
}

.jad-ai-status-line {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--jad-cyan);
}

.jad-ai-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 8px #22c55e;
    animation: jadStatusPulse 2s ease infinite;
}

.jad-ai-close {
    width: 34px;
    height: 34px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.2s;
}

.jad-ai-close:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.35);
    color: #fca5a5;
}

/* Messages */
.jad-ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    background:
        radial-gradient(ellipse at 50% 0%, rgba(34, 211, 238, 0.04), transparent 55%),
        var(--jad-panel);
}

.jad-ai-messages::-webkit-scrollbar { width: 4px; }
.jad-ai-messages::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.25);
    border-radius: 4px;
}

.jad-ai-msg-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    animation: jadMsgIn 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.jad-ai-msg-row--user {
    flex-direction: row-reverse;
}

.jad-ai-msg-avatar {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1e293b;
    border: 1px solid rgba(148, 163, 184, 0.2);
    overflow: hidden;
}

.jad-ai-msg-avatar svg {
    width: 28px;
    height: 28px;
}

.jad-ai-msg-avatar--user {
    background: linear-gradient(135deg, rgba(34, 211, 238, 0.15), rgba(99, 102, 241, 0.15));
    border-color: rgba(34, 211, 238, 0.25);
    color: var(--jad-cyan);
    font-size: 0.85rem;
}

.jad-ai-msg {
    max-width: calc(100% - 46px);
    padding: 11px 14px;
    border-radius: 16px;
    font-size: 0.84rem;
    line-height: 1.58;
}

.jad-ai-msg--bot {
    background: linear-gradient(145deg, #1a2230, #121820);
    border: 1px solid rgba(148, 163, 184, 0.14);
    color: #e2e8f0;
    border-bottom-left-radius: 4px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.jad-ai-msg--bot a {
    color: var(--jad-cyan);
    font-weight: 600;
    text-decoration: none;
    border-bottom: 1px solid rgba(34, 211, 238, 0.35);
}

.jad-ai-msg--bot a:hover {
    color: #67e8f9;
}

.jad-ai-msg--user {
    background: linear-gradient(135deg, rgba(34, 211, 238, 0.18), rgba(99, 102, 241, 0.14));
    border: 1px solid rgba(34, 211, 238, 0.22);
    color: #f8fafc;
    border-bottom-right-radius: 4px;
}

/* Typing row */
.jad-ai-typing-row {
    display: flex;
    gap: 10px;
    align-items: center;
    animation: jadMsgIn 0.3s ease both;
}

.jad-ai-typing-bubble {
    padding: 10px 16px;
    background: #1a2230;
    border: 1px solid rgba(148, 163, 184, 0.12);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.jad-ai-typing-text {
    font-size: 0.72rem;
    color: #64748b;
    font-weight: 600;
    letter-spacing: 0.03em;
}

.jad-ai-typing-dots {
    display: flex;
    gap: 4px;
}

.jad-ai-typing-dots span {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--jad-cyan);
    animation: jadDotBounce 1.1s ease infinite;
}

.jad-ai-typing-dots span:nth-child(2) { animation-delay: 0.12s; }
.jad-ai-typing-dots span:nth-child(3) { animation-delay: 0.24s; }

/* Quick actions */
.jad-ai-quick {
    padding: 4px 14px 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    background: var(--jad-panel);
}

.jad-ai-quick-btn {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 7px 12px;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    background: rgba(30, 41, 59, 0.6);
    color: #cbd5e1;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.jad-ai-quick-btn::before {
    content: '›';
    color: var(--jad-cyan);
    font-weight: 900;
}

.jad-ai-quick-btn:hover {
    background: rgba(34, 211, 238, 0.1);
    border-color: rgba(34, 211, 238, 0.35);
    color: #f1f5f9;
    transform: translateY(-1px);
}

/* Input area */
.jad-ai-input-wrap {
    padding: 12px 14px;
    border-top: 1px solid rgba(148, 163, 184, 0.12);
    background: linear-gradient(180deg, #10151e, #0c1018);
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.jad-ai-input-icon {
    width: 36px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #475569;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.jad-ai-input {
    flex: 1;
    min-width: 0;
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 14px;
    padding: 11px 14px;
    font-size: 0.84rem;
    background: rgba(15, 20, 28, 0.95);
    color: #f1f5f9;
    resize: none;
    max-height: 88px;
    line-height: 1.45;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.jad-ai-input::placeholder { color: #475569; }

.jad-ai-input:focus {
    outline: none;
    border-color: rgba(34, 211, 238, 0.45);
    box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.08);
}

.jad-ai-send {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    background: linear-gradient(145deg, var(--jad-cyan), var(--jad-indigo));
    color: #0f172a;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 16px rgba(34, 211, 238, 0.25);
}

.jad-ai-send:hover:not(:disabled) {
    transform: scale(1.06);
    box-shadow: 0 6px 22px rgba(34, 211, 238, 0.35);
}

.jad-ai-send:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.jad-ai-powered {
    text-align: center;
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    color: #334155;
    padding: 6px 0 10px;
    background: #0c1018;
}

.jad-ai-powered i {
    color: var(--jad-cyan);
    margin-right: 4px;
    opacity: 0.7;
}

/* Keyframes */
@keyframes jadRobotBob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

@keyframes jadRingPulse {
    0% { transform: scale(0.95); opacity: 0.7; }
    70% { transform: scale(1.15); opacity: 0; }
    100% { transform: scale(1.15); opacity: 0; }
}

@keyframes jadAntennaBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

@keyframes jadEyeGlow {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.75; }
}

@keyframes jadEyeThink {
    from { transform: scaleY(1); }
    to { transform: scaleY(0.15); }
}

@keyframes jadMouthPulse {
    from { opacity: 0.4; }
    to { opacity: 1; }
}

@keyframes jadAvatarGlow {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

@keyframes jadStatusPulse {
    0%, 100% { box-shadow: 0 0 8px #22c55e; }
    50% { box-shadow: 0 0 14px #22c55e, 0 0 4px #22c55e; }
}

@keyframes jadDotBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.35; }
    30% { transform: translateY(-5px); opacity: 1; }
}

@keyframes jadMsgIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Mobile */
@media (max-width: 768px) {
    .jad-ai-launcher {
        bottom: 148px;
        right: 14px;
    }
    .jad-ai-panel {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: min(88vh, 640px);
        transform-origin: bottom center;
    }
    .jad-ai-launcher-label { font-size: 0.58rem; }
    body.gt-theme-active .whatsapp-float,
    .whatsapp-float {
        bottom: 72px !important;
        right: 14px !important;
    }
}

/* Light theme */
body.gt-brightness-light.gt-theme-active .jad-ai-panel-frame {
    background: #f8fafc;
    border-color: #e2e8f0;
}
body.gt-brightness-light.gt-theme-active .jad-ai-header {
    background: linear-gradient(180deg, #fff, #f1f5f9);
}
body.gt-brightness-light.gt-theme-active .jad-ai-title h3 { color: #1e293b; }
body.gt-brightness-light.gt-theme-active .jad-ai-msg--bot {
    background: #fff;
    color: #334155;
    border-color: #e2e8f0;
}
body.gt-brightness-light.gt-theme-active .jad-ai-input {
    background: #fff;
    color: #1e293b;
}
body.gt-brightness-light.gt-theme-active .jad-ai-messages,
body.gt-brightness-light.gt-theme-active .jad-ai-quick,
body.gt-brightness-light.gt-theme-active .jad-ai-powered {
    background: #f8fafc;
}