/* 기본 스타일 리셋 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans KR', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 헤더 스타일 */
.header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 0;
    margin-bottom: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    text-align: center;
    overflow: hidden;
}

/* 타이틀 섹션 스타일 */
.title-section {
    background-image: url('title_image.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    border-radius: 20px 20px 0 0;
}

.title-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 20px 20px 0 0;
    z-index: 1;
}

.main-title {
    color: white !important;
    font-size: 3rem;
    font-weight: 900;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.8), 0 0 10px rgba(0, 0, 0, 0.5);
    margin: 0 0 10px 0;
    position: relative;
    z-index: 10;
    letter-spacing: 2px;
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    background: none !important;
    border: none !important;
}

.copyright {
    color: white !important;
    font-size: 1rem;
    font-weight: 400;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7);
    margin: 0;
    position: relative;
    z-index: 10;
    letter-spacing: 1px;
    display: block !important;
    opacity: 0.9 !important;
    visibility: visible !important;
    background: none !important;
    border: none !important;
    text-align: right;
    width: 100%;
    padding-right: 20px;
    box-sizing: border-box;
}

/* 기존 h1 스타일 제거 */
.header h1 {
    display: none;
}

.api-key-section {
    margin-bottom: 15px;
    text-align: center;
    padding: 20px;
}

.api-key-section label {
    display: block;
    font-weight: 500;
    color: #4a5568;
    margin-bottom: 5px;
}

.api-key-section input {
    padding: 8px 15px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    background: white;
    font-size: 14px;
    color: #4a5568;
    width: 100%;
    max-width: 400px;
    transition: all 0.3s ease;
}

.api-key-section input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.api-key-section small {
    display: block;
    color: #718096;
    font-size: 12px;
    margin-top: 5px;
}

.api-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 15px;
    background: linear-gradient(135deg, #10B981, #059669);
    color: white;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.api-status i {
    font-size: 16px;
}

.personality-selector {
    padding: 0 20px 20px 20px;
}

.personality-selector label {
    display: block;
    font-weight: 500;
    color: #4a5568;
    margin-bottom: 15px;
    text-align: center;
}

.personality-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.personality-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 15px 20px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    background: white;
    font-size: 14px;
    color: #4a5568;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 80px;
}

.personality-btn:hover {
    border-color: #667eea;
    background: #f7fafc;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.personality-btn.active {
    border-color: #667eea;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.personality-btn i {
    font-size: 24px;
    margin-bottom: 5px;
}

.personality-btn span {
    font-weight: 500;
}


/* 채팅 컨테이너 */
.chat-container {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    max-height: 500px;
}

/* 메시지 스타일 */
.message {
    display: flex;
    margin-bottom: 20px;
    animation: fadeInUp 0.3s ease;
}

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

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

.user-message .message-content {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    margin-left: 50px;
}

.bot-message .message-content {
    background: #f7fafc;
    color: #4a5568;
    margin-right: 50px;
    border: 1px solid #e2e8f0;
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.user-message .message-avatar {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    order: 2;
}

.bot-message .message-avatar {
    background: #e2e8f0;
    color: #667eea;
}

/* Personality-specific avatar colors */
.bot-message .message-avatar .fa-glasses {
    color: #8B4513; /* Brown for Franklin (wooden glasses) */
}

.bot-message .message-avatar .fa-university {
    color: #2E8B57; /* Sea Green for Hamilton (government) */
}

.bot-message .message-avatar .fa-dove {
    color: #87CEEB; /* Sky Blue for Gandhi (peace) */
}

.bot-message .message-avatar .fa-crown {
    color: #FFD700; /* Gold for Sejong (royalty) */
}

.bot-message .message-avatar .fa-user-tie {
    color: #4B0082; /* Indigo for custom character */
}

.bot-message .message-avatar .fa-robot {
    color: #667eea; /* Default blue for robot */
}

.message-content {
    max-width: 70%;
    padding: 15px 20px;
    border-radius: 20px;
    position: relative;
    word-wrap: break-word;
}

.message-text {
    line-height: 1.5;
    font-size: 14px;
}

/* 마크다운 스타일 */
.message-text h1,
.message-text h2,
.message-text h3,
.message-text h4,
.message-text h5,
.message-text h6 {
    margin: 10px 0 5px 0;
    font-weight: 600;
    color: inherit;
}

.message-text h1 { font-size: 1.2em; }
.message-text h2 { font-size: 1.1em; }
.message-text h3 { font-size: 1.05em; }

.message-text p {
    margin: 8px 0;
}

.message-text strong {
    font-weight: 600;
    color: inherit;
}

.message-text em {
    font-style: italic;
}

.message-text ul,
.message-text ol {
    margin: 8px 0;
    padding-left: 20px;
}

.message-text li {
    margin: 4px 0;
}

.message-text blockquote {
    margin: 8px 0;
    padding: 8px 12px;
    border-left: 3px solid #667eea;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 0 4px 4px 0;
}

.message-text code {
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 4px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.message-text pre {
    background: rgba(0, 0, 0, 0.05);
    padding: 10px;
    border-radius: 5px;
    overflow-x: auto;
    margin: 8px 0;
}

.message-text pre code {
    background: none;
    padding: 0;
}

.message-text a {
    color: #667eea;
    text-decoration: underline;
}

.message-text a:hover {
    color: #764ba2;
}

.message-time {
    font-size: 11px;
    opacity: 0.7;
    margin-top: 5px;
    text-align: right;
}

/* 입력 영역 */
.chat-input-container {
    padding: 20px;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
}

.input-wrapper {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

#messageInput {
    flex: 1;
    padding: 15px 20px;
    border: 2px solid #e2e8f0;
    border-radius: 25px;
    font-size: 14px;
    outline: none;
    transition: all 0.3s ease;
    background: white;
}

#messageInput:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.send-button {
    width: 50px;
    height: 50px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.3s ease;
}

.send-button:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.input-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.action-button {
    padding: 8px 15px;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    background: white;
    color: #4a5568;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 5px;
}

.action-button:hover {
    background: #f7fafc;
    border-color: #667eea;
    color: #667eea;
}

/* 로딩 스타일 */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    flex-direction: column;
    gap: 20px;
    color: white;
    font-size: 16px;
}

.loading.show {
    display: flex;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 반응형 디자인 */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .header h1 {
        font-size: 1.5rem;
    }
    
    .personality-selector {
        padding: 0 10px 10px 10px;
    }
    
    .personality-buttons {
        grid-template-columns: 1fr;
    }
    
    .personality-btn {
        min-height: 70px;
        padding: 12px 15px;
    }
    
    .message-content {
        max-width: 85%;
    }
    
    .user-message .message-content {
        margin-left: 20px;
    }
    
    .bot-message .message-content {
        margin-right: 20px;
    }
    
    .input-actions {
        flex-wrap: wrap;
    }
}

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

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}
