/* AI AID chat UI */

#aiaid.page.active {
    display: flex !important;
}

#aiaid {
    padding: 0 0 0;
    min-height: 100%;
}

.aiaid-container {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    height: 100%;
    padding-bottom: 75px;
}

body.web-desktop .aiaid-container {
    padding-bottom: 10px;
}

.aiaid-top-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    flex-shrink: 0;
}

.aiaid-hamburger {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.7);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.aiaid-hamburger:active {
    background: rgba(255, 255, 255, 0.12);
}

.aiaid-hamburger i {
    font-size: 20px;
}

.aiaid-type-tabs {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.aiaid-type-tabs::-webkit-scrollbar {
    display: none;
}

.aiaid-type-tab {
    border: none;
    border-radius: 20px;
    padding: 7px 12px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    background: rgba(255, 255, 255, 0.06);
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
}

.aiaid-type-tab.active {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.aiaid-type-tab--disabled {
    opacity: 0.35;
    cursor: default;
    pointer-events: none;
}

.aiaid-hidden {
    display: none;
}

/* Topics panel */
.aiaid-topics-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    z-index: 998;
}

.aiaid-topics-overlay.is-visible {
    opacity: 1;
    visibility: visible;
}

.aiaid-topics-panel {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(340px, 88vw);
    background: #16181C;
    z-index: 999;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
    padding: 16px;
    padding-top: calc(16px + var(--tg-safe-area-inset-top, 0px));
    border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.aiaid-topics-panel.is-open,
.aiaid-topics-panel[aria-hidden="false"] {
    transform: translateX(0);
}

.aiaid-topics-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    margin-bottom: 14px;
}

.aiaid-topics-close {
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.7);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.aiaid-topics-list {
    height: calc(100% - 110px);
    overflow: auto;
}

.aiaid-topics-empty {
    text-align: center;
    margin-top: 48px;
    color: rgba(255, 255, 255, 0.4);
}

.aiaid-topics-empty i {
    font-size: 32px;
    opacity: 0.5;
    display: block;
    margin-bottom: 10px;
}

.aiaid-topics-empty p {
    margin: 0 0 4px;
    font-size: 15px;
    color: rgba(255, 255, 255, 0.5);
}

.aiaid-topics-empty span {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.3);
}

/* Chat area */
.aiaid-chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.aiaid-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.aiaid-messages::-webkit-scrollbar {
    display: none;
}

/* Welcome screen */
.aiaid-welcome {
    min-height: 50vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px 0;
}

.aiaid-welcome-icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
    color: rgba(255, 255, 255, 0.15);
}

.aiaid-welcome-icon i {
    font-size: 40px;
}

.aiaid-welcome-title {
    margin: 0 0 4px;
    font-size: 26px;
    line-height: 1.15;
    font-weight: 600;
    color: #fff;
}

.aiaid-welcome-subtitle {
    margin: 0;
    color: rgba(255, 255, 255, 0.45);
    font-size: 15px;
}

.aiaid-welcome-suggestions {
    margin-top: 18px;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    width: 100%;
    scrollbar-width: none;
}

.aiaid-welcome-suggestions::-webkit-scrollbar {
    display: none;
}

.aiaid-suggestion {
    min-width: 190px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.04);
    color: #fff;
    text-align: left;
    padding: 12px 14px;
    transition: background 0.15s;
}

.aiaid-suggestion:active {
    background: rgba(255, 255, 255, 0.08);
}

.aiaid-suggestion-title {
    font-size: 13px;
    font-weight: 600;
    display: block;
    color: rgba(255, 255, 255, 0.85);
}

.aiaid-suggestion-sub {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.4);
    display: block;
    margin-top: 3px;
}

/* Input */
.aiaid-input-form {
    padding: 10px 0 0;
    flex-shrink: 0;
}

.aiaid-input-wrap {
    border-radius: 20px;
    background: #16181C;
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 10px 12px;
}

.aiaid-input {
    width: 100%;
    border: none;
    resize: none;
    min-height: 44px;
    max-height: 120px;
    background: transparent;
    color: #fff;
    font-size: 15px;
    outline: none;
    line-height: 1.4;
    font-family: inherit;
}

.aiaid-input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.aiaid-input-bottom-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 6px;
}

.aiaid-model-chip {
    border: none;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.6);
    font-size: 12px;
    padding: 5px 10px;
    transition: background 0.15s;
}

.aiaid-model-chip:active {
    background: rgba(255, 255, 255, 0.1);
}

.aiaid-input-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.aiaid-icon-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.6);
    transition: background 0.15s;
    font-size: 16px;
}

.aiaid-icon-btn:active {
    background: rgba(255, 255, 255, 0.12);
}

.aiaid-icon-btn--primary {
    background: #fff;
    color: #121417;
}

.aiaid-icon-btn--primary:active {
    background: rgba(255, 255, 255, 0.85);
}

.aiaid-icon-btn:disabled {
    opacity: 0.4;
    pointer-events: none;
}

/* Other panels */
.aiaid-other-panel {
    flex: 1;
    display: none;
    align-items: center;
    justify-content: center;
}

.aiaid-other-placeholder {
    text-align: center;
    color: rgba(255, 255, 255, 0.35);
}

.aiaid-other-placeholder i {
    font-size: 32px;
    display: block;
    margin-bottom: 8px;
    opacity: 0.5;
}

#aiaid[data-aiaid-current-type="video"] .aiaid-chat-area,
#aiaid[data-aiaid-current-type="image"] .aiaid-chat-area,
#aiaid[data-aiaid-current-type="tts"] .aiaid-chat-area,
#aiaid[data-aiaid-current-type="music"] .aiaid-chat-area {
    display: none;
}

#aiaid[data-aiaid-current-type="video"] .aiaid-other-panel,
#aiaid[data-aiaid-current-type="image"] .aiaid-other-panel,
#aiaid[data-aiaid-current-type="tts"] .aiaid-other-panel,
#aiaid[data-aiaid-current-type="music"] .aiaid-other-panel {
    display: flex;
}

/* ─── New chat button ─── */
.aiaid-new-chat-btn {
    width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    transition: background 0.15s;
}

.aiaid-new-chat-btn:active {
    background: rgba(255, 255, 255, 0.1);
}

.aiaid-new-chat-btn i {
    font-size: 16px;
}

/* ─── Topic items ─── */
.aiaid-topic-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s;
    margin-bottom: 2px;
}

.aiaid-topic-item:hover,
.aiaid-topic-item:active {
    background: rgba(255, 255, 255, 0.06);
}

.aiaid-topic-item.is-active {
    background: rgba(255, 255, 255, 0.1);
}

.aiaid-topic-title {
    flex: 1;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.8);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.aiaid-topic-delete {
    border: none;
    background: none;
    color: rgba(255, 255, 255, 0.3);
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
}

.aiaid-topic-item:hover .aiaid-topic-delete {
    opacity: 1;
}

.aiaid-topic-delete:hover {
    color: #ff4d4f;
}

/* ─── Chat messages ─── */
.aiaid-messages-list {
    padding: 8px 0;
}

.aiaid-msg {
    margin-bottom: 12px;
    max-width: 88%;
    animation: aiaidMsgIn 0.2s ease;
}

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

.aiaid-msg--user {
    margin-left: auto;
}

.aiaid-msg--assistant {
    margin-right: auto;
}

.aiaid-msg--system {
    margin: 8px auto;
    max-width: 90%;
    text-align: center;
}

.aiaid-msg-content {
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    color: #fff;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.aiaid-msg--user .aiaid-msg-content {
    background: #2681ff;
    border-bottom-right-radius: 6px;
}

.aiaid-msg--assistant .aiaid-msg-content {
    background: rgba(255, 255, 255, 0.06);
    border-bottom-left-radius: 6px;
}

.aiaid-msg--system .aiaid-msg-content {
    background: rgba(255, 180, 0, 0.1);
    color: rgba(255, 255, 255, 0.7);
    font-size: 13px;
    border-radius: 12px;
}

/* ─── Code blocks ─── */
.aiaid-code-block {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    padding: 10px 12px;
    margin: 8px 0;
    overflow-x: auto;
    font-family: 'Menlo', 'Consolas', monospace;
    font-size: 13px;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.85);
}

.aiaid-inline-code {
    background: rgba(255, 255, 255, 0.08);
    padding: 1px 5px;
    border-radius: 4px;
    font-family: 'Menlo', 'Consolas', monospace;
    font-size: 13px;
}

/* ─── Typing indicator ─── */
.aiaid-typing-dots {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 2px 0;
}

.aiaid-typing-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    animation: aiaidTypingBounce 1.2s infinite ease-in-out;
}

.aiaid-typing-dots span:nth-child(2) {
    animation-delay: 0.15s;
}

.aiaid-typing-dots span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes aiaidTypingBounce {
    0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1); }
}
