/* 전역 스타일 */
:root {
    --primary-color: #2563eb;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --dark-color: #1e293b;
    --light-color: #f8fafc;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* 토스트 메시지 애니메이션 */
@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans KR', sans-serif;
    background-color: var(--light-color);
    color: var(--dark-color);
    line-height: 1.6;
}

/* 앱 컨테이너 */
.app-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 헤더 */
.app-header {
    background: white;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1000;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.app-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.site-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.site-select {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    font-size: 0.875rem;
    background-color: white;
    min-width: 200px;
}

.header-actions {
    display: flex;
    gap: 1rem;
}

/* 버튼 스타일 */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: #1d4ed8;
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
}

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

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

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

.btn-icon {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.375rem;
    transition: background-color 0.2s;
}

.btn-icon:hover {
    background-color: var(--light-color);
}

.btn-outline {
    background-color: white;
    border: 1px solid var(--border-color);
    color: var(--dark-color);
}

.btn-outline:hover {
    background-color: var(--light-color);
}

.btn-view {
    background-color: var(--secondary-color);
    color: white;
}

.btn-view:hover {
    background-color: #475569;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

/* 메인 컨텐츠 */
.main-content {
    flex: 1;
    display: flex;
    position: relative;
    overflow: hidden;
    background-color: #f3f4f6;
}

/* 대시보드 뷰 */
.dashboard-view {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

/* 통계 컨테이너 */
.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    border-radius: 0.75rem;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
}

.stat-content {
    flex: 1;
}

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--dark-color);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--secondary-color);
    margin-top: 0.25rem;
}

/* 현장 그리드 */
.sites-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.site-card {
    background: white;
    border-radius: 0.75rem;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

.site-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.site-card-header {
    padding: 1.5rem;
    position: relative;
}

.site-card-color {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
}

.site-card-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.site-card-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.875rem;
    color: var(--secondary-color);
}

.site-card-body {
    padding: 0 1.5rem 1.5rem;
}

.site-progress {
    margin-bottom: 1rem;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.progress-bar {
    height: 8px;
    background-color: var(--light-color);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #06b6d4);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.site-card-stats {
    display: flex;
    justify-content: space-around;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.site-stat {
    text-align: center;
}

.site-stat-value {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--dark-color);
}

.site-stat-label {
    font-size: 0.75rem;
    color: var(--secondary-color);
    margin-top: 0.25rem;
}

.site-card-actions {
    padding: 1rem 1.5rem;
    background-color: var(--light-color);
    display: flex;
    gap: 0.5rem;
}

.site-card-actions .btn {
    flex: 1;
    font-size: 0.875rem;
    padding: 0.5rem;
}

/* 대시보드 지도 컨테이너 */
.dashboard-map-container {
    margin-bottom: 2rem;
}

/* 차트 컨테이너 */
.charts-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
}

.chart-card {
    background: white;
    border-radius: 0.75rem;
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.chart-card h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chart-wrapper {
    position: relative;
}

/* 지도 뷰 */
.map-view {
    flex: 1;
    display: flex;
    position: relative;
}

/* 지도 컨테이너 */
.map-container {
    flex: 1;
    height: 100%;
}

/* 지도 컨트롤 */
.map-controls {
    position: absolute;
    top: 1rem;
    left: 1rem;
    z-index: 500;
}

/* 지도 도구 */
.map-tools {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 500;
    display: flex;
    gap: 0.5rem;
}

.map-tool-btn {
    padding: 0.75rem 1rem;
    background: white;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    border-radius: 0.5rem;
    box-shadow: var(--shadow-lg);
    transition: all 0.2s;
    color: var(--secondary-color);
}

.map-tool-btn:hover {
    background-color: var(--light-color);
}

.map-tool-btn.active {
    background-color: var(--primary-color);
    color: white;
}

.map-tool-btn i {
    font-size: 1.125rem;
}

.map-tool-btn span {
    font-size: 0.75rem;
    font-weight: 500;
}

.map-type-selector {
    display: flex;
    background: white;
    border-radius: 0.5rem;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.map-type-btn {
    padding: 0.75rem 1rem;
    background: white;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    transition: all 0.2s;
    border-right: 1px solid var(--border-color);
    color: var(--secondary-color);
}

.map-type-btn:last-child {
    border-right: none;
}

.map-type-btn i {
    font-size: 1.125rem;
}

.map-type-btn span {
    font-size: 0.75rem;
    font-weight: 500;
}

.map-type-btn:hover {
    background-color: var(--light-color);
}

.map-type-btn.active {
    background-color: var(--primary-color);
    color: white;
}

/* 사이드바 */
.sidebar {
    width: 400px;
    background: white;
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    position: absolute;
    right: 0;
    top: 0;
    height: 100%;
    z-index: 999;
}

/* 현장 정보 카드 */
.site-info-card {
    background: linear-gradient(135deg, var(--primary-color), #06b6d4);
    color: white;
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
}

.site-info-card h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.site-info-stats {
    display: flex;
    gap: 1.5rem;
    font-size: 0.875rem;
}

.site-info-stats span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.sidebar.hidden {
    transform: translateX(100%);
}

.sidebar-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

/* 사이드바 토글 버튼 */
.sidebar-toggle {
    position: absolute;
    right: 1rem;
    top: 1rem;
    z-index: 998;
    background-color: white;
    border: 1px solid var(--border-color);
    padding: 0.75rem;
    border-radius: 0.375rem;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: all 0.2s;
}

.sidebar-toggle:hover {
    box-shadow: var(--shadow-lg);
}

.sidebar-toggle.hidden {
    display: none;
}

/* 검색 필터 */
.search-filter {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.search-input {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    font-size: 0.875rem;
}

.filter-select {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    font-size: 0.875rem;
    background-color: white;
}

/* 조사 목록 */
.survey-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.survey-item {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.survey-item:hover {
    box-shadow: var(--shadow);
    border-color: var(--primary-color);
}

.survey-item-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 0.5rem;
}

.survey-item-title {
    font-weight: 500;
    font-size: 0.95rem;
}

.survey-item-date {
    font-size: 0.75rem;
    color: var(--secondary-color);
}

.survey-item-location {
    font-size: 0.875rem;
    color: var(--secondary-color);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.survey-item-preview {
    display: flex;
    gap: 0.75rem;
}

.survey-item-image {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 0.375rem;
}

.survey-item-memo {
    flex: 1;
    font-size: 0.875rem;
    color: #64748b;
    line-height: 1.4;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

.survey-item-category {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    background-color: var(--light-color);
    border-radius: 0.25rem;
    font-size: 0.75rem;
    color: var(--secondary-color);
    margin-top: 0.5rem;
}

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

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 0.5rem;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
}

.modal-image-container {
    margin-bottom: 1.5rem;
}

.modal-image-container img {
    width: 100%;
    max-height: 300px;
    object-fit: contain;
    border-radius: 0.375rem;
    background-color: #f3f4f6;
}

/* 폼 스타일 */
.form-group {
    margin-bottom: 1.25rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.875rem;
}

.form-control {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    font-size: 0.875rem;
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

.gps-info {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 0.5rem;
    align-items: center;
}

.form-text {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: var(--secondary-color);
}

.required {
    color: var(--danger-color);
}

/* 색상 선택기 */
.color-picker {
    display: flex;
    gap: 0.5rem;
}

.color-picker input[type="radio"] {
    display: none;
}

.color-picker label {
    width: 40px;
    height: 40px;
    border-radius: 0.375rem;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.color-picker input[type="radio"]:checked + label {
    border-color: var(--dark-color);
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.1);
}

.form-actions {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1.5rem;
}

/* 로딩 인디케이터 */
.loading-indicator {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 2rem;
    border-radius: 0.5rem;
    box-shadow: var(--shadow-lg);
    z-index: 3000;
    text-align: center;
}

.loading-indicator.active {
    display: block;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    margin: 0 auto 1rem;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* 지도 마커 팝업 */
.leaflet-popup-content {
    width: 250px !important;
}

.marker-popup {
    padding: 0.5rem;
}

.marker-popup img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: 0.375rem;
    margin-bottom: 0.75rem;
}

.marker-popup h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.marker-popup p {
    font-size: 0.875rem;
    color: var(--secondary-color);
    margin-bottom: 0.25rem;
}

.marker-popup button {
    margin-top: 0.75rem;
    width: 100%;
}

/* 새로운 버튼 스타일 */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--secondary-color);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.125rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.empty-state p {
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
}

/* 상태 배지 */
.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.status-준비중 {
    background-color: #fef3c7;
    color: #92400e;
}

.status-진행중 {
    background-color: #dbeafe;
    color: #1e40af;
}

.status-완료 {
    background-color: #d1fae5;
    color: #065f46;
}

.status-보류 {
    background-color: #fee2e2;
    color: #991b1b;
}

.status-조사 {
    background-color: #dbeafe;
    color: #1e40af;
}

.status-진행 {
    background-color: #fed7aa;
    color: #9a3412;
}

.status-대기 {
    background-color: #f3f4f6;
    color: #374151;
}

.status-검토중 {
    background-color: #ede9fe;
    color: #5b21b6;
}

/* 반응형 디자인 */
@media (max-width: 768px) {
    .header-left {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .app-header h1 {
        font-size: 1.125rem;
    }
    
    .site-selector {
        width: 100%;
    }
    
    .site-select {
        flex: 1;
    }
    
    .stats-container {
        grid-template-columns: 1fr;
    }
    
    .sites-grid {
        grid-template-columns: 1fr;
    }
    
    .charts-container {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        width: 100%;
    }
    
    .modal-content {
        width: 95%;
        margin: 1rem;
    }
    
    .gps-info {
        grid-template-columns: 1fr;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .form-actions {
        flex-direction: column-reverse;
    }
    
    .map-type-selector {
        flex-direction: column;
    }
    
    .map-type-btn {
        flex-direction: row;
        justify-content: center;
        padding: 0.5rem 0.75rem;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    
    .map-type-btn:last-child {
        border-bottom: none;
    }
    
    .map-type-btn span {
        display: none;
    }
    
    .map-tools {
        top: 5rem;
        right: 0.5rem;
        flex-direction: column;
    }
    
    .map-tool-btn {
        flex-direction: row;
        padding: 0.5rem;
    }
    
    .map-tool-btn span {
        display: none;
    }
}

/* 위치 수정 모드 */
.edit-location-mode {
    cursor: crosshair !important;
}

.edit-location-active {
    border-color: var(--warning-color) !important;
    background-color: #fef3c7 !important;
}

/* 거리 측정 모드 */
.measure-mode {
    cursor: crosshair !important;
}

.distance-label {
    background: white;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    border: 1px solid var(--border-color);
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: var(--shadow);
}

/* 커스텀 사이트 마커 스타일 */
.custom-site-marker {
    cursor: move !important;
    transition: transform 0.2s ease;
}

.custom-site-marker:hover {
    transform: scale(1.1);
}

/* 드래그 중인 마커 스타일 */
.leaflet-marker-draggable {
    cursor: move !important;
}

.leaflet-drag-target {
    cursor: move !important;
}

/* 파일 마커 스타일 */
.custom-file-marker {
    cursor: move !important;
    transition: transform 0.2s ease;
}

.custom-file-marker:hover {
    transform: scale(1.15);
}

/* 드래그 가능한 마커 강조 */
.leaflet-marker-icon.custom-file-marker {
    cursor: move !important;
}

.leaflet-marker-draggable .custom-file-marker {
    cursor: move !important;
}

/* 파일 미리보기 컨테이너 */
.modal-file-container {
    margin-bottom: 1.5rem;
}

.modal-pdf-container,
.modal-video-container {
    margin-bottom: 1.5rem;
}

/* 조사 목록 파일 아이템 */
.survey-item-file {
    flex-shrink: 0;
}

/* 다운로드 버튼 스타일 */
.btn-outline {
    background: white;
    border: 1px solid var(--border-color);
    color: var(--secondary-color);
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

.btn-outline:hover {
    background: var(--light-color);
    border-color: var(--primary-color);
    color: var(--primary-color);
}