@import "../board/_search-input";

/* 전체 페이지 스크롤 방지 (이 페이지에만 적용) */
html, body {
	height: 100%;
}

body.map-search-page {
	overflow: hidden;
}

/* 모바일 검색 영역 */
.mobile-search-area {
	display: none; position: absolute; top: 0; left: 0; width: 100%; padding: 15px 20px; background: transparent; z-index: 9;
	.search-input {
		display: flex; gap: 0; justify-content: center;
		.input {
			flex: 1; max-width: 100%; border: none; border-radius: 25px; background: #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
			input {
				width: 100%; padding: 12px 20px; font-size: 1.4rem; border: none; background: transparent; border-radius: 25px;
				&::placeholder {
					color: #999;
				}
			}
		}
		.button {
			display: none; /* 버튼 숨김 */
		}
	}
}

.map-search {
	--map-list-width: 470px;
	position: relative; width: 100%; min-height: 100svh; padding: 0;
	.map-area {
		width: calc(100% - var(--map-list-width)); margin-left: var(--map-list-width); height: 100vh; background-image: url('../img/exploration/map_bg.png'); position: relative; background-size: cover; background-position: center; background-repeat: no-repeat; z-index: 1;
	}
	
	.marker {
		position: absolute; z-index: 5; max-width: 100%;
		& > img {
			width: 75px; height: 75px; cursor: pointer;
		}
		&.active {
			z-index: 10;
		}
		.detail-layer {
			display: none; position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); width: 320px; padding: 25px; background: #fff; border-radius: 10px; box-shadow: 0 8px 13px rgba(0, 0, 0, 0.2); z-index: 20; 
			&::after {
				content: ""; position: absolute; bottom: -8px; left: 50%; transform: translateX(-50%); width: 0; height: 0; border-left: 10px solid transparent; border-right: 10px solid transparent; border-top: 10px solid #fff;
			}
			.layer-close {
				position: absolute; top: 16px; right: 16px; width: 16px; height: 16px; border: none; background: transparent; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0;
				img {
					width: 100%; height: 100%; opacity: 0.5;
				}
				&:hover img {
					opacity: 1;
				}
			}
			.layer-label {
				display: inline-block; padding: 2px 10px; border-radius: 4px; font-size: 1.2rem; font-weight: 700;
				&.type-1 {
					background: var(--pink); color: #fff;
				}
				&.type-2 {
					background: var(--green); color: #fff;
				}
			}
			.layer-claim {
				font-size: 1.6rem; font-weight: 700; color: #222; margin: 10px 0 8px; line-height: 1.4;
			}
			.layer-desc {
				font-size: 1.4rem; color: #666; line-height: 1.5; margin-bottom: 15px; display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; text-overflow: ellipsis;
			}
			.layer-info {
				display: flex; flex-direction: column; gap: 5px; padding: 10px 0; border-top: 1px solid var(--line);
				.info-item {
					display: flex; gap: 12px; align-items: baseline;
					dt {
						flex-shrink: 0; font-size: 1.3rem; color: #999; font-weight: 500; min-width: 50px;
					}
					dd {
						font-size: 1.4rem; color: #333; font-weight: 600;
					}
				}
			}
			.layer-link {
				display: block; margin-top: 14px; padding: 10px; background: var(--navy); color: #fff; text-align: center; border-radius: 6px; font-size: 1.3rem; font-weight: 600; 
			}
		}
		&.active .detail-layer {
			display: block;
		}
	}
}

.map-list-area {
	position: fixed; bottom: 0; left: 0; height: calc(100vh - 101px); z-index: 99; width: var(--map-list-width);
	.mo-drag-btn {
		display: none; position: absolute; top: 0; left: 0; z-index: 100; text-align: center; width: 100%; padding: 13px 0;
		.drag-btn {
			width: 40px; height: 4px; background: #cdcdcd; border-radius: 20px; display: inline-block; 
		}
	}
	.place-list {
		position: relative; z-index: 2; height: calc(100vh - 101px); background: #fff; padding: 30px 0 0; display: flex; flex-direction: column; overflow: hidden;
		.head-area {
			padding: 0 20px; border-bottom: 1px solid var(--line); 
		}
        .type-select-area {
            display: flex; gap: 0; margin-bottom: 20px; padding-top: 0; flex-shrink: 0;
            .item {
                flex: 1; border: 1px solid var(--line); border-radius: 0; background: #fff; cursor: pointer; position: relative;
                &:first-child {
                    border-radius: 5px 0 0 5px;
                }
                &:last-child {
                    border-radius: 0 5px 5px 0;
                }
                & + .item {
                    margin-left: -1px;
                }
                .btn {
                    display: flex; align-items: center; justify-content: center; width: 100%; padding: 12px 20px; border: none; background: transparent; cursor: pointer;
                    p {
                        font-size: 1.5rem; font-weight: 600; color: #333;
                    }
                }
                &:hover {
                    border-color: var(--theme); background: rgba(16, 135, 245, 0.06); z-index: 1;
                    .btn p {
                        color: var(--theme);
                    }
                }
                &.active {
                    border-color: var(--theme); background: rgba(16, 135, 245, 0.10); z-index: 2;
                    .btn p {
                        color: var(--theme); font-weight: 700;
                    }
                }
            }
        }
		
		.search-area {
			flex-shrink: 0;
			.search-input {
				display: flex; gap: 0;
				.input {
					flex: 1; border: 1px solid var(--line); border-radius: 5px 0 0 5px; background: #fff;
					input {
						width: 100%; padding: 12px 15px; font-size: 1.5rem; border: none; background: transparent;
						&::placeholder {
							color: #999;
						}
					}
				}
				.button {
					button {
						padding: 13px 30px; background: var(--dark); color: #fff; border: none; border-radius: 0 5px 5px 0; font-size: 1.5rem; font-weight: 600; cursor: pointer;
						&:hover {
							background: #333;
						}
					}
				}
			}
		}
		
		.result-summary {
			display: flex; justify-content: space-between; align-items: center; padding: 30px 0 15px 0; flex-shrink: 0;
			.total {
				font-size: 1.6rem; color: #333; font-weight: 600;
				.num {
					color: var(--theme); font-weight: 700;
				}
			}
			.breakdown {
				display: flex; gap: 15px; font-size: 1.4rem; color: #666;
				span {
					strong {
						font-weight: 700; color: #333;
					}
				}
			}
		}
		
		.list-area {
			flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 15px; background: #f1f1f1;
			/* 얇은 스크롤바 스타일 */
			scrollbar-width: thin; /* Firefox */
			scrollbar-color: rgba(0, 0, 0, 0.2) transparent; /* Firefox */
			&::-webkit-scrollbar {
				width: 6px; /* 웹킷 브라우저 스크롤바 너비 */
			}
			&::-webkit-scrollbar-track {
				background: transparent; /* 스크롤바 트랙 배경 */
			}
			&::-webkit-scrollbar-thumb {
				background: rgba(0, 0, 0, 0.2); /* 스크롤바 색상 */
				border-radius: 3px; /* 스크롤바 모서리 둥글게 */
				&:hover {
					background: rgba(0, 0, 0, 0.3); /* 호버 시 색상 */
				}
			}
			.card-list-group {
				display: flex; flex-direction: column; gap: 15px;
				.item {
					display: block; padding: 20px; background: #fff; border: 1px solid var(--line); border-radius: 8px; text-decoration: none; color: inherit; transition: all 0.2s;
					&:hover {
						border: 1px solid var(--theme); transform: translateY(-2px);
					}
					.label {
						display: inline-block; padding: 4px 12px; border-radius: 4px; font-size: 1.3rem; font-weight: 700;
						&.type-1 {
							background: var(--pink); color: #fff;
						}
						&.type-2 {
							background: var(--green); color: #fff;
						}
					}
					.tit {
						font-size: 1.7rem; font-weight: 700; color: #333; margin: 11px 0;
						display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; text-overflow: ellipsis;
					}
					.info {
						display: flex; gap: 3px 15px; flex-wrap: wrap; margin-bottom: 10px; font-size: 1.4rem; color: #666;
						span {
							strong {
								font-weight: 600; color: #333;
							}
						}
					}
					.tags {
						display: flex; gap: 8px; flex-wrap: wrap;
						.tag {
							display: inline-block; padding: 4px 10px; background: #e8e8e8; border-radius: 4px; font-size: 1.3rem; color: #444;
						}
					}
				}
			}
		}
	}
}

@media (max-width: 1500px) {
	.map-list-area {
		height: calc(100vh - 98px);
	}
}

@media (max-width: 1024px) {
	.mobile-search-area {
		display: block;
	}
	.map-search {
		display: flex; flex-direction: column; min-height: 100svh; overflow: hidden;
		.marker {
			& > img {
				width: 60px; height: 60px;
			}
			.detail-layer {
				width: 280px; padding: 20px;
				.layer-claim {
					font-size: 1.5rem;
				}
				.layer-desc {
					font-size: 1.3rem; -webkit-line-clamp: 2; line-clamp: 2;
				}
				.layer-link {
					font-size: 1.2rem;
				}
			}
		}
		.map-area {
			width: 100%; height: 45vh; margin-left: 0;
		}
	}
	.map-list-area {
		padding-top: 50px; height: 50vh; width: 100%; background: #fff; display: flex; flex-direction: column; border-radius: 30px; transition: top 0.3s ease-out, height 0.3s ease-out; box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
		&.full-height {
			height: calc(100vh - 100px);
		}
		.mo-drag-btn {
			display: block;
		}
		.place-list {
			position: relative; display: flex; flex-direction: column; flex: 1; min-height: 0; max-width: 100%; border-radius: 20px 20px 0 0; cursor: grab; touch-action: pan-y; padding: 0;
			&:active {
				cursor: grabbing;
			}
			.type-select-area {
				.item {
					.btn {
						padding: 12px 10px;
						p {
							font-size: 1.5rem;
						}
					}
				}
			}
			.search-area {
				display: none;
			}
			.result-summary {
				padding: 20px 0 15px 0; 
				.total {
					font-size: 1.5rem;
				}
				.breakdown {
					font-size: 1.2rem;
				}
			}
			.list-area {
				flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; margin-bottom: 0;
				.card-list-group .item {
					padding: 15px;
					.tit {
						font-size: 1.5rem; margin: 8px 0;
					}
					.info {
						font-size: 1.3rem; flex-wrap: wrap;
					}
				}
			}
		}
	}
}

@media (max-width: 768px) {
	.map-list-area {
		.place-list {
            .type-select-area {
                margin-bottom: 0;
                .item {
                    .btn {
                        padding: 8px;
                        p {
                            font-size: 1.4rem;
                        }
                    }
                }
            }
			.list-area {
				.card-list-group {
					.item {
						.label {
							padding: 3px 9px; font-size: 1.2rem;
						}
						.info {
							margin-bottom: 7px; gap: 3px 15px;
						}
						.tags {
							.tag {
								padding: 3px 9px;
							}
						}
					}
				}
			}
		}
	}
}