/* [styles.css] - 가족 비밀 채팅방 전체 스타일 */

/* 기본 바디 스타일 */
body {
    background-color: #121212;
    color: #e6e1dc;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif, 'AppleSDGothicNeo-Regular', '맑은 고딕';
    margin: 0;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    box-sizing: border-box;
    overflow-x: hidden;
}

h1 {
    color: #ffb300;
    text-shadow: 0 0 6px #ffb300aa;
    margin-bottom: 30px;
    font-weight: 800;
    font-size: 2.8rem;
    user-select: none;
    letter-spacing: -0.5px;
}

/* 채팅 컨테이너 */
#chat-container {
    width: 90%;
    max-width: 650px;
    background: #222;
    border-radius: 16px;
    box-shadow: 0 4px 20px #ffb300cc;
    display: flex;
    flex-direction: column;
    height: 75vh;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease-out;
}

body.logged-in #chat-container {
    opacity: 1;
    pointer-events: auto;
}

/* 메시지 영역 */
#messages {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
    border-bottom: 1px solid #333;
    scrollbar-width: thin;
    scrollbar-color: #ffb30055 transparent;
}
#messages::-webkit-scrollbar {
    width: 8px;
}
#messages::-webkit-scrollbar-thumb {
    background-color: #ffb30099;
    border-radius: 6px;
}
#messages::-webkit-scrollbar-track {
    background: transparent;
}

/* 메시지 */
.message {
    max-width: 65%;
    padding: 14px 20px;
    border-radius: 24px;
    position: relative;
    font-size: 1rem;
    word-wrap: break-word;
    line-height: 1.4;
    box-shadow: 0 2px 6px #00000099;
    user-select: text;
}

.message.self {
    background: linear-gradient(135deg, #ffb300, #ffa000);
    color: #2c1b00;
    align-self: flex-end;
    border-bottom-right-radius: 6px;
}

.message.other {
    background: #333;
    color: #ddd;
    align-self: flex-start;
    border-bottom-left-radius: 6px;
}

/* 발신자 */
.message .sender {
    font-weight: 700;
    font-size: 0.85rem;
    margin-bottom: 6px;
    opacity: 0.9;
    letter-spacing: 0.03em;
    user-select: text;
}
.message.self .sender {
    color: rgba(51, 27, 0, 0.7);
}

/* 타임스탬프 */
.message .timestamp {
    font-size: 0.65rem;
    color: #bbb;
    position: absolute;
    bottom: 6px;
    right: 12px;
    user-select: none;
}
.message.self .timestamp {
    color: rgba(51, 27, 0, 0.6);
}

/* 입력 영역 */
#input-area {
    background: #1a1a1a;
    padding: 15px 20px;
    display: flex;
    gap: 14px;
    border-top: 1px solid #333;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease-out;
}

body.logged-in #input-area {
    opacity: 1;
    pointer-events: auto;
}

#message-input {
    flex-grow: 1;
    border-radius: 28px;
    border: none;
    padding: 14px 22px;
    font-size: 1rem;
    background: #2e2e2e;
    color: #eee;
    outline: none;
    box-shadow: inset 0 2px 4px #0008;
}
#message-input::placeholder {
    color: #888;
    font-style: italic;
}

#send-button {
    background: #ffb300;
    border: none;
    border-radius: 28px;
    padding: 14px 26px;
    font-weight: 700;
    font-size: 1rem;
    color: #2c1b00;
    cursor: pointer;
    box-shadow: 0 0 10px #ffb300aa;
    transition: background-color 0.25s ease, box-shadow 0.25s ease;
    user-select: none;
}
#send-button:hover {
    background-color: #ffa000;
    box-shadow: 0 0 14px #ffaf0077;
}
#send-button:active {
    background-color: #cc8f00;
    box-shadow: none;
    transform: translateY(1px);
}

/* 로그인 모달 */
#auth-modal {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    flex-direction: column;
    color: #e6e1dc;
}

.auth-box {
    background: #2e2e2e;
    padding: 30px 40px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.7);
    animation: fadeInScale 0.4s ease-out;
    max-width: 400px;
    width: 90%;
}

@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.auth-box h2 {
    color: #ffb300;
    margin-bottom: 25px;
    font-size: 2.2rem;
    text-shadow: 0 0 5px #ffb300aa;
}

.auth-box p {
    font-size: 1.1rem;
    color: #bbb;
    margin-bottom: 20px;
}

.auth-box input[type="text"],
.auth-box input[type="email"] {
    width: calc(100% - 24px);
    padding: 12px;
    margin-bottom: 15px;
    border: 1px solid #444;
    border-radius: 8px;
    background-color: #3e3e3e;
    color: #eee;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s ease;
}
.auth-box input[type="text"]:focus,
.auth-box input[type="email"]:focus {
    border-color: #ffb300;
    box-shadow: 0 0 8px #ffb300aa;
}
.auth-box input::placeholder {
    color: #999;
    font-style: italic;
}

.password-display {
    width: calc(100% - 24px);
    padding: 12px;
    margin-bottom: 25px;
    border: 1px solid #444;
    border-radius: 8px;
    background: #3e3e3e;
    color: #ffb300;
    font-size: 1.5rem;
    letter-spacing: 5px;
    text-align: center;
    font-family: monospace;
    transition: border-color 0.2s;
    user-select: none;
}
.password-display.error {
    border-color: #ff4a4a;
    animation: shake 0.3s;
}
@keyframes shake {
    0% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    50% { transform: translateX(5px); }
    75% { transform: translateX(-5px); }
    100% { transform: translateX(0); }
}

.auth-box button#auth-button {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 8px;
    background: #ffb300;
    color: #2c1b00;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 10px rgba(255,179,0,0.4);
}
.auth-box button#auth-button:hover {
    background: #ffa000;
    box-shadow: 0 6px 15px rgba(255,160,0,0.6);
}
.auth-box button#auth-button:active {
    background: #cc8f00;
    box-shadow: none;
    transform: translateY(1px);
}

.numeric-keypad {
    display: grid;
    grid-template-columns: repeat(3,1fr);
    gap: 12px;
    margin-top: 25px;
    max-width: 320px;
    margin-left: auto;
    margin-right: auto;
}

.numeric-keypad button {
    padding: 18px 0;
    font-size: 1.6rem;
    font-weight: 700;
    color: #ffb300;
    background-color: #3e3e3e;
    border: 1px solid #555;
    border-radius: 10px;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    box-shadow: 0 2px 5px rgba(0,0,0,0.4);
}
.numeric-keypad button:hover {
    background-color: #4a4a4a;
    transform: translateY(-2px);
}
.numeric-keypad button:active {
    background-color: #2e2e2e;
    transform: translateY(1px);
    box-shadow: none;
}
.numeric-keypad .clear-btn {
    color: #ff4a4a;
}
.numeric-keypad .back-btn {
    color: #bbb;
}

/* 모바일 대응 */
@media (max-width: 600px) {
    body { padding: 10px; }
    h1 { font-size: 2rem; margin-bottom: 20px; }
    #chat-container { width: 100%; height: 85vh; border-radius: 8px; }
    .auth-box { padding: 20px; width: 95%; }
    .auth-box h2 { font-size: 1.8rem; margin-bottom: 15px; }
    .auth-box p { font-size: 1rem; }
    .numeric-keypad { gap: 8px; max-width: none; }
    .numeric-keypad button { padding: 12px 0; font-size: 1.3rem; }
    .message { padding: 12px 16px; font-size: 0.95rem; }
    #message-input { padding: 12px 18px; }
    #send-button { padding: 12px 20px; }
}