/* --- MANTAS AI CHAT STYLES --- */
#mantas-chat-root {
    --bg: #121212;
    --surf: #1e1e1e;
    --txt: #e0e0e0;
    --prm: #8ab4f8;
    --brd: #333;
    --usr: #2b2b2b;
    --scrollbar-width: 8px;
    --marker-area-width: 24px;

    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--txt);
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    width: 100%;
}

#mantas-chat-root * {
    box-sizing: border-box;
    outline: 0;
}

#mantas-chat-root #main-content-wrapper {
    flex: 1;
    position: relative;
    overflow: hidden;
    /* Ensure scroll markers stay within */
}

#mantas-chat-root #chat {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow-y: auto;
    padding: 1rem;
    padding-right: calc(1rem + var(--marker-area-width));
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    width: 100%;
    scroll-behavior: smooth;
}

#mantas-chat-root .msg {
    max-width: 90%;
    line-height: 1.6;
    animation: f .3s ease-out;
    position: relative;
    word-wrap: break-word;
    /* Prevent overflow */
}

#mantas-chat-root .msg:has(pre) {
    max-width: 100%;
}

#mantas-chat-root .msg.user {
    align-self: flex-end;
    background: var(--usr);
    padding: 1rem;
    border-radius: 12px 12px 0 12px;
}

#mantas-chat-root .msg.model {
    align-self: flex-start;
    padding-bottom: 1rem;
    display: flex;
    flex-direction: column;
    width: 100%;
}

#mantas-chat-root .meta {
    font-size: .75rem;
    color: var(--prm);
    margin-bottom: .4rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

#mantas-chat-root .ts {
    color: #888;
    font-weight: 400;
    font-size: .7rem;
}

#mantas-chat-root .badge {
    font-size: .7rem;
    color: #aaa;
    background: #ffffff1a;
    padding: 2px 6px;
    border-radius: 4px;
}

#mantas-chat-root .copy-full-answer-btn {
    background: #3a3a3a;
    color: var(--prm);
    border: 1px solid var(--brd);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: .85rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all .2s;
    font-family: inherit;
    margin-top: 5px;
    margin-bottom: 10px;
    align-self: flex-start;
}

#mantas-chat-root .copy-full-answer-btn:hover {
    background: #4a4a4a;
    border-color: var(--prm);
}

#mantas-chat-root .code-block-controls {
    display: flex;
    gap: 10px;
    margin-top: 1rem;
    margin-bottom: 10px;
    margin-left: 0;
    /* Adjusted for chat logic */
    margin-right: 0;
    width: 100%;
    padding: 10px 1rem;
    box-sizing: border-box;
    background: #272822;
    border-radius: 6px 6px 0 0;
    align-items: center;
    flex-wrap: wrap;
}

#mantas-chat-root .code-block-controls button {
    background: #3a3a3a;
    color: var(--prm);
    border: 1px solid var(--brd);
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: .8rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all .2s;
    font-family: inherit;
}

#mantas-chat-root .code-block-controls button:hover {
    background: #4a4a4a;
    border-color: var(--prm);
}

#mantas-chat-root #chat .msg pre {
    background: #272822;
    border-radius: 0 0 6px 6px;
    overflow-x: auto;
    position: relative;
    margin: 0 0 1rem 0;
    width: 100%;
    padding: 1rem;
}

#mantas-chat-root code {
    font-family: 'Courier New', monospace;
    background: #ffffff1a;
    padding: .2em .4em;
    border-radius: 3px;
}

#mantas-chat-root pre code {
    background: 0 0;
    padding: 0;
}

#mantas-chat-root #chat .msg pre.line-numbers {
    padding-left: 3.8em;
}

#mantas-chat-root .line-numbers-rows {
    border-right: 1px solid var(--brd) !important;
}

#mantas-chat-root .line-numbers-rows>span:before {
    color: #5f5f5f !important;
}

#mantas-chat-root img {
    max-width: 100%;
    border-radius: 8px;
    margin-top: .5rem;
}

#mantas-chat-root #in {
    padding: 1rem;
    background: var(--surf);
    border-top: 1px solid var(--brd);
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
}

#mantas-chat-root #box {
    display: flex;
    gap: 0.5rem;
    width: 100%;
    align-items: flex-end;
    position: relative;
}

#mantas-chat-root textarea {
    flex: 1;
    background: var(--bg);
    border: 1px solid var(--brd);
    color: var(--txt);
    padding: 0.8rem 0.8rem 0.8rem 5rem;
    /* Space for buttons */
    border-radius: 8px;
    resize: none;
    font: inherit;
    max-height: 150px;
    transition: border-color .2s;
    min-height: 45px;
}

#mantas-chat-root textarea:focus {
    border-color: var(--prm);
}

#mantas-chat-root button {
    padding: .6rem 1rem;
    background: var(--prm);
    color: var(--bg);
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity .2s;
}

#mantas-chat-root button:hover {
    opacity: .9;
}

#mantas-chat-root .ico {
    padding: .5rem;
    background: 0 0;
    color: var(--txt);
    border: 1px solid var(--brd);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

#mantas-chat-root .ico:hover {
    background: #ffffff1a;
    border-color: var(--prm);
}

#mantas-chat-root #stop {
    background: #ff6b6b;
    color: #fff;
    display: none;
}

#mantas-chat-root #att-file,
#mantas-chat-root #att-folder {
    position: absolute;
    bottom: 10px;
    background: 0 0;
    border: none;
    color: #888;
    cursor: pointer;
    padding: 5px;
    font-size: 1.2rem;
}

#mantas-chat-root #att-file {
    left: 8px;
}

#mantas-chat-root #att-folder {
    left: 36px;
}

#mantas-chat-root #att-file:hover,
#mantas-chat-root #att-folder:hover {
    color: var(--txt);
}

#mantas-chat-root #prev {
    width: 100%;
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

#mantas-chat-root .pv {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #ffffff0d;
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid var(--brd);
    font-size: .85rem;
}

#mantas-chat-root .pv img {
    width: 40px;
    height: 40px;
    object-fit: cover;
    margin: 0;
}

#mantas-chat-root .del {
    margin-left: 8px;
    background: #ffffff1a;
    color: #aaa;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

#mantas-chat-root .del:hover {
    background: #ff6b6b;
    color: #fff;
}

#mantas-chat-root .typ {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

#mantas-chat-root .dot {
    width: 6px;
    height: 6px;
    background: var(--txt);
    border-radius: 50%;
    animation: b 1.4s infinite ease-in-out both;
    opacity: .6;
}

#mantas-chat-root .dot:nth-child(1) {
    animation-delay: -.32s;
}

#mantas-chat-root .dot:nth-child(2) {
    animation-delay: -.16s;
}

@keyframes b {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

@keyframes f {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#mantas-chat-root ::-webkit-scrollbar {
    width: var(--scrollbar-width);
}

#mantas-chat-root ::-webkit-scrollbar-track {
    background: var(--bg);
}

#mantas-chat-root ::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 4px;
}

#mantas-chat-root #hdr {
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--brd);
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    background: var(--surf);
    gap: 10px;
    flex-shrink: 0;
}

#mantas-chat-root #hdr h3 {
    margin: 0;
    font-size: 1rem;
}

#mantas-chat-root #mod {
    padding: .4rem;
    border-radius: 6px;
    background: var(--bg);
    color: var(--txt);
    border: 1px solid var(--brd);
    cursor: pointer;
    font-size: 0.85rem;
    max-width: 150px;
}

#mantas-chat-root #clr {
    padding: .4rem 0.8rem;
    background: 0 0;
    color: #ff6b6b;
    border: 1px solid #ff6b6b;
    border-radius: 6px;
    font-size: .8rem;
}

#mantas-chat-root #clr:hover {
    background: #ff6b6b;
    color: #fff;
}

#mantas-chat-root #chat-scroll-markers {
    position: absolute;
    right: 0;
    top: 2rem;
    bottom: 2rem;
    width: var(--marker-area-width);
    z-index: 5;
    pointer-events: none;
}

#mantas-chat-root .scroll-marker {
    position: absolute;
    right: calc(var(--scrollbar-width) + 4px);
    width: 6px;
    height: 6px;
    background-color: var(--prm);
    border-radius: 50%;
    cursor: pointer;
    pointer-events: auto;
    opacity: 0.7;
    transition: background-color 0.2s, opacity 0.2s;
    transform: translateY(-50%);
}

#mantas-chat-root .scroll-marker:hover {
    background-color: #a8c7fa;
    opacity: 1;
}

/* Preview floating above everything */
#scroll-marker-preview {
    position: fixed;
    display: none;
    background-color: #1e1e1e;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 1rem;
    overflow-y: auto;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    z-index: 9999;
    pointer-events: none;
    /* Changed to none for safety initially */
    font-size: 0.9rem;
    line-height: 1.6;
    color: #e0e0e0;
    white-space: pre-wrap;
    word-wrap: break-word;
    opacity: 0;
    max-width: 400px;
    max-height: 300px;
}

#scroll-marker-preview.visible {
    display: block;
    opacity: 1;
    pointer-events: auto;
}

#scroll-marker-preview pre {
    background: #272822;
    padding: 0.5rem;
    border-radius: 4px;
}

#stg-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #00000080;
    z-index: 2000;
    justify-content: center;
    align-items: center;
}

#stg-content {
    background: #1e1e1e;
    padding: 20px;
    border-radius: 8px;
    width: 350px;
    border: 1px solid #333;
    display: flex;
    flex-direction: column;
    gap: 15px;
    color: #e0e0e0;
}

#stg-content .stg-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}