body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
}

.modal {
    display: none;
}

.modal.active {
    display: flex;
}

.screen {
    display: none;
}

.screen.active {
    display: block;
}

/* ✅ OpenLayers 기본 Zoom 컨트롤 제거 */
.ol-zoom {
    display: none !important;
}

/* ✅ OpenLayers 전체화면 버튼 - 오른쪽 컨트롤들과 같은 높이 */
.ol-full-screen {
    position: absolute !important;
    top: 0.5em !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    right: auto !important;
    z-index: 100 !important;
}

.ol-full-screen button {
    background: rgba(255, 255, 255, 0.4) !important;
    color: white !important;
    font-size: 1.14em !important;
    padding: 0.5em !important;
    border-radius: 4px !important;
    width: 1.375em !important;
    height: 1.375em !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.ol-full-screen button:hover {
    background: rgba(255, 255, 255, 0.6) !important;
}

.ol-full-screen button:focus {
    background: rgba(255, 255, 255, 0.6) !important;
}

/* 사이드바 상태 */
.sidebar {
    transition: all 0.3s ease-in-out;
}

/* 사이드바 접힌 상태 - 아이콘만 표시 */
.sidebar.collapsed {
    width: 70px !important;
}

.sidebar.collapsed .sidebar-content {
    padding: 0.75rem 0.5rem;
}

.sidebar.collapsed .sidebar-header h3 {
    display: none;
}

.sidebar.collapsed button span:not(.icon-emoji) {
    display: none;
}

.sidebar.collapsed button {
    justify-content: center;
    padding: 0.75rem !important;
}

.sidebar.collapsed .control-label,
.sidebar.collapsed label {
    display: none;
}

.sidebar.collapsed .bg-slate-50 {
    background: transparent !important;
    padding: 0.5rem !important;
}

.sidebar.collapsed select {
    width: 40px;
    padding: 0.5rem !important;
    text-indent: -9999px;
    background-position: center;
}

.sidebar.collapsed input[type="range"] {
    display: none;
}

/* 토글 버튼 회전 애니메이션 */
.collapse-arrow {
    transition: transform 0.3s ease;
}

.sidebar.collapsed .collapse-arrow {
    transform: rotate(180deg);
}

/* ✅ 마커 목록 패널 위치 조정 - JavaScript로 동적 제어 */
#markerListPanel {
    position: absolute;
    top: 1rem;
    /* left는 JavaScript로만 제어 */
    z-index: 30;
    transition: left 0.3s ease-in-out;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    display: none; /* 기본은 숨김 */
}

/* ✅ 하단 정보창 기본 스타일 */
#bottomInfoPanel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    display: none;
    max-height: 85vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* ✅ 메모 모달은 정보창보다 위에 표시 */
#memoModal {
    z-index: 2000 !important;
}

/* ✅ 메모 모달 내부 버튼 스타일 - 명확하게 표시 */
#memoModal button {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0.75rem 1rem !important;
    font-size: 0.875rem !important;
    font-weight: 600 !important;
    border-radius: 0.5rem !important;
    transition: all 0.2s !important;
    cursor: pointer !important;
    visibility: visible !important;
    opacity: 1 !important;
    border: none !important;
}

/* 취소 버튼 */
#memoModal button[onclick*="closeMemoModal"] {
    background-color: #f1f5f9 !important;
    color: #475569 !important;
    border: 1px solid #cbd5e1 !important;
}

#memoModal button[onclick*="closeMemoModal"]:hover {
    background-color: #e2e8f0 !important;
}

/* 저장 버튼 */
#memoModal button[onclick*="saveMemo"] {
    background-color: #2563eb !important;
    color: white !important;
}

#memoModal button[onclick*="saveMemo"]:hover {
    background-color: #1d4ed8 !important;
}

/* 메모 모달 텍스트 영역 */
#memoModal textarea {
    display: block !important;
    width: 100% !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* ✅ 메모 추가 버튼 - 모든 화면에서 명확하게 표시 */
#bottomInfoPanel button[onclick^="openMemoModal"],
#bottomInfoPanel button[onclick*="openMemoModal"] {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.5rem !important;
    padding: 0.75rem 1rem !important;
    font-size: 0.875rem !important;
    font-weight: 600 !important;
    visibility: visible !important;
    opacity: 1 !important;
    white-space: nowrap !important;
    background-color: #2563eb !important;
    color: white !important;
    border-radius: 0.5rem !important;
    border: none !important;
    cursor: pointer !important;
    transition: background-color 0.2s !important;
}

#bottomInfoPanel button[onclick^="openMemoModal"]:hover,
#bottomInfoPanel button[onclick*="openMemoModal"]:hover {
    background-color: #1d4ed8 !important;
}

#bottomInfoPanel button[onclick^="openMemoModal"] svg,
#bottomInfoPanel button[onclick*="openMemoModal"] svg {
    display: inline-block !important;
    width: 16px !important;
    height: 16px !important;
    flex-shrink: 0 !important;
}

/* ✅ 애니메이션 */
@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* 모바일 최적화 */
@media (max-width: 768px) {
    /* ✅ 메모 모달 모바일 최적화 */
    #memoModal {
        padding: 1rem !important;
    }
    
    #memoModal .bg-white {
        max-width: 100% !important;
        width: calc(100vw - 2rem) !important;
    }
    
    /* 메모 모달 버튼들 - 모바일에서 확실히 표시 */
    #memoModal button {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 0.875rem 1.25rem !important;
        font-size: 1rem !important;
        font-weight: 600 !important;
        visibility: visible !important;
        opacity: 1 !important;
        min-height: 44px !important; /* 터치 가능한 최소 크기 */
        width: 100% !important;
    }
    
    #memoModal button[onclick*="closeMemoModal"] {
        background-color: #f1f5f9 !important;
        color: #475569 !important;
        border: 1px solid #cbd5e1 !important;
    }
    
    #memoModal button[onclick*="saveMemo"] {
        background-color: #2563eb !important;
        color: white !important;
        border: none !important;
    }
    
    #memoModal textarea {
        font-size: 1rem !important;
        padding: 0.75rem !important;
        min-height: 120px !important;
    }
    
    #memoModal h3 {
        font-size: 1.25rem !important;
    }
    
    #memoModal .flex.gap-3 {
        gap: 0.75rem !important;
        flex-direction: column !important; /* 모바일에서 세로 배치 */
    }
    
    /* 사이드바가 헤더 아래에 위치 */
    .sidebar {
        position: fixed !important;
        top: 73px !important;
        z-index: 40;
        max-height: calc(100vh - 73px) !important;
    }
    
    /* ✅ OpenLayers 전체화면 버튼 모바일 - 더 명확하게 보이도록 */
    .ol-full-screen {
        top: 10px !important;
        z-index: 100 !important;
        background: white !important;
        border-radius: 8px !important;
        box-shadow: 0 4px 12px rgba(0,0,0,0.25) !important;
        padding: 2px !important;
    }
    
    .ol-full-screen button {
        background: white !important;
        color: #334155 !important;
        font-size: 1.2em !important;
        padding: 0.6em !important;
        width: 2em !important;
        height: 2em !important;
        border: 2px solid rgba(0,0,0,0.1) !important;
    }
    
    .ol-full-screen button:hover,
    .ol-full-screen button:focus {
        background: #f1f5f9 !important;
    }
    
    /* ✅ 마커 목록 패널 모바일 최적화 */
    #markerListPanel {
        position: fixed !important;
        top: 73px !important; /* 헤더 바로 아래 (사이드바와 같은 위치) */
        /* left는 JavaScript로 동적 조정됨 - CSS 초기값 제거 */
        right: auto !important; /* 오른쪽 고정 해제 */
        width: calc(100vw - 170px) !important;
        max-width: 160px !important;
        max-height: calc(100vh - 85px) !important; /* 스크롤 가능하도록 */
        overflow-y: auto !important; /* 스크롤 활성화 */
        -webkit-overflow-scrolling: touch; /* 부드러운 스크롤 */
        transition: left 0.3s ease-in-out !important;
        transform: translate3d(0, 0, 0) !important; /* GPU 가속 강제 */
        will-change: left; /* 애니메이션 최적화 */
        backface-visibility: hidden; /* 렌더링 최적화 */
        -webkit-transform: translate3d(0, 0, 0) !important; /* Safari 최적화 */
    }
    
    /* ✅ CSS 선택자로 위치 제어 제거 - JavaScript로만 제어 */
    
    /* 마커 목록 헤더 */
    #markerListPanel .p-4 {
        padding: 0.75rem !important;
    }
    
    #markerListPanel h3 {
        font-size: 12px !important;
        font-weight: 600 !important;
    }
    
    /* 마커 목록 아이템 - 컴팩트하게 */
    #markerListPanel .text-xs {
        font-size: 11px !important;
    }
    
    /* 순번 배지 작게 */
    #markerListPanel .px-3 {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }
    
    #markerListPanel .py-1\.5 {
        padding-top: 0.25rem !important;
        padding-bottom: 0.25rem !important;
    }
    
    /* 상태 배지 작게 */
    #markerListPanel .px-2 {
        padding-left: 0.4rem !important;
        padding-right: 0.4rem !important;
    }
    
    #markerListPanel .py-0\.5 {
        padding-top: 0.15rem !important;
        padding-bottom: 0.15rem !important;
    }
    
    /* ✅ 하단 정보 패널 모바일 최적화 */
    #bottomInfoPanel {
        max-height: 75vh !important;
        border-radius: 16px 16px 0 0 !important;
    }
    
    #bottomInfoPanel .max-w-4xl {
        max-width: 100% !important;
        margin: 0 !important;
    }
    
    #bottomInfoPanel .rounded-t-2xl {
        border-radius: 16px 16px 0 0 !important;
    }
    
    /* 하단 정보창 내부 패딩 조정 */
    #bottomInfoPanel .p-6 {
        padding: 1rem !important;
    }
    
    #bottomInfoPanel .px-6 {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    #bottomInfoPanel .py-3 {
        padding-top: 0.5rem !important;
        padding-bottom: 0.5rem !important;
    }
    
    /* 제목 크기 조정 */
    #bottomInfoPanel h3 {
        font-size: 1.125rem !important;
        line-height: 1.5 !important;
        margin-bottom: 0.5rem !important;
    }
    
    /* 연락처, 주소 텍스트 크기 */
    #bottomInfoPanel .text-sm {
        font-size: 0.875rem !important;
    }
    
    #bottomInfoPanel .text-xs {
        font-size: 0.75rem !important;
        line-height: 1.4 !important;
    }
    
    /* 버튼 크기 조정 - 일반 버튼 */
    #bottomInfoPanel button:not([onclick^="openMemoModal"]) {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.875rem !important;
    }
    
    /* ✅ 메모 추가 버튼 모바일에서 확실히 표시 - 더 구체적인 선택자 */
    #bottomInfoPanel button[onclick^="openMemoModal"],
    #bottomInfoPanel button[onclick*="openMemoModal"] {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 0.5rem !important;
        padding: 0.75rem 1rem !important;
        font-size: 0.875rem !important;
        font-weight: 600 !important;
        visibility: visible !important;
        opacity: 1 !important;
        white-space: nowrap !important;
        width: auto !important;
        min-width: fit-content !important;
        margin: 0 !important;
        background-color: #2563eb !important;
        color: white !important;
        border-radius: 0.5rem !important;
    }
    
    #bottomInfoPanel button[onclick^="openMemoModal"] svg,
    #bottomInfoPanel button[onclick*="openMemoModal"] svg {
        display: inline-block !important;
        width: 16px !important;
        height: 16px !important;
        flex-shrink: 0 !important;
    }
    
    #bottomInfoPanel .px-4 {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }
    
    #bottomInfoPanel .py-2 {
        padding-top: 0.5rem !important;
        padding-bottom: 0.5rem !important;
    }
    
    /* 상태 버튼 컨테이너 */
    #bottomInfoPanel .flex.gap-2 {
        gap: 0.375rem !important;
        flex-wrap: wrap !important;
    }
    
    /* 닫기 버튼 */
    #bottomInfoPanel .absolute.top-4.right-4 {
        top: 0.75rem !important;
        right: 0.75rem !important;
    }
    
    /* 내비게이션 버튼 */
    #bottomInfoPanel .p-1\.5 {
        padding: 0.375rem !important;
    }
    
    /* 메모 영역 */
    #bottomInfoPanel .max-h-32 {
        max-height: 6rem !important;
    }
    
    #bottomInfoPanel .rounded-lg.p-4 {
        padding: 0.75rem !important;
    }
    
    /* 스크롤 컨테이너 */
    #bottomInfoPanel .max-h-\[70vh\] {
        max-height: 65vh !important;
    }
    
    /* 간격 조정 */
    #bottomInfoPanel .mb-4 {
        margin-bottom: 0.75rem !important;
    }
    
    #bottomInfoPanel .gap-4 {
        gap: 0.75rem !important;
    }
    
    /* 여러 항목이 있을 때 알림 */
    #bottomInfoPanel .bg-blue-50 {
        padding: 0.5rem 1rem !important;
    }
    
    /* 항목 구분선 */
    #bottomInfoPanel .border-t-2 {
        margin-top: 0.75rem !important;
        padding-top: 0.75rem !important;
    }
}

/* 데스크톱 */
@media (min-width: 769px) {
    .sidebar {
        position: absolute !important;
        top: 1rem !important;
    }
    
    /* 데스크톱에서 마커 목록 위치 - 사이드바와 같은 높이 */
    #markerListPanel {
        position: absolute !important;
        top: 1rem !important;
    }
    
    /* 데스크톱에서 하단 정보창 */
    #bottomInfoPanel {
        max-height: 80vh;
        padding: 0 1rem;
    }
}

/* 애니메이션 */
@keyframes slideIn {
    from {
        transform: translateX(-100%);
    }
    to {
        transform: translateX(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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