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

body {
    font-family: 'Noto Sans KR', Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

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

header {
    text-align: center;
    margin-bottom: 40px;
    padding: 20px 0;
    background-color: #1e3a8a;
    color: white;
    border-radius: 10px;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

h2 {
    margin-bottom: 20px;
    color: #1e3a8a;
}

.form-group {
    background: white;
    padding: 25px;
    margin-bottom: 30px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

label {
    display: block;
    margin: 15px 0 5px;
    font-weight: bold;
}

select, input[type="date"] {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 16px;
    margin-bottom: 10px;
}

/* 후보자 스타일 */
.candidates {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.candidate {
    position: relative;
    text-align: center;
}

.candidate input[type="radio"] {
    position: absolute;
    opacity: 0;
}

.candidate label {
    cursor: pointer;
    display: block;
    padding: 15px;
    background-color: #fff;
    border: 2px solid #ddd;
    border-radius: 10px;
    transition: all 0.3s ease;
}

.candidate input[type="radio"]:checked + label {
    border-color: #1e3a8a;
    box-shadow: 0 0 15px rgba(30, 58, 138, 0.3);
}

.candidate-img {
    margin-bottom: 10px;
    max-width: 150px; /* 사진 최대 너비 제한 */
    margin: 0 auto 10px auto; /* 가운데 정렬 */
}

.candidate-img img {
    width: 100%;
    height: auto;
    border-radius: 50%;
    object-fit: cover;
}

.candidate h3 {
    font-size: 1.2rem;
    margin: 10px 0 5px;
}

/* 버튼 스타일 */
button {
    background-color: #1e3a8a;
    color: white;
    border: none;
    padding: 12px 25px;
    font-size: 16px;
    border-radius: 5px;
    cursor: pointer;
    display: block;
    margin: 20px auto;
    transition: background-color 0.3s ease;
}

button:hover {
    background-color: #152c69;
}

/* 결과 스타일 */
.results {
    background: white;
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-top: 40px;
}

.election-stats {
    text-align: center;
    font-size: 1.1rem;
    margin-bottom: 20px;
    color: #555;
}

/* 탭 스타일 */
.result-tabs {
    display: flex;
    justify-content: center;
    margin: 25px 0;
    padding: 10px;
    border-radius: 8px;
    background-color: #f5f5f5;
}

.tab-button {
    padding: 12px 25px;
    margin: 0 5px;
    background-color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    color: #555;
    transition: all 0.3s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.tab-button:hover {
    color: #111;
    background-color: #f0f0f0;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.tab-button.active {
    background-color: #2D5AF6;
    color: #fff;
    font-weight: 600;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(45,90,246,0.3);
}

.tab-content {
    display: none;
    padding: 20px 0;
}

.tab-content.active {
    display: block;
}

/* 총합 결과 스타일 */
.result-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
}

.pie-chart-container {
    flex: 1;
    min-width: 300px;
    position: relative;
    margin: auto;
}

.pie-chart {
    width: 280px;
    height: 280px;
    border-radius: 50%;
    position: relative;
    margin: auto;
    overflow: hidden;
}

.pie-segment {
    position: absolute;
    width: 100%;
    height: 100%;
    transform-origin: 50% 50%;
}

.segment1 {
    background-color: #2D5AF6; /* 홍길동 - 파랑 */
    clip-path: polygon(50% 0%, 100% 0%, 100% 100%, 50% 100%, 50% 50%);
    z-index: 1;
}

.segment2 {
    background-color: #E74C3C; /* 김민수 - 빨강 */
    clip-path: polygon(50% 0%, 0% 0%, 0% 100%, 50% 100%, 50% 50%);
    z-index: 2;
}

.segment3 {
    background-color: #F39C12; /* 이지은 - 노랑 */
    clip-path: polygon(50% 50%, 50% 0%, 0% 0%, 0% 50%);
    z-index: 3;
}

.segment4 {
    background-color: #27AE60; /* 박재민 - 초록 */
    clip-path: polygon(50% 50%, 100% 50%, 100% 0%, 50% 0%);
    z-index: 4;
}

.chart-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: white;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    z-index: 5;
}

.percentage {
    font-size: 1.8rem;
    font-weight: bold;
    color: #1e3a8a;
}

.candidate-name {
    font-size: 1rem;
    color: #333;
}

.total-stats {
    flex: 2;
    min-width: 300px;
}

.candidate-info {
    display: flex;
    align-items: center;
    margin-bottom: 5px;
}

.candidate-number {
    background-color: #1e3a8a;
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    margin-right: 10px;
    font-weight: bold;
}

.vote-count {
    margin-left: auto;
    font-weight: bold;
}

.candidate1-color { background-color: #2D5AF6; }
.candidate2-color { background-color: #E74C3C; }
.candidate3-color { background-color: #F39C12; }
.candidate4-color { background-color: #27AE60; }

/* 지역별 결과 탭 스타일 */
.map-container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 30px;
}

.korea-map {
    flex: 1;
    min-width: 300px;
    height: 450px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background-color: #f9f9f9;
    position: relative;
}

.region-detail {
    flex: 1;
    min-width: 300px;
    padding: 20px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background-color: #f9f9f9;
}

.region-title {
    text-align: center;
    color: #1e3a8a;
    margin-bottom: 15px;
}

.region-list {
    display: grid;
    grid-template-columns: repeat(3, 1fr); /* 한 줄에 3개씩 표시 */
    gap: 15px;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 8px;
    margin-top: 10px;
    border: 1px solid #ddd;
}

.region-card {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 12px;
    background-color: white;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    min-height: 100px;
}

.region-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.region-card.selected {
    border-color: #1e3a8a;
    box-shadow: 0 0 0 2px rgba(30, 58, 138, 0.3);
}

/* 지역 카드 후보자별 색상 */
.region-card.winner1 { border-color: #2D5AF6; border-width: 3px; } /* 기호 1번 이재명 - 파란색 */
.region-card.winner2 { border-color: #E74C3C; border-width: 3px; } /* 기호 2번 김문수 - 빨간색 */
.region-card.winner3 { border-color: #FF7F00; border-width: 3px; } /* 기호 4번 이준석 - 주황색 */
.region-card.winner4 { border-color: #F39C12; border-width: 3px; } /* 기호 5번 권영국 - 노란색 */

.region-card h4 {
    font-size: 1.2rem;
    margin-bottom: 8px;
    color: #1e3a8a;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
    font-weight: 700;
    text-align: center;
}

.region-winner {
    display: flex;
    align-items: center;
    margin-top: 8px;
}

.winner-color {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    margin-right: 8px;
}

.region-votes {
    margin-top: 8px;
    font-size: 0.95rem;
    color: #333;
    font-weight: 600;
    text-align: center;
    background-color: #f3f3f3;
    padding: 5px;
    border-radius: 4px;
}

.region-card-footer {
    margin-top: auto;
    padding-top: 8px;
    font-size: 0.8rem;
    text-align: center;
    color: #666;
    font-style: italic;
    border-top: 1px dashed #eee;
    margin-top: 8px;
}

/* 지역 구현 */
.region-path {
stroke: #444;
stroke-width: 1;
transition: all 0.3s ease;
}

#korea-map svg path {
    transition: fill 0.3s ease;
    cursor: pointer;
}

/* 지도에 표시되는 지역명 텍스트 효과 */
#korea-map svg text {
    user-select: none;
    filter: drop-shadow(1px 1px 1px rgba(0,0,0,0.5));
    transition: all 0.3s ease;
}

#korea-map svg path:hover {
    opacity: 0.8;
    filter: brightness(120%);
}

.region-path.winner1 {
    fill: #2D5AF6; /* 기호 1번 이재명 - 파란색 */
}

.region-path.winner2 {
    fill: #E74C3C; /* 기호 2번 김문수 - 빨간색 */
}

.region-path.winner3 {
    fill: #FF7F00; /* 기호 3번 이준석 - 주황색 */
}

.region-path.winner4 {
    fill: #F39C12; /* 기호 4번 권영국 - 노란색 */
}

/* 투표가 없는 지역을 위한 기본 색상 */
.region-path:not(.winner1):not(.winner2):not(.winner3):not(.winner4) {
    fill: #cccccc;
}

/* 지역 테두리 스타일링 */
.region-path {
    fill: #cccccc;
    stroke: #444;
    stroke-width: 1;
    transition: fill 0.3s ease;
}

/* 한국 지도 컨테이너 스타일 */
.korea-map {
    width: 100%;
    height: 500px;
    min-height: 500px;
    display: block;
    margin: 0 auto;
    background-color: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 10px;
    box-sizing: border-box;
}

.region-path.selected {
    stroke: #000;
    stroke-width: 2;
}

/* 나이대별 결과 탭 스타일 */
.age-chart-container {
    width: 100%;
    height: 300px;
    margin-bottom: 30px;
}

.age-detail {
    padding: 15px 10px;
    background-color: #f9f9f9;
    border-radius: 8px;
}

.age-filter {
    display: flex;
    flex-wrap: nowrap;
    gap: 2px;
    margin: 10px auto;
    padding: 5px;
    justify-content: center;
    background-color: #2D5AF6;
    border-radius: 5px;
    max-width: 100%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    border: 1px solid #1e3a8a;
    overflow-x: auto;
    white-space: nowrap;
}

.age-button {
    background-color: #ffffff;
    border: 1px solid #1e3a8a;
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: bold;
    font-size: 12px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    color: #1e3a8a;
    flex-shrink: 0;
}

.age-button:hover {
    background-color: #e8f0ff;
    transform: translateY(-2px);
    border-color: #2D5AF6;
}

.age-button.active {
    background-color: #ffffff;
    color: #2D5AF6;
    border-color: #ffffff;
    box-shadow: 0 4px 8px rgba(255,255,255,0.5);
    transform: scale(1.05);
    font-weight: 900;
}

.age-result-card {
    background-color: white;
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 10px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.age-result-header h3 {
    font-size: 1rem;
    margin-bottom: 8px;
    color: #1e3a8a;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
}

.candidate-bars {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.candidate-result {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 8px;
    border-bottom: 1px solid #eee;
    padding-bottom: 6px;
}

.candidate-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.candidate-name {
    font-weight: 600;
}

.candidate-percentage {
    font-weight: bold;
}

/* 후보자 사진이 포함된 결과 레이아웃 */
.candidate-result.with-image {
    display: flex;
    align-items: center;
    gap: 15px;
}

.candidate-img-container {
    flex: 0 0 80px;
}

.candidate-result-img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 50%;
    border: 2px solid #ddd;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.candidate-detail {
    flex: 1;
}

.vote-count {
    font-size: 0.8rem;
    color: #555;
    text-align: right;
    font-weight: bold;
    margin-top: 1px;
}

.candidate-percentage {
    font-weight: bold;
    color: #333;
    font-size: 0.9rem;
}

.result-bar-container {
    background-color: #eee;
    height: 6px;
    border-radius: 3px;
    overflow: hidden;
    position: relative;
    margin-bottom: 2px;
    margin-top: 1px;
}

.result-bar {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
}

.vote-count {
    text-align: right;
    font-weight: bold;
    font-size: 1.05rem;
    color: #333;
    padding-top: 2px;
    padding-bottom: 5px;
    background-color: #f8f8f8;
    border-radius: 5px;
    padding: 5px 10px;
    display: inline-block;
    margin-left: auto;
}

.result-bar {
    margin-bottom: 15px;
}

.candidate-name {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

.bar-container {
    background-color: #eee;
    height: 30px;
    border-radius: 15px;
    overflow: hidden;
}

.bar {
    height: 100%;
    background-color: #1e3a8a;
    color: white;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 10px;
    font-weight: bold;
    transition: width 0.5s ease;
}

.total-votes {
    text-align: right;
    font-weight: bold;
    margin-top: 20px;
}

footer {
    text-align: center;
    padding: 20px;
    margin-top: 40px;
    color: #777;
}

/* 모달 스타일 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 100;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: white;
    padding: 30px;
    border-radius: 10px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.modal h2 {
    margin-bottom: 20px;
    color: #1e3a8a;
}

.modal-info {
    margin: 20px 0;
    padding: 15px;
    background-color: #f5f5f5;
    border-radius: 5px;
}

.modal-buttons {
    display: flex;
    justify-content: space-between;
}

/* 모바일 반응형 */
@media (max-width: 768px) {
    .candidates {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 480px) {
    .candidates {
        grid-template-columns: 1fr;
    }
    
    .modal-buttons {
        flex-direction: column;
    }
    
    .modal-buttons button {
        margin: 5px 0;
    }
}

/* 이미 투표한 사용자 메시지 스타일 */
.already-voted-message {
    background-color: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 30px;
    margin: 20px auto;
    max-width: 600px;
    text-align: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.already-voted-message h2 {
    color: #d9534f;
    margin-bottom: 20px;
}

.already-voted-message p {
    color: #555;
    font-size: 16px;
    line-height: 1.6;
    margin-bottom: 10px;
}

/* 시크릿 모드 경고 스타일 */
.private-mode-warning {
    background-color: #fff3cd;
    border: 1px solid #ffeeba;
    border-radius: 8px;
    padding: 15px 20px;
    margin: 0 0 25px 0;
    text-align: left;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.private-mode-warning h3 {
    color: #856404;
    margin-bottom: 10px;
    font-size: 18px;
}

.private-mode-warning p {
    color: #856404;
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 5px;
}
