/* 전역 스타일 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* 헤더 */
header {
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    color: #2c3e50;
    font-size: 24px;
}

/* 버튼 스타일 */
button {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s;
}

.btn-primary {
    background-color: #3498db;
    color: white;
}

.btn-primary:hover {
    background-color: #2980b9;
}

.btn-secondary {
    background-color: #95a5a6;
    color: white;
}

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

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

.btn-danger:hover {
    background-color: #c0392b;
}

/* 메인 컨텐츠 */
main {
    background-color: #fff;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* 게시물 목록 */
.posts-container h2 {
    margin-bottom: 20px;
    color: #2c3e50;
}

.posts-list {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(2, minmax(0, 1fr)); /* 한 줄에 2개 */
}

.post-item {
    background-color: #f8f9fa;
    padding: 14px 16px;
    border-radius: 6px;
    border-left: 4px solid #3498db;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

.post-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.post-item-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 0;
}

.post-item-content {
    flex: 1;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
}

.post-item-title {
    font-size: 16px;
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 6px;
}

.post-item-meta {
    margin-top: 4px;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    box-sizing: border-box;
}

.meta-row {
    display: flex;
    margin-bottom: 2px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.meta-row:last-child {
    margin-bottom: 0;
}

/* 라벨 줄: 작성자 / 작성일 타이틀 사이 간격은 조금 넓게 */
.meta-row-labels {
    gap: 12px; /* 타이틀 간격은 조금 넓게 */
    width: 100px; /* 라벨 줄 가로 길이 고정 */
}

/* 값 줄: 실제 이름 / 날짜는 더 붙여서 표시 */
.meta-row-values {
    gap: 4px;
    min-width: 100px;
}

.meta-label {
    font-size: 12px;
    color: #7f8c8d;
    min-width: 90px;
    font-weight: 500;
}

.meta-value {
    font-size: 13px;
    color: #2c3e50;
    flex: 0 1 auto;
    white-space: nowrap;
    min-width: 100px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 두 번째 값(날짜)은 이름보다 조금 더 안쪽으로 들여쓰기 */
.meta-row-values .meta-value:last-child {
    margin-left: 4px; /* 작성일: 레이블보다 살짝 뒤에서 시작 */
}

.status-badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
}

.status-waiting {
    background-color: #f39c12;
    color: white;
}

.status-processing {
    background-color: #3498db;
    color: white;
}

.status-completed {
    background-color: #27ae60;
    color: white;
}

.status-error {
    background-color: #e74c3c;
    color: white;
}

/* 폼 스타일 */
.form-container {
    max-width: 600px;
    margin: 0 auto;
}

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

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #2c3e50;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="file"],
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
}

.form-group textarea {
    resize: vertical;
}

.form-group small {
    display: block;
    margin-top: 5px;
    color: #7f8c8d;
    font-size: 12px;
}

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

/* 게시물 상세 */
.post-header {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #ecf0f1;
}

.post-header h2 {
    color: #2c3e50;
    margin-bottom: 15px;
}

.post-actions {
    margin-top: 15px;
    display: flex;
    gap: 10px;
}

.post-meta {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    font-size: 14px;
    color: #7f8c8d;
}

.post-content {
    margin-top: 30px;
}

.section {
    margin-bottom: 30px;
    padding: 20px;
    background-color: #f8f9fa;
    border-radius: 6px;
}

.section h3 {
    color: #2c3e50;
    margin-bottom: 15px;
    font-size: 18px;
}

.text-content {
    background-color: white;
    padding: 15px;
    border-radius: 4px;
    line-height: 1.8;
    white-space: pre-wrap;
}

.keywords-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.keyword {
    background-color: #3498db;
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
}

.error-content {
    background-color: #fee;
    color: #c33;
    padding: 15px;
    border-radius: 4px;
    border-left: 4px solid #e74c3c;
}

/* 로딩 및 오류 메시지 */
.loading {
    text-align: center;
    padding: 40px;
    color: #7f8c8d;
    font-size: 16px;
}

.error {
    background-color: #fee;
    color: #c33;
    padding: 15px;
    border-radius: 4px;
    margin-top: 20px;
    border-left: 4px solid #e74c3c;
}

.success {
    background-color: #efe;
    color: #3c3;
    padding: 15px;
    border-radius: 4px;
    margin-top: 20px;
    border-left: 4px solid #27ae60;
}

/* 페이징 스타일 */
.pagination-container {
    margin-top: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.pagination {
    display: flex;
    gap: 5px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

.page-btn {
    padding: 8px 12px;
    border: 1px solid #ddd;
    background-color: white;
    color: #2c3e50;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    min-width: 40px;
}

.page-btn:hover:not(.disabled):not(.active) {
    background-color: #f8f9fa;
    border-color: #3498db;
}

.page-btn.active {
    background-color: #3498db;
    color: white;
    border-color: #3498db;
    font-weight: bold;
}

.page-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.page-ellipsis {
    padding: 8px 4px;
    color: #7f8c8d;
}

.pagination-info {
    color: #7f8c8d;
    font-size: 14px;
    text-align: center;
}

/* 반응형 디자인 */
@media (max-width: 768px) {
    /* 모바일에서 컨테이너 좌우 여백 줄이기 */
    .container {
        padding: 10px;
    }
    
    /* 모바일에서는 1열로 표시 */
    .posts-list {
        grid-template-columns: 1fr;
    }
    
    /* 게시물 항목 좌우 여백 줄이기 */
    .post-item {
        padding: 12px 10px;
    }
    
    header {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
        padding: 15px;
    }

    header h1 {
        font-size: 20px;
    }

    /* 상태 배지는 항상 우측에 고정 */
    .post-item-header {
        flex-direction: row;
        align-items: flex-start;
    }
    
    .post-item-content {
        flex: 1;
        min-width: 0; /* 텍스트 오버플로우 방지 */
    }
    
    .status-badge {
        flex-shrink: 0; /* 상태 배지 크기 고정 */
        margin-left: 10px;
    }
    
    /* 모바일에서 메타 정보 오버플로우 방지 */
    .post-item {
        padding: 12px 8px; /* 좌우 패딩 더 줄이기 */
    }
    
    .post-item-content {
        min-width: 0;
        max-width: calc(100% - 60px); /* 상태 배지 공간 확보 */
    }
    
    .post-item-meta {
        overflow: hidden;
        width: 100%;
        max-width: 100%;
    }
    
    .meta-row {
        overflow: hidden;
        width: 100%;
        max-width: 100%;
    }
    
    .meta-row-labels {
        width: auto;
        gap: 6px; /* 간격 더 줄이기 */
        flex-wrap: nowrap;
    }
    
    .meta-row-values {
        min-width: auto;
        gap: 4px;
        overflow: hidden;
        flex-wrap: nowrap;
    }
    
    .meta-label {
        min-width: auto;
        flex-shrink: 0;
        font-size: 11px;
    }
    
    .meta-value {
        min-width: auto;
        max-width: 50%; /* 각 값이 최대 50%만 차지 */
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 12px;
    }
    
    /* 모바일에서 날짜(마지막 값)는 전체 표시 */
    .meta-value:last-child {
        text-overflow: clip; /* ellipsis 제거 */
        overflow: visible; /* 넘쳐도 보이게 */
        max-width: none; /* 최대 너비 제한 제거 */
        white-space: normal; /* 줄바꿈 허용 */
    }

    .post-meta {
        flex-direction: column;
        gap: 5px;
    }

    .form-actions {
        flex-direction: column;
    }

    button {
        width: 100%;
    }
}

