:root{
	--dunkelblau: #002b44; /*Schrift: Weiss*/
    --hellgrau: #f5f5f5; /*Schrift: Blau*/
	--dunkelgrau:#5c5c5c; /*Schrift: Weiss*/
	--weiss:#ffffff; /*Schrift: Blau*/
	--schwarz:#000000; /*Schrift: Weiss*/
	--eisblau:#bed4dc; /*Schrift: Blau*/
	--taubenblau:#47617f; /*Schrift: Weiss*/
	--graublau:#85a6ba;  /*Schrift: Blau - nicht optimal - nur Überschriften*/
	--lachsrot:#ca7069;  /*Schrift: Schwarz - nicht optimal - nur Überschriften*/
    --blaugruen:#BDDBCF;
	
	--rot:#a90D00; /*Schrift: Weiss Verwendung: Links*/
	--hellrot1:#d63100; /*Schrift: Weiss - Nicht optimal - nur Überschriften*/
	--hellrot2:#ff5242; /*Schrift: Blau Verwendung: Links(Hover, Focus)*/
}

/* Container, der Seitenleiste und Chatbereich hält */
.ai-chat-main-wrapper {
    display: flex;
    margin: 20px auto;
    border-radius: 5px;
    align-items: stretch; /* Wichtig für gleiche Höhe */
    max-height:100vh;
    gap:20px
}

/* Stil für die Chat-Verlauf Seitenleiste */
.ai-chat-history {
    width: 23%;
    padding: 10px;
    background-color: var(--eisblau);
    border-radius: 15px;
    display: flex;
    flex-direction: column;
    flex-shrink: 0; 
    min-width:225px;
}

/* Stil für den "Neuer Chat"-Button */
.new-chat-button.avia-button {
    width: 100%;
    padding: 10px;
    margin:0 0 15px 0;
    background-color: var(--dunkelblau); 
    color: var(--weiss);
    border:none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.2s;
    font-family:'lato';
    font-size:20px;
}

.new-chat-button:is(:hover, :focus, :focus-visible) {
    background-color: var(--hellrot2);
}

/* Stil für den Container der Checkbox */
.storage-toggle-area {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 15px;
    padding: 10px;
    background-color: var(--hellgrau);
    border-radius: 5px;
    font-size: 0.9em;
}

.storage-toggle-area label {
    user-select: none;
    cursor: pointer;
    margin: 0;
}
#toggle-history-storage{
    cursor:pointer;
}

.history-header {
    margin-bottom: 10px;
}

.ai-chat-history h3 {
    margin-top: 0; 
    margin-bottom: 0;
    font-size: 1.1em;
    color: #333;
}

/* Container für die scrollbaren History-Einträge */
#chat-history {
    overflow-y: auto;
    display:flex;
    flex-direction:column;
    gap:5px;
    max-height:380px;
}

/* Wrapper, der Titel und Icon pro Chat-Eintrag hält */
.history-item-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 5px 0 0; 
    background-color: #fff;
    border-radius: 5px;
    transition: background-color 0.2s;
}

.history-item-wrapper:is(:hover, :focus, :focus-within){
    background-color: var(--hellrot2);
    color:var(--weiss);
}

/* Der eigentliche Chat-Titel */
.history-item {
    flex-grow: 1; 
    padding: 8px 10px;
    margin-bottom: 0;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.9em;
    background-color: transparent;
}

/* Stil für das Lösch-Symbol (❌) */
.delete-item-button {
    cursor: pointer;
    padding: 0 5px;
    line-height: 1; 
    transition: color 0.2s;
    font-family:'entypo-fontello';
    font-size:24px;
}

/* Aktiver (geladener) Chat-Eintrag */
.history-item.active {
    background-color: var(--rot);
    color: white;
    font-weight: bold;
}
.history-item-wrapper:has(.history-item.active) {
    background-color: var(--rot);
    color: white;
}
.history-item-wrapper:has(.history-item.active) .history-item {
    background-color: transparent;
    color: white;
}
.history-item-wrapper:has(.history-item.active) .delete-item-button {
    color: white;
}


/* Chat-Container (rechter Hauptbereich) */
.ai-chat-container {
    flex-grow: 1;
    background-color: #fff;
    border: none;
    min-height: 550px; /* Stellt die Mindesthöhe des Moduls sicher */
    display: flex;
    flex-direction: column;
}

.ai-chat-container-overlay {
    height: 100%;
    max-height:500px;
    background-color: #fff;
    margin-bottom: 15px;
    position:relative;
    border-radius:15px;
    box-shadow:inset 0 0 7px 2px rgba(0,0,0,0.2);
    padding:10px;
}

.ai-chat-log{
    overflow-y: auto;  
    padding: 10px 10px 35px 10px;  
    display: flex;
    flex-direction: column;
    gap:10px;
    height:100%;
    mask-image:linear-gradient(180deg, #000 90%, transparent);
}


.user-message, .bot-message {
    padding: 8px 12px;
    border-radius: 5px;
    margin-bottom: 10px;
    max-width: 80%;
    word-wrap: break-word;
}

.user-message {
    background-color: var(--eisblau);
    color: var(--dunkelblau);
    align-self: flex-end;
    margin-left: auto;
    filter:drop-shadow(0 0 3px rgba(23,54,92,0.8))
}

.bot-message {
    background-color: var(--hellgrau);
    color: var(--dunkelblau);
    align-self: flex-start;
    filter:drop-shadow(0 0 3px rgba(23,54,92,0.8))
}
#top .bot-message a:link:is(:hover, :focus, :focus-visible){
    text-decoration: underline;
}

.bot-message.loading {
    font-style: italic;
    color: var(--dunkelgrau);
}

.ai-chat-input-area {
    display: flex;
    margin-top: auto; 
    border-radius:5px;
}

#top #user-input {
    flex-grow: 1;
    padding: 10px;
    border-radius:5px 0 0 5px;
    margin-bottom:0;
    background-color:var(--hellgrau);
    border: 1px solid rgb(231, 231, 231) !important;
    box-shadow: rgba(0, 0, 0, 0.1) 0 0 10px 0;
}
#top .ai-chat-input-area:focus-within{
    border-color: rgba(84, 182, 181, 0.5);
    box-shadow: rgba(0, 43, 68, 0.5) 0 0 0 3px;
}
input[type="text"]::placeholder{
    color:var(--dunkelgrau)!important;
    opacity:0.9;
}

#send-button {
    background-color: var(--dunkelblau);
    color: var(--weiss);
    border: none;
    border-radius: 0 5px 5px 0;
    padding: 10px 10px;
    cursor: pointer;
    font-family:"lato";
    min-width:100px;
    font-size:20px;
    line-height:1.6rem;
}

#send-button:is(:hover, :focus, :focus-visible) {
    background-color: var(--hellrot2);
}

/* Stil für deaktivierte Buttons */
#send-button:disabled,
.new-chat-button:disabled { /* Falls Sie den neuen Chat Button auch mal deaktivieren möchten */
    background-color: #cccccc; /* Ein hellgrauer Hintergrund */
    color: #666666;             /* Dunklerer Text */
    cursor: not-allowed;        /* Zeigt den "nicht erlaubt"-Cursor an */
    opacity: 0.7;               /* Leicht transparent, um den Zustand zu betonen */
    box-shadow: none;           /* Entfernt Schatten, falls vorhanden */
}

/* Stil für deaktivierte Eingabefelder */
#user-input:disabled {
    background-color: #e9e9e9; /* Ein hellerer grauer Hintergrund */
    color: #888888;            /* Grauer Text */
    cursor: not-allowed;       /* Zeigt den "nicht erlaubt"-Cursor an */
    border-color: #cccccc;     /* Angepasste Rahmenfarbe */
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.05); /* Optional: leichter Innenschatten */
}

@media screen and (max-width: 767px){
    .ai-chat-main-wrapper{
        flex-direction:column;
        flex-wrap: nowrap;
        margin-bottom:50px;
    }
    .ai-chat-history{
        width:100%;
        flex-direction:row;
        flex-wrap:wrap;
        gap:10px;
    }
    .new-chat-button.avia-button, .storage-toggle-area{
        width:calc(50% - 5px);
    }
    .history-header{
        width:100%;
    }
    #chat-history{
        flex-direction:row;
        flex-wrap:wrap;
        width:100%;
    }
    .history-item-wrapper{
        max-width:200px;
    }
    .ai-chat-log{
        mask-image: none;
        min-height:450px;
    }
    .ai-chat-container-overlay{
        overflow:scroll;
    }
}
@media screen and (max-width: 499px){
    .new-chat-button.avia-button, .storage-toggle-area{
        width:100%;
    }
    .history-item-wrapper{
        width:100%;
        max-width:none;
    }
}

