/* 기본 스타일 */
:root {
    --primary-color: #6A0572; /* 보라색 계열 */
    --secondary-color: #A030A9; /* 더 밝은 보라색 */
    --accent-color: #FFC300; /* 강조 색상 (노란색) */
    --background-color: #F8F8F8; /* 밝은 배경 */
    --card-background: #FFFFFF; /* 카드 배경 */
    --text-color: #333333; /* 어두운 텍스트 */
    --light-text-color: #666666; /* 밝은 텍스트 */
    --border-color: #E0E0E0; /* 경계선 색상 */
    --shadow-color: rgba(0, 0, 0, 0.1); /* 그림자 색상 (투명도 약간 증가) */
    --success-color: #28A745; /* 성공 메시지 */
    --error-color: #DC3545; /* 오류 메시지 */
    --info-color: #17A2B8; /* 정보 메시지 */
}

body {
    font-family: 'Noto Sans KR', sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.3s ease;
}

a:hover {
    color: var(--secondary-color);
    text-decoration: underline;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Poppins', sans-serif;
    color: var(--primary-color);
    margin-top: 0;
    margin-bottom: 15px;
}

h1 { font-size: 2.5em; }
h2 { font-size: 2em; }
h3 { font-size: 1.5em; }

/* 헤더 */
header {
    background-color: var(--primary-color);
    color: #FFFFFF;
    padding: 15px 0;
    box-shadow: 0 2px 5px var(--shadow-color);
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap; /* 모바일에서 줄 바꿈 */
}

header h1 {
    margin: 0;
    font-size: 1.8em;
}

header h1 a {
    color: #FFFFFF;
    text-decoration: none;
}

header nav a,
header nav button {
    color: #FFFFFF;
    text-decoration: none;
    margin-left: 20px;
    padding: 8px 12px;
    border-radius: 5px;
    transition: background-color 0.3s ease;
    font-weight: 500;
    background: none;
    border: none;
    cursor: pointer;
    font-family: 'Noto Sans KR', sans-serif;
    font-size: 1em;
}

header nav a:hover,
header nav button:hover {
    background-color: var(--secondary-color);
    text-decoration: none;
}

header nav button.logout-button {
    background-color: #DC3545;
}

header nav button.logout-button:hover {
    background-color: #C82333;
}

/* 메인 콘텐츠 */
main {
    flex-grow: 1;
    padding: 40px 0;
}

.section-title {
    text-align: center;
    margin-bottom: 30px;
    font-size: 2.2em;
    color: var(--primary-color);
    position: relative;
    padding-bottom: 10px;
}

.section-title::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: 0;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background-color: var(--accent-color);
    border-radius: 2px;
}

/* 챌린지 카드 그리드 (수정된 부분) */
.challenge-cards-grid,
.creator-cards-grid,
#challenge-list-main,
#extended-challenge-list,
#legacy-challenge-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
    margin-top: 30px;
}

.challenge-card,
.creator-card {
    background-color: var(--card-background);
    border-radius: 12px;
    box-shadow: 0 4px 15px var(--shadow-color);
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 800px;
}

.challenge-card:hover,
.creator-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.challenge-card-link {
    display: flex;
    flex-direction: column;
    height: 100%;
    color: inherit;
    text-decoration: none;
    align-items: stretch;
}

.challenge-image-preview {
    width: 100%;
    height: 400px;
    flex-shrink: 0;
    overflow: hidden;
    border-radius: 12px 12px 0 0;
}

.challenge-image-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.challenge-card-main-content {
    padding: 20px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.challenge-card-header {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
}

.challenge-card .rank {
    background-color: var(--accent-color);
    color: var(--primary-color);
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 5px;
    margin-right: 10px;
    font-size: 0.9em;
}

.challenge-card h3 {
    margin: 0;
    font-size: 1.3em;
    color: var(--primary-color);
    flex-grow: 1;
}

.challenge-card .difficulty {
    font-weight: 700;
    padding: 5px 10px;
    border-radius: 5px;
    display: inline-block;
    margin-bottom: 10px;
    font-size: 0.85em;
    text-transform: uppercase;
    color: white;
}

/* 난이도별 색상 */
.difficulty-easy_demon { background-color: #F44336; }
.difficulty-medium_demon { background-color: #E91E63; }
.difficulty-hard_demon { background-color: #9C27B0; }
.difficulty-insane_demon { background-color: #673AB7; }
.difficulty-extreme_demon { background-color: #3F51B5; }

.challenge-card .description-preview {
    font-size: 0.95em;
    color: var(--light-text-color);
    margin-bottom: 15px;
    flex-grow: 1;
}

.challenge-card .level-id-group {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    font-size: 0.9em;
    color: var(--light-text-color);
}

.challenge-card .level-id-group .copy-btn {
    background-color: var(--secondary-color);
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 5px;
    cursor: pointer;
    margin-left: 10px;
    font-size: 0.8em;
    transition: background-color 0.3s ease;
}

.challenge-card .level-id-group .copy-btn:hover {
    background-color: var(--primary-color);
}

.challenge-card .card-footer {
    display: flex;
    justify-content: space-between;
    font-size: 0.85em;
    color: var(--light-text-color);
    margin-top: auto;
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
}

.challenge-card .creator,
.challenge-card .verifier,
.challenge-card .stats {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.challenge-card .verifier {
    font-weight: 500;
}


/* 챌린지 상세 페이지 */
.challenge-detail-page {
    background-color: var(--card-background);
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 15px var(--shadow-color);
}

.challenge-detail-page h2 {
    text-align: center;
    margin-bottom: 25px;
    font-size: 2.5em;
    color: var(--primary-color);
}

.challenge-detail-page .detail-item {
    margin-bottom: 20px;
    padding: 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: #FDFDFD;
}

.challenge-detail-page .detail-item p {
    margin-bottom: 8px;
}

.challenge-detail-page .difficulty-display {
    font-weight: 700;
    padding: 6px 12px;
    border-radius: 6px;
    display: inline-block;
    margin-bottom: 15px;
    font-size: 1em;
    text-transform: uppercase;
    color: white;
}

.challenge-detail-page .level-id-group .copy-btn {
    background-color: var(--secondary-color);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 5px;
    cursor: pointer;
    margin-left: 10px;
    font-size: 0.9em;
    transition: background-color 0.3s ease;
}

.challenge-detail-page .level-id-group .copy-btn:hover {
    background-color: var(--primary-color);
}

.challenge-detail-page .video-container {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 비율 */
    height: 0;
    margin-top: 20px;
    border-radius: 8px;
    overflow: hidden;
}

.challenge-detail-page .video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

.challenge-detail-page .challenge-main-image {
    width: 50%;
    max-height: 400px;
    overflow: hidden;
    border-radius: 8px;
    margin-top: 20px;
    text-align: center;
}

.challenge-detail-page .challenge-main-image img {
    max-width: 100%;
    height: auto;
    object-fit: contain;
    display: block;
    margin: 0 auto;
}

.go-back-link {
    display: inline-block;
    margin-top: 30px;
    font-size: 1.1em;
    font-weight: 500;
    padding: 10px 15px;
    border-radius: 8px;
    background-color: var(--border-color);
    color: var(--text-color);
    transition: background-color 0.3s ease;
}

.go-back-link:hover {
    background-color: #CCCCCC;
    text-decoration: none;
}

/* 기록 제출 섹션 */
.submitted-records-section {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.submitted-records-section h3 {
    color: var(--primary-color);
    margin-bottom: 20px;
    font-size: 1.8em;
}

.records-list {
    display: grid;
    gap: 20px;
}

.record-card {
    background-color: #FDFDFD;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s ease;
}

.record-card:hover {
    transform: translateY(-3px);
}

.record-card.zre-verified {
    border-left: 5px solid var(--success-color);
    background-color: #E6F7ED;
}

.record-card.zre-verified h4 {
    color: var(--success-color);
    margin-top: 0;
    margin-bottom: 10px;
}

.record-card .record-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 0.9em;
    color: var(--light-text-color);
}

.record-card .record-submitter {
    font-weight: 700;
    color: var(--primary-color);
}

.record-card .record-comment {
    font-size: 0.95em;
    margin-bottom: 15px;
}

.record-card .record-video a {
    display: inline-block;
    background-color: var(--secondary-color);
    color: white;
    padding: 8px 15px;
    border-radius: 5px;
    font-size: 0.9em;
    transition: background-color 0.3s ease;
}

.record-card .record-video a:hover {
    background-color: var(--primary-color);
    text-decoration: none;
}

.record-card .record-image {
    margin-top: 15px;
    text-align: center;
}

.record-card .record-image img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.record-card .zre-proof {
    margin-top: 15px;
    padding: 15px;
    background-color: #D4EDDA;
    border: 1px solid #C3E6CB;
    border-radius: 8px;
    color: #155724;
}

.record-card .zre-proof img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    margin-top: 10px;
}

.no-records-message,
.no-results,
.loading-message,
.not-found-message {
    text-align: center;
    color: var(--light-text-color);
    font-size: 1.1em;
    padding: 20px;
    background-color: #F0F0F0;
    border-radius: 8px;
    margin-top: 20px;
}

/* 폼 섹션 (로그인/회원가입, 챌린지 업로드, 기록 제출) */
.form-section {
    background-color: var(--card-background);
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 4px 15px var(--shadow-color);
    max-width: 500px;
    margin: 40px auto;
}

.form-section h2 {
    text-align: center;
    margin-bottom: 30px;
    color: var(--primary-color);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-color);
}

.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="text"],
.form-group input[type="url"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1em;
    box-sizing: border-box;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(106, 5, 114, 0.2);
    outline: none;
}

.form-group textarea {
    min-height: 100px;
    resize: vertical;
}

.button-submit {
    display: block;
    width: 100%;
    padding: 15px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

.button-submit:hover {
    background-color: var(--secondary-color);
    transform: translateY(-2px);
}

.auth-switch-link {
    text-align: center;
    margin-top: 20px;
    font-size: 0.95em;
}

.auth-switch-link a {
    font-weight: 600;
}

.button-primary {
    background-color: var(--primary-color);
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    text-align: center;
    display: inline-block;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

.button-primary:hover {
    background-color: var(--secondary-color);
    transform: translateY(-2px);
    text-decoration: none;
}

/* 내 프로필 페이지 */
.profile-section {
    background-color: var(--card-background);
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 15px var(--shadow-color);
    max-width: 800px;
    margin: 40px auto;
}

.profile-info p {
    font-size: 1.1em;
    margin-bottom: 10px;
}

.profile-info strong {
    color: var(--primary-color);
}

.profile-section .section-title {
    text-align: left;
    margin-top: 30px;
    margin-bottom: 20px;
    font-size: 1.8em;
    color: var(--primary-color);
    padding-bottom: 5px;
}

.profile-section .section-title::after {
    left: 0;
    transform: translateX(0);
    width: 40px;
}

.profile-section ul {
    list-style: none;
    padding: 0;
}

.profile-section ul li {
    background-color: #FDFDFD;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1em;
}

.profile-section ul li a {
    font-weight: 600;
}

.profile-section ul li .actions button {
    background-color: var(--secondary-color);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 5px;
    cursor: pointer;
    margin-left: 10px;
    transition: background-color 0.3s ease;
    font-size: 0.9em;
}

.profile-section ul li .actions button:hover {
    background-color: var(--primary-color);
}

.profile-section .logout-button {
    background-color: #DC3545;
    color: white;
    padding: 12px 25px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    margin-top: 30px;
    transition: background-color 0.3s ease;
}

.profile-section .logout-button:hover {
    background-color: #C82333;
}

/* 크리에이터 페이지 */
.creator-card {
    background-color: var(--card-background);
    border-radius: 12px;
    box-shadow: 0 4px 15px var(--shadow-color);
    padding: 25px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.creator-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.creator-card h3 {
    color: var(--primary-color);
    margin-bottom: 15px;
    font-size: 1.6em;
    text-align: center;
    border-bottom: 2px solid var(--accent-color);
    padding-bottom: 10px;
}

.creator-card .creator-challenges h4 {
    font-size: 1.2em;
    color: var(--secondary-color);
    margin-top: 20px;
    margin-bottom: 10px;
}

.creator-card .creator-challenges ul {
    list-style: disc;
    padding-left: 20px;
}

.creator-card .creator-challenges ul li {
    margin-bottom: 5px;
    font-size: 0.95em;
    color: var(--light-text-color);
}

.creator-card .creator-challenges ul li a {
    font-weight: 500;
}

/* 필터 및 정렬 (챌린지 목록) */
.filter-sort-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
    margin-bottom: 30px;
    padding: 20px;
    background-color: var(--card-background);
    border-radius: 12px;
    box-shadow: 0 2px 10px var(--shadow-color);
}

.filter-sort-controls .form-group {
    margin-bottom: 0;
    flex: 1 1 auto;
    min-width: 180px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.filter-sort-controls label {
    font-weight: 600;
    margin-bottom: 5px;
    color: var(--primary-color);
}

.filter-sort-controls input[type="text"],
.filter-sort-controls select {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.95em;
    height: 40px;
}

/* 푸터 */
footer {
    background-color: var(--text-color);
    color: #FFFFFF;
    text-align: center;
    padding: 20px 0;
    margin-top: 40px;
    font-size: 0.9em;
}

/* 미디어 쿼리 (반응형 디자인) */
@media (max-width: 768px) {
    header .container {
        flex-direction: column;
        text-align: center;
    }

    header nav {
        margin-top: 15px;
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
    }

    header nav a,
    header nav button {
        margin: 5px 10px;
    }

    .section-title {
        font-size: 1.8em;
    }

    /* 모바일에서는 챌린지 카드 그리드가 여전히 1열로 표시되지만,
    이미지는 상단에 배치되도록 변경합니다. */
    .challenge-cards-grid,
    .creator-cards-grid {
        display: flex;
        flex-direction: column;
        gap: 20px;
        align-items: center;
    }

    .challenge-card-link {
        flex-direction: column;
    }

    .challenge-image-preview {
        width: 100%;
        height: 180px;
        border-radius: 12px 12px 0 0;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .challenge-card-main-content {
        padding: 15px;
    }

    .challenge-card h3 {
        font-size: 1.2em;
    }

    .challenge-detail-page {
        padding: 20px;
    }

    .challenge-detail-page h2 {
        font-size: 2em;
    }

    .form-section {
        padding: 25px;
        margin: 20px auto;
    }

    .filter-sort-controls {
        flex-direction: column;
        gap: 15px;
        padding: 15px;
    }

    .filter-sort-controls .form-group {
        width: 100%;
        min-width: unset;
    }
}

