html {
    box-sizing: border-box;
    height: 100%; /* Ensure html can be a reference for percentage heights */
}

*, *:before, *:after {
    box-sizing: inherit;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    margin: 0;
    background-color: #f0f2f5;
    display: flex; /* Zorgt ervoor dat .page-container de body kan vullen */
    flex-direction: column;
    min-height: 100vh; /* Fallback for general cases, will be overridden for mobile */
    color: #1c1e21;
}

.page-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 720px; /* Iets breder voor comfort */
    margin: 0 auto; /* Centreer de container */
    padding: 0 10px; /* Padding aan zijkanten, geen top/bottom hier */
    flex-grow: 1; /* Neemt beschikbare verticale ruimte in body */
}

.logo-container {
    padding: 15px 0; /* Iets minder padding */
    text-align: center;
    flex-shrink: 0; /* Voorkomt dat logo krimpt */
}

#logo {
    max-width: 160px; /* Iets kleiner voor strakkere look */
    height: auto;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background-color: #004A7F; /* Brover Blue */
    color: white;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    height: 60px; /* Fixed height for header */
}

.logo-title {
    display: flex;
    align-items: center;
}

#logo {
    height: 40px;
    margin-right: 15px;
}

.header h1 {
    font-size: 1.5em;
    margin: 0;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 20px;
}

.version-selector-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.version-selector-container label {
    font-size: 0.9em;
    margin-bottom: 0; /* Override general label styles if any */
}

#botVersion {
    padding: 5px 8px;
    border-radius: 4px;
    border: 1px solid #ccc;
    background-color: #fff;
    color: #333;
    font-size: 0.9em;
}

.admin-link {
    color: #fff;
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 4px;
    background-color: #005b9f; /* Slightly different blue for emphasis */
    transition: background-color 0.3s ease;
    font-size: 0.9em;
}

.admin-link:hover {
    background-color: #0077cc; /* Lighter blue on hover */
}

.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 60px); /* Full viewport height minus header */
    margin-top: 60px; /* Account for fixed header */
    background-color: #f4f7f6;
    max-width: 800px; /* Max width for chat interface */
    margin-left: auto;
    margin-right: auto;
    box-shadow: 0 0 20px rgba(0,0,0,0.1); /* Softer shadow */
}

.chat-messages {
    flex-grow: 1;
    padding: 15px 20px; /* Meer horizontale padding */
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

#chatMessages {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px;
    background-color: #ffffff;
    border-bottom: 1px solid #ddd;
}

.message {
    margin-bottom: 12px; /* Iets meer ruimte tussen berichten */
    padding: 10px 16px;
    border-radius: 20px; /* Nog ronder */
    line-height: 1.45;
    max-width: 78%;
    word-wrap: break-word;
    position: relative; /* Voor positionering kopieerknop */
}

.message.user .message-content {
    background-color: #007bff; /* User message blue */
}

.user-message {
    background-color: #007AFF; /* iOS blauw */
    color: white;
    align-self: flex-end;
    margin-left: auto;
    border-bottom-right-radius: 8px; /* Subtiele aanpassing */
}

.message.bot .message-content {
    background-color: #e9ecef; /* Bot message light grey */
}

.bot-message {
    background-color: #E9E9EB; /* iOS grijs */
    color: #000000;
    align-self: flex-start;
    margin-right: auto;
    border-bottom-left-radius: 8px;
}

.chat-input-area {
    display: flex;
    align-items: center; /* Centreer items verticaal */
    padding: 12px;
    border-top: 1px solid #E0E0E0; /* Subtielere lijn */
    background-color: #f9f9f9; /* Lichte achtergrond voor input area */
    flex-shrink: 0; /* Voorkomt dat input area krimpt */
}

.chat-input-area {
    display: flex;
    padding: 15px;
    background-color: #f8f9fa; /* Light background for input area */
    border-top: 1px solid #ddd;
}

#chatInput {
    flex-grow: 1;
    padding: 10px 18px;
    border: 1px solid #DCDCDC;
    border-radius: 20px;
    margin-right: 10px;
    font-size: 0.95rem;
    outline: none;
    background-color: #fff;
}

#userInput {
    flex-grow: 1;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 20px; /* Rounded input field */
    margin-right: 10px;
    font-size: 1em;
}

#sendButton {
    padding: 10px 20px;
    background-color: #007AFF;
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: background-color 0.15s ease;
}

#sendButton {
    padding: 12px 20px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 20px; /* Rounded button */
    cursor: pointer;
    font-size: 1em;
    transition: background-color 0.3s ease;
}

#sendButton:hover {
    background-color: #005ECB;
}

#sendButton:hover {
    background-color: #0056b3;
}

#sendButton:disabled {
    background-color: #B0D7FF;
    cursor: not-allowed;
}

.bot-message.thinking {
    font-style: italic;
    color: #555;
    background-color: #f5f5f5;
}

.bot-message.error-message {
    background-color: #ffebee; /* Lichter rood */
    color: #c62828; /* Donkerder rood voor tekst */
    border: 1px solid #ef9a9a;
}

.copy-button {
    background-color: rgba(0, 0, 0, 0.05);
    color: #555;
    border: none;
    border-radius: 12px;
    padding: 3px 8px;
    font-size: 0.7rem;
    cursor: pointer;
    position: absolute;
    bottom: 5px;
    right: 8px;
    opacity: 0.6;
    transition: opacity 0.2s ease, background-color 0.2s ease;
}

.bot-message:hover .copy-button {
    opacity: 1;
}

.copy-button:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

.copy-button.copied {
    background-color: #4CAF50; /* Groen voor succes */
    color: white;
    opacity: 1;
}


/* Responsive aanpassingen */
@media (max-width: 600px) {
    html, body {
        height: 100%;
        overflow: hidden;
        margin: 0; /* Ensure no default margins */
        padding: 0; /* Ensure no default paddings */
    }

    /* body inherits display:flex, flex-direction:column from global */

    .page-container {
        /* display:flex, flex-direction:column from global */
        /* align-items:center from global - children need width 100% to override */
        flex-grow: 1; /* Ensure it grows to fill body */
        height: 100%; /* Occupy full height of body */
        width: 100%;
        max-width: none;
        padding: 0; /* Override desktop padding */
        margin: 0; /* Override desktop margin */
        min-height: 0; /* Allow shrinking if necessary */
    }

    .logo-container {
        /* flex-shrink:0 from global */
        width: 100%; /* Ensure full width against parent's align-items:center */
        padding: 8px 0; /* Slightly reduced padding */
        text-align: center; /* Global */
    }

    #logo {
        max-width: 120px; /* Slightly smaller logo for mobile */
    }

    .version-selector-container {
        padding: 8px 0;
    }

    #botVersionSelector {
        font-size: 0.85rem;
        padding: 6px 10px;
    }

    .chat-container {
        /* display:flex, flex-direction:column from global */
        flex-grow: 1; /* This is key to take remaining vertical space */
        width: 100%; /* Ensure full width */
        min-height: 0; /* CRUCIAL: Allows chat-container to shrink, e.g., for keyboard */
        overflow: hidden; /* Global, good */
        border-radius: 0; /* Mobile specific */
        margin-bottom: 0; /* Mobile specific */
        background-color: #ffffff; /* Global */
    }

    .chat-messages {
        /* display:flex, flex-direction:column, overflow-y:auto from global */
        flex-grow: 1; /* Key to take remaining space in chat-container */
        min-height: 0; /* CRUCIAL: Allows messages area to shrink and enable scrolling */
        padding: 10px 12px; /* Mobile specific */
    }
    .message {
        margin-bottom: 10px; /* Iets minder ruimte tussen berichten */
        padding: 10px 14px;
        border-radius: 18px; /* Iets minder rond */
        line-height: 1.4;
        max-width: 80%;
        word-wrap: break-word;
        position: relative; /* Voor positionering kopieerknop */
    }

    .user-message {
        background-color: #007AFF; /* iOS blauw */
        color: white;
        align-self: flex-end;
        margin-left: auto;
        border-bottom-right-radius: 8px; /* Subtiele aanpassing */
    }

    .bot-message {
        background-color: #E9E9EB; /* iOS grijs */
        color: #000000;
        align-self: flex-start;
        margin-right: auto;
        border-bottom-left-radius: 8px;
    }

    .chat-input-area {
        /* display: flex; align-items: center; border-top; background-color; flex-shrink: 0; are already global */
        padding: 8px 10px; /* Adjusted padding */
        width: 100%; /* Ensure it takes full width of its parent */
    }
    #chatInput {
        padding: 9px 15px;
        font-size: 0.9rem;
        margin-right: 8px;
    }
    #sendButton {
        padding: 9px 15px;
        font-size: 0.9rem;
    }
    .copy-button {
        font-size: 0.65rem;
        padding: 2px 6px;
        bottom: 4px;
        right: 6px;
    }
}

@media (max-width: 768px) {
    .header {
        padding: 10px 15px;
        height: auto; /* Allow header to wrap if needed */
        flex-direction: column; /* Stack logo/title and controls */
        align-items: flex-start;
    }

    .logo-title {
        margin-bottom: 10px; /* Space between logo/title and controls */
    }

    .header-controls {
        width: 100%;
        justify-content: space-between; /* Space out version selector and admin link */
    }

    #logo {
        height: 30px;
    }
    .header h1 {
        font-size: 1.2em;
    }
    .chat-container {
        margin-top: 100px; /* Adjust based on new header height, might need dynamic calculation or more robust CSS */
        height: calc(100vh - 100px); /* Adjust height */
        max-width: 100%; /* Use full width on mobile */
    }
    #chatMessages {
        padding: 10px;
    }
    .chat-input-area {
        padding: 10px;
    }
    #userInput {
        padding: 10px;
        font-size: 0.9em;
    }
    #sendButton {
        padding: 10px 15px;
        font-size: 0.9em;
    }
    .message .message-content {
        max-width: 90%;
        padding: 8px 12px;
    }
}

@media (max-width: 480px) {
    .header-controls {
        flex-direction: column; /* Stack version selector and admin link */
        align-items: flex-start;
        gap: 10px;
    }

    .admin-link {
        width: 100%;
        text-align: center;
    }

    #botVersion {
        width: 100%;
    }

     .chat-container {
        margin-top: 150px; /* Further adjust for potentially taller header */
        height: calc(100vh - 150px);
    }

}
