/* ===== 기본 리셋 & 변수 ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg-deep: #06001a;
    --bg-panel: #0d0628;
    --bg-card: #12083a;
    --bg-card-hover: #1a0f50;
    --border: rgba(124, 58, 237, 0.25);
    --border-active: rgba(167, 139, 250, 0.6);
    --purple: #7c3aed;
    --purple-light: #a78bfa;
    --purple-bright: #c4b5fd;
    --blue: #60a5fa;
    --gold: #fbbf24;
    --text-primary: #e2d9f3;
    --text-secondary: #9d8bbd;
    --text-muted: #5a4d7a;
    --chat-user-bg: rgba(124, 58, 237, 0.25);
    --chat-ai-bg: rgba(30, 20, 70, 0.8);
    --shadow: 0 4px 24px rgba(124, 58, 237, 0.15);
}

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

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-deep);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
}

/* ===== 레이아웃 ===== */
.app-container {
    display: flex;
    height: 100vh;
    gap: 0;
}

/* ===== 왼쪽 패널 ===== */
.left-panel {
    width: 62%;
    min-width: 320px;
    max-width: 85%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
}

/* ===== 드래그 리사이즈 핸들 ===== */
.resize-handle {
    width: 5px;
    background: var(--border);
    cursor: col-resize;
    flex-shrink: 0;
    transition: background 0.2s;
    position: relative;
}

.resize-handle:hover,
.resize-handle.dragging {
    background: var(--purple);
}

.resize-handle::after {
    content: '⋮';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--text-muted);
    font-size: 14px;
    pointer-events: none;
}

.left-header {
    padding: 16px 20px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-panel);
    flex-shrink: 0;
}

.title {
    font-size: 18px;
    font-weight: 700;
    color: var(--purple-bright);
    margin-bottom: 10px;
    letter-spacing: 0.5px;
}

.filter-bar {
    display: flex;
    gap: 8px;
}

.filter-btn {
    padding: 5px 14px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.filter-btn:hover {
    border-color: var(--purple-light);
    color: var(--purple-light);
}

.filter-btn.active {
    background: var(--purple);
    border-color: var(--purple);
    color: white;
}

/* ===== 카드 그리드 ===== */
.card-grid {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-content: start;
}

.card-grid::-webkit-scrollbar { width: 6px; }
.card-grid::-webkit-scrollbar-track { background: transparent; }
.card-grid::-webkit-scrollbar-thumb { background: var(--purple); border-radius: 3px; }

/* ===== 인물 카드 ===== */
.person-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
    flex: 0 0 150px;
    width: 150px;
    height: 200px;
    display: flex;
    flex-direction: column;
}

.person-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--purple), var(--blue));
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 3;
}

.person-card:hover {
    border-color: var(--border-active);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.person-card:hover::before { opacity: 1; }

.person-card.selected {
    border-color: var(--purple-light);
    box-shadow: 0 0 20px rgba(124, 58, 237, 0.5);
}

.person-card.selected::before { opacity: 1; }

/* 사진 영역 */
.card-photo {
    flex: 1;
    background-size: cover;
    background-position: center top;
    background-repeat: no-repeat;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-photo .card-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, transparent 50%, rgba(6,0,26,0.85) 100%);
}

.card-initials {
    font-size: 36px;
    font-weight: 700;
    color: rgba(255,255,255,0.9);
    z-index: 1;
    position: relative;
}

/* 카드 하단 정보 */
.card-info {
    padding: 8px 10px 10px;
    background: var(--bg-card);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.card-name-ko {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-worth {
    font-size: 12px;
    font-weight: 700;
    color: var(--gold);
    text-align: center;
}

.card-type {
    display: block;
    text-align: center;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
    align-self: center;
}

.card-type.billionaire {
    background: rgba(251, 191, 36, 0.15);
    color: var(--gold);
    border: 1px solid rgba(251, 191, 36, 0.3);
}

.card-type.investor {
    background: rgba(96, 165, 250, 0.15);
    color: var(--blue);
    border: 1px solid rgba(96, 165, 250, 0.3);
}

/* ===== 오른쪽 패널 ===== */
.right-panel {
    flex: 1;
    min-width: 260px;
    display: flex;
    flex-direction: column;
    background: var(--bg-panel);
    overflow: hidden;
}

/* ===== 정보 패널 ===== */
.info-panel {
    flex: 1;
    overflow-y: auto;
    border-bottom: 1px solid var(--border);
    min-height: 0;
}

.info-panel::-webkit-scrollbar { width: 4px; }
.info-panel::-webkit-scrollbar-thumb { background: var(--purple); border-radius: 2px; }

.info-default {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--text-muted);
    gap: 8px;
}

.info-icon { font-size: 32px; }

.info-content { padding: 20px; }

.info-top {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.info-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.info-basic h2 {
    font-size: 16px;
    font-weight: 700;
    color: var(--purple-bright);
    margin-bottom: 2px;
}

.info-name-ko {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.info-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.info-badge.billionaire {
    background: rgba(251, 191, 36, 0.15);
    color: var(--gold);
    border: 1px solid rgba(251, 191, 36, 0.3);
}

.info-badge.investor {
    background: rgba(96, 165, 250, 0.15);
    color: var(--blue);
    border: 1px solid rgba(96, 165, 250, 0.3);
}

.info-stats {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    padding: 12px;
    background: rgba(124, 58, 237, 0.08);
    border-radius: 10px;
    border: 1px solid var(--border);
}

.stat-item {
    flex: 1;
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 10px;
    color: var(--text-muted);
    margin-bottom: 3px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-value.gold { color: var(--gold); }

.info-section {
    margin-bottom: 14px;
}

.info-section h3 {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tag {
    padding: 3px 10px;
    background: rgba(124, 58, 237, 0.15);
    border: 1px solid rgba(124, 58, 237, 0.3);
    border-radius: 20px;
    font-size: 11px;
    color: var(--purple-light);
}

.quote-list { display: flex; flex-direction: column; gap: 8px; }

.quote-item {
    padding: 8px 12px;
    background: rgba(124, 58, 237, 0.08);
    border-left: 2px solid var(--purple);
    border-radius: 0 6px 6px 0;
    font-size: 12px;
    color: var(--text-secondary);
    font-style: italic;
    line-height: 1.5;
}

/* ===== 챗 패널 ===== */
.chat-panel {
    display: flex;
    flex-direction: column;
    height: 380px;
    flex-shrink: 0;
    border-top: 1px solid var(--border);
}

.chat-header {
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 600;
    color: var(--purple-light);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

/* ===== 샘플 질문 ===== */
.sample-questions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    background: rgba(124, 58, 237, 0.04);
}

.sample-btn {
    padding: 4px 10px;
    background: rgba(124, 58, 237, 0.1);
    border: 1px solid rgba(124, 58, 237, 0.25);
    border-radius: 20px;
    color: var(--purple-light);
    font-size: 11px;
    cursor: pointer;
    transition: all 0.18s;
    white-space: nowrap;
}

.sample-btn:hover {
    background: rgba(124, 58, 237, 0.28);
    border-color: var(--purple-light);
    color: var(--purple-bright);
    transform: translateY(-1px);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--purple); border-radius: 2px; }

.chat-msg {
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 12px;
    line-height: 1.6;
    max-width: 92%;
    animation: msgSlideIn 0.2s ease;
    word-break: break-word;
}

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

.chat-msg.user {
    background: var(--chat-user-bg);
    border: 1px solid rgba(124, 58, 237, 0.3);
    align-self: flex-end;
    color: var(--purple-bright);
}

.chat-msg.assistant {
    background: var(--chat-ai-bg);
    border: 1px solid var(--border);
    align-self: flex-start;
    color: var(--text-primary);
}

.chat-msg.error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
    align-self: flex-start;
}

.typing-dots { display: inline-flex; gap: 4px; align-items: center; height: 16px; }
.typing-dots span {
    width: 6px; height: 6px;
    background: var(--purple-light);
    border-radius: 50%;
    animation: typingBounce 1.2s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-5px); opacity: 1; }
}

.chat-input-row {
    display: flex;
    padding: 10px 12px;
    gap: 8px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.chat-input-row input {
    flex: 1;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input-row input:focus { border-color: var(--purple-light); }
.chat-input-row input::placeholder { color: var(--text-muted); }

.chat-input-row button {
    background: var(--purple);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 8px 16px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: background 0.2s;
    white-space: nowrap;
}

.chat-input-row button:hover { background: #6d28d9; }
.chat-input-row button:disabled { opacity: 0.5; cursor: not-allowed; }

.loading-msg {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--text-muted);
    padding: 40px;
    font-size: 14px;
}
