/* === Basisstruktur === */
html,body { height: 100%; }
body {
    margin-top: .2em;
    font: .8em Verdana;
    padding: .7em;
}

a { color: #1b02ff; text-decoration: underline; }
a:visited  { color: purple; text-decoration: underline; }

/* === Kontextmenü für Sessioneinträge === */
.session-item {
    position: relative;
}

.session-title {
    display: inline-block;
    max-width: 80%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.menu-button {
    float: right;
    cursor: pointer;
    font-weight: bold;
    padding-left: 0.5em;
}

.context-menu {
    position: absolute;
    top: 1.5em;
    right: 0;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 6px;
    padding: 0.3em 0;
    list-style: none;
    margin: 0;
    /*   display: none; */
    z-index: 1000;
    font-size: 0.9em;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    min-width: 10em;
}

.context-menu li {
    padding: 0.4em 1em;
    cursor: pointer;
    white-space: nowrap;
}

.context-menu li:hover {
    background-color: #f0f0f0;
}

.context-menu.hidden {
    display: none !important;
}

.context-menu.visible {
    display: block;
}

/* === Vorhandene CSS bleibt unverändert === */

body { margin-top: .2em ;
    font: .8em Verdana;
    padding: .7em;}
.mira-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5em 1em;
    gap: 1em;
    background: linear-gradient(to right, #f9f9f9, #ffffff);
    border-bottom: 1px solid #ccc;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    flex-wrap: wrap;
}

pre {
    font-family: monospace;
    white-space: pre-wrap;
    background: #02ffbb;
    padding: 0.2em 0.2em;
    border-radius: 6px;
    margin: 0 .5em;
}


.mira-avatar img {
    height: 4.0em;
    /*  border-radius: 50%; */
    box-shadow: 0 0 6px rgba(255, 230, 150, 0.4);
    /*  opacity: 0.95; */
}

.mira-title {
    flex: 1;
    text-align: center;
}

.mira-title h1 {
    margin: 0;
    font-size: 1.3rem;
    letter-spacing: 0.04em;
    color: #333;
    font-family: 'Segoe UI', 'Helvetica Neue', sans-serif;
}


.mira-title i {
    font-size: 0.85em;
    font-style: normal;
    color: #777;
}

.mira-user {
    min-width: 6em;
    text-align: right;
    font-size: 0.9em;
    color: #999;
}

.user > *:first-child, .ki > *:first-child {
    font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", "Twemoji Mozilla", sans-serif;
}

.main {
    height: 100%;
    display: grid;
    grid-template-columns: minmax(5%,25%)  auto
}

.main > *:first-child { /* max-width: 20%; */ }
.main > *:first-child h2 { white-space: nowrap; }
.modellInfo { min-height: 4rem; margin-bottom: 2em }
.modellInfo  td:nth-child(odd) { font-weight: bold; padding-right: .5em }

.chatMain {display: flex; flex-direction: column}

#chatContainer { flex: 1; overflow-y: auto;}

.chatContainer { display: flex; flex-direction: column; gap: 0.5em; padding: 1em; height: 400px; overflow-y: auto; background: #f8f9fa; border-radius: 8px; }
.msgContainer { padding: 0.5em;
}


.msgContainer .message {
    white-space : pre-wrap; /* !important; */
    background-color: #d1e7dd
}
/*.msgContainer .message * { white-space : pre-wrap !important; }*/

.msgContainer .message ol {
    list-style-type: none;
}

.msgContainer .message ol > li > ol,
.msgContainer .message ol > li > ul {
    padding-left: 2.2em;
}



.msgContainer[data-role=assistant]  { margin-left: 2em }
.msgContainer[data-role=assistant]  .message { background-color: #e2e3e5 }
.msgContainer  .tool_info { margin-left: 1.5em; font-style: italic }
#chatContainer { scroll-padding-bottom: 20dvh; }
#chatContainer .message { border-radius: 8px;  padding: .3em; }
.chatContainer .message:nth-child(odd) { background-color: #f8f9fa }
.chatContainer .message:nth-child(even) { background-color: #fff }
.chatContainer .message:last-child { margin-bottom: 0 }
#chatContainer .message .name { font-weight: bold }
.chatContainer .message .text { margin-left: 0.5em }
.chatContainer .message .text:empty { display: none }
#chatContainer .message .time { font-size: 0.8em; color: #6c757d }
#chatContainer .message .time:empty { display: none }
#chatContainer .file-container {
    background-color: #fff5ea;
    display: grid;
    grid-template-columns: min-content 1fr;
    gap: 8px;
    align-items: center;
    .file-symbole { font-size: 1.4em }
    .files {
        display: flex;
        gap: 2em;
        span {
            color: blue;
            text-decoration: underline
        }
    }
}



#chatContainer .message {
    table {  table-layout: auto;
        width: auto;
        height: auto;
    }
    table tr             { border-bottom: dotted 1px  #000; }
    table tr:first-child { border-bottom: solid  1px  #000; }
    table th, table td   { padding: 0.2em 0.5em; }

}

.tool_info_pulse::after {
    content: "";
    display: inline-block;
    margin-left: 8px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #0099ff;
    animation: pulse 1.2s infinite ease-in-out;
    vertical-align: middle;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 0.6; }
    50% { transform: scale(1.6); opacity: 1; }
}

#chatContainer > DIV.thinkToggle,
#chatContainer > SPAN.aiThink {  display: none  }

#chatContainer .message div.gridTemplate {
    grid-template-columns: min-content 1fr;
}

#chatContainer .message .aiThink {
    background-color: #fff3cd;
    border-left: 4px solid #ffeeba;
   /* padding: 0.5em; */
    margin: 0.5em 0;
    font-style: italic;
    display: block;
    line-height: normal;
    font-size: 0.8rem;
}

#chatContainer .message .thinkToggle {
    display: grid;
    gap: 8px;
    align-items: start;
    button {  margin-top: .4em; }
    .hide  {  display:none }
    .minimize {
        max-height: 3.6em;
        overflow: hidden;
    }
}

#chatContainer .message .thinkToggle.noThink {
    display: none;
}


#chatContainer .tool_call {
    display: none
}

#chatContainer .aiThink .tool_call {
    display: inline;
}


.infoNew { display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: .2em 3em 0 0; }

.chatInput { margin-top: auto; padding-bottom: 4em;;
    display: flex; gap: 0.5em; }
.chatInput input { flex-grow: 1; font-size: 1.2em; }
.chatInput button { padding: 0.5em; }

.modellInfo {
    max-width: fit-content;
}



.foldable {
    border: 1px solid #aaa;
    border-radius: 8px;
    margin: 1em 0;
    font-family: sans-serif;
    background-color: #f9f9f9;
}

.fold-header {
    background-color: #eee;
    padding: 4px 6px;;
    cursor: pointer;
    font-weight: bold;
}

.fold-content {
    display: none;
    padding: 10px 12px;
    background: #fff;
    border-top: 1px solid #ccc;
    font-family: monospace;
}

.fold-content.visible {
    display: block;
}

/* Strukturierte Titel im Folding-Block */
.fold-header {
    display: flex;
    align-items: center;
    gap: 0.5em;
    font-size: 1em;
}

/* Icons in Folding-Header klarer darstellen */
.fold-header span {
    font-size: 1em;
}

/* Spezialisierte Folding-Blöcke */
.foldable:has(.fold-header:contains('Prompt')) {
    border-left: 4px solid #0d6efd;
}

.foldable:has(.fold-header:contains('Ausgabe')) {
    border-left: 4px solid #198754;
}

/* Optional: andere Typen markieren (falls du später Tab, Fehler usw. trennst) */
.foldable:has(.fold-header:contains('Fehler')) {
    border-left: 4px solid #dc3545;
}

#composer-wrapper {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    border-top: 1px solid #ccc;
    box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.1);
    z-index: 999;
    display: flex;
    flex-direction: column;
    padding: 12px 16px;
    max-height: 50dvh;
}

#composer-input {
    flex: 1;
    overflow-y: auto;
    max-height: 30dvh;
    min-height: 3em;
    resize: none;
    border: none;
    outline: none;
    padding: 8px 12px;
    font-size: 1rem;
    line-height: 1.5;
    background: #f9f9f9;
    border-radius: 8px;
}

#composer-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 8px;
}

.composer-button {
    background: #000;
    color: #fff;
    padding: 6px 12px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
}

.composer-button:hover {
    background: #333;
}

.upload-wrapper {
    position: relative;
    display: inline-block;
}

.upload-menu {
    position: absolute;
    bottom: 100%;
    left: 0;
    margin-bottom: 5px;
    background: #f0f0f0;
    border: 1px solid #ccc;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    z-index: 1000;
    display: none;
    flex-direction: column;
    width: max-content;
    min-width: 160px;
}

.upload-menu.visible {
    display: flex;
}

.upload-option {
    padding: 8px 12px;
    cursor: pointer;
    white-space: nowrap;
    font-family: sans-serif;
    font-size: 110%;
}

.upload-option:hover {
    background-color: #e6e6e6;
}

.speech-wrapper {
    position: relative;
    display: inline-block;
}

.speech-menu {
    position: absolute;
    bottom: 100%;
    left: 0;
    margin-bottom: 5px;
    background: #f0f0f0;
    border: 1px solid #ccc;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    z-index: 1000;
    display: none;
    flex-direction: column;
    width: max-content;
    min-width: 160px;
}

.speech-menu.visible {
    display: flex;
}

.speech-option {
    padding: 8px 12px;
    cursor: pointer;
    white-space: nowrap;
    font-family: sans-serif;
    font-size: 110%;
}

.speech-option:hover {
    background-color: #e6e6e6;
}

.composer-button.active-speech {
    background-color: #3399ff;
    color: white;
}
.composer-button.active-speech:hover {
    background-color: #2a82d7;
}



.tools-wrapper {
    position: relative;
    display: inline-block;
}

.tools-menu {
    position: absolute;
    bottom: 100%;
    left: 0;
    margin-bottom: 5px;
    background: #f0f0f0;
    border: 1px solid #ccc;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    z-index: 1000;
    display: none;
    flex-direction: column;
    padding: 8px;
    min-width: 180px;
}

.tools-menu.visible {
    display: flex;
}

.tool-option {
    margin: 4px 0;
    cursor: pointer;
    user-select: none;
}

.tool-option input {
    margin-right: 6px;
}

.history-wrapper {
    position: relative;
    display: inline-block;
    width: 33%;
}

#history-button {
    padding: .4em .8em;
    border-radius: 6px;
    border: 1px solid #ccc;
    background: #eee;
    font-size: 1em;
    cursor: pointer;
    transition: background-color 0.2s;
    color: inherit;
    margin: 0.5em auto;
}

#history-button:hover {
    background-color: #f5f5f5;
}

.history-menu {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    background-color: #fff;
    border: 1px solid #ccc;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    z-index: 1000;
    display: none;
    flex-direction: column;
    min-width: 160px;
    padding: 4px 0;
}

.history-menu.visible {
    display: flex;
}

.history-option {
    padding: 8px 14px;
    cursor: pointer;
    font-family: sans-serif;
    font-size: 110%;
    white-space: nowrap;
}

.history-option:hover {
    background-color: #f0f0f0;
}


.backgroundGray { background-color: #eee; color: #000;}

#thinking-toggle.active {
    background-color: #28a745;
    color: white;
}

#chat-bottom-spacer {
    height: 20dvh;
    flex-shrink: 0;
}

#mira-box {
    position: fixed;
    top: 50%;
    left: 35%;%;
    transform: translate(-50%, -50%);
    transition: opacity 0.4s ease-in-out;
    z-index: 20000 !important;
    background-color: #fff;
    padding: 1em 1.5em;
    border: 1px solid #ccc;
    border-left: 5px solid #0d6efd;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: none;
    max-width: 90%;
    text-align: center;
    animation: miraFadeIn 0.2s ease-in-out;
    font-size: 1rem;
}

#mira-box ul {
    text-align: left;
    padding-left: 1.2em;
    margin: 0.4em 0 0 0;
}
#mira-box li {
    margin-bottom: 0.2em;
}


#mira-box .mira-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5em;
    flex-wrap: wrap;
}

.mira-icon {
    font-size: 1.2em;
    animation: miraTwinkle 1s infinite ease-in-out;
}

.mira-box-visible {
    display: block !important;
}

@keyframes miraFadeIn {
    from { opacity: 0; transform: translate(-50%, -45%); }
    to   { opacity: 1; transform: translate(-50%, -50%); }
}

@keyframes miraTwinkle {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%      { opacity: 0.6; transform: scale(1.2); }
}

.toolbar-row {
    display: none;
}

#login-btn.small {
    font-size: 0.8em;
    padding: 4px 8px;
    margin-left: 0.5em;
}

.hidden {
    display: none !important;
}

/* Button in Toolbar für Sessionanzeige */
#session-toggle {
    background: #eee;
    margin: 0.5em auto;
    border: 1px solid #ccc;
    border-radius: 6px;
    padding: 0.4em 0.8em;
    font-size: 1em;
}

#session-toggle:hover {
    background: #ddd;
}

#session-popup {
    display: none;
}

#session-popup.visible {
    display: block;
}

@media screen and (orientation: landscape) {
    .main > *:last-child {
        border-left: solid 1px #000;
        margin-left: 1em;
        padding-left: 1em;
    }
    #model-toggle {
        display: none;
    }

    #model-box {
        display: block !important;
    }


    #session-toggle {
        display: none;
    }

    #session-inline-list {
        margin-top: 1em;
        font-size: 1.3em;
        height: 60%;
        overflow-y: auto;
    }

    #session-inline-ul li {
        padding: 0.4em 0;
        border-bottom: 1px solid #ccc;
        cursor: pointer;
    }

    #session-inline-ul li:hover {
        background-color: #f0f0f0;
    }

}




@media screen and (orientation: portrait) {
    body {
        font: .7em Verdana;
        background: #f8f9fa;
        /*       background-image: url('MiraPortrait.png');
               background-size: cover;
               background-repeat: no-repeat;
               background-position: center; */
    }

    h1, h2, h3 {
        font-size: .95rem
    }

    .main {
        display: block;
    }

    padding-right: .2em;
    .main > *:first-child {
        margin-left: 5%;
    }

    .modellInfo {
        margin-bottom: .2em
    }


    .infoNew { padding-right: .2em}

    .main > *:last-child {
        border-top: solid 1px #000;
        margin-top: .3em;
        padding-top: .2em;
    }

    .toolbar-row {
        display: flex;
        justify-content: center;
        gap: 0.5em;
        margin: 0.5em auto;
    }

    .toolbar-row > * {
     /*   flex: 1;
        text-align: center; */
    }

    .toolbar-row button {
        width: 100%;
        max-width: 10em;
    }

    #model-toggle {
        display: block;
        margin: 0.5em auto;
        background: #eee;
        border: 1px solid #ccc;
        border-radius: 6px;
        padding: 0.4em 0.8em;
        font-size: 1em;
    }
    #model-toggle:hover {
        background: #ddd;
    }

    #download-chat {
        display: block;
        margin: 0.5em auto;
        background: #eee;
        border: 1px solid #ccc;
        border-radius: 6px;
        padding: 0.4em 0.8em;
        font-size: 1em;
    }

    #model-box {
        display: none;
    }

    #model-box.visible {
        display: block;
        background-color: #fff;
    }

    .backGroundPic {
        background-image: url('MiraPortrait.png');
        background-size: cover;
        background-repeat: no-repeat;
        background-position: center;
    }

    #mira-box ul { font-size: .85rem }




    /* === Session-Popup für Portrait-Ansicht === */
    #session-popup {
        position: fixed;
        top: 40%;
        left: 50%;
        transform: translate(-50%, -35%);
        z-index: 9999;
        background: #fff;
        border: 1px solid #ccc;
        padding: 1em;
        border-radius: 12px;
        box-shadow: 0 6px 16px rgba(0,0,0,0.2);
        text-align: center;

        width: 95vw;
        max-height: 60vh; /* wichtig! */
        overflow-y: auto;
    }

    #popup-session-list {
        list-style: none;
        text-align: left;
        max-height: 70vh;
        overflow-y: auto;
        padding: 0;
        margin-bottom: 1em;
    }

    #popup-session-list {
        height: 45vh; /* passt sich an */
        overflow-y: auto;
    }

    /*  #session-popup.visible {
          display: block;
      } */



    #popup-session-list li {
        padding: 0.4em 0.6em;
        border-bottom: 1px solid #ddd;
        cursor: pointer;
        font-size: 1.1em;
    }

    #popup-session-list li:hover {
        background-color: #f0f0f0;
    }

    #session-inline-list {
        display: none;
    }

}
