/* agentmaster.css */
#agent-master-wrapper {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 700px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: none;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

#agent-master-wrapper>* {
    pointer-events: auto;
}

#agent-master-wrapper.agent-docking {
    pointer-events: none;
}

#agent-master-wrapper.agent-docked {
    width: 58px;
    height: 58px;
    max-width: 58px;
    left: auto;
    right: 22px;
    bottom: 22px;
    transform: none;
    align-items: stretch;
    pointer-events: auto;
    touch-action: none;
}

#agent-master-wrapper.agent-docking #agent-chat-window,
#agent-master-wrapper.agent-docking .agent-suggestions,
#agent-master-wrapper.agent-docking .agent-input-container {
    opacity: 0;
    transform: translateY(14px) scale(.94);
    filter: blur(2px);
}

#agent-master-wrapper.agent-docked #agent-chat-window,
#agent-master-wrapper.agent-docked .agent-suggestions,
#agent-master-wrapper.agent-docked .agent-input-container {
    display: none;
}

#agent-master-wrapper.agent-dragging {
    cursor: grabbing;
}

#agent-orb {
    display: none;
    width: 58px;
    height: 58px;
    border: 1px solid rgba(64, 224, 255, .15);
    border-radius: 50%;
    cursor: grab;
    color: var(--text, #ecf0f1);
    align-items: center;
    justify-content: center;
    background: rgba(0, 20, 40, .4);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: inset 0 0 15px rgba(64, 224, 255, .05), 0 0 16px rgba(12, 153, 134, .72), 0 0 32px rgba(12, 153, 134, .35);
    padding: 0;
}

#agent-master-wrapper.agent-docked #agent-orb {
    display: flex;
    animation: agentOrbEnter .32s cubic-bezier(.16, 1, .3, 1) both;
}

#agent-orb:active {
    cursor: grabbing;
}

#agent-orb .agent-orb-label {
    color: #ffb02e;
    font-size: .78rem;
    font-weight: 800;
    letter-spacing: .02em;
    line-height: 1;
    text-shadow: 0 0 6px rgba(255, 176, 46, .55), 0 0 14px rgba(255, 125, 32, .3);
}

@keyframes agentOrbEnter {
    0% {
        opacity: 0;
        transform: translateY(10px) scale(.55) rotate(-12deg);
    }

    65% {
        opacity: 1;
        transform: translateY(-2px) scale(1.08) rotate(2deg);
    }

    100% {
        opacity: 1;
        transform: translateY(0) scale(1) rotate(0);
    }
}

/* Chat Window */
#agent-chat-window {
    width: 100%;
    height: 50vh;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, .14), rgba(255, 255, 255, .04)),
        linear-gradient(145deg, rgba(17, 28, 38, .58), rgba(10, 18, 28, .46));
    backdrop-filter: blur(24px) saturate(135%);
    -webkit-backdrop-filter: blur(24px) saturate(135%);
    border: 1px solid rgba(255, 255, 255, .16);
    box-shadow: 0 22px 48px rgba(0, 0, 0, .38), inset 0 1px 0 rgba(255, 255, 255, .12);
    border-radius: 20px;
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(.95);
    transform-origin: bottom center;
    transition: all .3s cubic-bezier(.16, 1, .3, 1);
    visibility: hidden;
}

#agent-chat-window.active {
    opacity: 1;
    transform: translateY(0) scale(1);
    visibility: visible;
}

/* Header */
.agent-chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, .05);
    font-size: .9rem;
    color: #8b9bb4;
    font-weight: 500;
}

.agent-collapse-btn {
    background: none;
    border: none;
    color: #8b9bb4;
    cursor: pointer;
    font-size: .85rem;
    transition: color .2s;
}

.agent-collapse-btn:hover {
    color: #fff;
}

/* Chat History */
.agent-chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    scroll-behavior: smooth;
}

.agent-chat-history::-webkit-scrollbar {
    width: 6px;
}

.agent-chat-history::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, .1);
    border-radius: 3px;
}

/* Messages */
.agent-msg {
    max-width: 85%;
    line-height: 1.5;
    font-size: .95rem;
    word-break: break-word;
}

.agent-msg-user {
    align-self: flex-end;
    color: #fff;
    padding: 10px 16px;
    background: linear-gradient(135deg, #f09270, #e86a5d);
    border-radius: 16px;
    border-top-right-radius: 4px;
    box-shadow: 0 4px 15px rgba(232, 106, 93, .2);
}

.agent-msg-ai {
    align-self: flex-start;
    color: #e2e8f0;
}

.agent-msg-tool {
    align-self: flex-start;
    color: #9fb3c8;
    font-size: .82rem;
    padding: 6px 10px;
    border-radius: 8px;
    background: rgba(139, 255, 185, .08);
    border: 1px solid rgba(139, 255, 185, .15);
}

.agent-msg-ai p {
    margin: 0 0 10px;
}

.agent-msg-ai p:last-child {
    margin-bottom: 0;
}

.agent-msg-ai ul {
    margin: 5px 0 10px 20px;
    padding: 0;
}

.agent-msg-ai li {
    margin-bottom: 4px;
}

.agent-msg-ai .agent-table-wrap {
    max-width: 100%;
    margin: 10px 0;
    overflow-x: auto;
    border: 1px solid rgba(142, 231, 255, .18);
    border-radius: 8px;
    background: rgba(5, 16, 26, .32);
}

.agent-msg-ai .agent-markdown-table {
    width: 100%;
    min-width: 420px;
    border-collapse: collapse;
    font-size: .88rem;
    line-height: 1.45;
}

.agent-msg-ai .agent-markdown-table th,
.agent-msg-ai .agent-markdown-table td {
    padding: 8px 10px;
    border-right: 1px solid rgba(142, 231, 255, .14);
    border-bottom: 1px solid rgba(142, 231, 255, .12);
    text-align: left;
    vertical-align: top;
}

.agent-msg-ai .agent-markdown-table th:last-child,
.agent-msg-ai .agent-markdown-table td:last-child {
    border-right: 0;
}

.agent-msg-ai .agent-markdown-table tr:last-child td {
    border-bottom: 0;
}

.agent-msg-ai .agent-markdown-table th {
    color: #fff;
    font-weight: 700;
    background: rgba(64, 224, 255, .1);
    white-space: nowrap;
}

.agent-msg-ai .agent-markdown-table td {
    color: #dbeafe;
}

.agent-msg-ai strong {
    color: #fff;
}

.agent-msg-ai code {
    background: rgba(0, 0, 0, .3);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: inherit;
    font-size: .9em;
    color: #8bffb9;
}

.agent-msg-ai pre {
    background: rgba(0, 0, 0, .5);
    padding: 15px;
    border-radius: 8px;
    overflow-x: auto;
    border: 1px solid rgba(255, 255, 255, .05);
}

.agent-msg-ai pre code {
    background: transparent;
    padding: 0;
    color: #e2e8f0;
}

/* Loading Dots */
.agent-loading {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 10px 0;
}

.agent-dot {
    width: 6px;
    height: 6px;
    background: #8b9bb4;
    border-radius: 50%;
    animation: agentBounce 1.4s infinite ease-in-out both;
}

.agent-dot:nth-child(1) {
    animation-delay: -.32s;
}

.agent-dot:nth-child(2) {
    animation-delay: -.16s;
}

@keyframes agentBounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

.agent-caret {
    display: inline-block;
    width: 6px;
    height: 1em;
    vertical-align: middle;
    background: #8bffb9;
    border-radius: 2px;
    margin-left: 2px;
    animation: agentBounce 1s infinite alternate;
}

.agent-ui-highlight {
    outline: 2px solid rgba(139, 255, 185, .95) !important;
    box-shadow: 0 0 0 6px rgba(139, 255, 185, .18), 0 0 28px rgba(139, 255, 185, .45) !important;
    transition: outline-color .2s, box-shadow .2s;
}

/* Suggestions */
.agent-suggestions {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
    flex-wrap: wrap;
    justify-content: flex-start;
    width: 100%;
    transition: opacity .24s cubic-bezier(.16, 1, .3, 1), visibility .24s, transform .24s cubic-bezier(.16, 1, .3, 1), filter .24s;
}

.agent-suggestions.hidden {
    opacity: 0;
    visibility: hidden;
    height: 0;
    margin: 0;
}

.agent-suggestion-btn {
    background: rgba(255, 255, 255, .05);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, .1);
    color: #cbd5e1;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: .85rem;
    cursor: pointer;
    transition: all .2s;
    white-space: nowrap;
}

.agent-suggestion-btn:hover {
    background: rgba(255, 255, 255, .1);
    border-color: rgba(255, 255, 255, .2);
    color: #fff;
}

/* Input Area */
.agent-input-container {
    width: 100%;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, .13), rgba(255, 255, 255, .04)),
        linear-gradient(90deg, rgba(15, 27, 38, .58), rgba(22, 50, 62, .48));
    backdrop-filter: blur(24px) saturate(135%);
    -webkit-backdrop-filter: blur(24px) saturate(135%);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, .12);
    box-shadow: 0 14px 38px rgba(0, 0, 0, .34), inset 0 1px 0 rgba(255, 255, 255, .12);
    transform-origin: bottom center;
    transition: box-shadow .3s, opacity .24s cubic-bezier(.16, 1, .3, 1), transform .24s cubic-bezier(.16, 1, .3, 1), filter .24s;
}

.agent-input-container:focus-within {
    border-color: rgba(255, 255, 255, .12);
    box-shadow: 0 14px 38px rgba(0, 0, 0, .34), inset 0 1px 0 rgba(255, 255, 255, .12);
}

#agent-textarea {
    flex: 1 !important;
    background: transparent !important;
    border: none !important;
    color: #f8fafc !important;
    font-size: 1rem !important;
    resize: none !important;
    outline: none !important;
    padding: 0 !important;
    margin: 0 !important;
    line-height: 24px !important;
    min-height: 24px !important;
    height: 52px !important;
    max-height: 120px !important;
    font-family: inherit !important;
    scrollbar-width: none !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
}

#agent-textarea::placeholder {
    color: #64748b;
}

#agent-textarea:focus {
    box-shadow: none !important;
    background: transparent !important;
    border: none !important;
    outline: none !important;
}

.agent-submit-btn {
    position: relative;
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    background: rgba(255, 255, 255, .06);
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 50%;
    color: #aebaca;
    cursor: pointer;
    margin-left: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color .2s, transform .1s, background .2s;
    padding: 0;
    touch-action: manipulation;
    user-select: none;
}

.agent-submit-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, .1);
    text-shadow: none;
}

.agent-submit-btn:active {
    transform: scale(.95);
}

.agent-submit-btn.agent-voice-arming {
    color: #8bffb9;
    background: rgba(139, 255, 185, .12);
    border-color: rgba(139, 255, 185, .24);
}

.agent-submit-btn.agent-voice-recording {
    color: #fff;
    background: rgba(255, 70, 92, .22);
    border-color: rgba(255, 92, 112, .5);
    box-shadow: 0 0 0 6px rgba(255, 70, 92, .12), 0 0 24px rgba(255, 70, 92, .28);
    animation: agentVoicePulse 1s ease-in-out infinite;
}

.agent-submit-btn.agent-voice-recording::after {
    content: "";
    position: absolute;
    top: 7px;
    right: 7px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ff5c70;
    box-shadow: 0 0 10px rgba(255, 92, 112, .8);
}

@keyframes agentVoicePulse {
    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.06);
    }
}

.agent-submit-btn svg {
    width: 28px;
    height: 28px;
}
