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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 800px;
    margin: 0 auto;
}

/* 챗봇 스타일 */
.chat-container {
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 80vh;
    max-height: 700px;
}

.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 25px;
    text-align: center;
}

.chat-header h1 {
    font-size: 28px;
    margin-bottom: 5px;
}

.chat-header p {
    opacity: 0.9;
    font-size: 14px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f5f7fa;
}

.message {
    margin-bottom: 15px;
    display: flex;
    animation: fadeIn 0.3s ease-in;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.bot-message {
    justify-content: flex-start;
}

.message-content {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    line-height: 1.5;
}

.user-message .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.bot-message .message-content {
    background: white;
    color: #333;
    border: 1px solid #e0e0e0;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    white-space: pre-wrap; /* \n, 여러 공백을 그대로 출력 */
    line-height: 1.6;      /* 줄 간격 조금 넓게 */
}

/* 메루카리 판단 결과는 HTML 구조이므로 white-space를 상속받지 않도록 */
.bot-message .message-content .mercari-judgment {
    white-space: normal;
}

.bot-message .message-content .mercari-judgment p {
    white-space: pre-wrap; /* 메루카리 판단 이유는 줄바꿈 허용 */
}

.message-time {
    font-size: 11px;
    color: #999;
    margin-top: 5px;
    text-align: right;
}

.bot-message .message-time {
    text-align: left;
}

.chat-input-container {
    display: flex;
    padding: 20px;
    background: white;
    border-top: 1px solid #e0e0e0;
    gap: 10px;
}

#userInput {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 25px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s;
}

#userInput:focus {
    border-color: #667eea;
}

#sendButton {
    padding: 12px 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 600;
    transition: transform 0.2s, box-shadow 0.2s;
}

#sendButton:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

#sendButton:active {
    transform: translateY(0);
}

.admin-link {
    text-align: center;
    margin-top: 15px;
}

.admin-link a {
    color: white;
    text-decoration: none;
    font-size: 14px;
    opacity: 0.9;
}

.admin-link a:hover {
    opacity: 1;
    text-decoration: underline;
}

/* 관리자 페이지 스타일 */
.admin-container {
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    padding: 30px;
    margin-bottom: 20px;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #f0f0f0;
}

.admin-header h1 {
    color: #333;
    font-size: 28px;
}

.back-link {
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s;
}

.back-link:hover {
    color: #764ba2;
}

.add-qa-section {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 15px;
    margin-bottom: 30px;
}

.add-qa-section h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 20px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #555;
    font-weight: 500;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group textarea:focus {
    border-color: #667eea;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.qa-list-section h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 20px;
}

.qa-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.qa-item {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 12px;
    border: 1px solid #e0e0e0;
    transition: box-shadow 0.3s;
}

.qa-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.qa-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
}

.qa-item-id {
    color: #667eea;
    font-weight: 600;
    font-size: 14px;
}

.qa-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    margin-right: 5px;
}

#selectAllCheckbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.qa-item-actions {
    display: flex;
    gap: 10px;
}

.btn-edit,
.btn-delete {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-edit {
    background: #667eea;
    color: white;
}

.btn-edit:hover {
    background: #5568d3;
}

.btn-delete {
    background: #e74c3c;
    color: white;
}

.btn-delete:hover {
    background: #c0392b;
}

.qa-question {
    font-weight: 600;
    color: #333;
    margin-bottom: 10px;
    font-size: 15px;
}

.qa-answer {
    color: #666;
    line-height: 1.6;
    font-size: 14px;
    white-space: pre-wrap; /* 줄바꿈 유지 */
}

.qa-meta {
    margin-top: 10px;
    font-size: 12px;
    color: #999;
}

.loading {
    text-align: center;
    padding: 40px;
    color: #999;
}

.empty-state {
    text-align: center;
    padding: 40px;
    color: #999;
}

.edit-form {
    display: none;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e0e0e0;
}

.edit-form.active {
    display: block;
}

.edit-form .form-group {
    margin-bottom: 10px;
}

.edit-form input,
.edit-form textarea {
    width: 100%;
    padding: 10px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
}

.edit-form-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.btn-save {
    background: #27ae60;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
}

.btn-cancel {
    background: #95a5a6;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
}

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

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

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

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

/* 모드 선택 화면 */
.mode-selection-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.mode-selection-content {
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    padding: 40px;
    max-width: 900px;
    width: 100%;
    text-align: center;
}

.mode-selection-content h1 {
    font-size: 32px;
    color: #333;
    margin-bottom: 10px;
}

.mode-selection-content > p {
    color: #666;
    font-size: 16px;
    margin-bottom: 40px;
}

.mode-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 30px;
}

.mode-btn {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 15px;
    padding: 30px 20px;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
}

.mode-btn:hover {
    border-color: #667eea;
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.2);
}

.mode-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

.mode-title {
    font-size: 20px;
    font-weight: 600;
    color: #333;
    margin-bottom: 10px;
}

.mode-description {
    font-size: 14px;
    color: #666;
    line-height: 1.5;
}

/* 모드 변경 버튼 */
.change-mode-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 12px;
    margin-top: 10px;
    transition: all 0.3s;
}

.change-mode-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* 간단문의 모드 UI */
.simple-inquiry-ui {
    padding: 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
}

.simple-inquiry-steps {
    max-width: 600px;
    margin: 0 auto;
}

.simple-inquiry-steps h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 18px;
}

.selection-title {
    margin-bottom: 10px;
    font-weight: 500;
}

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

.selection-btn {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 10px 15px;
    cursor: pointer;
    text-align: left;
    font-size: 14px;
    color: #333;
    transition: all 0.3s;
    width: 100%;
}

.selection-btn:hover {
    border-color: #667eea;
    background: #f0f4ff;
    transform: translateX(5px);
}

.back-to-categories-btn {
    background: #95a5a6;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 15px;
    cursor: pointer;
    text-align: center;
    font-size: 13px;
    transition: all 0.3s;
    width: 100%;
}

.back-to-categories-btn:hover {
    background: #7f8c8d;
}

.back-btn {
    background: #95a5a6;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    margin-bottom: 15px;
    transition: all 0.3s;
}

.back-btn:hover {
    background: #7f8c8d;
}

/* 메루카리 판단 결과 */
.mercari-judgment {
    padding: 20px;
    border-radius: 12px;
    margin: 10px 0;
}

.mercari-judgment.judgment-safe {
    background: #d4edda;
    border: 2px solid #28a745;
}

.mercari-judgment.judgment-warning {
    background: #fff3cd;
    border: 2px solid #ffc107;
}

.mercari-judgment.judgment-danger {
    background: #f8d7da;
    border: 2px solid #dc3545;
}

.mercari-judgment h3 {
    margin-bottom: 15px;
    font-size: 20px;
}

.mercari-judgment.judgment-safe h3 {
    color: #155724;
}

.mercari-judgment.judgment-warning h3 {
    color: #856404;
}

.mercari-judgment.judgment-danger h3 {
    color: #721c24;
}

.mercari-judgment p {
    margin-bottom: 10px;
    line-height: 1.6;
}

.product-info {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.product-info h4 {
    margin-bottom: 10px;
    font-size: 16px;
}

.product-info p {
    margin-bottom: 8px;
    font-size: 14px;
}

/* 반응형 디자인 */
@media (max-width: 768px) {
    .chat-container {
        height: 90vh;
    }

    .message-content {
        max-width: 85%;
    }

    .admin-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .mode-buttons {
        grid-template-columns: 1fr;
    }

    .mode-selection-content {
        padding: 20px;
    }
}

/* 카테고리 할당 모달 */
#categoryAssignModal {
    animation: fadeIn 0.3s ease-in;
}

#categoryAssignModal > div {
    animation: slideUp 0.3s ease-out;
}

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


