/* base.css */
/* ==============================================
    Global basic styles
============================================== */
html {
    font-size: 16px;
    /* 1rem = 16px */
}

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Mouse choose text color */
*::selection {
    background-color: var(--select-bg);
    color: var(--select-color);
}

*::-webkit-scrollbar {
    width: 0.25rem;
    height: 0.25rem;
    transition: all 200ms ease;
}
*::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 99rem;
}
*::-webkit-scrollbar-thumb {
    background: transparent;
    border-radius: 99rem;
}
*:hover:-webkit-scrollbar-thumb, *:active::-webkit-scrollbar-thumb {
    background: var(--color-black-alpha-1a);
}
*::-webkit-scrollbar-thumb:hover {
    cursor: pointer;
    background-color: var(--color-black-alpha-4c);
}

a {
    text-decoration: none;
    /* remove decoration */
    color: inherit;
    /* inherit the text color of the parent element */
}

button,
input[type="button"] {
    border: none;
    background: none;
    padding: 0;
    outline: none;
    /* Remove outline when focus is removed */
}

body,
h1,
h2,
h3,
h4,
h5,
h6,
p,
ul,
ol,
li {
    margin: var(--base-margin);
    padding: var(--base-padding);
}

body {
    margin: 0;
    padding: 0;
    overflow: auto;
    overflow-x: hidden;
}
/* Icon color */
svg {
    color: var(--color-icon);
}

/* text color */
p {
    color: var(--color-text-primary);
}

textarea {
    border: none;
    border-width: none;
    background: transparent;
    background-color: none;
    outline: none;
    line-height: 150%;
    resize: none;
    margin: 0;
    padding: 0 0.625rem;
    box-shadow: none;
    -webkit-tap-highlight-color: transparent;
    white-space: pre-wrap;
    word-break: break-word;
}


/* ==============================================
    Page style
============================================== */

/* ==============================================
    tooltip
============================================== */

.tooltip {
    position: absolute;
    top: 110%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-black);
    color: var(--color-white);
    font-size: 0.75rem;
    padding: 0.3125rem 0.5rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;

    border-radius: 0.5rem;
    pointer-events: none;
}

/* ==============================================
    Settings Module 
==============================================*/

.settings {
    display: flex;
    align-items: center;
    gap: 0.025rem;
    padding: 0.5rem;
    border-radius: 100rem;
    position: relative;
    display: inline-flex;
    align-items: center;
}

.settings:hover {
    background-color: var(--color-surface-icon-hover);
}

.settings:active {
    background-color: var(--color-surface-icon-hover);
}

/* hover visiblr tooltip */
.settings:hover .tooltip {
    opacity: 1;
    visibility: visible;
}

/* Pop-up style */
.popup {
    box-shadow: var(--shadow-popup);
    background-color: var(--color-surface-popup);
    border-radius: 1rem;
    padding: 0.375rem 0.625rem;
    width: max-content;
}

/* Settings popup */
.settings-wrapper {
    position: relative;
    display: inline-block;
}

/* Popup */
.settings-menu {
    position: absolute;
    top: 110%;
    right: 0;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: 0.2s;
    z-index: 100;
}

/* Popup menu */
.menu-item {
    display: inline-flex;
    justify-content: center;
    height: 2.25rem;
    gap: 0.5rem;
    padding: 0.625rem 0.375rem;
    border-radius: 0.625rem;
    color: var(--color-text-primary);
    /* cursor */
    cursor: pointer;
}

.menu-item:hover {
    background: var(--color-surface-menu-hover);
}

/* Settings popup open status */
.settings-wrapper.active .settings-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Footer copyright */
.copyright {
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--color-text-secondary);
}


/* input style */
#msgInput {
    height: auto;
    max-height: 12rem;
    width: 100%;
    overflow-wrap: break-word;
    white-space: pre-wrap;
    color: var(--color-text-primary);
    /* font-size: 16px; */
    outline: none;
}

/* set input placeholder color */
#msgInput::placeholder {
    color: var(--color-text-placeholder);
    opacity: 1;
}

/* hidden welcome */
#welcome.hidden {
    display: none !important;
}
.input {
    max-width: 48rem;
    width: 100%;

    padding: 1rem 0.625rem 0.625rem 0.625rem;
    border-radius: 1.625rem;
    background-color: var(--color-surface-input);
    box-shadow: var(--shadow-input);
    z-index: 1000;
}

#welcome.hidden ~ .input {
    max-width: 48rem;
    width: calc(100% - 3rem);
    margin-bottom: 2rem;
    position: fixed;
    bottom: 0rem;
    left: 50%;
    transform: translateX(-50%);
    padding: 1rem 0.625rem 0.625rem 0.625rem;
    z-index: 1000;
}

#chatBox {
    display: none;
    padding-top: 3rem;
    flex: none;
    overflow: visible;
}

/* chatBox fill up the space when start chat */
#chatBox.active {
    display: flex;
    flex: 1;
    overflow: visible;
    scroll-behavior: smooth;
    opacity: 1;
    padding-bottom: 8.625rem;
}


#welcome {
    height: 38.2%;
}

/* hidden welcom when start chat */
#welcome.hidden {
    display: none !important;
}

/* message bubble */
.msg {
    padding: 0.75rem 0.875rem;
    border-radius: 1.125rem;
    line-height: 1.5;

    /* word wrap */
    word-wrap: break-word;
    word-break: break-all;
    white-space: normal;
}
.msg.user {
    max-width: 75%;
    align-self: flex-end;
    background: var(--color-surface-message-user);
    color: var(--color-text-message-user);

}
.msg.ai {
    align-self: flex-start;
    color: var(--color-text-primary);
}

.msg.ai h1,
.msg.ai h2,
.msg.ai h3 {
    margin: 12px 0 8px;
    font-weight: 600;
}
.msg.ai p {
    margin: 0 0 8px;
}
.msg.ai code {
    background: #f1f1f1;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
}
.msg.ai pre {
    background: #f8f8f8;
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 8px 0;
}
.msg.ai ul,
.msg.ai ol {
    margin: 8px 0;
    padding-left: 24px;
}
.msg.ai blockquote {
    border-left: 3px solid #ddd;
    padding-left: 12px;
    color: #666;
    margin: 8px 0;
}
.add {
    cursor: pointer;
}
.add:hover {
    background-color: var(--color-surface-icon-hover);
}

.add:active {
    background-color: var(--color-surface-icon-active);
}
.add:hover .tooltip {
    opacity: 1;
    visibility: visible;
    left: 50%;
}

/* default disable state */
.enter {
  background-color: var(--color-surface-enter-disable);
  cursor: default;        /* Do not cursor */
  pointer-events: none;   /* Do not click */
}
.enter svg {
  color: var(--color-icon-enter-disable);
}

/* Enabled status when have content */
.enter.enabled {
  pointer-events: auto;
  cursor: pointer;
  background-color: var(--color-surface-enter-activate);
}
.enter.enabled svg {
    color: var(--color-icon-enter-activate);
}
.enter.enabled:active {
  background-color: var(--color-surface-enter-activate);
}
.enter.enabled:active svg {
  color: var(--color-icon-enter-activate);
}

/* tooltip */
.enter:hover .tooltip {
  opacity: 1;
  visibility: visible;
  left: 50%;
}