/* ==========================================
   CSS VARIABLES & GLOBAL SETTINGS
   ========================================== */
:root {
    --main-color: rgb(242, 59, 255);
    --header-height: 62px;
    --header-width: 1290px;
    --input-height: 86px;
    --chat-width: 800px;
    --chat-pad: 16px;
    --background-col: white;
}

/* Reset default browser styles */
* {
    box-sizing: border-box;
}

/* Ensure full height for html */
html {
    height: 100%;
    margin: 0;
}


header {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background-color: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(16px);
    height: var(--header-height);
    z-index: 100;
    border-bottom: 1px solid #e0e0e052;
    padding: 12px;
    gap: 16px;
    align-items: center;
    justify-content: center;
}


body {
    font-family: Arial, sans-serif;
    background: var(--background-col);
    margin: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    /* Erlaubt dem Body zu wachsen */
}

main {
    margin-top: var(--header-height);
    width: 100%;
    /* ÄNDERUNG: Nutzt die volle verfügbare Bildschirmhöhe */
    min-height: calc(100vh - var(--header-height)); 
    display: flex;
    flex-direction: column;
    justify-content: center; /* Zentriert die Inputbar am Anfang vertikal */
    align-items: center;
}



/* ==========================================
   HEADER
   ========================================== */

.header-cont {
    display: flex;
    height: 100%;
    width: 100%;
    max-width: var(--header-width);
    gap: 16px;
    align-items: center;
    justify-content: space-between;
}

.logo-and-model {
    width: fit-content; /* Auf Desktop zieht es sich nur so breit wie nötig */
    height: 100%;
    display: flex;
    gap: 16px;
    align-items: center;
}

.logo {
    display: flex;
    height: 100%;
    width: fit-content;

    align-items: center;
    gap: 6px;
    font-size: 25px;
    color: rgb(83, 83, 83);
    font-weight: 400;
    line-height: 1em;
    text-decoration: none;

    white-space: nowrap;

    img {
        height: 100%;
        width: auto;
    }
}


.model-selector {
    height: fit-content;
    padding: 10px 14px;
    border: none;
    color: #292929;

    &:hover {
        background-color: rgba(224, 224, 224, 0.305);
    }

    appearance: base-select;
    align-items: center;
    /*padding-right: 14px;*/


    option {
        border-radius: 6px;
        border: none;
    }
}
.model-selector::picker-icon {
    content: ""; /* Löscht das gefüllte Standard-Dreieck */
    
    /* Größe des Pfeils definieren */
    width: 8px;
    height: 8px;
    
    /* Nur zwei Linien zeichnen (rechts und unten) */
    border-right: 2px solid #333; /* Stärke und Farbe der Linie */
    border-bottom: 2px solid #333;
    
    /* Um 45 Grad drehen, damit es nach unten zeigt */
    transform: translateY(-30%) rotate(45deg);
    
    /* Positionierung anpassen */
    right: 16px; 

}

.nav-menu {
    display: flex;
    gap: 20px;

    height: fit-content;
    width: fit-content;
    padding: 10px;

    white-space: nowrap;

    a {
        color: #333333;
        text-decoration: none;
        font-size: 16px;

        &:hover {
            color: #1c1c1c;
        }
    }
}


/* ==========================================
   WELCOME SCREEN
   ========================================== */
.welcome-screen {
    text-align: center;
    margin-bottom: 14px; /* Abstand zur Inputbar */
    transition: opacity 0.2s ease-in-out, transform 0.2s ease-in-out;
    opacity: 1;
    width: 100%;
    max-width: calc(var(--chat-width) - (var(--chat-pad) * 2));
}

.welcome-screen h1 {
    font-size: 32px;
    color: #222;
    margin: 0;
    font-weight: 500;
}

/* Wird per JS ausgelöst, wenn die erste Nachricht fliegt */
.welcome-screen.hidden {
    opacity: 0;
    transform: translateY(-10px);
    display: none;
}


/* ==========================================
   CHAT
   ========================================== */

.chat-area {
    margin-left: auto;
    margin-right: auto;
    width: 100%;
    max-width: var(--chat-width);
    padding: var(--chat-pad);
    display: flex;
    flex-direction: column;
    flex: 1; /* Füllt den Raum aus */
    justify-content: flex-start; /* Drückt die leere Chatbox zusammen */
}


/* Chat box that displays messages */
.chat-box {
    width: 100%;
    margin-bottom: var(--input-height);
}


/* Suggestions */

.suggestions-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    max-width: calc(var(--chat-width) - (var(--chat-pad) * 2));
    min-height: fit-content;
}



/* Absolute Positionierung: Verhindert jegliches Glitchen im Layout */
.scroll-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.9); /* Leicht transparent */
    backdrop-filter: blur(4px);
    border: 1px solid rgba(92, 92, 92, 0.2);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: none; 
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
    color: #444;
    box-shadow: 0 2px 5px rgba(0,0,0,0.15);
    z-index: 10;
    transition: background-color 0.2s, opacity 0.2s;
    user-select: none;
}

/* FIX: Jetzt mit Abstand zum inneren Rand, statt außerhalb zu hängen */
.scroll-btn.prev { left: 0px; }
.scroll-btn.next { right: 0px; }

.scroll-btn:hover { background: #ffffff; }

/* Auf Smartphones (Touch) generell keine Buttons erzwingen */
@media (hover: none) and (pointer: coarse) {
    .scroll-btn { display: none !important; }
}



/* Container für die Kärtchen oberhalb der Input-Box */
.suggestions-container {
    display: flex;
    gap: 8px;
    width: 100%;
    flex-direction: row;
    flex-wrap: nowrap; 
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 4px 0;
    scrollbar-width: none;  /* Firefox */
}
.suggestions-container::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

.suggestions-container {
    -ms-overflow-style: none;  /* IE und Edge */
    scrollbar-width: none;  /* Firefox */
}

/* Einzelnes Kärtchen Design */
.suggestion-card {
    background-color: #ffffff;
    border: 1px solid rgba(92, 92, 92, 0.2);
    border-radius: 16px;
    padding: 8px 14px;
    font-size: 14px;
    color: #444;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: background-color 0.2s, transform 0.1s;
    
    /* WICHTIG: Verhindert, dass die Kärtchen zusammengedrückt werden */
    flex-shrink: 0; 
    white-space: nowrap; 
}

.suggestion-card:hover {
    background-color: #f5f5f5;
    border-color: rgba(92, 92, 92, 0.4);
}

.suggestion-card:active {
    transform: scale(0.98);
}



/* Der Standard-Zustand (Unten fixiert, wenn Nachrichten da sind) */
.input-area {
    display: flex;
    flex-direction: column;
    align-items: center;      
    justify-content: flex-end;
    gap: 7px;

    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 99;
    width: 100%;              
    
    background: linear-gradient(
        to bottom,
        rgba(255, 255, 255, 0) 0%,
        var(--background-col) 50%,
        var(--background-col) 100%
    );
    
    padding: 6px var(--chat-pad) 12px var(--chat-pad); 
    transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1); /* Macht das Heruntergleiten super smooth */
}

/* NEU: Dieser Zustand erzwingt die exakte Bildschirmmitte am Anfang */
.input-area.initial-center {
    top: 50%;
    bottom: auto;
    transform: translateY(-50%); /* Zentriert den gesamten Block aus Text + Input perfekt */
    background: transparent;
}

.input-area small {
    color: rgba(0, 0, 0, 0.518);
    text-align: center;
    font-size: 12px;
}

/* Neu: Sorgt dafür, dass der absolut positionierte Button sich am Input orientiert */
.input-wrapper {
    position: relative;
    width: 100%;
    
    /* DER FIX: 700px minus 2x das Padding (links & rechts), 
       damit es exakt so breit ist wie der Textbereich im Chat */
    max-width: calc(var(--chat-width) - (var(--chat-pad) * 2)); 
    
    display: block; 
}


input {
    flex: 1;
    width: 100%;
    height: fit-content;
    max-height: 450px;
    padding: 14px 42px 14px 16px; /* Behalte das extra Padding rechts für den Button */
    resize: none;
    field-sizing: content;
    min-height: 1lh;
    background-color: rgb(255, 255, 255);
    border: 1px solid rgba(92, 92, 92, 0.288);
    border-radius: 25px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    font-family: "Google Sans", sans-serif;
    font-size: 16px;
    outline: none;
}


.send-btn {
    position: absolute;
    right: 8px; /* Ein Stück vom rechten Rand des Inputs eingerückt */
    top: 50%; /* Schiebt die obere Kante des Buttons in die Mitte */
    transform: translateY(-50%); /* Zieht den Button exakt um seine halbe Eigenhöhe hoch */

    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex; /* Verhindert unerwünschte Abstände um das Icon-Bild */
    align-items: center;
    justify-content: center;
}

.send-btn img {
    width: 18px;
    height: 18px;
    object-fit: contain;
    pointer-events: none;
    opacity: 70%;
}







/* ==========================================
   MESSAGE STYLES
   ========================================== */
/* Base message styling */
.msg {
    margin: 10px 0;
    padding: 10px;
    /*border-radius: 8px;*/
    max-width: 80%;
    display: block;
    clear: both;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
    overflow: hidden;
}

/* User message styling (right side, purple background) */
.user {
    /*background: var(--main-color);*/
    background-color: #f2f2f2;
    /*color: white;*/
    color: black;
    float: right;
    text-align: right;
    border-radius: 12px 2px 12px 12px;
}

/* Bot message styling (left side, gray background) */
.bot {
    /*background: #e4e6eb;*/
    color: black;
    float: left;
    border-radius: 2px 12px 12px 12px;
}



/* Der suggest button direkt in der Chat-Blase der KI */
.inline-suggestion-btn {
    display: block; /* Platziert ihn auf einer neuen Zeile innerhalb der Blase */
    margin-top: 12px;
    background-color: #ffffff;
    border: 1px solid rgba(92, 92, 92, 0.2);
    border-radius: 12px;
    padding: 6px 12px;
    font-size: 13px;
    color: #464646;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s, color 0.2s, transform 0.1s;
    width: fit-content;
}

.inline-suggestion-btn:hover {
    /* Macht den Hintergrund zu einem hauchzarten (3%) transparenten Schimmer deiner Hauptfarbe */
    background-color: color-mix(in srgb, var(--main-color) 3%, transparent);
    
    /* Ein ganz sanfter Rahmen-Akzent */
    border-color: color-mix(in srgb, var(--main-color) 40%, transparent);
    
    /* Text bleibt unverändert in deiner Hauptfarbe */
    color: var(--main-color);
}

.inline-suggestion-btn:active {
    transform: scale(0.97);
}


/* ==========================================
   TEXT FORMATTING IN MESSAGES
   ========================================== */
/* Inline code styling */
code {
    background: #f4f4f4;
    padding: 2px 6px;
    border-radius: 4px;
    word-break: break-all;
    overflow-wrap: break-word;
}

/* Code block styling */
pre {
    background: #f4f4f4;
    padding: 12px;
    border-radius: 4px;
    overflow-x: auto;
    max-width: 100%;
}

/* Link styling */
a {
    word-break: break-all;
    overflow-wrap: break-word;
}



/* mobile hide nav */
@media (max-width: 520px) {
    .nav-menu {
        display: none !important; /* Blendet "Visit Jossko" aus */
    }

    .logo-and-model {
        width: 100%; /* Nutzt jetzt die gesamte Breite des Headers */
        justify-content: space-between; /* Drückt Logo nach links, Selector nach rechts */
    }

    .welcome-screen h1 {
        font-size: 24px !important;
        padding: 0px 20px;
    }
}