/*
    Page
*/

.page {
    max-width: 400px;
    width: 100%;
    margin: 16px auto;
    border-radius: 8px;
    min-height: calc(100svh - 32px);
    background-color: var(--color-black);

    display: flex;
    flex-direction: column;
}

.page-section {
    padding: 1rem;
    gap: 1rem;
}

.page-cta {
    margin-top: auto;
    padding: 1rem 1rem 2rem;
    gap: 1rem;
}

.page-entity {
    padding: 0.5rem;
}


/* 
    Modal
*/

.modal-wrapper {
    position: fixed;
    inset: 0;
    padding: 2rem 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    max-height: 100svh;
    background-color: rgba(0, 0, 0, 0.8);
}

.modal-close-target {
    position: fixed;
    inset: 0;
}

.modal {
    background-color: var(--color-surface);
    border-radius: 1rem;
    max-width: 400px;
    z-index: 1;
}

.modal-title,
.modal-text,
.modal-consents {
    padding: 1rem;
}

/* 
    Form 
*/

.form-consents {
    padding: 1rem;
}


.form-hr {
    margin: 1rem 0;
    height: 1px;
    border: 0;
    background-color: rgba(255, 255, 255, 0.25);
}

.form-fields {
    padding: 0.5rem 1rem;
}

.form-error {
    color: var(--color-red);
    padding: 0.5rem 1rem;
}

.form-actions {
    display: flex;
    padding: 1rem;
    gap: 1rem;
}

.form-actions .button {
    width: 100%;
}

/* Button */
.button {
    display: block;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    text-align: center;
    text-decoration: none;
    transition: background-color 200ms ease, color 200ms ease, opacity 200ms ease;
    cursor: pointer;
    background-color: var(--color-surface);
}

.button:hover,
.button:focus-visible {
    background-color: var(--color-black-deep);
}

.button.primary {
    background-color: var(--color-white);
    color: var(--color-black);
}

.button.primary:hover,
.button.primary:focus-visible {
    background-color: var(--color-gray);
    outline: none;
}

.button.primary:active {
    background-color: var(--color-gray);
}

.button.ghost {
    background-color: transparent;
    color: var(--color-white);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3);
}

.button.ghost:hover,
.button.ghost:focus-visible {
    background-color: rgba(255, 255, 255, 0.08);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.6);
    outline: none;
}

.button.ghost:active {
    background-color: rgba(255, 255, 255, 0.15);
}

/* Checkbox */
.checkbox {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--color-gray);
}

.checkbox input {
    border: 0;
    background-color: rgba(0, 0, 0, 1);
}


/* Field */
.field {
    display: block;
    background-color: var(--color-black-deep);
    padding: 0.5rem;
    border-radius: 4px;
}

.field-input {
    background-color: transparent;
    border: 0;
    color: inherit;
    width: 100%;
    outline: none;
    transition: opacity 200ms ease, color 200ms ease;
}

.field-input:hover {
    opacity: 0.8;
}

.field-input:focus,
.field-input:focus-visible {
    outline: none;
    opacity: 1;
}

.field:has(.field-input:focus-visible) {
    outline: 2px solid var(--color-white);
    outline-offset: 2px;
}

.field-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.field-input:autofill,
.field-input:-webkit-autofill,
.field-input:-internal-autofill-selected {
    -webkit-text-fill-color: var(--color-white);
    caret-color: var(--color-white);
    box-shadow: 0 0 0 1000px var(--color-black-deep) inset;
    -webkit-box-shadow: 0 0 0 1000px var(--color-black-deep) inset;
    transition: background-color 9999s ease-in-out 0s;
}


/* 
    Entity 
*/

.entity {
    display: flex;
    gap: 1rem;
}

.entity.open {
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--color-surface);
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    max-width: 400px;
}

.entity-cover {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.entity-info {
    text-align: left;
}

.entity-content {
    display: none;
    flex-direction: column;
    text-align: left;
}

.entity.open .entity-content {
    display: block;
}



/* 
    Chat 
*/
.chat {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Chat: Messages */
.chat-messages {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem ; 
}

/* Chat: Message */
.chat-message {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    max-width: 75%;
}

.chat-message--sent {
    align-self: flex-end;
}

.chat-message--received {
    align-self: flex-start;
}

.chat-message-author {
    font-size: 0.75rem;
    color: var(--color-gray);
}

.chat-message-bubble {
    background-color: var(--color-black-deep);
    padding: 0.5rem;
    border-radius: 8px;
}

.chat-message--sent .chat-message-bubble {
    background-color: var(--color-white);
    color: var(--color-black);
}

.chat-message--participant .chat-message-bubble {
    background-color: var(--color-black-deep);
    color: var(--color-white);
}

.chat-message--editor .chat-message-bubble {
    background-color: var(--color-red);
    color: var(--color-white);
}

.chat-message--prompt {
    align-self: center;
    max-width: 90%;
    text-align: center;
    margin: 1rem 0;
}

.chat-message--prompt .chat-message-bubble {
    background-color: var(--color-red);
    color: var(--color-white);
    padding: 1rem 1.25rem;
    border-radius: 12px;
}

.chat-message-prompt-author {
    font-size: 0.875rem;
    color: var(--color-gray);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.chat-message-prompt-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
    line-height: 1.3;
}

.chat-message-reply-button {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    padding: 0.25rem 0.75rem;
    background-color: var(--color-white);
    color: var(--color-black);
    border: none;
    border-radius: 999px;
    cursor: pointer;
}

.chat-message-replying-to {
    padding: 0.375rem 0.625rem;
    border-left: 2px solid var(--color-red);
    background-color: rgba(255, 255, 255, 0.04);
    border-radius: 4px;
    font-size: 0.75rem;
    max-width: 100%;
    overflow: hidden;
}

.chat-message-replying-to-preview {
    color: var(--color-gray);
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-form-reply {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background-color: var(--color-black-deep);
    border-left: 3px solid var(--color-red);
    border-radius: 6px;
    color: var(--color-white);
    font-size: 0.875rem;
    position: absolute;
    bottom: 100%;
    left: 1rem;
    right: 1rem;
    margin-bottom: 0.5rem;
}

.chat-form-reply-preview {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--color-gray);
}

.chat-form-reply-cancel {
    background: none;
    border: none;
    color: var(--color-white);
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
    padding: 0 0.25rem;
}

.chat-message-time {
    font-size: 0.75rem;
    color: var(--color-gray);
    align-self: flex-end;
}


/* Chat: Form */
.chat-form {
    display: flex;
    gap: 0.5rem;
    width: 100%;
    position: sticky;
    bottom: 0;
    padding: 2rem 1rem 1rem;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0));
}

.chat-form-input {
    flex: 1;
    display: flex;
    align-items: center;
}

.chat-form-file-preview {
    color: var(--color-gray);
    font-size: 0.75rem;
    padding: 0.5rem;
    position: absolute;
    bottom: calc(100% + 0.25rem);
    background-color: var(--color-black-deep);
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;

    opacity: 1;
    transition: opacity 300ms ease;
}

.chat-form-file-preview[hidden] {
    opacity: 0;
}

.chat-form-file-preview img {
    width: 6rem;
    height: 6rem;
    object-fit: contain;
    border-radius: 8px;
    display: block;
}