/* 페이지 기본 설정 */
body {
    font-family: 'Noto Sans KR', sans-serif;
    color: #fff;
    display: flex;
    min-height: 100%;
    justify-content: center;
    padding: 30px 0;
}

/* 전체 페이지 배경 이미지 설정 */
.background-image {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background-image: url('bg.webp');
    background-repeat: no-repeat;
    background-position: center center;
    background-size: cover;
    opacity: 0.8;
}

.background-image:before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: -1;
}

/* 채팅 컨테이너 설정 */
.chat-container {
    background-color: rgba(0, 0, 0, 0.73);
    border-radius: 20px;
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
    padding: 20px;
    width: 80%;
    max-width: 700px; /* 최대 너비를 키워 텍스트가 한 줄로 나오도록 조정 */
    display: flex;
    flex-direction: column;
    margin: 5% auto;
    position: relative;
    min-width: 420px; /* 최소 너비를 500px로 설정 */
}

/* 채팅 메시지 영역 스타일 */
.chat-content {
    overflow-y: auto;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 420px; /* 최소 너비를 500px로 설정 */
}

/* 메시지 영역 배경 투명 설정 */
.messages {
    flex-grow: 1;
    overflow-y: auto;
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    min-height: 20px;
    align-content: center;
    flex-wrap: wrap;
    background-color: rgba(0, 0, 0, 0.73); /* 투명한 배경색 설정 */
    padding: 20px;
    border-radius: 20px;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.2); /* 메시지 영역의 그림자 효과 */
}


/* 메시지의 기본 스타일 */
.message {
    margin: 30px 0 10px;
    padding: 10px;
    border-radius: 20px;
    max-width: 80%;
    width: 100%;
    word-wrap: break-word;
    font-size: 16px;
    line-height: 1.5;
    box-sizing: border-box;
    position: relative;
}

/* 사용자가 보낸 메시지 스타일 */
.message.me {
    align-self: flex-end;
    background-color: #8d6aff;
    color: #fff;
}

/* 카리나가 보낸 메시지 스타일 */
.message.bot {
    width: calc(100% - 20px);
    max-width: 100%;
    align-self: flex-start;
    background-color: #fff;
    color: #333;
}

/* 메시지 전송 관련 요소 스타일 */
textarea {
    padding: 10px;
    border-radius: 20px;
    border: none;
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
    font-size: 16px;
    background-color: rgba(255, 255, 255, 0.8);
    color: #333;
    width: calc(100% - 70px);
    margin-right: 10px;
    resize: none;
    overflow: hidden;
}

/* 전송 버튼 스타일 */
button {
    padding: 10px;
    background-color: #8d6aff;
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 24px;
    transition: all 0.3s ease;
    align-self: flex-end;
    width: 50px;
    height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
}

button:hover {
    background-color: #4b2f91;
}

button:disabled,
button[disabled] {
    border: 1px solid #999999;
    background-color: #cccccc;
    color: #666666;
}

/* 사용자 메시지의 화살표 스타일 */
.message.me:before {
    content: "";
    position: absolute;
    border-width: 10px 10px 10px 0;
    border-color: transparent #8d6aff transparent transparent;
    top: 10px;
    left: -10px;
}

/* 카리나 메시지의 화살표 스타일 */
.message.bot:before {
    content: "";
    position: absolute;
    border-width: 10px 0 10px 10px;
    border-color: transparent transparent transparent #fff;
    top: 10px;
    right: -10px;
}

/* 헤더 및 소개 문구 스타일 */
h1 {
    font-size: 28px;
    text-shadow: 2px 2px #000;
    text-align: center;
    margin-bottom: 0;
}

p {
    font-size: 24px;
    margin-bottom: 30px;
    text-align: center;
}

/* 로딩 애니메이션 스타일 */
#loading {
    padding-bottom: 10px;
    display: none;
}

/* 캐릭터 이미지 스타일 */
.character-image {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    object-fit: cover;
    margin: 0 auto;
    display: block;
}

/* 애니메이션 효과 추가 */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* 환영 메시지 스타일 및 애니메이션 */
.welcome-message {
    animation: fadeIn 2s ease-in-out;
    font-size: 18px;
    text-align: center;
    margin-top: 20px;
    color: #fff;
}

/* 미디어 쿼리 - 모바일 최적화 */
@media (max-width: 600px) {
    .chat-container {
        width: 100%;
        padding: 15px;
        min-width: auto; /* 모바일에서는 최소 너비 제한을 없앰 */
    }

    .chat-content {
        min-width: auto; /* 모바일에서는 최소 너비 제한을 없앰 */
    }

    #introduction {
        font-size: 18px; /* 모바일에서는 글자 크기를 줄임 */
    }

    h1 {
        font-size: 22px; /* 모바일에서 제목 글자 크기 조정 */
    }

    .character-image {
        width: 120px; /* 모바일에서 캐릭터 이미지 크기 조정 */
        height: 120px;
    }
}

/* 메시지 래퍼 스타일 */
.message-wrapper {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    margin-bottom: 10px; /* 사용자와 카리나 메시지 간 간격을 더 좁힘 */
}

/* 닉네임과 썸네일을 감싸는 래퍼 */
.nickname-thumbnail-wrapper {
    display: flex;
    align-items: center;
    margin-bottom: 3px; /* 닉네임과 메시지 간의 간격을 최소화 */
}

/* 썸네일 이미지 스타일 */
.thumbnail {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 10px;
    object-fit: cover;
}

/* 닉네임 스타일 */
.nickname {
    font-weight: bold;
    color: #ffffff;
}

/* 메시지 스타일 */
.message {
    padding: 10px;
    border-radius: 10px;
    max-width: 80%;
    word-wrap: break-word;
    font-size: 16px;
    line-height: 1.5;
    box-sizing: border-box;
    background-color: #ffffff;
    color: #333;
    margin-top: 1px; /* 카리나의 메시지를 닉네임 바로 아래에 붙임 */
}

/* 사용자가 보낸 메시지 스타일 */
.message.me {
    align-self: flex-end;
    background-color: #8d6aff;
    color: #fff;
    margin-bottom: 10px; /* 사용자 메시지와 카리나 메시지 간격을 동일하게 설정 */
}

/* 카리나가 보낸 메시지 스타일 */
.message.bot {
    align-self: flex-start;
    background-color: #f0f0f0;
    color: #333;
    margin-bottom: 10px; /* 카리나 메시지와 사용자 메시지 간격을 동일하게 설정 */
}