/*
 * SongsChat Chatbot Styles
 * 원본: template.html 12-330줄에서 분리
 * 
 * 이게 뭔지: 챗봇 UI의 모든 스타일(색상, 크기, 애니메이션)을 모아둔 파일
 * 왜 분리했나: 스타일만 수정할 때 이 파일만 건드리면 됨 (다른 코드 망가뜨릴 위험 없음)
 * 
 * 2025-12-27 수정: 회원 인증 UI 스타일 추가 (모달, 버튼, 토스트)
 */

/* 마루부리 폰트 */
@font-face {
    font-family: 'MaruBuri';
    src: url('https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_20-10-21@1.0/MaruBuri-Regular.woff') format('woff');
}

/* CSS 변수 - config.json에서 동적으로 변경됨 */
:root {
    --color-left: #3B82F6;
    --color-middle: #1E90FF;
    --color-right: #0EA271;
    --font-family: 'MaruBuri', sans-serif;
    --font-size: 15px;
    --line-height: 1.6;
    --text-color: #FFFFFF;
    --bold-color: #0EA271;
    --link-color: #3B82F6;
    --bubble-bg: #404040;
    --border-radius: 18px;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --bg-solid: #667eea;
}

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

html, body {
    height: 100%;
    overflow: hidden;
    margin: 0;
}

body {
    font-family: var(--font-family);
    background: linear-gradient(135deg, var(--color-left) 0%, var(--color-middle) 50%, var(--color-right) 100%);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.chat-container {
    width: 100%;
    height: 90vh;
    height: 90dvh;
    background: #2a2a2a;
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.chat-header {
    background: linear-gradient(135deg, var(--color-left) 0%, var(--color-middle) 50%, var(--color-right) 100%);
    color: white;
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.chat-header h1 { font-size: 20px; font-weight: 600; }

/* 헤더 오른쪽 버튼 그룹 (2025-12-27 추가) */
.header-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
}

.admin-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
}
.admin-btn:hover { background: rgba(255,255,255,0.3); }

/* 로그인 버튼 (2025-12-27 추가) */
.auth-btn {
    background: rgba(255,255,255,0.25);
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    padding: 8px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s;
}
.auth-btn:hover {
    background: rgba(255,255,255,0.35);
}

/* 사용자 정보 표시 (로그인 후) */
.user-info {
    display: none;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,0.15);
    padding: 6px 12px;
    border-radius: 8px;
}

.user-name {
    font-size: 13px;
    font-weight: 500;
    color: white;
}

.logout-btn {
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    font-size: 11px;
    padding: 2px 6px;
}
.logout-btn:hover {
    color: white;
}

/* ============================================
   인증 모달 (2025-12-27 추가)
   ============================================ */

.auth-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.auth-modal-content {
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 360px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.auth-modal-header {
    background: linear-gradient(135deg, var(--color-left), var(--color-right));
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.auth-modal-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.auth-close-btn {
    background: transparent;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    opacity: 0.8;
}
.auth-close-btn:hover {
    opacity: 1;
}

/* 탭 버튼 */
.auth-tabs {
    display: flex;
    border-bottom: 1px solid #E2E8F0;
}

.auth-tab {
    flex: 1;
    padding: 14px;
    background: transparent;
    border: none;
    font-size: 14px;
    font-weight: 500;
    color: #64748B;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-family);
}

.auth-tab:hover {
    color: var(--color-left);
}

.auth-tab.active {
    color: var(--color-left);
    border-bottom: 2px solid var(--color-left);
    margin-bottom: -1px;
}

/* 폼 영역 */
.auth-form {
    padding: 20px;
}

.auth-form-group {
    margin-bottom: 16px;
}

.auth-form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    margin-bottom: 6px;
}

.auth-form-group input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #E2E8F0;
    border-radius: 10px;
    font-size: 15px;
    font-family: var(--font-family);
    transition: border-color 0.2s;
}

.auth-form-group input:focus {
    outline: none;
    border-color: var(--color-left);
}

.auth-submit-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--color-left), var(--color-right));
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
    font-family: var(--font-family);
}

.auth-submit-btn:hover {
    opacity: 0.9;
}

.auth-error {
    display: none;
    background: #FEE2E2;
    color: #DC2626;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 16px;
}

/* 토스트 메시지 (2025-12-27 추가) */
.auth-toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #1F2937;
    color: white;
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 14px;
    z-index: 3000;
    opacity: 0;
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.auth-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ============================================
   기존 스타일 (변경 없음)
   ============================================ */

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #1e1e1e;
}

.message {
    margin-bottom: 16px;
    display: flex;
    animation: fadeIn 0.3s ease;
}

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

.message.user { justify-content: flex-end; }

.message-bubble {
    max-width: 75%;
    padding: 14px 18px;
    border-radius: var(--border-radius);
    line-height: var(--line-height);
    font-size: var(--font-size);
    font-family: var(--font-family);
}

.message.bot .message-bubble {
    background: var(--bubble-bg);
    color: var(--text-color);
    border: 1px solid #555555;
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow);
}

.message.user .message-bubble {
    background: linear-gradient(135deg, var(--color-left), var(--color-right));
    color: white;
    border-bottom-right-radius: 4px;
}

.message.bot .message-bubble h1,
.message.bot .message-bubble h2,
.message.bot .message-bubble h3 {
    color: var(--color-left);
    margin: 12px 0 8px 0;
    font-size: 16px;
}

.message.bot .message-bubble strong { color: var(--bold-color); }

/* 이미지 스타일 (2026-01-06 추가) */
/* 이게 뭔지: AI가 출력하는 이미지 크기와 스타일 설정 */
/* 왜 필요: 기본 크기가 너무 작아서 보기 어려움 */
/* 비유: 액자 크기 조절 - 사진을 보기 좋게 키움 */
.message.bot .message-bubble img {
    max-width: 100%;        /* 말풍선 폭에 맞춤 (넘치지 않게) */
    height: auto;           /* 비율 유지 (찌그러지지 않게) */
    border-radius: 8px;     /* 모서리 둥글게 */
    margin: 10px 0;         /* 위아래 여백 (텍스트와 분리) */
    display: block;         /* 블록으로 표시 (중앙 정렬 가능) */
}

.message.bot .message-bubble a { color: var(--link-color); text-decoration: none; }
.message.bot .message-bubble a:hover { text-decoration: underline; }

.message.bot .message-bubble code {
    background: #F1F5F9;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 13px;
}

.message.bot .message-bubble ul,
.message.bot .message-bubble ol { padding-left: 20px; margin: 8px 0; }
.message.bot .message-bubble li { margin: 4px 0; }

.typing-indicator { display: flex; gap: 4px; padding: 12px 16px; }
.typing-indicator span {
    width: 8px; height: 8px; border-radius: 50%;
    background: #94A3B8; animation: typing 1.4s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-8px); }
}

/* 말풍선 안 버튼 스타일 (inline-buttons) */
.inline-buttons {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid #E2E8F0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.inline-btn {
    padding: 8px 14px;
    background: linear-gradient(135deg, var(--color-left), var(--color-right));
    border: none;
    border-radius: 16px;
    font-size: 13px;
    color: white;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
    font-family: var(--font-family);
}

.inline-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.chat-input-wrapper {
    position: relative;
}

.chat-input {
    padding: 20px;
    background: #2a2a2a;
    border-top: 1px solid #555555;
    display: flex;
    gap: 12px;
    flex-shrink: 0;
}

#userInput {
    flex: 1;
    padding: 14px 20px;
    border: 1px solid #555555;
    border-radius: 28px;
    font-size: 15px;
    outline: none;
    font-family: var(--font-family);
    /* 다크모드 (2026-01-08 추가) */
    background: #404040;
    color: #FFFFFF;
    /* 자동 높이 조절용 (2025-12-29 추가) */
    resize: none;
    overflow: hidden;
    min-height: 48px;
    max-height: 120px;
    line-height: 1.4;
}
#userInput:focus { border-color: var(--color-left); }
#userInput::placeholder { color: #999999; }

#sendBtn {
    padding: 14px 24px;
    background: linear-gradient(135deg, var(--color-left), var(--color-right));
    color: white;
    border: none;
    border-radius: 28px;
    cursor: pointer;
    font-weight: 600;
    white-space: nowrap;
}
#sendBtn:hover { opacity: 0.9; }

.copy-warning {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 20px 30px;
    border-radius: 12px;
    z-index: 1000;
    font-size: 16px;
    text-align: center;
    max-width: 300px;
}

/* Lottie Walker - 입력창 위 선을 따라 걷기 */
.lottie-walker {
    position: absolute;
    bottom: 100%;
    width: 60px;
    height: 60px;
    z-index: 100;
    pointer-events: none;
    opacity: 0;
    margin-bottom: -10px;
}

/* 일정-모드: 차분하게 일정 속도 */
@keyframes walkSteady {
    0% { left: -60px; opacity: 1; }
    95% { opacity: 1; }
    100% { left: 100%; opacity: 0; }
}

/* 가속-모드: 천천히 걷다가 빨라짐 (ease-in) */
@keyframes walkAccelerate {
    0% { left: -60px; opacity: 1; }
    40% { left: 25%; }
    95% { opacity: 1; }
    100% { left: 100%; opacity: 0; }
}

/* 지각이다!-모드: 걷다가 멈추고 제자리 점프 후 달림 */
@keyframes walkLate {
    0% { left: -60px; transform: translateY(0); opacity: 1; }
    35% { left: 30%; transform: translateY(0); }
    40% { left: 30%; transform: translateY(0); }
    45% { left: 30%; transform: translateY(-25px); }
    50% { left: 30%; transform: translateY(0); }
    95% { opacity: 1; transform: translateY(0); }
    100% { left: 100%; transform: translateY(0); opacity: 0; }
}

/* 변신-모드: 걷다가 멈추고 공중회전 후 달림 */
@keyframes walkTransform {
    0% { left: -60px; transform: translateY(0) rotate(0deg); opacity: 1; }
    35% { left: 30%; transform: translateY(0) rotate(0deg); }
    40% { left: 30%; transform: translateY(-30px) rotate(0deg); }
    50% { left: 30%; transform: translateY(-30px) rotate(360deg); }
    55% { left: 30%; transform: translateY(0) rotate(360deg); }
    95% { opacity: 1; transform: translateY(0) rotate(360deg); }
    100% { left: 100%; transform: translateY(0) rotate(360deg); opacity: 0; }
}

.lottie-walker.walk-steady { animation: walkSteady 15.4s linear forwards; }
.lottie-walker.walk-accelerate { animation: walkAccelerate 10s ease-in forwards; }
.lottie-walker.walk-late { animation: walkLate 10s linear forwards; }
.lottie-walker.walk-transform { animation: walkTransform 10s linear forwards; }

/* 모바일 반응형 */
@media (max-width: 480px) {
    body { padding: 0; }
    .chat-container {
        height: 100vh;
        height: 100dvh;
        max-height: none;
        border-radius: 0;
    }
    .chat-header { padding: 16px 20px; }
    .chat-header h1 { font-size: 18px; }
    .chat-messages { padding: 16px; }
    .chat-input { padding: 16px; }
    #userInput { padding: 12px 16px; font-size: 16px; }
    #sendBtn { padding: 12px 20px; }
    .lottie-walker {
        width: 50px;
        height: 50px;
    }
    .inline-btn {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    /* 모바일 인증 UI */
    .header-buttons {
        gap: 4px;
    }
    .auth-btn {
        padding: 6px 10px;
        font-size: 11px;
    }
    .user-info {
        padding: 4px 8px;
    }
    .user-name {
        font-size: 11px;
    }
    .auth-modal-content {
        width: 95%;
        max-width: 320px;
    }
}
