/* Grunt - Modern Dark Theme */

/* === Reset & Base === */
*, *::before, *::after {
    box-sizing: border-box;
}

:root {
    --bg-primary: #0c0c0e;
    --bg-secondary: #18181b;
    --bg-tertiary: #27272a;
    --text-primary: #fafafa;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-subtle: rgba(59, 130, 246, 0.1);
    --border: #27272a;
    --border-light: #3f3f46;
    --error: #ef4444;
    --success: #22c55e;
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif, 'Noto Color Emoji';
    --header-height: 48px;
}

/* === Noto Color Emoji Class === */
.noto-color-emoji-regular {
    font-family: "Noto Color Emoji", sans-serif;
    font-weight: 400;
    font-style: normal;
}

html {
    font-size: 16px;
    height: 100%;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-sans);
    max-width: 800px;
    margin: 0 auto;
    padding: 0;
    width: 100dvw;
    height: 100dvh;
    overflow: hidden;
    padding-bottom: env(safe-area-inset-bottom);

    display: flex;
    flex-direction: column;
    background-image: url("data:image/svg+xml,%3Csvg width='256' height='256' xmlns='http://www.w3.org/2000/svg'%3E%3Cg opacity='0.06'%3E%3Ccircle cx='42' cy='85' r='2' fill='%23fff'/%3E%3Ccircle cx='178' cy='34' r='1.5' fill='%23fff'/%3E%3Ccircle cx='95' cy='162' r='2.5' fill='%23fff'/%3E%3Ccircle cx='210' cy='198' r='1.5' fill='%23fff'/%3E%3Ccircle cx='65' cy='225' r='2' fill='%23fff'/%3E%3Ccircle cx='145' cy='55' r='1.5' fill='%23fff'/%3E%3Ccircle cx='190' cy='135' r='2.5' fill='%23fff'/%3E%3Ccircle cx='115' cy='210' r='1.5' fill='%23fff'/%3E%3Ccircle cx='55' cy='125' r='2' fill='%23fff'/%3E%3Ccircle cx='165' cy='248' r='1.5' fill='%23fff'/%3E%3Ccircle cx='235' cy='95' r='2.5' fill='%23fff'/%3E%3Ccircle cx='80' cy='215' r='1.5' fill='%23fff'/%3E%3C/g%3E%3C/svg%3E");
    background-repeat: repeat;
}

/* === Sticky Header === */
.chat-header {
    background-color: var(--bg-primary);
    border-bottom: 1px solid var(--border);
    height: var(--header-height);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-left: 24px;
    padding-right: 24px;
}

.chat-header .header-inner {
    display: flex;
    align-items: center;
    gap: 16px;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
}

.chat-header h1 {
    margin: 0;
    font-size: 20px;
    flex-grow: 1;
}

/* === Header Elements === */
.brand-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--accent);
    flex-shrink: 0;
}

.profile-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;

    display: block;
    transition: all 0.2s ease;
}

.profile-icon .avatar {
    width: 32px;
    height: 32px;
}

.profile-icon:hover {
    background-color: var(--accent-subtle);
}

/* === Main Content Area === */
main#messages {
    flex: 1;
    overflow-y: auto;
    padding-left: 0;
    padding-right: 24px;
    padding-bottom: 8px;
}

/* === Sticky Footer === */
.chat-footer {
    background-color: var(--bg-primary);
    border-top: 1px solid var(--border);
    padding: 12px 24px;
}

.chat-footer form {
    display: flex !important;
    flex-direction: row !important;
    gap: 12px;
    align-items: stretch;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
}

.chat-footer form input {
    flex: 1;
    margin-bottom: 0;
    min-width: 0;
    width: auto;
}

/* === Buttons === */
form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

input {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 10px 14px;
    font-family: var(--font-sans);
    font-size: 15px;
    border-radius: 8px;
    transition: all 0.2s ease;
}

input.full-width {
    width: 100%;
}

textarea {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 10px 14px;
    font-family: var(--font-sans);
    font-size: 15px;
    border-radius: 8px;
    transition: all 0.2s ease;
    width: 100%;
    resize: none;
    overflow-y: hidden;
    min-height: 40px;
}

textarea:hover {
    border-color: var(--border-light);
}

textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-subtle);
}

textarea::placeholder {
    color: var(--text-muted);
}

input:hover {
    border-color: var(--border-light);
}

input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-subtle);
}

input::placeholder {
    color: var(--text-muted);
}

/* === Buttons === */
button {
    background-color: var(--accent);
    border: none;
    color: white;
    padding: 10px 20px;
    font-family: var(--font-sans);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s ease;
}

button:hover {
    background-color: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
}

button:active {
    transform: translateY(0);
    box-shadow: none;
}

/* === Send Button === */

.chat-footer .send-button {
    width: 40px;
    height: 40px;
    padding: 0;
    margin: 0;
    border: none;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    flex-shrink: 0;
}

.chat-footer .send-button:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
}

.chat-footer .send-button svg {
    width: 20px;
    height: 20px;
    display: block;
}

/* === Toggle Buttons (login/register) === */
.toggle-btn {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: 14px;
    margin-top: 12px;
    padding: 6px;
    text-decoration: none;
    transition: color 0.2s ease, text-decoration-color 0.2s ease;
}

.toggle-btn:hover {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-color: var(--accent-hover);
}

/* === Login Form === */
.login-form {
    max-width: 320px;
    margin: 64px auto;
    padding: 0 24px;
}

.login-form form {
    gap: 12px;
    margin-bottom: 16px;
}

.login-form input {
    width: 100%;
}

/* === Messages === */
#messages {
    display: flex;
    flex-direction: column;
}

#messages * {
    overflow-anchor: none;
}

#scroll-anchor {
    overflow-anchor: auto;
    height: 1px;
    flex-shrink: 0;
}

.message-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding-left: 24px;
    margin-top: 8px;
}

.message-row.message-row--grouped {
    margin-top: 4px;
}

.message-row .avatar-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 32px;
    flex-shrink: 0;
    gap: 4px;
    margin-top: 2px;
}

.message-row .avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;

}

.avatar svg {
    display: block;
}

.message-row .timestamp {
    font-size: 10px;
    color: var(--text-muted);
    text-align: center;
    line-height: 1;
}

.message-row .message-bubble {
    flex: 1;
    min-width: 0;
    background-color: var(--bg-secondary);
    border-radius: 8px;
    transition: background-color 0.2s ease;
}

.username-bubble-wrapper {
    display: flex;
    flex-direction: column;
}

.message-row .msg-username {
    height: 16px;
    display: flex;
    align-items: center;
    padding-left: 8px;
}

.message-row .msg-username h4 {
    margin: 0;
    font-size: 12px;
    font-weight: 200;
    line-height: 16px;
    white-space: nowrap;

    text-overflow: ellipsis;
    color: var(--text-secondary);
}

.message-row p {
    margin: 6px 8px 8px 8px;
    color: var(--text-primary);
    word-break: break-word;
    white-space: pre-wrap;
    font-size: 16px;
    line-height: 18px;
}

/* === Sections (settings page) === */
.section {
    width: 360px;
    margin-bottom: 8px;
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background-color: var(--bg-secondary);
}

.section h2 {
    margin-top: 0;
    font-size: 18px;
    color: var(--text-primary);
}

/* === Utility Classes === */
.hidden {
    display: none !important;
}

.sse-event {
    display: none;
}

.success {
    color: var(--success);
    font-weight: 600;
}

.error {
    color: var(--error);
    font-weight: 600;
}

#response {
    color: var(--error);
    margin-top: 12px;
    font-size: 14px;
    min-height: 1.5em;
    text-align: center;
    max-width: 320px;
    margin-left: auto;
    margin-right: auto;
}

/* === Scrollbar Styling === */
::-webkit-scrollbar {
    width: 8px;
}

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

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

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* === Selection === */
::selection {
    background-color: var(--accent);
    color: white;
}

/* === Focus Visible for Accessibility === */
*:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* === Links === */
a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}
/* === Version Footer === */
.version-footer {
    margin-top: auto;
    text-align: center;
    padding: 8px 24px;
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.version-footer span {
    margin: 0 4px;
}
