/*
 * Songil Astra Child Theme - Chat CSS
 * 작성자: Songil, Grok (xAI)
 * 최종 수정: 2025-06-01
 * 목차:
 * 문단 1. 채팅 컨테이너 및 레이아웃
 * 문단 2. 채팅 메시지 및 말풍선 스타일
 * 문단 3. 채팅 입력 영역 스타일
 * 문단 4. 채팅 요청 목록 스타일
 * 문단 5. 읽음/안 읽음 표시 스타일
 * 문단 6. 알림 드롭다운 스타일
 * 문단 7. 채팅창 커서 및 포커스
 */

/*
 * 문단 1. 채팅 컨테이너 및 레이아웃
 * - 채팅창 컨테이너 및 버튼 레이아웃
 * - members_profile, chat-requests 페이지별 스타일
 * - 견적/결제/거래 확정 버튼 스타일
 * 수정: 2025-05-23, amount-container를 고정 크기 상위 컨테이너로 설정
 * 수정: 2025-05-23, 한글 원화 표기 한 줄 표시 및 크기 고정
 * 추가: 2025-05-26, .check-estimate 버튼 스타일링
 * 수정: 2025-10-16, 채팅창 폭 좁아짐 문제 해결, min-width 600px로 복원, flex 레이아웃 적용
 * 수정: 2025-05-31, 채팅창 폭을 800px로 절대 크기 설정, 모바일 반응형 추가
 * 수정: 2025-06-01, 채팅창 폭을 900px로 확장, 상위 컨테이너 간섭 제거, 반응형 최적화
 * 수정: 2025-06-01, 채팅창 폭을 300px로 축소, 전문가 목록 가시성 확보
 * 수정: 2025-06-01, 채팅창 폭을 400px로 통일, #chat-container 중복 정의 제거
 */
#chat-requests-container {
    width: 100% !important;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0;
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: flex-start;
    gap: 20px;
}

#chat-container {
    width: 100%;
    max-width: 400px;
    margin: 20px 0;
    border: none;
    padding: 0;
    background-color: transparent;
}

.chat-container {
    width: 400px !important;
    max-width: 95vw;
    position: sticky;
    top: 20px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    z-index: 100000 !important;
    display: flex;
    flex-direction: column;
    padding: 15px;
    margin: 0;
    justify-content: flex-start;
    height: 800px;
    overflow-y: auto !important;
    box-sizing: border-box;
}

.chat-container.chat-requests {
    width: 400px !important;
    max-width: 95vw;
    height: auto;
    padding: 15px;
}

.chat-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    position: sticky;
    top: 0;
    z-index: 100001;
    background: #fff;
    padding: 10px 0;
    width: 100%;
    box-sizing: border-box;
}

.deal-button, .quote-button, .pay-button, .confirm-transaction-button {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    text-decoration: none;
    color: white;
    font-size: 14px;
}

.deal-button {
    background-color: #007bff;
}

.deal-button:hover {
    background-color: #0056b3;
}

.quote-button {
    background-color: #28a745;
}

.quote-button:hover {
    background-color: #218838;
}

.pay-button {
    background-color: #ff9900;
    margin-top: 10px;
}

.pay-button:hover {
    background-color: #e68a00;
}

.confirm-transaction-button {
    background-color: #17a2b8;
    margin-top: 10px;
}

.confirm-transaction-button:hover {
    background-color: #138496;
}

.additional-buttons {
    display: flex;
    gap: 10px;
}

.estimate-message, .payment-message, .transaction-confirmed-message {
    max-width: 70%;
    padding: 15px;
    border-radius: 10px;
    background-color: #f8f9fa;
    border: 1px solid #ddd;
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 10px;
}

.check-estimate {
    display: inline-block;
    margin-left: 10px;
    padding: 5px 10px;
    background-color: #0073aa;
    color: #fff;
    text-decoration: none;
    border-radius: 3px;
    font-size: 14px;
}

.check-estimate:hover {
    background-color: #005177;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 100001;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    width: 400px;
    max-width: 90%;
    position: relative;
    text-align: center;
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 20px;
    cursor: pointer;
    color: #333;
}

.modal-close:hover {
    color: #ff0000;
}

.modal-content h3 {
    margin-bottom: 20px;
    font-size: 18px;
}

.modal-content label {
    display: block;
    margin-bottom: 5px;
    font-size: 14px;
}

.modal-content input, .modal-content textarea {
    width: 100%;
    padding: 8px;
    margin-bottom: 15px;
    border: 1px solid #ddd;
    border-radius: 5px;
    box-sizing: border-box;
}

.amount-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 350px;
    max-width: 350px;
    margin: 0 auto 15px;
    padding: 10px;
    box-sizing: border-box;
}

#estimate-amount {
    width: 150px;
    max-width: 150px;
    margin-right: 10px;
}

.amount-in-words {
    width: 180px;
    max-width: 180px;
    font-size: 14px;
    color: #555;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#estimate-description {
    width: 100%;
    height: 100px;
    resize: none;
}

.modal-content button {
    background: #28a745;
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
}

.modal-content button:hover {
    background: #218838;
}

@media screen and (max-width: 768px) {
    #chat-requests-container {
        flex-direction: column;
        align-items: center;
    }

    #chat-container {
        max-width: 90vw;
    }

    .chat-container, .chat-container.chat-requests {
        width: 90vw !important;
        max-width: 90vw;
        padding: 10px;
    }
}

/*
 * 문단 2. 채팅 메시지 및 말풍선 스타일
 * - 메시지 영역 및 카카오톡 스타일 말풍선
 * 수정: 2025-06-12, fade-in 애니메이션 추가, chat-loading-spinner 스타일 추가, 메시지 전환 최적화
 */
#chat-messages {
    width: 100%;
    max-width: 370px; /* 400px - padding 15px*2 */
    height: 520px;
    overflow-y: scroll;
    padding: 15px;
    background-color: #fff;
    border-radius: 10px;
    border: 1px solid #e0e0e0;
    margin-bottom: 15px;
    scrollbar-width: thin;
    scrollbar-color: #ccc #f5f5f5;
    position: relative;
    box-sizing: border-box;
}

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

#chat-messages::-webkit-scrollbar-track {
    background: #f5f5f5;
    border-radius: 10px;
}

#chat-messages::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 10px;
}

#chat-messages::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}

#chat-messages .message {
    display: flex;
    flex-direction: column;
    margin: 10px 0;
    min-height: 50px;
    opacity: 0;
    animation: fadeIn 0.3s ease-in forwards;
}

#chat-messages .message.fade-in {
    animation: fadeIn 0.3s ease-in forwards;
}

#chat-messages .message.sent {
    align-items: flex-end;
}

#chat-messages .message.received {
    align-items: flex-start;
}

#chat-messages .message-wrapper {
    max-width: 70%;
    padding: 10px;
    border-radius: 18px;
    background-color: #e0e0e0;
    font-size: 14px;
    line-height: 1.5;
}

#chat-messages .message.sent .message-wrapper {
    background-color: #ffeb33;
    color: #000;
    border-radius: 18px 18px 0 18px;
}

#chat-messages .message.received .message-wrapper {
    background-color: #f5f5f5;
    border: 1px solid #e0e0e0;
    border-radius: 18px 18px 18px 0;
}

#chat-messages .message-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 5px;
    width: 100%;
}

#chat-messages .message-header .avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    order: 1;
}

#chat-messages .message.sent .message-header .avatar {
    order: 2;
    margin-left: 5px;
}

#chat-messages .message.received .message-header .avatar {
    order: 1;
    margin-right: 5px;
}

#chat-messages .message-header .sender-name {
    font-size: 12px;
    color: #000;
    background: transparent;
    order: 2;
}

#chat-messages .message.sent .message-header .sender-name {
    order: 1;
    text-align: right;
}

#chat-messages .message.received .message-header .sender-name {
    order: 2;
    text-align: left;
}

#chat-messages .message-header .avatar[src=""],
#chat-messages .message-header .avatar:not([src]) {
    display: none;
}

#chat-messages .message-content .message-text {
    margin: 0;
    word-wrap: break-word;
}

#chat-messages .message-footer {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #888;
    margin-top: 5px;
}

#chat-messages .message.sent .message-footer {
    justify-content: flex-end;
}

.date-separator {
    text-align: center;
    font-size: 12px;
    color: #888;
    padding: 10px 0;
    margin: 10px 0;
    border-top: 1px solid #e0e0e0;
    border-bottom: 1px solid #e0e0e0;
}

.scroll-date {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 5px 10px;
    border-radius: 12px;
    font-size: 12px;
    z-index: 100;
    transition: opacity 0.3s ease;
    opacity: 0;
}

.scroll-date[style*="display: block"] {
    opacity: 1;
}

.media-upload-button {
    display: inline-block;
    width: 30px;
    height: 30px;
    line-height: 30px;
    text-align: center;
    background-color: #007bff;
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    margin-right: 10px;
}

.media-upload-button:hover {
    background-color: #0056b3;
}

.media-upload-panel {
    display: none;
    margin-top: 10px;
    padding: 10px;
    border: 1px solid #ccc;
    background-color: #f9f9f9;
}

.media-upload-panel input[type="file"] {
    display: block;
    margin-bottom: 10px;
}

.media-upload-panel button {
    margin-right: 10px;
    padding: 5px 10px;
    cursor: pointer;
}

.media-upload-panel {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 10px;
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.media-upload-panel input[type="file"] {
    width: 100%;
}

.media-upload-panel button {
    background: #007bff;
    color: #fff;
    border: none;
    border-radius: 5px;
    padding: 8px 15px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.media-upload-panel button:hover {
    background: #0056b3;
}

.media-upload-panel button#media-upload-cancel {
    background: #dc3545;
}

.media-upload-panel button#media-upload-cancel:hover {
    background: #c82333;
}

.media-message img,
.media-message video {
    max-width: 100%;
    max-height: 200px;
    border-radius: 8px;
    margin-top: 5px;
}

.chat-loading-spinner {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007bff;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    z-index: 100002;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

@media (max-width: 768px) {
    #chat-messages {
        max-width: 100%;
        height: 60vh;
        min-height: 300px;
        max-height: 400px;
    }
}

/*
 * 문단 3. 채팅 입력 영역 스타일
 * - 메시지 입력창 및 전송 버튼
 * 수정: 2025-06-01, 입력창과 버튼 너비를 400px 컨테이너에 맞춤
 */
.chat-input-area {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    max-width: 370px; /* 400px - padding 15px*2 */
    box-sizing: border-box;
}

#chat-input {
    width: 75%;
    max-width: 275px; /* 370px * 0.75 */
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 25px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s;
    resize: none;
    height: 50px;
    box-sizing: border-box;
}

#chat-input:focus {
    border-color: #007bff;
}

#chat-send {
    width: 20%;
    max-width: 74px; /* 370px * 0.20 */
    padding: 12px;
    border: none;
    background-color: #007bff;
    color: white;
    border-radius: 25px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.3s;
    box-sizing: border-box;
}

#chat-send:hover {
    background-color: #0056b3;
}

@media screen and (max-width: 768px) {
    .chat-input-area {
        max-width: 100%;
    }

    #chat-input {
        width: 70%;
        max-width: none;
    }

    #chat-send {
        width: 25%;
        max-width: none;
    }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/*
 * 문단 4. 채팅 요청 목록 스타일
 * - chat-requests 및 guest-chat-requests 페이지의 목록
 * 수정: 2025-06-01, .guest-list 폭을 30%에서 60%로 확장, 반응형 조정
 * 수정: 2025-06-01, .guest-list 폭을 40%로 최적화, 채팅창과 균형 유지
 */
.chat-requests-container {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: flex-start;
    gap: 20px;
    padding: 20px;
    max-width: 1000px;
    margin: 0 auto;
}

.guest-list {
    width: 40%;
    max-width: 400px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    overflow-y: auto;
    max-height: 600px;
}

.guest-list h2 {
    font-size: 20px;
    margin-bottom: 15px;
    color: #333;
}

.chat-requests-list {
    list-style: none;
    padding: 0;
}

.chat-requests-list li {
    margin-bottom: 10px;
}

.chat-requests-list li a {
    display: flex;
    align-items: center;
    padding: 10px;
    text-decoration: none;
    color: #333;
    border-radius: 5px;
    transition: background 0.3s ease;
}

.chat-requests-list li a:hover {
    background: #f0f0f0;
}

.chat-requests-list li.selected a {
    background: #e0e0e0;
}

.guest-photo,
.guest-list .avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    margin-right: 10px;
    object-fit: cover;
}

/* 이미지 로드 실패 시 숨김 처리 */
.guest-photo[src=""],
.guest-photo:not([src]),
.guest-list .avatar[src=""],
.guest-list .avatar:not([src]) {
    display: none;
}

.chat-info {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.chat-user {
    font-size: 16px;
    font-weight: bold;
    color: #333;
}

.chat-preview {
    font-size: 14px;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.unread-count {
    background: #ff0000;
    color: #fff;
    border-radius: 50%;
    padding: 2px 8px;
    font-size: 12px;
    margin-left: auto;
}

.chat-requests-list p {
    font-size: 14px;
    color: #666;
    text-align: center;
    padding: 20px;
    margin: 0;
}

@media screen and (max-width: 768px) {
    .chat-requests-container {
        flex-direction: column;
        align-items: center;
    }
    .guest-list {
        width: 90vw;
        max-width: 90vw;
        order: -1; /* 목록을 상단으로 이동 */
    }
}

/*
 * 문단 5. 읽음/안 읽음 표시 스타일
 * - 메시지 옆에 "1" 표시로 안 읽음 상태 표시
 * 수정: 변경 없음, 기존 스타일 유지
 */
.read-status {
    font-size: 12px;
    color: #ff0000;
    margin-left: 5px;
    display: inline-block;
}

.message.me .read-status {
    margin-right: 5px;
    text-align: right;
}

/*
 * 문단 6. 알림 드롭다운 스타일
 * - 종소리 알림 아이콘 및 드롭다운 UI
 * 수정: 변경 없음, 기존 스타일 유지
 */
.notification-dropdown {
    position: absolute;
    top: 60px;
    right: 20px;
    background-color: #fff;
    border: 1px solid #ccc;
    border-radius: 5px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    display: none;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1002;
    min-width: 250px;
}

.notification-dropdown div {
    padding: 10px;
    border-bottom: 1px solid #eee;
    font-size: 14px;
    color: #333;
}

.notification-dropdown div a {
    color: #007bff;
    text-decoration: none;
}

.notification-dropdown div a:hover {
    text-decoration: underline;
}

.notification-dropdown div:last-child {
    border-bottom: none;
}

.notification-icon {
    cursor: pointer;
    margin-left: 40px;
    position: relative;
    font-size: 14px;
    line-height: 1
}

.notification-count {
    position: absolute;
    top: -5px;
    right: -0px;
    background: #ff0000;
    color: white;
    padding: 2px;
    font-size: 2px;
}

/*
 * 문단 작성7. 채팅창 커서 및 포커스
 */
.chat-input:focus {
    outline: none;
    border: 2px solid #007bff; /* 테두리 색상 */
    caret-color: #000; /* 커서 색상 */
}