* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

.navbar {
    background-color: #2c3e50;
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: white;
    text-decoration: none;
}

.nav-links {
    display: flex;
    gap: 2rem;
}

.nav-links a {
    color: white;
    text-decoration: none;
    transition: opacity 0.3s;
}

.nav-links a:hover {
    opacity: 0.8;
}

.main-content {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 2rem;
    min-height: calc(100vh - 200px);
}

.footer {
    background-color: #2c3e50;
    color: white;
    text-align: center;
    padding: 1rem;
    margin-top: 3rem;
}

/* 채팅 페이지 */
.chat-container {
    display: flex;
    gap: 2rem;
    height: calc(100vh - 200px);
}

.chat-sidebar {
    width: 300px;
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.chat-sidebar h3 {
    margin-bottom: 1rem;
    color: #2c3e50;
}

.case-selector {
    margin-bottom: 2rem;
}

.case-selector input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 0.5rem;
}

.case-selector button {
    width: 100%;
    padding: 0.5rem;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.case-selector button:hover {
    background-color: #2980b9;
}

.case-list h4 {
    margin-bottom: 0.5rem;
    color: #555;
    font-size: 0.9rem;
}

.case-list ul {
    list-style: none;
}

.case-list li {
    margin-bottom: 0.5rem;
}

.case-list a {
    color: #3498db;
    text-decoration: none;
}

.case-list a:hover {
    text-decoration: underline;
}

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    overflow: hidden;
}

.chat-header {
    padding: 1rem 1.5rem;
    background-color: #34495e;
    color: white;
    border-bottom: 1px solid #ddd;
}

.chat-header h2 {
    font-size: 1.2rem;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.message {
    padding: 1rem;
    border-radius: 8px;
    max-width: 80%;
}

.message-user {
    align-self: flex-end;
    background-color: #3498db;
    color: white;
}

.message-assistant {
    align-self: flex-start;
    background-color: #ecf0f1;
    color: #333;
}

.message-role {
    font-size: 0.85rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
    opacity: 0.8;
}

.message-content {
    white-space: pre-wrap;
    word-wrap: break-word;
}

.message-time {
    font-size: 0.75rem;
    margin-top: 0.5rem;
    opacity: 0.7;
}

.template-buttons {
    padding: 1rem 1.5rem;
    border-top: 1px solid #ddd;
    background-color: #f8f9fa;
}

.template-buttons h4 {
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
    color: #555;
    font-weight: 600;
}

.template-button-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.template-btn {
    padding: 0.5rem 1rem;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background-color 0.2s;
}

.template-btn:hover {
    background-color: #2980b9;
}

.template-btn:active {
    transform: scale(0.98);
}

.learn-btn {
    width: 100%;
    padding: 0.75rem 1rem;
    background-color: #e67e22;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    transition: background-color 0.2s;
}

.learn-btn:hover:not(:disabled) {
    background-color: #d35400;
}

.learn-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.chat-input-area {
    padding: 1rem 1.5rem;
    border-top: 1px solid #ddd;
    display: flex;
    gap: 1rem;
}

.chat-input-area textarea {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    resize: none;
    font-family: inherit;
}

.chat-input-area button {
    padding: 0.75rem 2rem;
    background-color: #27ae60;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}

.chat-input-area button:hover:not(:disabled) {
    background-color: #229954;
}

.chat-input-area button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* 케이스 페이지 */
.cases-container {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.cases-container h1 {
    margin-bottom: 2rem;
    color: #2c3e50;
}

.case-create-form {
    margin-bottom: 3rem;
    padding-bottom: 2rem;
    border-bottom: 2px solid #ecf0f1;
}

.call-upload-form {
    margin-bottom: 3rem;
    padding-bottom: 2rem;
    border-bottom: 2px solid #ecf0f1;
}

.call-upload-form h2 {
    margin-bottom: 1rem;
    color: #34495e;
}

.call-upload-form input[type="file"] {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.call-upload-form button {
    padding: 0.75rem 2rem;
    background-color: #e67e22;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}

.call-upload-form button:hover:not(:disabled) {
    background-color: #d35400;
}

.call-upload-form button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.case-create-form h2 {
    margin-bottom: 1rem;
    color: #34495e;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #555;
}

.form-group input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.form-group input:focus {
    outline: none;
    border-color: #3498db;
}

.case-create-form button {
    padding: 0.75rem 2rem;
    background-color: #27ae60;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}

.case-create-form button:hover {
    background-color: #229954;
}

.cases-table {
    width: 100%;
    border-collapse: collapse;
}

.cases-table th,
.cases-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

.cases-table th {
    background-color: #34495e;
    color: white;
    font-weight: 600;
}

.cases-table tr:hover {
    background-color: #f8f9fa;
}

.btn-link {
    color: #3498db;
    text-decoration: none;
    font-weight: 500;
}

.btn-link:hover {
    text-decoration: underline;
}

/* 관리자 로그 페이지 */
.admin-logs-container {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.admin-logs-container h1 {
    margin-bottom: 2rem;
    color: #2c3e50;
}

.search-form {
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 2px solid #ecf0f1;
}

.search-form h2 {
    margin-bottom: 1rem;
    color: #34495e;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.form-row .form-group {
    margin-bottom: 0;
}

.form-row select,
.form-row input[type="text"],
.form-row input[type="datetime-local"] {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.form-actions button {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
}

.form-actions button[type="submit"] {
    background-color: #3498db;
    color: white;
}

.form-actions button[type="submit"]:hover {
    background-color: #2980b9;
}

.form-actions button[type="button"] {
    background-color: #95a5a6;
    color: white;
}

.form-actions button[type="button"]:hover {
    background-color: #7f8c8d;
}

.logs-table-container {
    overflow-x: auto;
    max-height: 600px;
    overflow-y: auto;
}

.logs-table {
    width: 100%;
    border-collapse: collapse;
}

.logs-table th,
.logs-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

.logs-table th {
    background-color: #34495e;
    color: white;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
}

.logs-table tr:hover {
    background-color: #f8f9fa;
}

.content-cell {
    max-width: 400px;
    word-wrap: break-word;
}

.role-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 500;
}

.role-badge.role-user {
    background-color: #3498db;
    color: white;
}

.role-badge.role-assistant {
    background-color: #27ae60;
    color: white;
}

/* 반응형 디자인 */
@media (max-width: 768px) {
    .chat-container {
        flex-direction: column;
        height: auto;
    }
    
    .chat-sidebar {
        width: 100%;
        margin-bottom: 1rem;
    }
    
    .template-button-group {
        gap: 0.4rem;
    }
    
    .template-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.85rem;
        flex: 1;
        min-width: calc(50% - 0.2rem);
    }
    
    .chat-input-area {
        flex-direction: column;
    }
    
    .chat-input-area button {
        width: 100%;
    }
}

/* 메모리 모달 */
.memory-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    justify-content: center;
    align-items: center;
}

.memory-modal-content {
    background-color: white;
    border-radius: 8px;
    max-width: 800px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.memory-modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #34495e;
    color: white;
    border-radius: 8px 8px 0 0;
}

.memory-modal-header h2 {
    margin: 0;
    font-size: 1.3rem;
}

.memory-modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    padding: 0;
    width: 2rem;
    height: 2rem;
    line-height: 2rem;
    text-align: center;
}

.memory-modal-close:hover {
    opacity: 0.7;
}

.memory-modal-body {
    padding: 1.5rem;
}

.memory-section {
    margin-bottom: 1.5rem;
}

.memory-section h3 {
    color: #2c3e50;
    margin-bottom: 0.75rem;
    font-size: 1.1rem;
    border-bottom: 2px solid #3498db;
    padding-bottom: 0.5rem;
}

.memory-section ul {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

.memory-section li {
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

.memory-tag {
    display: inline-block;
    background-color: #3498db;
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.85rem;
    margin-right: 0.5rem;
    margin-bottom: 0.5rem;
}

.memory-date {
    color: #7f8c8d;
    font-size: 0.9rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #ecf0f1;
}

/* 학습 페이지 */
.learn-container {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.learn-container h1 {
    margin-bottom: 2rem;
    color: #2c3e50;
}

.case-selector-simple {
    margin-bottom: 2rem;
}

.case-selector-simple label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #555;
}

.case-input-group {
    display: flex;
    gap: 0.5rem;
}

.case-input-group input {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.btn-small {
    padding: 0.75rem 1rem;
    background-color: #95a5a6;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
}

.btn-small:hover {
    background-color: #7f8c8d;
}

.upload-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    border-bottom: 2px solid #ecf0f1;
}

.tab-btn {
    padding: 0.75rem 1.5rem;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-weight: 500;
    color: #7f8c8d;
    transition: all 0.2s;
}

.tab-btn.active {
    color: #3498db;
    border-bottom-color: #3498db;
}

.upload-tab-content {
    display: none;
}

.upload-tab-content.active {
    display: block;
}

.upload-area {
    margin-bottom: 2rem;
}

.upload-box {
    border: 2px dashed #3498db;
    border-radius: 8px;
    padding: 3rem;
    text-align: center;
    cursor: pointer;
    background-color: #f8f9fa;
    transition: all 0.2s;
    margin-bottom: 1rem;
    position: relative;
    z-index: 1;
    pointer-events: auto;
    /* label 기반 구조 지원 */
    display: block;
    user-select: none;
}

/* label.upload-box 스타일 (label 기반 구조) */
label.upload-box {
    position: relative;
    z-index: 10;
    pointer-events: auto;
    cursor: pointer;
}

.upload-box:hover {
    background-color: #e8f4f8;
    border-color: #2980b9;
}

.upload-box p {
    margin: 0.5rem 0;
    color: #555;
    pointer-events: none; /* 내부 텍스트는 클릭 이벤트 차단 */
}

/* label 내부의 숨겨진 input */
.upload-box input[type="file"] {
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
    pointer-events: none;
}

.file-name {
    font-weight: 600;
    color: #3498db !important;
}

.text-input-area textarea {
    width: 100%;
    padding: 1rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    margin-bottom: 1rem;
}

.btn-primary {
    padding: 0.75rem 2rem;
    background-color: #e67e22;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    font-size: 1rem;
}

.btn-primary:hover:not(:disabled) {
    background-color: #d35400;
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.recent-learnings {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 2px solid #ecf0f1;
}

.recent-learnings h2 {
    margin-bottom: 1rem;
    color: #2c3e50;
}

.learnings-table {
    width: 100%;
    border-collapse: collapse;
}

.learnings-table th,
.learnings-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

.learnings-table th {
    background-color: #34495e;
    color: white;
    font-weight: 600;
}

.learnings-table tr:hover {
    background-color: #f8f9fa;
}

.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 500;
}

.status-badge.status-done {
    background-color: #27ae60;
    color: white;
}

.status-badge.status-processing {
    background-color: #f39c12;
    color: white;
}

/* 질문 페이지 */
.ask-container {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    max-width: 900px;
    margin: 0 auto;
}

.ask-container h1 {
    margin-bottom: 2rem;
    color: #2c3e50;
}

.chat-area {
    margin-top: 2rem;
}

.chat-messages {
    max-height: 500px;
    overflow-y: auto;
    padding: 1rem;
    background-color: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chat-input-area {
    display: flex;
    gap: 1rem;
}

.chat-input-area textarea {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    resize: none;
    font-family: inherit;
}

.chat-input-area button {
    padding: 0.75rem 2rem;
    background-color: #27ae60;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}

.chat-input-area button:hover:not(:disabled) {
    background-color: #229954;
}

.chat-input-area button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.memory-reference {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 2px solid #ecf0f1;
}

.memory-toggle {
    width: 100%;
    padding: 0.75rem;
    background-color: #ecf0f1;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    text-align: left;
    color: #555;
}

.memory-toggle:hover {
    background-color: #d5dbdb;
}

.memory-content {
    margin-top: 1rem;
    padding: 1rem;
    background-color: #f8f9fa;
    border-radius: 4px;
}

.memory-item {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #ddd;
}

.memory-item:last-child {
    border-bottom: none;
}

.memory-item h4 {
    margin-bottom: 0.5rem;
    color: #34495e;
    font-size: 0.95rem;
}

.memory-item p {
    margin: 0.25rem 0;
    font-size: 0.9rem;
    color: #555;
    line-height: 1.5;
}
