/* ============================================
   CSS Variables & Color Customization
   ============================================
   색상 커스터마이징 가이드:
   --primary: 메인 강조 색상 (현재: 형광 하늘색 #00f2ff)
   --secondary: 보조 강조 색상 (현재: 보라색 #7000ff)
   원하는 색상 코드로 변경하면 사이트 전체 분위기가 바뀝니다.
   예: --primary: #ff6b6b; (빨간색) 또는 --secondary: #4ecdc4; (청록색)
*/
:root {
    --bg-dark: #020617;
    --bg-card: #0f172a;
    --primary: #00f2ff; /* Cyan - 메인 강조 색상 (변경 가능) */
    --secondary: #7000ff; /* Purple - 보조 강조 색상 (변경 가능) */
    --text-main: #ffffff;
    --text-muted: #94a3b8;
    --font-main: 'Inter', sans-serif;
}

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

body {
    font-family: var(--font-main);
    background-color: var(--bg-dark);
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
}

a { text-decoration: none; color: inherit; }
ul { list-style: none; }

/* --- Animations --- */
@keyframes glow {
    0% { box-shadow: 0 0 20px rgba(0, 242, 255, 0.2); }
    50% { box-shadow: 0 0 40px rgba(112, 0, 255, 0.4); }
    100% { box-shadow: 0 0 20px rgba(0, 242, 255, 0.2); }
}

@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
    100% { transform: translateY(0px); }
}

/* --- Header --- */
header {
    position: fixed;
    top: 0;
    width: 100%;
    padding: 20px 5%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(2, 6, 23, 0.8);
    backdrop-filter: blur(10px);
    z-index: 1000;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: 2px;
    background: linear-gradient(135deg, #00f2ff 0%, #00d4ff 50%, #00b8ff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    cursor: pointer;
    transition: all 0.3s ease;
}

.logo:hover {
    background: linear-gradient(135deg, #00ffff 0%, #00f2ff 50%, #00d4ff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 8px rgba(0, 242, 255, 0.5));
}

nav ul {
    display: flex;
    gap: 30px;
}

nav a {
    font-size: 0.9rem;
    color: var(--text-muted);
    transition: color 0.3s;
}

nav a:hover { color: var(--primary); }

/* --- Hero Section --- */
.hero {
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 0 20px;
    background: radial-gradient(circle at center, rgba(112, 0, 255, 0.15) 0%, rgba(2, 6, 23, 1) 70%);
    position: relative;
}

.hero h1 {
    font-size: 4rem;
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 20px;
    background: linear-gradient(135deg, #fff 30%, var(--primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero p {
    font-size: 1.2rem;
    color: var(--text-muted);
    max-width: 600px;
    margin-bottom: 40px;
}

.cta-btn {
    padding: 15px 40px;
    border-radius: 30px;
    background: linear-gradient(90deg, var(--secondary), var(--primary));
    color: white;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: transform 0.2s;
}

.cta-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(0, 242, 255, 0.4);
}

/* --- Features Section --- */
.features {
    padding: 100px 10%;
}

.section-title {
    text-align: center;
    font-size: 2.5rem;
    margin-bottom: 60px;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
}

.card {
    background: var(--bg-card);
    padding: 40px;
    border-radius: 16px;
    border: 1px solid rgba(255,255,255,0.05);
    transition: 0.3s;
}

.card:hover {
    transform: translateY(-5px);
    border-color: var(--primary);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.card h3 {
    margin-bottom: 15px;
    font-size: 1.4rem;
}

.card p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.icon {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, var(--secondary), var(--primary));
    border-radius: 12px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.5rem;
}

/* --- Chat Interface Section --- */
.chat-section {
    padding: 100px 5%;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: linear-gradient(180deg, var(--bg-dark) 0%, #0a0a1a 100%);
}

.chat-container {
    width: 100%;
    max-width: 500px;
    background: rgba(15, 23, 42, 0.8);
    border-radius: 24px;
    border: 1px solid rgba(255,255,255,0.1);
    backdrop-filter: blur(20px);
    padding: 30px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    animation: glow 4s infinite ease-in-out;
}

/* PC 화면일 때 chat-container 더 넓게 */
@media (min-width: 769px) {
    .chat-container {
        max-width: 800px;
    }
}

.chat-header {
    display: flex;
    align-items: center;
    margin-bottom: 25px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    padding-bottom: 15px;
}

.nika-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 15px;
    border: 2px solid var(--primary);
    overflow: hidden;
    flex-shrink: 0;
}

.nika-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.nika-avatar::after {
    content: 'N';
    display: none;
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary);
}

.nika-avatar:not(:has(img))::after {
    display: flex;
    align-items: center;
    justify-content: center;
}

.bot-status h4 {
    font-size: 1.1rem;
    margin-bottom: 2px;
}

.bot-status span {
    font-size: 0.8rem;
    color: var(--primary);
    display: flex;
    align-items: center;
}

.bot-status span::before {
    content: '';
    width: 8px;
    height: 8px;
    background-color: var(--primary);
    border-radius: 50%;
    margin-right: 6px;
    box-shadow: 0 0 10px var(--primary);
}

.message-bubble {
    background: rgba(255,255,255,0.05);
    padding: 15px;
    border-radius: 0 15px 15px 15px;
    margin-bottom: 25px;
    font-size: 0.95rem;
    color: #e2e8f0;
    border-left: 3px solid var(--secondary);
    animation: fadeIn 0.5s ease-out;
}

.input-area {
    display: flex;
    gap: 10px;
    position: relative;
}

.chat-input {
    flex: 1;
    background: rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.1);
    padding: 15px 20px;
    border-radius: 30px;
    color: white;
    font-size: 0.95rem;
    outline: none;
    transition: 0.3s;
}

.chat-input:focus {
    border-color: var(--primary);
}

.send-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    background: var(--primary);
    color: var(--bg-dark);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.3s;
}

.send-btn:hover {
    background: white;
    transform: scale(1.1);
}

.send-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* 로딩 스피너 애니메이션 */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.send-btn.loading {
    opacity: 0.7;
    cursor: not-allowed;
    pointer-events: none;
}

.send-btn.loading::before {
    content: '⏳';
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

.chat-input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.disclaimer-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
    margin-top: 15px;
    opacity: 0.7;
}

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

.success-message {
    text-align: center;
    color: var(--primary);
    margin-top: 20px;
    font-weight: 600;
    animation: fadeIn 0.5s ease-out;
}

/* Chart Section */
.chart-section {
    padding: 100px 5%;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: linear-gradient(180deg, #0a0a1a 0%, var(--bg-dark) 100%);
}

.chart-container {
    width: 100%;
    max-width: 800px;
    background: var(--bg-card);
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 10px 40px rgba(0, 242, 255, 0.1);
    border: 1px solid rgba(0, 242, 255, 0.1);
}

.chart-container canvas {
    max-height: 400px;
}

footer {
    padding: 50px 10%;
    text-align: center;
    border-top: 1px solid rgba(255,255,255,0.05);
    color: var(--text-muted);
    font-size: 0.8rem;
}

.nika-avatar.no-image {
    background: linear-gradient(135deg, var(--secondary), var(--primary));
}

.nika-avatar.no-image::after {
    content: 'N';
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    color: white;
    width: 100%;
    height: 100%;
}

.nika-avatar:has(img[style*="display: block"])::after {
    display: none;
}

@media (max-width: 768px) {
    .hero h1 { font-size: 2.5rem; }
    nav { display: none; }
    .grid { grid-template-columns: 1fr; }
    .chat-container { padding: 20px; }
    .hero { padding: 0 15px; }
}

/* --- Chat Messages Styles --- */
.chat-messages {
    max-height: 400px;
    min-height: 200px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    background: rgba(0,0,0,0.2);
    box-sizing: border-box;
}

/* 참조 프로젝트 스타일: .txt 클래스 사용 */
.chat-messages .txt {
    margin: 16px 0 0 0;
    line-height: 1.6;
    font-size: 16px;
    font-weight: 500;
    color: #e2e8f0;
    word-wrap: break-word;
    word-break: break-word;
    animation: fadeIn 0.3s ease-out;
}

.chat-messages .txt:first-of-type {
    margin-top: 0 !important;
}

/* 에이전트 메시지 (왼쪽 정렬) - C0002 */
.chat-messages .txt.you {
    margin: 16px auto 0 0;
    text-align: left;
    color: #e2e8f0;
    padding: 14px;
    padding-left: 17px; /* border-left 공간 확보 */
    border-left: 3px solid var(--secondary);
    background: rgba(255,255,255,0.05);
    border-radius: 0 8px 8px 8px;
}

/* 사용자 메시지 (오른쪽 정렬) - C0001 */
.chat-messages .txt.me {
    margin: 16px 0 0 auto;
    padding: 14px;
    border-radius: 8px 0 8px 8px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    text-align: right;
    max-width: 80%;
}

/* 오류 메시지 스타일 */
.chat-messages .txt.error-message {
    border-left-color: #ff4444;
    background: rgba(255, 68, 68, 0.1);
    color: #ff8888;
    animation: errorPulse 0.5s ease-out;
}

@keyframes errorPulse {
    0% { opacity: 0; transform: translateX(-10px); }
    100% { opacity: 1; transform: translateX(0); }
}

/* 로딩 그라데이션 애니메이션 */
@keyframes loading-gradient {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.chat-messages .txt.me.loading-gradient {
    background: linear-gradient(270deg, var(--primary), var(--secondary), var(--primary));
    background-size: 200% 200%;
    animation: loading-gradient 1.5s ease infinite;
    opacity: 0.8;
}

/* 채팅 메시지 스크롤바 스타일 */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.05);
    border-radius: 10px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 10px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--secondary);
}

/* 참고 이미지 스타일 */
.reference-images {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.reference-image-item {
    margin-bottom: 8px;
    position: relative;
    display: inline-block;
    width: 100%;
}

.reference-image-item img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 4s ease, opacity 4s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: block;
    filter: blur(5px);
    opacity: 0.7;
}

.reference-image-item img.loaded {
    filter: blur(0px);
    opacity: 1;
}

.reference-image-item img:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0, 242, 255, 0.3);
    border-color: var(--primary);
}

/* 참조 이미지 오버레이 레이블 */
.reference-image-label {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: var(--primary);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    backdrop-filter: blur(4px);
    border: 1px solid rgba(0, 242, 255, 0.3);
    pointer-events: none;
    z-index: 1;
}

@media (max-width: 480px) {
    .hero h1 { font-size: 2rem; }
    .hero p { font-size: 1rem; }
    .section-title { font-size: 2rem; }
    .chat-message {
        max-width: 90%;
    }
}

/* --- NIKA Table Styles (content_blocks) --- */
.nika-table-container {
    margin: 16px 0;
    width: 100%;
    overflow-x: auto;
}

.nika-table-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid rgba(0, 242, 255, 0.3);
}

.nika-table {
    width: 100%;
    border-collapse: collapse;
    background: rgba(15, 23, 42, 0.6);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.9rem;
}

.nika-table thead {
    background: linear-gradient(135deg, rgba(112, 0, 255, 0.3), rgba(0, 242, 255, 0.3));
}

.nika-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-main);
    border-bottom: 2px solid rgba(0, 242, 255, 0.2);
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
}

.nika-table tbody tr {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: background-color 0.2s ease;
}

.nika-table tbody tr:hover {
    background-color: rgba(0, 242, 255, 0.1);
}

.nika-table tbody tr:last-child {
    border-bottom: none;
}

.nika-table td {
    padding: 12px 16px;
    color: var(--text-muted);
    vertical-align: top;
}

.nika-table tbody tr:nth-child(even) {
    background-color: rgba(255, 255, 255, 0.02);
}

/* 채팅 메시지 내부의 테이블 스타일 조정 */
.chat-messages .txt .nika-table-container {
    margin: 12px 0;
}

.chat-messages .txt.you .nika-table-container {
    margin-left: 0;
    margin-right: 0;
}

.chat-messages .txt.me .nika-table-container {
    margin-left: auto;
    margin-right: 0;
    max-width: 100%;
}

/* 모바일 반응형 */
@media (max-width: 768px) {
    .nika-table {
        font-size: 0.8rem;
    }
    
    .nika-table th,
    .nika-table td {
        padding: 8px 12px;
    }
    
    .nika-table-title {
        font-size: 0.9rem;
    }
}

/* 차트 블록 스타일 */
.nika-chart-container {
    margin: 16px 0;
    width: 100%;
    padding: 16px;
    background: rgba(15, 23, 42, 0.6);
    border-radius: 12px;
    border: 1px solid rgba(0, 242, 255, 0.2);
}

.nika-chart-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid rgba(0, 242, 255, 0.3);
}

.nika-chart-canvas {
    max-height: 400px;
    width: 100% !important;
    height: auto !important;
    margin-bottom: 40px; /* X축 레이블과 하단 메시지 사이 여백 확보 */
}

/* 채팅 메시지 내부의 차트 스타일 조정 */
.chat-messages .txt .nika-chart-container {
    margin: 12px 0;
}

.chat-messages .txt.you .nika-chart-container {
    margin-left: 0;
    margin-right: 0;
}

.chat-messages .txt.me .nika-chart-container {
    margin-left: auto;
    margin-right: 0;
    max-width: 100%;
}

/* 모바일 반응형 - 차트 */
@media (max-width: 768px) {
    .nika-chart-container {
        padding: 12px 8px; /* 좌우 패딩 줄여서 차트 공간 확보 */
        overflow: visible;
        position: relative;
    }
    
    .nika-chart-title {
        font-size: 0.9rem;
    }
    
    /* 모바일에서 차트를 크게 표시 (scale 제거, 실제 크기 조정) */
    .nika-chart-canvas {
        max-height: 350px;
        min-height: 250px;
        width: 100% !important;
        height: auto !important;
        margin-bottom: 30px; /* X축 레이블과 메시지 사이 적절한 여백 */
    }
    
    /* 컨테이너 하단 여백 최소화 */
    .nika-chart-container {
        padding-bottom: 0;
    }
}

/* 다운로드/공유 버튼 스타일 */
.nika-download-share-container {
    margin-top: 40px; /* 차트 X축 레이블과의 충분한 간격 확보 */
    padding: 16px;
    background: rgba(15, 23, 42, 0.8);
    border-radius: 8px;
    border: 1px solid rgba(0, 242, 255, 0.2);
}

.nika-download-share-message {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 12px;
    text-align: center;
}

.nika-button-group {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.nika-action-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-main);
}

.nika-download-btn {
    background: linear-gradient(135deg, rgba(0, 242, 255, 0.2), rgba(112, 0, 255, 0.2));
    color: var(--primary);
    border: 1px solid rgba(0, 242, 255, 0.3);
}

.nika-download-btn:hover {
    background: linear-gradient(135deg, rgba(0, 242, 255, 0.3), rgba(112, 0, 255, 0.3));
    border-color: rgba(0, 242, 255, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 242, 255, 0.2);
}

.nika-share-btn {
    background: linear-gradient(135deg, rgba(112, 0, 255, 0.2), rgba(0, 242, 255, 0.2));
    color: var(--secondary);
    border: 1px solid rgba(112, 0, 255, 0.3);
}

.nika-share-btn:hover {
    background: linear-gradient(135deg, rgba(112, 0, 255, 0.3), rgba(0, 242, 255, 0.3));
    border-color: rgba(112, 0, 255, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(112, 0, 255, 0.2);
}

.nika-action-btn span {
    font-size: 1rem;
}

/* 모바일 반응형 - 버튼 */
@media (max-width: 768px) {
    .nika-download-share-container {
        padding: 12px;
        margin-top: 20px; /* 모바일에서 차트와 메시지 사이 최소 여백 */
    }
    
    .nika-download-share-message {
        font-size: 0.85rem;
    }
    
    .nika-action-btn {
        padding: 8px 16px;
        font-size: 0.85rem;
        flex: 1;
        min-width: 120px;
    }
    
    .nika-button-group {
        gap: 8px;
    }
}