@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@300;400;500;700&display=swap');

:root {
    --primary-color: #818cf8;       /* 메인 컬러 (파스텔 인디고) */
    --primary-soft: #eef2ff;        /* 연한 배경용 */
    --primary-hover: #6366f1;       /* 버튼 호버 */
    --ai-bubble: #f1f5f9;           /* AI 말풍선 배경 */
    --user-bubble: #e0e7ff;         /* 사용자 말풍선 배경 */
    --bg-color: #f8fafc;            /* 전체 배경 */
    --white: #ffffff;
    --text-dark: #334155;
    --text-gray: #64748b;
    --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05);
    --radius: 20px;
}

body { 
    font-family: 'Noto Sans KR', sans-serif; 
    background-color: var(--bg-color); 
    margin: 0; 
    color: var(--text-dark); 
}

/* ================= HEADER ================= */
header {
    background: var(--white); 
    padding: 1rem 2rem;
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.03); 
    position: sticky; 
    top: 0; 
    z-index: 100;
}

.header-logo { display: flex; align-items: center; text-decoration: none; }
.header-logo img { height: 35px; margin-right: 12px; }
.header-logo span { font-size: 1.5rem; font-weight: 800; color: var(--primary-color); letter-spacing: -0.5px; }

nav { display: flex; gap: 12px; } 

.nav-btn { 
    padding: 0.6rem 1.2rem; 
    border-radius: 14px; 
    border: 1px solid #e2e8f0; 
    background: white; 
    cursor: pointer; 
    font-weight: 600; 
    transition: 0.2s; 
    color: var(--text-dark); 
    text-decoration: none;
    font-size: 0.9rem;
}
.nav-btn.primary { background: var(--primary-color); color: white; border: none; }
.nav-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.05); }

/* ================= MAIN LAYOUT ================= */
main { max-width: 1000px; margin: 2rem auto; padding: 0 1rem; }

/* ================= CHAT UI ================= */
.chat-container { 
    background: var(--white); 
    border-radius: 24px; 
    height: 70vh; 
    display: flex; 
    flex-direction: column; 
    overflow: hidden; 
    box-shadow: var(--shadow); 
    border: 1px solid #f1f5f9; 
}

#chatWindow { 
    flex: 1; 
    padding: 30px; 
    overflow-y: auto; 
    display: flex; 
    flex-direction: column; 
    gap: 24px; 
    background: #ffffff; 
}

.msg { 
    max-width: 75%; 
    padding: 16px 22px; 
    border-radius: 22px; 
    line-height: 1.7; 
    font-size: 1rem; 
    position: relative; 
    border: 1px solid rgba(0,0,0,0.03); 
}
.ai-msg { background: var(--ai-bubble); color: var(--text-dark); align-self: flex-start; border-bottom-left-radius: 4px; }
.user-msg { background: var(--user-bubble); color: var(--text-dark); align-self: flex-end; border-bottom-right-radius: 4px; }

.copy-icon-btn { 
    background: none; border: none; cursor: pointer; color: var(--text-gray); 
    font-size: 0.85rem; margin-top: 8px; display: flex; align-items: center; gap: 6px; float: right;
    transition: color 0.2s;
}
.copy-icon-btn:hover { color: var(--primary-color); }

/* --- [중요] 입력창 스타일 복구 --- */
.input-area { 
    padding: 25px; 
    background: white; 
    border-top: 1px solid #f1f5f9; 
    display: flex; 
    gap: 15px; 
    align-items: center; 
}
textarea { 
    flex: 1; 
    border: 1px solid #e2e8f0; 
    border-radius: 18px; 
    padding: 15px; 
    resize: none; 
    height: 50px; 
    font-size: 1rem; 
    background: #fcfdfe; 
    transition: 0.3s; 
    font-family: inherit; 
    outline: none;
}
textarea:focus { border-color: var(--primary-color); box-shadow: 0 0 0 4px var(--primary-soft); background: white; }

/* ================= MY PAGE UI ================= */
/* 상단 가로 스크롤 카드 */
.history-scroll { 
    display: flex; overflow-x: auto; gap: 20px; padding: 15px 5px; scrollbar-width: thin; margin-bottom: 40px; 
}
.history-card { 
    min-width: 260px; 
    background: #ffffff; 
    padding: 24px; 
    border-radius: 16px; 
    border: 2px solid #e2e8f0; 
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    position: relative; 
    transition: all 0.2s ease; 
    flex-shrink: 0; 
    cursor: pointer;
}
.history-card:hover { border-color: var(--primary-color); box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1); transform: translateY(-3px); }
.history-card h4 { margin: 0 0 15px 0; color: var(--text-dark); font-size: 1.1rem; font-weight: 700; border-bottom: 2px solid var(--primary-soft); padding-bottom: 8px; }
.history-item-preview { font-size: 0.9rem; color: var(--text-dark); margin-bottom: 10px; line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 날짜별 삭제 버튼 */
.del-date-btn { 
    position: absolute; top: 20px; right: 20px; cursor: pointer; 
    background: #fff1f2; border: none; width: 32px; height: 32px; border-radius: 8px; 
    display: flex; align-items: center; justify-content: center; color: #f43f5e; 
    transition: 0.2s; z-index: 10; 
}
.del-date-btn:hover { background: #ffe4e6; color: #e11d48; }

/* --- [중요] 마이페이지 그리드 레이아웃 복구 --- */
.settings-grid { 
    display: grid; 
    grid-template-columns: 1fr 1fr; 
    gap: 24px; 
}
.section-card { 
    background: white; 
    padding: 30px; 
    border-radius: 24px; 
    box-shadow: var(--shadow); 
    border: 1px solid #f1f5f9; 
    height: fit-content;
}
.section-card h3 { margin-top: 0; color: var(--primary-color); font-size: 1.2rem; margin-bottom: 20px; font-weight: 700; }

.input-group { margin-bottom: 15px; }
.input-group label { display: block; font-size: 0.85rem; color: var(--text-gray); margin-bottom: 8px; font-weight: 500; margin-left: 4px; }
.section-card input { 
    width: 100%; padding: 14px; border-radius: 14px; border: 1px solid #e2e8f0; 
    box-sizing: border-box; font-size: 0.95rem; background: #fcfdfe; outline: none; 
}
.section-card input:focus { border-color: var(--primary-color); background: #fff; }

.delete-section { margin-top: 25px; padding-top: 20px; border-top: 1px dashed #fecaca; text-align: right; }
.del-btn { background: white; border: 1px solid #fecaca; color: #ef4444; padding: 8px 16px; border-radius: 10px; cursor: pointer; font-size: 0.85rem; transition: 0.2s; font-weight: 600; }
.del-btn:hover { background: #fef2f2; border-color: #ef4444; }

/* ================= ADMIN & COMMON ================= */
.admin-card { grid-column: span 2; margin-top: 20px; }
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; }
.admin-edit { width: 100%; height: 400px; font-family: monospace; padding: 20px; border-radius: 18px; border: 1px solid #e2e8f0; font-size: 0.95rem; line-height: 1.6; background: #fdfdfd; box-sizing: border-box; }

.user-list-item { 
    padding: 15px; border-bottom: 1px solid #f1f5f9; transition: 0.2s; 
    border-radius: 12px; display: flex; justify-content: space-between; align-items: center; 
}
.user-list-item:hover { background: var(--primary-soft); }

.force-del-btn { background: #fff1f2; color: #ef4444; border: 1px solid #fecaca; border-radius: 6px; padding: 4px 8px; font-size: 0.75rem; cursor: pointer; margin-left: 10px; }
.force-del-btn:hover { background: #ef4444; color: white; }

/* ================= MODALS ================= */
.modal { 
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; 
    background: rgba(0,0,0,0.5); z-index: 1000; align-items: center; justify-content: center; 
    backdrop-filter: blur(4px); 
}
.modal-content { 
    background: white; padding: 2.5rem; border-radius: 24px; position: relative; 
    width: 90%; max-width: 400px; box-shadow: var(--shadow); max-height: 90vh; overflow-y: auto; 
}
.close-x { position: absolute; top: 20px; right: 20px; font-size: 1.5rem; cursor: pointer; border: none; background: none; color: var(--text-gray); }

.modal h2 { margin-top: 0; margin-bottom: 20px; color: var(--text-dark); font-weight: 700; }
.modal input:not([type="checkbox"]) { 
    width: 100%; padding: 14px; margin: 8px 0; border: 1px solid #e2e8f0; 
    border-radius: 12px; box-sizing: border-box; font-size: 1rem; outline: none; background: #fcfdfe;
}
.modal input:focus { border-color: var(--primary-color); background: #fff; }

.pw-wrapper { position: relative; width: 100%; margin: 8px 0; }
.pw-toggle-btn { position: absolute; right: 15px; top: 50%; transform: translateY(-50%); cursor: pointer; color: #94a3b8; font-size: 1rem; z-index: 5; }

.disclaimer-box { background: #f8fafc; padding: 15px; border-radius: 12px; font-size: 0.85rem; color: #64748b; line-height: 1.5; margin-bottom: 15px; border: 1px solid #e2e8f0; height: 80px; overflow-y: auto; }
.agree-check { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; margin-bottom: 20px; cursor: pointer; }

/* ================= TOAST (Z-INDEX 최상위) ================= */
#toast-container { position: fixed; top: 24px; right: 24px; z-index: 99999; }
.toast { 
    background: white; padding: 16px 28px; border-radius: 12px; 
    box-shadow: 0 10px 40px rgba(0,0,0,0.2); border-left: 6px solid var(--primary-color); 
    margin-bottom: 15px; font-weight: 500; animation: slideIn 0.3s forwards; 
}
@keyframes slideIn { from { transform: translateY(-20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ================= MOBILE ================= */
@media (max-width: 768px) {
    .settings-grid, .admin-grid, .footer-section { grid-template-columns: 1fr; }
    .msg { max-width: 90%; }
}