/* Global styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background-image: url('/static/img/bg.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
}

/* Chat container */
.chat-container {
    width: 80%;
    max-width: 800px;
    height: 80vh;
    display: flex;
    flex-direction: column;
    /*background-color: #1e1e2e;*/
    background-color: rgba(30,30,46,0.85);
    color: #e2e2e2;
    border-radius: 12px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

/* Chat header */
.chat-header {
    padding: 20px;
    background-color: #181825;  /* Darker header */
    color: white;
    text-align: center;
    position: relative;
}

.chat-header h1 {
    margin-bottom: 5px;
    font-size: 24px;
}

.chat-header p {
    font-size: 14px;
    opacity: 0.8;
}

/* Chat messages area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Custom scrollbar for the chat area */
.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #313244;
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #45475a;
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #7287fd;
}

/* Message styles */
.message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 10px;
    line-height: 1.4;
}

.message p {
    margin-bottom: 8px;
}

.message p:last-child {
    margin-bottom: 0;
}

.message.system {
    align-self: center;
    background-color: #313244;  /* Dark gray for system messages */
    color: #cdd6f4;
    font-style: italic;
    width: 100%;
    text-align: center;
}

.message.user {
    align-self: flex-end;
    background-color: #45475a;  /* User message background */
    color: white;
}

.message.assistant {
    align-self: flex-start;
    background-color: #313244;  /* Assistant message background */
    color: white;
}

/* Input area */
.chat-input {
    padding: 15px;
    background-color: #181825;  /* Dark input area */
    border-top: 1px solid #313244;
}

#chat-form {
    display: flex;
    gap: 10px;
}

#user-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #45475a;
    border-radius: 6px;
    font-size: 16px;
    outline: none;
    background-color: #313244;  /* Dark input field */
    color: white;
}

#user-input::placeholder {
    color: #a6adc8;
}

#user-input:focus {
    border-color: #7287fd;
}

button {
    padding: 0 20px;
    background-color: #7287fd;  /* Accent color for button */
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.2s;
}

button:hover {
    background-color: #89b4fa;  /* Lighter accent on hover */
}

button:active {
    transform: translateY(1px);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .chat-container {
        width: 90%;
        height: 85vh;
    }

    .chat-header h1 {
        font-size: 20px;
    }

    .message {
        max-width: 90%;
    }
}

@media (max-width: 480px) {
    .chat-container {
        width: 95%;
        height: 90vh;
    }

    .chat-header {
        padding: 15px;
    }

    .chat-header h1 {
        font-size: 18px;
    }

    .chat-input {
        padding: 10px;
    }

    #user-input {
        padding: 10px;
        font-size: 14px;
    }

    button {
        padding: 0 15px;
        font-size: 14px;
    }
}

/* Troll image positioning and responsive behavior */
.troll-image {
    position: fixed;
    right: 0;
    bottom: 0;
    height: 40vh; /* Adjust size as needed */
    z-index: 10;
    pointer-events: none; /* So it doesn't interfere with clicks */
    transition: opacity 0.5s ease, transform 0.5s ease;
    opacity: 1; /* Start fully opaque */
}

/* Class for semi-transparent state */
.troll-image.semi-transparent {
    opacity: 0.8;
}

/* Class for fully transparent state when input is active */
.troll-image.input-active {
    opacity: 0.4; /* Almost fully transparent when typing */
    transform: scale(0.8) translateX(10%);
}

/* Media query for mobile devices */
@media (max-width: 768px) {
    .troll-image.semi-transparent {
        transform: scale(0.8) translateX(15%); /* Slightly smaller and moved to the side */
        transform-origin: bottom right;
        opacity: 0.4; /* More transparent on mobile */
    }

    .troll-image.input-active {
        opacity: 0.1; /* Fully transparent when typing on mobile */
        transform: scale(0.7) translateX(20%);
    }

    /* Ensure the chat container is above the troll when needed */
    .chat-container {
        position: relative;
        z-index: 5; /* Lower than troll's z-index but will be raised when active */
    }

    /* When the input is focused, raise the z-index of the chat container */
    .chat-container.input-active {
        z-index: 15; /* Higher than troll's z-index */
    }
}

/* Very small screens need more aggressive handling */
@media (max-width: 480px) {
    .troll-image {
        transform: scale(0.5) translateX(25%);
    }

    .troll-image.input-active {
        opacity: 0.1; /* Almost invisible when typing on very small screens */
        transform: scale(0.4) translateX(30%);
    }
}

/* Header controls container */
.header-controls {
    position: absolute;
    top: 15px;
    left: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Switch Container */
.switch-container {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    color: #a6adc8;
    user-select: none;
}

/* Hide default HTML checkbox */
.switch-container input {
    opacity: 0;
    width: 0;
    height: 0;
}

/* The slider */
.switch-slider {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
    background-color: #313244;
    border: 1px solid #45475a;
    border-radius: 20px;
    transition: background-color 0.2s, border-color 0.2s;
}

/* The slider round thumb */
.switch-slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 2px;
    bottom: 2px;
    background-color: #cdd6f4;
    border-radius: 50%;
    transition: transform 0.2s;
}

/* Checked states */
.switch-container input:checked + .switch-slider {
    background-color: #a6e3a1; /* Cute soft green */
    border-color: #a6e3a1;
}

.switch-container input:checked + .switch-slider:before {
    transform: translateX(16px);
    background-color: #11111b; /* Dark contrasting color */
}

/* Reset button styling */
.reset-button {
    position: absolute;
    top: 15px;
    right: 20px;
    padding: 6px 12px;
    font-size: 13px;
    background-color: #313244;
    color: #cdd6f4;
    border: 1px solid #45475a;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}

.reset-button:hover {
    background-color: #f38ba8; /* Soft red warning on hover */
    color: #11111b;
    border-color: #f38ba8;
}

