body {
    font-family: Arial, sans-serif;
    margin-left: 20px;
    margin-right: 20px;
    line-height: 1.6;
    color: var(--text-color);
    background: var(--background-gradient);
    transition: background 0.5s ease, color 0.5s ease;
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: top;
    align-items: center;
}

:root {
    --background-gradient: linear-gradient(to bottom, #ffffff, #e6e6e6);
    --text-color: #333;
    --input-bg: #f9f9f9;
    --input-border: #ccc;
    --button-bg: #007BFF;
    --button-hover-bg: #0056b3;
    --chat-bg: #f1f1f1;
    --placeholder-color: #888;
    --scrollbar-bg: #e6e6e6;
    --scrollbar-thumb: #cccccc;
}

[data-theme="dark"] {
    --background-gradient: linear-gradient(to bottom, #1c1c1c, #3c3c3c);
    --text-color: #f9f9f9;
    --input-bg: #2a2a2a;
    --input-border: #555;
    --button-bg: #007BFF;
    --button-hover-bg: #0056b3;
    --chat-bg: #2a2a2a;
    --placeholder-color: #bbb;
    --scrollbar-bg: #2a2a2a;
    --scrollbar-thumb: #555;
}

.theme-switch {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    font-size: 14px;
    color: var(--text-color);
    gap: 10px;
}

.theme-switch input {
    display: none;
}

.theme-switch .slider {
    width: 40px;
    height: 20px;
    background: var(--input-border);
    border-radius: 20px;
    position: relative;
    cursor: pointer;
    transition: background 0.3s ease;
}

.theme-switch .slider::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: var(--chat-bg);
    border-radius: 50%;
    transition: transform 0.3s ease, background 0.3s ease;
}

.theme-switch input:checked + .slider {
    background: var(--button-bg);
}

.theme-switch input:checked + .slider::before {
    transform: translateX(20px);
    background: var(--button-hover-bg);
}

h1 {
    text-align: center;
    margin-bottom: 5%px;
    color: var(--text-color);
}

p {
    text-align: center;
    margin-bottom: 1%;
    color: var(--text-color);
}

textarea, input {
    width: 100%;
    height: 10px;
    margin: 15px;
    padding: 12px;
    border: 1px solid var(--input-border);
    border-radius: 4px;
    background: var(--input-bg);
    color: var(--text-color);
    transition: background 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

textarea::placeholder, input::placeholder {
    color: var(--placeholder-color);
}

textarea:focus, input:focus {
    outline: none;
    border-color: var(--button-bg);
}

button {
    padding: 10px 20px;
    margin: 5px;
    border: none;
    border-radius: 4px;
    background-color: var(--button-bg);
    color: white;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

button:hover {
    background-color: var(--button-hover-bg);
    transform: scale(1.05);
}

button:active {
    transform: scale(0.95);
}

#chat {
    margin-top: 20px;
    padding: 10px;
    border: 1px solid var(--input-border);
    border-radius: 4px;
    background: var(--chat-bg);
    color: var(--text-color);
    height: 50vh;
    width : 100%;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-bg);
}

#chat::-webkit-scrollbar {
    width: 8px;
}

#chat::-webkit-scrollbar-track {
    background: var(--scrollbar-bg);
}

#chat::-webkit-scrollbar-thumb {
    background-color: var(--scrollbar-thumb);
    border-radius: 4px;
}

#connectionStatus {
    margin-top: 10px;
    font-weight: bold;
    text-align: center;
    color: var(--text-color);
}

@media (max-width: 600px) {
    body {
        margin: 10px;
    }

    textarea, input, button {
        width: 100%;
    }

    .theme-switch {
        top: 10px;
        right: 10px;
        font-size: 12px;
    }
}
