/* ========================================================
   고슴도치 재경이의 마음 충전소 테마 스타일시트
   따뜻한 라떼 & 고슴도치 브라운 & 소프트 핑크 파스텔 감성
   ======================================================== */

:root {
    --bg-main: #fbf7f2;
    --bg-card: #ffffff;
    --bg-card-soft: #fbf2eb;
    --primary-brown: #5d3a29;
    --secondary-brown: #8d5b4c;
    --accent-warm: #d97742;
    --accent-peach: #f4a261;
    --accent-pink: #ff6b8b;
    --accent-soft-pink: #ffe5ec;
    --text-main: #332219;
    --text-muted: #8c7a70;
    --chat-bubble-character: #ffffff;
    --chat-bubble-user: #ffe4c4;
    --border-light: rgba(141, 91, 76, 0.15);
    --shadow-soft: 0 8px 24px rgba(109, 76, 65, 0.08);
    --shadow-card: 0 12px 32px rgba(93, 58, 41, 0.12);
    --font-heading: 'Jua', 'Gowun Dodum', sans-serif;
    --font-body: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, Roboto, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: var(--bg-main);
    background-image: 
        radial-gradient(#e9dacb 1px, transparent 1px),
        radial-gradient(#e9dacb 1px, var(--bg-main) 1px);
    background-size: 32px 32px;
    background-position: 0 0, 16px 16px;
    font-family: var(--font-body);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
}

/* 떠다니는 하트 배경 효과 */
.floating-hearts-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.floating-heart-item {
    position: absolute;
    bottom: -30px;
    font-size: 18px;
    animation: floatUp 8s linear infinite;
    opacity: 0.6;
}

@keyframes floatUp {
    0% {
        transform: translateY(0) rotate(0deg) scale(0.8);
        opacity: 0;
    }
    15% {
        opacity: 0.7;
    }
    90% {
        opacity: 0.7;
    }
    100% {
        transform: translateY(-110vh) rotate(360deg) scale(1.2);
        opacity: 0;
    }
}

/* ==================== 메인 앱 컨테이너 ==================== */
.chat-app-container {
    width: 100%;
    max-width: 480px;
    height: 100vh;
    max-height: 920px;
    background: #fffdfa;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
    box-shadow: var(--shadow-card);
    border-radius: 28px;
    overflow: hidden;
    border: 1px solid rgba(141, 91, 76, 0.12);
}

@media (max-width: 500px) {
    .chat-app-container {
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        border: none;
    }
}

/* ==================== 상단 헤더 ==================== */
.chat-header {
    background: rgba(255, 253, 250, 0.94);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 12px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-light);
    z-index: 10;
}

.header-character {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
    transition: transform 0.15s ease;
}

.header-character:active {
    transform: scale(0.96);
}

.avatar-ring {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    overflow: hidden;
    border: 2.5px solid var(--accent-warm);
    background: #fff;
    box-shadow: 0 2px 8px rgba(217, 119, 66, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
}

.header-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.header-title-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.header-name {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    color: var(--primary-brown);
    letter-spacing: -0.3px;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
    animation: pulseDot 2s infinite ease-in-out;
}

@keyframes pulseDot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(0.85); }
}

.header-sub {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 500;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.icon-btn {
    background: var(--bg-card-soft);
    border: 1px solid var(--border-light);
    width: 38px;
    height: 38px;
    border-radius: 50%;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.icon-btn:hover {
    transform: scale(1.08);
    background: #fae1d7;
}

.heart-btn:active {
    transform: scale(0.85);
}

/* ==================== 캐릭터 환영 히어로 카드 ==================== */
.character-hero-card {
    background: linear-gradient(135deg, #fff7f0 0%, #fdefeb 100%);
    margin: 10px 14px 6px;
    padding: 14px 16px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    border: 1px solid rgba(244, 162, 97, 0.25);
    box-shadow: var(--shadow-soft);
    position: relative;
    transition: all 0.3s ease;
}

.hero-avatar-wrapper {
    position: relative;
    width: 72px;
    height: 72px;
    flex-shrink: 0;
    cursor: pointer;
}

.hero-character-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: 50% 15%;
    border-radius: 50%;
    border: 3px solid #fff;
    box-shadow: 0 4px 12px rgba(109, 76, 65, 0.15);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.hero-avatar-wrapper:hover .hero-character-img,
.hero-avatar-wrapper:active .hero-character-img {
    transform: scale(1.08) rotate(3deg);
}

.heart-bubble-badge {
    position: absolute;
    bottom: -2px;
    right: -2px;
    background: var(--accent-pink);
    color: white;
    font-size: 13px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    box-shadow: 0 2px 6px rgba(255, 107, 139, 0.4);
    animation: heartBounce 2s infinite ease-in-out;
}

@keyframes heartBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

.hero-text {
    flex: 1;
    min-width: 0;
}

.hero-tag {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--accent-warm);
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.hero-greeting {
    font-family: var(--font-heading);
    font-size: 1.02rem;
    color: var(--primary-brown);
    line-height: 1.35;
    margin-bottom: 3px;
}

.hero-desc {
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.3;
}

/* ==================== 퀵 추천 칩 버튼 ==================== */
.quick-chips-wrapper {
    padding: 6px 14px 8px;
    background: #fffdfa;
}

.quick-chips-scroll {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: none;
}

.quick-chips-scroll::-webkit-scrollbar {
    display: none;
}

.chip-btn {
    white-space: nowrap;
    background: #fbf2ea;
    border: 1px solid rgba(217, 119, 66, 0.22);
    color: var(--primary-brown);
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 0.78rem;
    font-weight: 600;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.chip-btn:hover {
    background: #fae4d2;
    transform: translateY(-1px);
}

.chip-btn:active {
    transform: scale(0.95);
    background: var(--accent-warm);
    color: white;
}

/* ==================== 채팅 메시지 영역 ==================== */
.chat-messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 12px 14px 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scroll-behavior: smooth;
    background: #fffdfa;
}

.message-row {
    display: flex;
    gap: 10px;
    max-width: 85%;
    animation: messageSlideIn 0.25s ease-out;
}

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

/* 고슴도치 재경이 메시지 (좌측) */
.character-row {
    align-self: flex-start;
}

.msg-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    border: 1.5px solid var(--accent-warm);
    background: #fff;
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}

.msg-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
}

.msg-content {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}

.msg-sender {
    font-size: 0.74rem;
    font-weight: 600;
    color: var(--secondary-brown);
    margin-left: 2px;
}

.msg-bubble {
    background: #ffffff;
    color: var(--text-main);
    padding: 11px 15px;
    border-radius: 18px 18px 18px 4px;
    font-size: 0.92rem;
    line-height: 1.5;
    box-shadow: 0 3px 12px rgba(109, 76, 65, 0.08);
    border: 1px solid rgba(141, 91, 76, 0.12);
    word-break: break-word;
    white-space: pre-line;
    position: relative;
}

.msg-time {
    font-size: 0.68rem;
    color: #a89a90;
    margin-left: 4px;
    margin-top: 1px;
}

/* 상경이 메시지 (우측) */
.user-row {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.user-row .msg-content {
    align-items: flex-end;
}

.user-row .msg-bubble {
    background: linear-gradient(135deg, #f4a261 0%, #e76f51 100%);
    color: #ffffff;
    border-radius: 18px 18px 4px 18px;
    border: none;
    box-shadow: 0 4px 14px rgba(231, 111, 81, 0.28);
    font-weight: 500;
}

.user-row .msg-time {
    margin-right: 4px;
}

/* ==================== 타이핑 인디케이터 ==================== */
.typing-indicator-bar {
    padding: 6px 14px 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: transparent;
    animation: fadeIn 0.2s ease;
}

.typing-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    border: 1.5px solid var(--accent-warm);
    background: #fff;
}

.typing-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
}

.typing-bubble {
    background: #ffffff;
    padding: 8px 14px;
    border-radius: 16px;
    border: 1px solid rgba(141, 91, 76, 0.12);
    display: flex;
    align-items: center;
    gap: 5px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: var(--accent-warm);
    border-radius: 50%;
    display: inline-block;
    animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

.typing-text {
    font-size: 0.74rem;
    color: var(--text-muted);
    margin-left: 6px;
    font-weight: 500;
}

/* ==================== 메시지 입력창 ==================== */
.chat-input-bar {
    background: #ffffff;
    border-top: 1px solid var(--border-light);
    padding: 10px 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-input {
    flex: 1;
    background: #fbf7f3;
    border: 1.5px solid rgba(141, 91, 76, 0.16);
    padding: 12px 16px;
    border-radius: 24px;
    font-size: 0.92rem;
    font-family: var(--font-body);
    color: var(--text-main);
    outline: none;
    transition: all 0.2s ease;
}

.chat-input:focus {
    border-color: var(--accent-warm);
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(244, 162, 97, 0.2);
}

.btn-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #d97742 0%, #b85d28 100%);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(217, 119, 66, 0.35);
    transition: all 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
    flex-shrink: 0;
}

.send-icon {
    width: 20px;
    height: 20px;
    margin-left: 2px;
}

.btn-send:hover {
    transform: scale(1.08);
}

.btn-send:active {
    transform: scale(0.92);
}

/* ==================== 🤫 비밀 관리자 모달 & 드로어 (재경이 전용) ==================== */
.admin-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(43, 24, 16, 0.65);
    backdrop-filter: blur(6px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

.admin-modal-card {
    background: #ffffff;
    border-radius: 22px;
    padding: 24px;
    max-width: 360px;
    width: 100%;
    box-shadow: 0 20px 40px rgba(0,0,0,0.25);
    border: 2px solid var(--accent-warm);
}

.admin-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.admin-modal-header h3 {
    font-family: var(--font-heading);
    color: var(--primary-brown);
    font-size: 1.15rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #999;
    cursor: pointer;
}

.admin-tip {
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.45;
    margin-bottom: 16px;
}

.admin-pin-group {
    display: flex;
    gap: 8px;
}

.admin-pin-group input {
    flex: 1;
    padding: 10px 14px;
    border: 1.5px solid #ddd;
    border-radius: 12px;
    font-size: 1rem;
    text-align: center;
    letter-spacing: 3px;
    outline: none;
}

.admin-pin-group input:focus {
    border-color: var(--accent-warm);
}

.btn-admin-primary {
    background: var(--accent-warm);
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
}

.error-msg {
    color: #e63946;
    font-size: 0.78rem;
    margin-top: 8px;
    text-align: center;
}

/* 관리자 실시간 개입 하단 드로어 패널 */
.admin-panel-drawer {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 520px;
    background: #2b1f1a;
    color: #fbf7f2;
    border-radius: 24px 24px 0 0;
    box-shadow: 0 -8px 30px rgba(0,0,0,0.35);
    z-index: 999;
    padding: 16px 18px 24px;
    border: 2px solid #e76f51;
    border-bottom: none;
    animation: drawerSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes drawerSlideUp {
    from { transform: translate(-50%, 100%); }
    to { transform: translate(-50%, 0); }
}

.admin-drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255,255,255,0.12);
}

.admin-status-badge {
    font-size: 0.84rem;
    display: flex;
    align-items: center;
    gap: 6px;
    color: #ffd166;
}

.live-dot {
    width: 8px;
    height: 8px;
    background: #ef476f;
    border-radius: 50%;
    display: inline-block;
    animation: pulseDot 1s infinite;
}

.admin-controls-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 토글 스위치 */
.toggle-switch {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 0.75rem;
    color: #f0eae1;
}

.toggle-switch input {
    display: none;
}

.slider {
    width: 34px;
    height: 18px;
    background: #555;
    border-radius: 18px;
    position: relative;
    transition: 0.2s;
}

.slider::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    background: white;
    border-radius: 50%;
    transition: 0.2s;
}

.toggle-switch input:checked + .slider {
    background: #10b981;
}

.toggle-switch input:checked + .slider::after {
    transform: translateX(16px);
}

.admin-btn-mini {
    background: rgba(255,255,255,0.12);
    border: none;
    color: #ddd;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.72rem;
    cursor: pointer;
}

.admin-btn-mini.logout {
    background: rgba(239, 71, 111, 0.25);
    color: #ff99ac;
}

.admin-live-tip {
    font-size: 0.74rem;
    color: #d6ccc2;
    margin-bottom: 10px;
    line-height: 1.4;
}

.admin-quick-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.admin-quick-btn {
    background: rgba(244, 162, 97, 0.2);
    border: 1px solid rgba(244, 162, 97, 0.4);
    color: #ffe8d6;
    padding: 5px 9px;
    border-radius: 12px;
    font-size: 0.72rem;
    cursor: pointer;
    transition: background 0.15s;
}

.admin-quick-btn:hover {
    background: var(--accent-warm);
    color: white;
}

.admin-input-group {
    display: flex;
    gap: 8px;
}

.admin-input-group input {
    flex: 1;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 0.88rem;
    outline: none;
}

.admin-input-group input:focus {
    border-color: #f4a261;
    background: rgba(255,255,255,0.15);
}

.btn-admin-send {
    background: linear-gradient(135deg, #e76f51 0%, #d97742 100%);
    border: none;
    color: white;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 0.84rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
}

/* Firebase 아코디언 */
.firebase-settings-accordion {
    margin-top: 10px;
    border-top: 1px dashed rgba(255,255,255,0.15);
    padding-top: 8px;
    font-size: 0.74rem;
    color: #aaa;
}

.firebase-settings-accordion summary {
    cursor: pointer;
    color: #ffd166;
    outline: none;
}

.firebase-config-box {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.firebase-config-box input {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    color: #eee;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 0.72rem;
}

.btn-admin-secondary {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 0.72rem;
    cursor: pointer;
    align-self: flex-end;
}
